LAPTOP-SB56SG4Q\86185
3 years ago
28 changed files with 2535 additions and 1 deletions
@ -1,3 +1,6 @@
|
||||
# open-JSD-6177 |
||||
|
||||
JSD-6177 多层级选择树控件 |
||||
JSD-6177 多层级选择树控件\ |
||||
免责说明:该源码为第三方爱好者提供,不保证源码和方案的可靠性,也不提供任何形式的源码教学指导和协助!\ |
||||
仅作为开发者学习参考使用!禁止用于任何商业用途!\ |
||||
为保护开发者隐私,开发者信息已隐去!若原开发者希望公开自己的信息,可联系hugh处理。 |
Binary file not shown.
@ -0,0 +1,21 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?><plugin> |
||||
<id>com.fr.plugin.third.party.xxxx</id> |
||||
<name><![CDATA[多层级选择控件]]></name> |
||||
<active>yes</active> |
||||
<version>0.1</version> |
||||
<env-version>10.0</env-version> |
||||
<jartime>2019-01-01</jartime> |
||||
<vendor>fr.open</vendor> |
||||
<description><![CDATA[]]></description> |
||||
<change-notes><![CDATA[]]></change-notes> |
||||
<extra-core> |
||||
<JavaScriptFileHandler class="com.fr.plugin.third.party.xxxx.web.JavaScriptFileLoader"/> |
||||
<CssFileHandler class="com.fr.plugin.third.party.xxxx.web.CssFileLoader"/> |
||||
<FunctionDefineProvider class= "com.fr.plugin.third.party.xxxx.function.GetHonorLevelValue" name="GetHonorLevelValue" description="获取层级数据"/> |
||||
</extra-core> |
||||
<extra-designer> |
||||
<ParameterWidgetOptionProvider class="com.fr.plugin.third.party.xxxx.MultilevelSelectionWidgetOptionProvider"/> |
||||
<FormWidgetOptionProvider class="com.fr.plugin.third.party.xxxx.MultilevelSelectionWidgetOptionProvider"/> |
||||
</extra-designer> |
||||
<function-recorder class="com.fr.plugin.third.party.xxxx.MultilevelSelectionWidgetOptionProvider"/> |
||||
</plugin> |
@ -0,0 +1,490 @@
|
||||
package com.fr.plugin.third.party.xxxx; |
||||
|
||||
import com.fanruan.api.util.StringKit; |
||||
import com.fanruan.api.xml.XmlKit; |
||||
import com.fr.base.TableData; |
||||
import com.fr.data.core.DataCoreUtils; |
||||
import com.fr.data.core.db.DBUtils; |
||||
import com.fr.data.core.db.dialect.DialectFactory; |
||||
import com.fr.data.impl.Connection; |
||||
import com.fr.data.impl.DBTableData; |
||||
import com.fr.file.TableDataConfig; |
||||
import com.fr.form.ui.DataControl; |
||||
import com.fr.form.ui.DirectWriteEditor; |
||||
import com.fr.form.ui.concept.data.ValueInitializer; |
||||
import com.fr.general.data.DataModel; |
||||
import com.fr.general.data.TableDataException; |
||||
import com.fr.json.JSONArray; |
||||
import com.fr.json.JSONException; |
||||
import com.fr.json.JSONObject; |
||||
import com.fr.plugin.third.party.xxxx.config.CustomLevelDictionaryConfig; |
||||
import com.fr.plugin.third.party.xxxx.config.CustomLevelDictionarySettings; |
||||
import com.fr.plugin.third.party.xxxx.data.CustomReturnDataConfig; |
||||
import com.fr.plugin.third.party.xxxx.data.CustomWidgetConfig; |
||||
import com.fr.script.Calculator; |
||||
import com.fr.stable.core.NodeVisitor; |
||||
import com.fr.stable.script.CalculatorProvider; |
||||
import com.fr.stable.web.Repository; |
||||
import com.fr.stable.web.SessionProvider; |
||||
import com.fr.stable.xml.XMLPrintWriter; |
||||
import com.fr.stable.xml.XMLableReader; |
||||
import com.fr.web.core.TemplateSessionIDInfo; |
||||
import com.fr.web.utils.WebUtils; |
||||
|
||||
import javax.servlet.http.HttpServletRequest; |
||||
import java.util.ArrayList; |
||||
import java.util.List; |
||||
|
||||
public class MultilevelSelectionEditor extends DirectWriteEditor implements DataControl { |
||||
private CustomWidgetConfig widgetConfig = new CustomWidgetConfig(); |
||||
private CustomReturnDataConfig returnDataConfig = new CustomReturnDataConfig(); |
||||
|
||||
|
||||
@Override |
||||
public int[] getValueType() { |
||||
return new int[0]; |
||||
} |
||||
|
||||
@Override |
||||
public void setWidgetValue(ValueInitializer valueInitializer) { |
||||
|
||||
} |
||||
|
||||
@Override |
||||
public ValueInitializer getWidgetValue() { |
||||
return null; |
||||
} |
||||
|
||||
@Override |
||||
public void createValueResult(CalculatorProvider calculatorProvider, JSONObject jsonObject) { |
||||
|
||||
} |
||||
|
||||
@Override |
||||
public String getFormatText() { |
||||
return null; |
||||
} |
||||
|
||||
@Override |
||||
public String getDataBindDefaultValue(CalculatorProvider calculatorProvider) { |
||||
return null; |
||||
} |
||||
|
||||
@Override |
||||
public String getXType() { |
||||
/*只能小写*/ |
||||
return "honormultilevelselectionwidget"; |
||||
} |
||||
|
||||
|
||||
public CustomWidgetConfig getWidgetConfig() { |
||||
return widgetConfig; |
||||
} |
||||
|
||||
public void setWidgetConfig(CustomWidgetConfig widgetConfig) { |
||||
this.widgetConfig = widgetConfig; |
||||
} |
||||
|
||||
public CustomReturnDataConfig getReturnDataConfig() { |
||||
return returnDataConfig; |
||||
} |
||||
|
||||
public void setReturnDataConfig(CustomReturnDataConfig returnData) { |
||||
this.returnDataConfig = returnData; |
||||
} |
||||
|
||||
public JSONObject createJSONConfig(Repository paramRepository, Calculator paramCalculator, NodeVisitor paramNodeVisitor) throws JSONException { |
||||
JSONObject jSONObject = super.createJSONConfig(paramRepository, paramCalculator, paramNodeVisitor); |
||||
jSONObject.put("widgetConfig_" + "returnArray", this.returnDataConfig.isReturnArray()); |
||||
jSONObject.put("widgetConfig_" + "delimiter", this.returnDataConfig.getDelimiter()); |
||||
jSONObject.put("widgetConfig_" + "startSymbol", this.returnDataConfig.getStartSymbol()); |
||||
jSONObject.put("widgetConfig_" + "endSymbol", this.returnDataConfig.getEndSymbol()); |
||||
|
||||
//jSONObject.put("widgetConfig_" + "windowTitle", this.widgetConfig.getWindowTitle());
|
||||
//jSONObject.put("widgetConfig_" + "filterTitle", this.widgetConfig.getFilterTitle());
|
||||
//jSONObject.put("widgetConfig_" + "candidateTitle", this.widgetConfig.getCandidateTitle());
|
||||
//jSONObject.put("widgetConfig_" + "selectedTitle", this.widgetConfig.getSelectedTitle());
|
||||
jSONObject.put("widgetConfig_" + "width", this.widgetConfig.getWidth()); |
||||
jSONObject.put("widgetConfig_" + "height", this.widgetConfig.getHeight()); |
||||
jSONObject.put("widgetConfig_" + "fontSize", this.widgetConfig.getFontSize()); |
||||
|
||||
CustomLevelDictionarySettings settings = this.widgetConfig.getDicSettings(); |
||||
|
||||
JSONArray jsonArray = createLevelSettings(); |
||||
int levelCount = jsonArray.size(); |
||||
jSONObject.put("widgetConfig_" + "levelCount", levelCount); |
||||
jSONObject.put("widgetConfig_" + "levelSettings", jsonArray); |
||||
return jSONObject; |
||||
} |
||||
|
||||
private JSONArray createLevelSettings() { |
||||
JSONArray jsonArray = new JSONArray(); |
||||
CustomLevelDictionarySettings settings = this.widgetConfig.getDicSettings(); |
||||
if (settings == null) { |
||||
return jsonArray; |
||||
} |
||||
|
||||
CustomLevelDictionaryConfig[] configs = settings.getConfigs(); |
||||
if ((configs == null) || (configs.length <= 0)) { |
||||
return jsonArray; |
||||
} |
||||
JSONObject configObject; |
||||
CustomLevelDictionaryConfig config; |
||||
for (int i = 0, max = configs.length - 1; i <= max; i++) { |
||||
config = configs[i]; |
||||
if (config == null) { |
||||
continue; |
||||
} |
||||
configObject = new JSONObject(); |
||||
configObject.put("valueColumnName", config.getValueColumnName()); |
||||
configObject.put("nameColumnName", config.getNameColumnName()); |
||||
configObject.put("title", config.getTitle()); |
||||
configObject.put("levelWidth", config.getLevelWidth()); |
||||
jsonArray.add(configObject); |
||||
} |
||||
return jsonArray; |
||||
} |
||||
|
||||
public JSONArray createJSONData(SessionProvider sessionProvider, Calculator calculator, HttpServletRequest request) throws Exception { |
||||
return createJSONData(sessionProvider, (CalculatorProvider) calculator, request); |
||||
} |
||||
|
||||
public JSONArray createJSONData(SessionProvider sessionProvider, CalculatorProvider calculatorProvider, HttpServletRequest request) throws Exception { |
||||
String dataType = WebUtils.getHTTPRequestParameter(request, "dataType"); |
||||
JSONArray jsonArray = new JSONArray(); |
||||
TemplateSessionIDInfo templateSessionIDInfo = null; |
||||
if ((sessionProvider != null) && (sessionProvider instanceof TemplateSessionIDInfo)) { |
||||
templateSessionIDInfo = (TemplateSessionIDInfo) sessionProvider; |
||||
} |
||||
if ("ALL".equalsIgnoreCase(dataType)) { |
||||
jsonArray = getUpperData((Calculator) calculatorProvider, templateSessionIDInfo); |
||||
} else if ("VALUE".equalsIgnoreCase(dataType)) { |
||||
String upperValue = WebUtils.getHTTPRequestParameter(request, "upperValue"); |
||||
//jsonArray = getValueData((Calculator) calculatorProvider, upperValue, templateSessionIDInfo);
|
||||
jsonArray = getValueData((Calculator) calculatorProvider , templateSessionIDInfo,request); |
||||
} |
||||
return jsonArray; |
||||
} |
||||
|
||||
|
||||
/** |
||||
* 获取父级所有数据 |
||||
* |
||||
* @param calculator |
||||
* @return |
||||
* @throws TableDataException |
||||
*/ |
||||
private JSONArray getUpperData(Calculator calculator, TemplateSessionIDInfo templateSessionIDInfo) throws TableDataException { |
||||
JSONArray jsonArray = new JSONArray(); |
||||
DataModel dataModel = getDataModel(calculator, templateSessionIDInfo); |
||||
if (dataModel == null) { |
||||
return jsonArray; |
||||
} |
||||
|
||||
int upperValueIndex = dataModel.getColumnIndex(this.widgetConfig.getUpperValue()); |
||||
int upperNameIndex = dataModel.getColumnIndex(this.widgetConfig.getUpperName()); |
||||
if ((upperValueIndex <= -1) || (upperNameIndex <= -1)) { |
||||
return jsonArray; |
||||
} |
||||
List<String> values = new ArrayList<>(); |
||||
int rowCount = dataModel.getRowCount(); |
||||
String value, name; |
||||
JSONObject jsonObject; |
||||
for (int i = 0, max = rowCount - 1; i <= max; i++) { |
||||
value = (String) dataModel.getValueAt(i, upperValueIndex); |
||||
name = (String) dataModel.getValueAt(i, upperNameIndex); |
||||
if (StringKit.isEmpty(value) || StringKit.isEmpty(name)) { |
||||
continue; |
||||
} |
||||
if (values.contains(value)) { |
||||
continue; |
||||
} |
||||
values.add(value); |
||||
jsonObject = new JSONObject(); |
||||
jsonObject.put("value", value); |
||||
jsonObject.put("text", name); |
||||
jsonArray.add(jsonObject); |
||||
} |
||||
values.clear(); |
||||
return jsonArray; |
||||
} |
||||
|
||||
|
||||
/** |
||||
* 获取子级数据 |
||||
* |
||||
* @param calculator |
||||
* @param templateSessionIDInfo |
||||
* @param request |
||||
* @return |
||||
* @throws TableDataException |
||||
*/ |
||||
private JSONArray getValueData(Calculator calculator, TemplateSessionIDInfo templateSessionIDInfo, HttpServletRequest request) throws TableDataException { |
||||
JSONArray jsonArray = new JSONArray(); |
||||
|
||||
String upperValue = WebUtils.getHTTPRequestParameter(request, "upperValue"); |
||||
String currentValue = WebUtils.getHTTPRequestParameter(request, "currentValue"); |
||||
String levelIndexValue = WebUtils.getHTTPRequestParameter(request, "levelIndex"); |
||||
|
||||
int levelIndex = Integer.valueOf(levelIndexValue); |
||||
List<String> upperValues = getValues(upperValue); |
||||
|
||||
DataModel dataModel = getDataModel(calculator, templateSessionIDInfo); |
||||
if (dataModel == null) { |
||||
return jsonArray; |
||||
} |
||||
|
||||
String upperValueColName = getColumnName(levelIndex, "UPPER_VALUE"); |
||||
String valueColName = getColumnName(levelIndex, "VALUE"); |
||||
String nameColName = getColumnName(levelIndex, "NAME"); |
||||
|
||||
int upperValueIndex = dataModel.getColumnIndex(upperValueColName); |
||||
int valueIndex = dataModel.getColumnIndex(valueColName); |
||||
int nameIndex = dataModel.getColumnIndex(nameColName); |
||||
if ((valueIndex <= -1) || (nameIndex <= -1)) { |
||||
return jsonArray; |
||||
} |
||||
List<String> values = new ArrayList<>(); |
||||
int rowCount = dataModel.getRowCount(); |
||||
String value, name, tempUpperValue = ""; |
||||
JSONObject jsonObject; |
||||
for (int i = 0, max = rowCount - 1; i <= max; i++) { |
||||
if ((levelIndex >= 1) && (upperValues.size() >= 1)) { |
||||
tempUpperValue = (String) dataModel.getValueAt(i, upperValueIndex); |
||||
} |
||||
value = (String) dataModel.getValueAt(i, valueIndex); |
||||
name = (String) dataModel.getValueAt(i, nameIndex); |
||||
if (StringKit.isEmpty(value) || StringKit.isEmpty(name)) { |
||||
continue; |
||||
} |
||||
|
||||
if (StringKit.isNotEmpty(currentValue) && (name.indexOf(currentValue) <= 0)) { |
||||
continue; |
||||
} |
||||
|
||||
if (values.contains(value)) { |
||||
continue; |
||||
} |
||||
if ((levelIndex >= 1) && (upperValues.size() >= 1) && (!upperValues.contains(tempUpperValue))) { |
||||
continue; |
||||
} |
||||
values.add(value); |
||||
jsonObject = new JSONObject(); |
||||
jsonObject.put("value", value); |
||||
jsonObject.put("text", name); |
||||
jsonArray.add(jsonObject); |
||||
} |
||||
values.clear(); |
||||
return jsonArray; |
||||
} |
||||
|
||||
private String getColumnName(int level, String type) { |
||||
if (level <= -1) { |
||||
return ""; |
||||
} |
||||
if (StringKit.isEmpty(type)) { |
||||
return ""; |
||||
} |
||||
|
||||
if (type.startsWith("UPPER") && (level <= 0)) { |
||||
return ""; |
||||
} |
||||
|
||||
CustomLevelDictionarySettings settings = this.widgetConfig.getDicSettings(); |
||||
CustomLevelDictionaryConfig[] configs = settings.getConfigs(); |
||||
if ((configs == null) || (configs.length <= level)) { |
||||
return ""; |
||||
} |
||||
|
||||
int index = level; |
||||
if (type.startsWith("UPPER")) { |
||||
index = level - 1; |
||||
} |
||||
CustomLevelDictionaryConfig config = configs[index]; |
||||
if ("UPPER_NAME".equalsIgnoreCase(type) || "NAME".equalsIgnoreCase(type)) { |
||||
return config.getNameColumnName(); |
||||
} |
||||
|
||||
if ("UPPER_VALUE".equalsIgnoreCase(type) || "VALUE".equalsIgnoreCase(type)) { |
||||
return config.getValueColumnName(); |
||||
} |
||||
return ""; |
||||
} |
||||
|
||||
|
||||
private List<String> getValues(String content) { |
||||
List<String> values = new ArrayList<>(); |
||||
if (StringKit.isEmpty(content)) { |
||||
return values; |
||||
} |
||||
String[] tempValues = content.split(","); |
||||
if ((tempValues == null) || (tempValues.length <= 0)) { |
||||
return values; |
||||
} |
||||
|
||||
String tempValue; |
||||
for (int i = 0, max = tempValues.length - 1; i <= max; i++) { |
||||
tempValue = tempValues[i]; |
||||
if (StringKit.isEmpty(tempValue)) { |
||||
continue; |
||||
} |
||||
values.add(tempValue); |
||||
} |
||||
return values; |
||||
} |
||||
|
||||
|
||||
/** |
||||
* 获取子级数据 |
||||
* |
||||
* @param calculator |
||||
* @param upperValue |
||||
* @return |
||||
* @throws TableDataException |
||||
*/ |
||||
private JSONArray getValueData(Calculator calculator, String upperValue, TemplateSessionIDInfo templateSessionIDInfo) throws TableDataException { |
||||
JSONArray jsonArray = new JSONArray(); |
||||
if (StringKit.isEmpty(upperValue)) { |
||||
return jsonArray; |
||||
} |
||||
DataModel dataModel = getDataModel(calculator, templateSessionIDInfo); |
||||
if (dataModel == null) { |
||||
return jsonArray; |
||||
} |
||||
|
||||
int upperValueIndex = dataModel.getColumnIndex(this.widgetConfig.getUpperValue()); |
||||
int valueIndex = dataModel.getColumnIndex(this.widgetConfig.getValue()); |
||||
int nameIndex = dataModel.getColumnIndex(this.widgetConfig.getName()); |
||||
if ((upperValueIndex <= -1) || (valueIndex <= -1) || (nameIndex <= -1)) { |
||||
return jsonArray; |
||||
} |
||||
List<String> values = new ArrayList<>(); |
||||
int rowCount = dataModel.getRowCount(); |
||||
String value, name, tempUpperValue; |
||||
JSONObject jsonObject; |
||||
for (int i = 0, max = rowCount - 1; i <= max; i++) { |
||||
tempUpperValue = (String) dataModel.getValueAt(i, upperValueIndex); |
||||
value = (String) dataModel.getValueAt(i, valueIndex); |
||||
name = (String) dataModel.getValueAt(i, nameIndex); |
||||
if (StringKit.isEmpty(tempUpperValue) || StringKit.isEmpty(value) || StringKit.isEmpty(name)) { |
||||
continue; |
||||
} |
||||
if (values.contains(value)) { |
||||
continue; |
||||
} |
||||
if (!upperValue.equals(tempUpperValue)) { |
||||
continue; |
||||
} |
||||
values.add(value); |
||||
jsonObject = new JSONObject(); |
||||
jsonObject.put("value", value); |
||||
jsonObject.put("text", name); |
||||
jsonArray.add(jsonObject); |
||||
} |
||||
values.clear(); |
||||
return jsonArray; |
||||
} |
||||
|
||||
private DataModel getDataModel(Calculator calculator, TemplateSessionIDInfo templateSessionIDInfo) throws TableDataException { |
||||
TableData tableData = null; |
||||
/*if (this.widgetConfig.getDicTypeIndex() == 0) { |
||||
tableData = getDsTableData(templateSessionIDInfo); |
||||
} else { |
||||
tableData = getDbTableData(); |
||||
}*/ |
||||
tableData = getDsTableData(templateSessionIDInfo); |
||||
if (tableData == null) { |
||||
return null; |
||||
} |
||||
if (calculator == null) { |
||||
calculator = Calculator.createCalculator(); |
||||
} |
||||
DataModel dataModel = tableData.createDataModel(calculator); |
||||
if (dataModel.getRowCount() <= 0) { |
||||
return null; |
||||
} |
||||
return dataModel; |
||||
} |
||||
|
||||
private TableData getDsTableData(TemplateSessionIDInfo templateSessionIDInfo) { |
||||
TableData tableData = null; |
||||
if (templateSessionIDInfo != null) { |
||||
tableData = templateSessionIDInfo.getTableDataSource().getTableData(this.widgetConfig.getDsName()); |
||||
} |
||||
if (tableData == null) { |
||||
tableData = TableDataConfig.getInstance().getTableData(this.widgetConfig.getDsName()); |
||||
} |
||||
return tableData; |
||||
} |
||||
|
||||
|
||||
private TableData getDbTableData() { |
||||
Connection connection = DBUtils.checkDBConnection(this.widgetConfig.getDbName()); |
||||
DBTableData tableData = new DBTableData(connection, DataCoreUtils.createSelectSQL(this.widgetConfig.getSchemaName(), this.widgetConfig.getTableName(), DialectFactory.getDialectByName(this.widgetConfig.getDbName()))); |
||||
return tableData; |
||||
} |
||||
|
||||
public void readXML(XMLableReader paramXMLableReader) { |
||||
super.readXML(paramXMLableReader); |
||||
if (paramXMLableReader.isChildNode()) { |
||||
String tagName = paramXMLableReader.getTagName(); |
||||
if (tagName.equals("DicAttr")) { |
||||
this.widgetConfig.setDsName(paramXMLableReader.getAttrAsString("dsName", "")); |
||||
} else if ("RetAttr".equals(tagName)) { |
||||
this.returnDataConfig.setReturnArray(paramXMLableReader.getAttrAsBoolean("returnArray", true)); |
||||
this.returnDataConfig.setDelimiter(paramXMLableReader.getAttrAsString("delimiter", "")); |
||||
this.returnDataConfig.setStartSymbol(paramXMLableReader.getAttrAsString("startSymbol", "")); |
||||
this.returnDataConfig.setEndSymbol(paramXMLableReader.getAttrAsString("endSymbol", "")); |
||||
} else if ("PopupAttr".equals(tagName)) { |
||||
this.widgetConfig.setWidth(paramXMLableReader.getAttrAsDouble("width", 0)); |
||||
this.widgetConfig.setHeight(paramXMLableReader.getAttrAsDouble("height", 0)); |
||||
this.widgetConfig.setFontSize(paramXMLableReader.getAttrAsInt("fontSize", 12)); |
||||
} |
||||
|
||||
if (CustomLevelDictionaryConfig.XML_TAG.equals(tagName)) { |
||||
CustomLevelDictionaryConfig config = (CustomLevelDictionaryConfig) XmlKit.readXMLable(paramXMLableReader); |
||||
CustomLevelDictionarySettings settings = this.widgetConfig.getDicSettings(); |
||||
if (settings == null) { |
||||
settings = new CustomLevelDictionarySettings(); |
||||
this.widgetConfig.setDicSettings(settings); |
||||
} |
||||
settings.addConfig(config); |
||||
} |
||||
} |
||||
} |
||||
|
||||
public void writeXML(XMLPrintWriter paramXMLPrintWriter) { |
||||
super.writeXML(paramXMLPrintWriter); |
||||
paramXMLPrintWriter.startTAG("DicAttr"); |
||||
paramXMLPrintWriter.attr("dsName", this.widgetConfig.getDsName()); |
||||
paramXMLPrintWriter.end(); |
||||
|
||||
paramXMLPrintWriter.startTAG("RetAttr"); |
||||
paramXMLPrintWriter.attr("returnArray", this.returnDataConfig.isReturnArray()); |
||||
paramXMLPrintWriter.attr("delimiter", this.returnDataConfig.getDelimiter()); |
||||
paramXMLPrintWriter.attr("startSymbol", this.returnDataConfig.getStartSymbol()); |
||||
paramXMLPrintWriter.attr("endSymbol", this.returnDataConfig.getEndSymbol()); |
||||
paramXMLPrintWriter.end(); |
||||
|
||||
paramXMLPrintWriter.startTAG("PopupAttr"); |
||||
paramXMLPrintWriter.attr("width", this.widgetConfig.getWidth()); |
||||
paramXMLPrintWriter.attr("height", this.widgetConfig.getHeight()); |
||||
paramXMLPrintWriter.attr("fontSize", this.widgetConfig.getFontSize()); |
||||
paramXMLPrintWriter.end(); |
||||
|
||||
CustomLevelDictionarySettings settings = this.widgetConfig.getDicSettings(); |
||||
if (settings == null) { |
||||
return; |
||||
} |
||||
CustomLevelDictionaryConfig[] configs = settings.getConfigs(); |
||||
if (configs == null) { |
||||
return; |
||||
} |
||||
for (CustomLevelDictionaryConfig config : configs) { |
||||
XmlKit.writeXMLable(paramXMLPrintWriter, config, CustomLevelDictionaryConfig.XML_TAG); |
||||
} |
||||
|
||||
|
||||
} |
||||
|
||||
} |
@ -0,0 +1,30 @@
|
||||
package com.fr.plugin.third.party.xxxx; |
||||
|
||||
import com.fr.design.fun.impl.AbstractFormWidgetOptionProvider; |
||||
import com.fr.intelli.record.Focus; |
||||
import com.fr.intelli.record.Original; |
||||
import com.fr.record.analyzer.EnableMetrics; |
||||
|
||||
@EnableMetrics |
||||
public class MultilevelSelectionWidgetOptionProvider extends AbstractFormWidgetOptionProvider { |
||||
@Override |
||||
@Focus(id = "com.fr.plugin.third.party.xxxx", text = "plugin-jsd-6177", source = Original.PLUGIN) |
||||
public Class<? extends MultilevelSelectionEditor> classForWidget() { |
||||
return MultilevelSelectionEditor.class; |
||||
} |
||||
|
||||
@Override |
||||
public Class<?> appearanceForWidget() { |
||||
return XMsw.class; |
||||
} |
||||
|
||||
@Override |
||||
public String iconPathForWidget() { |
||||
return "com/fr/plugin/third/party/xxxx/images/selection_16.png"; |
||||
} |
||||
|
||||
@Override |
||||
public String nameForWidget() { |
||||
return "多层选择控件"; |
||||
} |
||||
} |
@ -0,0 +1,81 @@
|
||||
package com.fr.plugin.third.party.xxxx; |
||||
|
||||
import com.fanruan.api.design.DesignKit; |
||||
import com.fr.design.designer.creator.CRPropertyDescriptor; |
||||
import com.fr.design.designer.creator.XLayoutContainer; |
||||
import com.fr.design.designer.creator.XWScaleLayout; |
||||
import com.fr.design.designer.creator.XWidgetCreator; |
||||
import com.fr.design.gui.itextfield.UITextField; |
||||
import com.fr.design.layout.FRGUIPaneFactory; |
||||
import com.fr.plugin.third.party.xxxx.ui.CustomDictionaryPropertyEditor; |
||||
import com.fr.plugin.third.party.xxxx.ui.ReturnTypePropertyEditor; |
||||
import com.fr.stable.ArrayUtils; |
||||
|
||||
import javax.swing.*; |
||||
import java.awt.*; |
||||
import java.beans.IntrospectionException; |
||||
|
||||
|
||||
public class XMsw extends XWidgetCreator { |
||||
LimpidButton btn; |
||||
|
||||
public XMsw(MultilevelSelectionEditor widget, Dimension dimension) { |
||||
super(widget, dimension); |
||||
} |
||||
|
||||
@Override |
||||
protected JComponent initEditor() { |
||||
if (this.editor == null) { |
||||
this.editor = FRGUIPaneFactory.createBorderLayout_S_Pane(); |
||||
UITextField var1 = new UITextField(5); |
||||
var1.setOpaque(false); |
||||
this.editor.add(var1, "Center"); |
||||
float opacity = this.toData().isVisible() ? 1.0F : 0.4F; |
||||
this.btn = new LimpidButton("", this.getIconPath(), opacity); |
||||
this.btn.setPreferredSize(new Dimension(21, 21)); |
||||
this.btn.setOpaque(true); |
||||
this.editor.add(this.btn, "East"); |
||||
this.editor.setBackground(Color.WHITE); |
||||
} |
||||
|
||||
return this.editor; |
||||
} |
||||
|
||||
public String getIconPath() { |
||||
return "/com/fr/plugin/third/party/xxxx/images/selection_16.png"; |
||||
} |
||||
|
||||
@Override |
||||
protected String getIconName() { |
||||
return "/com/fr/plugin/third/party/xxxx/images/selection_16.png"; |
||||
} |
||||
|
||||
@Override |
||||
public boolean shouldScaleCreator() { |
||||
return true; |
||||
} |
||||
|
||||
@Override |
||||
protected XLayoutContainer getCreatorWrapper(String var1) { |
||||
return new XWScaleLayout(); |
||||
} |
||||
|
||||
@Override |
||||
public CRPropertyDescriptor[] supportedDescriptor() throws IntrospectionException { |
||||
CRPropertyDescriptor[] oldValues = super.supportedDescriptor(); |
||||
CRPropertyDescriptor setDescriptor = new CRPropertyDescriptor("widgetConfig", this.data.getClass()); |
||||
//setDescriptor.setI18NName(DesignKit.i18nText("Fine-Design_Form_DS_Dictionary"));
|
||||
setDescriptor.setI18NName(DesignKit.i18nText("Fine-Design_Basic_Widget_Settings")); |
||||
setDescriptor.putKeyValue("category", "Fine-Design_Basic_Advanced"); |
||||
setDescriptor.setEditorClass(CustomDictionaryPropertyEditor.class); |
||||
|
||||
CRPropertyDescriptor retDescriptor = new CRPropertyDescriptor("returnDataConfig", this.data.getClass()); |
||||
retDescriptor.setI18NName(DesignKit.i18nText("Fine-Design_Basic_Widget_Date_Selector_Return_Type")); |
||||
retDescriptor.putKeyValue("category", "Fine-Design_Basic_Advanced"); |
||||
retDescriptor.setEditorClass(ReturnTypePropertyEditor.class); |
||||
|
||||
return ArrayUtils.addAll(oldValues, setDescriptor,retDescriptor); |
||||
|
||||
//return ArrayUtils.addAll(oldValues, setDescriptor);
|
||||
} |
||||
} |
@ -0,0 +1,115 @@
|
||||
package com.fr.plugin.third.party.xxxx.config; |
||||
|
||||
import com.fanruan.api.util.AssistKit; |
||||
import com.fanruan.api.util.StringKit; |
||||
import com.fr.stable.xml.XMLPrintWriter; |
||||
import com.fr.stable.xml.XMLable; |
||||
import com.fr.stable.xml.XMLableReader; |
||||
|
||||
public class CustomLevelDictionaryConfig implements XMLable { |
||||
public static final String XML_TAG = "CustomLevelDictionaryConfig"; |
||||
private String valueColumnName; |
||||
private String nameColumnName; |
||||
private String title; |
||||
private int levelWidth = 150; |
||||
|
||||
public CustomLevelDictionaryConfig() { |
||||
} |
||||
|
||||
public CustomLevelDictionaryConfig(final String valueColumnName, final String nameColumnName, final String title, final int levelWidth) { |
||||
this.valueColumnName = valueColumnName; |
||||
this.nameColumnName = nameColumnName; |
||||
this.title = title; |
||||
this.levelWidth = levelWidth; |
||||
} |
||||
|
||||
public String getValueColumnName() { |
||||
if (StringKit.isEmpty(valueColumnName)) { |
||||
return ""; |
||||
} |
||||
return valueColumnName; |
||||
} |
||||
|
||||
public void setValueColumnName(String valueColumnName) { |
||||
this.valueColumnName = valueColumnName; |
||||
} |
||||
|
||||
public String getNameColumnName() { |
||||
if (StringKit.isEmpty(nameColumnName)) { |
||||
return ""; |
||||
} |
||||
return nameColumnName; |
||||
} |
||||
|
||||
public void setNameColumnName(String nameColumnName) { |
||||
this.nameColumnName = nameColumnName; |
||||
} |
||||
|
||||
public String getTitle() { |
||||
if (StringKit.isEmpty(title)) { |
||||
return ""; |
||||
} |
||||
return title; |
||||
} |
||||
|
||||
public void setTitle(String title) { |
||||
this.title = title; |
||||
} |
||||
|
||||
public int getLevelWidth() { |
||||
return levelWidth; |
||||
} |
||||
|
||||
public void setLevelWidth(int levelWidth) { |
||||
this.levelWidth = levelWidth; |
||||
} |
||||
|
||||
public void readXML(final XMLableReader reader) { |
||||
if (reader.isChildNode()) { |
||||
String tagName = reader.getTagName(); |
||||
if ("valueColumnName".equals(tagName)) { |
||||
this.valueColumnName = reader.getElementValue(); |
||||
} else if ("nameColumnName".equals(tagName)) { |
||||
this.nameColumnName = reader.getElementValue(); |
||||
} else if ("title".equals(tagName)) { |
||||
this.title = reader.getElementValue(); |
||||
} else if ("levelWidth".equals(tagName)) { |
||||
this.levelWidth = Integer.parseInt(reader.getElementValue()); |
||||
} |
||||
} |
||||
} |
||||
|
||||
public void writeXML(final XMLPrintWriter writer) { |
||||
if (StringKit.isNotEmpty(valueColumnName)) { |
||||
writer.startTAG("valueColumnName").textNode(valueColumnName).end(); |
||||
} |
||||
if (StringKit.isNotEmpty(nameColumnName)) { |
||||
writer.startTAG("nameColumnName").textNode(nameColumnName).end(); |
||||
} |
||||
if (StringKit.isNotEmpty(title)) { |
||||
writer.startTAG("title").textNode(title).end(); |
||||
} |
||||
writer.startTAG("levelWidth").textNode(String.valueOf(levelWidth)).end(); |
||||
|
||||
} |
||||
|
||||
@Override |
||||
public boolean equals(final Object o) { |
||||
return o instanceof CustomLevelDictionaryConfig |
||||
&& AssistKit.equals(((CustomLevelDictionaryConfig) o).valueColumnName, valueColumnName) |
||||
&& AssistKit.equals(((CustomLevelDictionaryConfig) o).nameColumnName, nameColumnName) |
||||
&& AssistKit.equals(((CustomLevelDictionaryConfig) o).title, title) |
||||
&& AssistKit.equals(((CustomLevelDictionaryConfig) o).levelWidth, levelWidth); |
||||
} |
||||
|
||||
@Override |
||||
public Object clone() throws CloneNotSupportedException { |
||||
CustomLevelDictionaryConfig cloned = (CustomLevelDictionaryConfig) super.clone(); |
||||
cloned.valueColumnName = valueColumnName; |
||||
cloned.nameColumnName = nameColumnName; |
||||
cloned.title = title; |
||||
cloned.levelWidth = levelWidth; |
||||
return cloned; |
||||
} |
||||
} |
||||
|
@ -0,0 +1,77 @@
|
||||
package com.fr.plugin.third.party.xxxx.config; |
||||
|
||||
import com.fanruan.api.xml.XmlKit; |
||||
import com.fr.stable.xml.XMLPrintWriter; |
||||
import com.fr.stable.xml.XMLReadable; |
||||
import com.fr.stable.xml.XMLable; |
||||
import com.fr.stable.xml.XMLableReader; |
||||
|
||||
import java.util.ArrayList; |
||||
import java.util.List; |
||||
|
||||
public class CustomLevelDictionarySettings implements XMLable { |
||||
public static final String XML_TAG = "CustomLevelDictionarySettings"; |
||||
private List<CustomLevelDictionaryConfig> settings = new ArrayList<>(); |
||||
private String dsName; |
||||
|
||||
public String getDsName() { |
||||
return dsName; |
||||
} |
||||
|
||||
public void setDsName(String dsName) { |
||||
this.dsName = dsName; |
||||
} |
||||
|
||||
public void addConfig(CustomLevelDictionaryConfig config) { |
||||
settings.add(config); |
||||
} |
||||
|
||||
public void clearConfigs() { |
||||
settings.clear(); |
||||
} |
||||
|
||||
public void removeConfig(CustomLevelDictionaryConfig config) { |
||||
settings.remove(config); |
||||
} |
||||
|
||||
public CustomLevelDictionaryConfig[] getConfigs() { |
||||
return settings.toArray(new CustomLevelDictionaryConfig[0]); |
||||
} |
||||
|
||||
|
||||
@Override |
||||
public void readXML(XMLableReader reader) { |
||||
if (reader.isChildNode()) { |
||||
reader.readXMLObject(new XMLReadable() { |
||||
@Override |
||||
public void readXML(XMLableReader xmLableReader) { |
||||
if (xmLableReader.isChildNode()) { |
||||
String tagName = xmLableReader.getTagName(); |
||||
if (CustomLevelDictionaryConfig.XML_TAG.equals(tagName)) { |
||||
CustomLevelDictionaryConfig target = (CustomLevelDictionaryConfig) XmlKit.readXMLable(xmLableReader); |
||||
settings.add(target); |
||||
} |
||||
} |
||||
} |
||||
}); |
||||
} |
||||
} |
||||
|
||||
@Override |
||||
public void writeXML(XMLPrintWriter writer) { |
||||
for (CustomLevelDictionaryConfig target : settings) { |
||||
XmlKit.writeXMLable(writer, target, CustomLevelDictionaryConfig.XML_TAG); |
||||
} |
||||
} |
||||
|
||||
@Override |
||||
public Object clone() throws CloneNotSupportedException { |
||||
CustomLevelDictionarySettings cloned = (CustomLevelDictionarySettings) super.clone(); |
||||
List<CustomLevelDictionaryConfig> list = new ArrayList<CustomLevelDictionaryConfig>(); |
||||
for (CustomLevelDictionaryConfig target : settings) { |
||||
list.add((CustomLevelDictionaryConfig) target.clone()); |
||||
} |
||||
cloned.settings = list; |
||||
return cloned; |
||||
} |
||||
} |
@ -0,0 +1,68 @@
|
||||
package com.fr.plugin.third.party.xxxx.data; |
||||
|
||||
/** |
||||
* 数据字典 |
||||
*/ |
||||
public class CustomDictionaryData { |
||||
|
||||
/** |
||||
* 数据集名称 |
||||
*/ |
||||
private String dsName; |
||||
/** |
||||
* 实际值列名 |
||||
*/ |
||||
private String value; |
||||
/** |
||||
* 显示值列名 |
||||
*/ |
||||
private String name; |
||||
/** |
||||
* 父级实际值列名 |
||||
*/ |
||||
private String upperValue; |
||||
/** |
||||
* 父级显示值列名 |
||||
*/ |
||||
private String upperName; |
||||
|
||||
public String getDsName() { |
||||
return dsName; |
||||
} |
||||
|
||||
public void setDsName(String dsName) { |
||||
this.dsName = dsName; |
||||
} |
||||
|
||||
public String getValue() { |
||||
return value; |
||||
} |
||||
|
||||
public void setValue(String value) { |
||||
this.value = value; |
||||
} |
||||
|
||||
public String getName() { |
||||
return name; |
||||
} |
||||
|
||||
public void setName(String name) { |
||||
this.name = name; |
||||
} |
||||
|
||||
public String getUpperValue() { |
||||
return upperValue; |
||||
} |
||||
|
||||
public void setUpperValue(String upperValue) { |
||||
this.upperValue = upperValue; |
||||
} |
||||
|
||||
public String getUpperName() { |
||||
return upperName; |
||||
} |
||||
|
||||
public void setUpperName(String upperName) { |
||||
this.upperName = upperName; |
||||
} |
||||
} |
@ -0,0 +1,63 @@
|
||||
package com.fr.plugin.third.party.xxxx.data; |
||||
|
||||
/** |
||||
* 返回值类型 |
||||
*/ |
||||
public class CustomReturnData { |
||||
/** |
||||
* 返回值类型 数组,字符串 |
||||
*/ |
||||
private boolean returnArray = false; |
||||
/** |
||||
* 分割符 |
||||
*/ |
||||
private String delimiter = ","; |
||||
/** |
||||
* 起始符 |
||||
*/ |
||||
private String startSymbol = ""; |
||||
/** |
||||
* 结束符 |
||||
*/ |
||||
private String endSymbol = ""; |
||||
|
||||
public boolean isReturnArray() { |
||||
return returnArray; |
||||
} |
||||
|
||||
public void setReturnArray(boolean option) { |
||||
this.returnArray = option; |
||||
} |
||||
|
||||
public boolean isReturnString() { |
||||
return !this.returnArray; |
||||
} |
||||
|
||||
public void setReturnString(boolean option) { |
||||
this.returnArray = !option; |
||||
} |
||||
|
||||
public String getDelimiter() { |
||||
return delimiter; |
||||
} |
||||
|
||||
public void setDelimiter(String delimiter) { |
||||
this.delimiter = delimiter; |
||||
} |
||||
|
||||
public String getStartSymbol() { |
||||
return startSymbol; |
||||
} |
||||
|
||||
public void setStartSymbol(String startSymbol) { |
||||
this.startSymbol = startSymbol; |
||||
} |
||||
|
||||
public String getEndSymbol() { |
||||
return endSymbol; |
||||
} |
||||
|
||||
public void setEndSymbol(String endSymbol) { |
||||
this.endSymbol = endSymbol; |
||||
} |
||||
} |
@ -0,0 +1,63 @@
|
||||
package com.fr.plugin.third.party.xxxx.data; |
||||
|
||||
/** |
||||
* 返回值类型 |
||||
*/ |
||||
public class CustomReturnDataConfig { |
||||
/** |
||||
* 返回值类型 数组,字符串 |
||||
*/ |
||||
private boolean returnArray = false; |
||||
/** |
||||
* 分割符 |
||||
*/ |
||||
private String delimiter = ","; |
||||
/** |
||||
* 起始符 |
||||
*/ |
||||
private String startSymbol = ""; |
||||
/** |
||||
* 结束符 |
||||
*/ |
||||
private String endSymbol = ""; |
||||
|
||||
public boolean isReturnArray() { |
||||
return returnArray; |
||||
} |
||||
|
||||
public void setReturnArray(boolean option) { |
||||
this.returnArray = option; |
||||
} |
||||
|
||||
public boolean isReturnString() { |
||||
return !this.returnArray; |
||||
} |
||||
|
||||
public void setReturnString(boolean option) { |
||||
this.returnArray = !option; |
||||
} |
||||
|
||||
public String getDelimiter() { |
||||
return delimiter; |
||||
} |
||||
|
||||
public void setDelimiter(String delimiter) { |
||||
this.delimiter = delimiter; |
||||
} |
||||
|
||||
public String getStartSymbol() { |
||||
return startSymbol; |
||||
} |
||||
|
||||
public void setStartSymbol(String startSymbol) { |
||||
this.startSymbol = startSymbol; |
||||
} |
||||
|
||||
public String getEndSymbol() { |
||||
return endSymbol; |
||||
} |
||||
|
||||
public void setEndSymbol(String endSymbol) { |
||||
this.endSymbol = endSymbol; |
||||
} |
||||
} |
@ -0,0 +1,274 @@
|
||||
package com.fr.plugin.third.party.xxxx.data; |
||||
|
||||
import com.fr.plugin.third.party.xxxx.config.CustomLevelDictionarySettings; |
||||
|
||||
/** |
||||
* 控件设置 |
||||
*/ |
||||
public class CustomWidgetConfig { |
||||
/** |
||||
* 数据字典类型索引号 |
||||
*/ |
||||
private int dicTypeIndex = 0; |
||||
/** |
||||
* 数据集名称 |
||||
*/ |
||||
private String dsName; |
||||
|
||||
|
||||
/** |
||||
* 数据库名称 |
||||
*/ |
||||
private String dbName; |
||||
|
||||
/** |
||||
* 模式名称 |
||||
*/ |
||||
private String schemaName; |
||||
/** |
||||
* 表名称 |
||||
*/ |
||||
private String tableName; |
||||
|
||||
/** |
||||
* 实际值列名 |
||||
*/ |
||||
private String value; |
||||
/** |
||||
* 显示值列名 |
||||
*/ |
||||
private String name; |
||||
/** |
||||
* 父级实际值列名 |
||||
*/ |
||||
private String upperValue; |
||||
/** |
||||
* 父级显示值列名 |
||||
*/ |
||||
private String upperName; |
||||
|
||||
private int fontSize = 12; |
||||
|
||||
public int getDicTypeIndex() { |
||||
return dicTypeIndex; |
||||
} |
||||
|
||||
public void setDicTypeIndex(int dicTypeIndex) { |
||||
this.dicTypeIndex = dicTypeIndex; |
||||
} |
||||
|
||||
public String getDsName() { |
||||
return dsName; |
||||
} |
||||
|
||||
public void setDsName(String dsName) { |
||||
this.dsName = dsName; |
||||
} |
||||
|
||||
public String getDbName() { |
||||
return dbName; |
||||
} |
||||
|
||||
public void setDbName(String dbName) { |
||||
this.dbName = dbName; |
||||
} |
||||
|
||||
public String getSchemaName() { |
||||
return schemaName; |
||||
} |
||||
|
||||
public void setSchemaName(String schemaName) { |
||||
this.schemaName = schemaName; |
||||
} |
||||
|
||||
public String getTableName() { |
||||
return tableName; |
||||
} |
||||
|
||||
public void setTableName(String tableName) { |
||||
this.tableName = tableName; |
||||
} |
||||
|
||||
public String getValue() { |
||||
return value; |
||||
} |
||||
|
||||
public void setValue(String value) { |
||||
this.value = value; |
||||
} |
||||
|
||||
public String getName() { |
||||
return name; |
||||
} |
||||
|
||||
public void setName(String name) { |
||||
this.name = name; |
||||
} |
||||
|
||||
public String getUpperValue() { |
||||
return upperValue; |
||||
} |
||||
|
||||
public void setUpperValue(String upperValue) { |
||||
this.upperValue = upperValue; |
||||
} |
||||
|
||||
public String getUpperName() { |
||||
return upperName; |
||||
} |
||||
|
||||
public void setUpperName(String upperName) { |
||||
this.upperName = upperName; |
||||
} |
||||
|
||||
|
||||
/** |
||||
* 返回值类型 数组,字符串 |
||||
*/ |
||||
private boolean returnArray = false; |
||||
/** |
||||
* 分割符 |
||||
*/ |
||||
private String delimiter = ","; |
||||
/** |
||||
* 起始符 |
||||
*/ |
||||
private String startSymbol = ""; |
||||
/** |
||||
* 结束符 |
||||
*/ |
||||
private String endSymbol = ""; |
||||
/* |
||||
public boolean isReturnArray() { |
||||
return returnArray; |
||||
} |
||||
|
||||
public void setReturnArray(boolean option) { |
||||
this.returnArray = option; |
||||
} |
||||
|
||||
public boolean isReturnString() { |
||||
return !this.returnArray; |
||||
} |
||||
|
||||
public void setReturnString(boolean option) { |
||||
this.returnArray = !option; |
||||
} |
||||
|
||||
public String getDelimiter() { |
||||
return delimiter; |
||||
} |
||||
|
||||
public void setDelimiter(String delimiter) { |
||||
this.delimiter = delimiter; |
||||
} |
||||
|
||||
public String getStartSymbol() { |
||||
return startSymbol; |
||||
} |
||||
|
||||
public void setStartSymbol(String startSymbol) { |
||||
this.startSymbol = startSymbol; |
||||
} |
||||
|
||||
public String getEndSymbol() { |
||||
return endSymbol; |
||||
} |
||||
|
||||
public void setEndSymbol(String endSymbol) { |
||||
this.endSymbol = endSymbol; |
||||
} |
||||
*/ |
||||
|
||||
/** |
||||
* 弹出框的标题 |
||||
*/ |
||||
private String windowTitle; |
||||
/** |
||||
* 筛选列标题 |
||||
*/ |
||||
private String filterTitle; |
||||
/** |
||||
* 待选列表标题 |
||||
*/ |
||||
private String candidateTitle; |
||||
/** |
||||
* 选中列表标题 |
||||
*/ |
||||
private String selectedTitle; |
||||
/** |
||||
* 弹出框宽度 |
||||
*/ |
||||
private double width; |
||||
/** |
||||
* 弹出框高度 |
||||
*/ |
||||
private double height; |
||||
|
||||
public String getWindowTitle() { |
||||
return windowTitle; |
||||
} |
||||
|
||||
public void setWindowTitle(String windowTitle) { |
||||
this.windowTitle = windowTitle; |
||||
} |
||||
|
||||
public String getFilterTitle() { |
||||
return filterTitle; |
||||
} |
||||
|
||||
public void setFilterTitle(String filterTitle) { |
||||
this.filterTitle = filterTitle; |
||||
} |
||||
|
||||
public String getCandidateTitle() { |
||||
return candidateTitle; |
||||
} |
||||
|
||||
public void setCandidateTitle(String candidateTitle) { |
||||
this.candidateTitle = candidateTitle; |
||||
} |
||||
|
||||
public String getSelectedTitle() { |
||||
return selectedTitle; |
||||
} |
||||
|
||||
public void setSelectedTitle(String selectedTitle) { |
||||
this.selectedTitle = selectedTitle; |
||||
} |
||||
|
||||
public double getWidth() { |
||||
return width; |
||||
} |
||||
|
||||
public void setWidth(double width) { |
||||
this.width = width; |
||||
} |
||||
|
||||
public double getHeight() { |
||||
return height; |
||||
} |
||||
|
||||
public void setHeight(double height) { |
||||
this.height = height; |
||||
} |
||||
|
||||
public int getFontSize() { |
||||
return fontSize; |
||||
} |
||||
|
||||
public void setFontSize(int fontSize) { |
||||
this.fontSize = fontSize; |
||||
} |
||||
|
||||
|
||||
private CustomLevelDictionarySettings dicSettings; |
||||
|
||||
public CustomLevelDictionarySettings getDicSettings() { |
||||
return dicSettings; |
||||
} |
||||
|
||||
public void setDicSettings(CustomLevelDictionarySettings dicSettings) { |
||||
this.dicSettings = dicSettings; |
||||
} |
||||
} |
@ -0,0 +1,23 @@
|
||||
package com.fr.plugin.third.party.xxxx.function; |
||||
|
||||
import com.fr.json.JSONArray; |
||||
import com.fr.script.AbstractFunction; |
||||
|
||||
public class GetLevelValue extends AbstractFunction { |
||||
public Object run(Object[] args) { |
||||
if ((args == null) || (args.length <= 1)) { |
||||
return ""; |
||||
} |
||||
String content = String.valueOf(args[0]); |
||||
int index = Integer.valueOf(String.valueOf(args[1])); |
||||
if (index <= -1) { |
||||
return ""; |
||||
} |
||||
JSONArray jsonArray = new JSONArray(content); |
||||
if ((jsonArray == null) || (jsonArray.size() <= index)) { |
||||
return ""; |
||||
} |
||||
Object object = jsonArray.get(index); |
||||
return object; |
||||
} |
||||
} |
@ -0,0 +1,42 @@
|
||||
package com.fr.plugin.third.party.xxxx.ui; |
||||
|
||||
import com.fr.base.TableData; |
||||
import com.fr.design.data.DesignTableDataManager; |
||||
import com.fr.design.present.dict.DatabaseDictPane; |
||||
|
||||
import java.awt.event.ItemListener; |
||||
import java.util.ArrayList; |
||||
import java.util.List; |
||||
|
||||
public class CustomDatabaseDictPane extends DatabaseDictPane { |
||||
private List<ItemListener> listeners = new ArrayList<>(); |
||||
|
||||
public CustomDatabaseDictPane() { |
||||
if (this.getComponentCount() >= 2) { |
||||
this.getComponent(1).setVisible(false); |
||||
} |
||||
} |
||||
|
||||
public List<String> getColumnNames() { |
||||
TableData var1 = this.chooseTable.createSelectTableData(); |
||||
List<String> var2 = DesignTableDataManager.getColumnNamesByTableData(var1); |
||||
return var2; |
||||
} |
||||
|
||||
|
||||
public void dbChange() { |
||||
super.dbChange(); |
||||
ItemListener listener; |
||||
for (int i = 0, max = listeners.size() - 1; i <= max; i++) { |
||||
listener = listeners.get(i); |
||||
listener.itemStateChanged(null); |
||||
} |
||||
} |
||||
|
||||
public void addListener(ItemListener listener) { |
||||
if (listener == null) { |
||||
return; |
||||
} |
||||
this.listeners.add(listener); |
||||
} |
||||
} |
@ -0,0 +1,65 @@
|
||||
package com.fr.plugin.third.party.xxxx.ui; |
||||
|
||||
import com.fr.design.dialog.BasicDialog; |
||||
import com.fr.design.dialog.DialogActionAdapter; |
||||
import com.fr.design.mainframe.widget.accessibles.UneditableAccessibleEditor; |
||||
import com.fr.design.mainframe.widget.wrappers.DictionaryWrapper; |
||||
import com.fr.plugin.third.party.xxxx.data.CustomWidgetConfig; |
||||
|
||||
import javax.swing.*; |
||||
|
||||
public class CustomDictionaryEditor extends UneditableAccessibleEditor { |
||||
//import com.fr.design.mainframe.widget.accessibles.AccessibleDictionaryEditor;
|
||||
private CustomDictionaryPane dictPane; |
||||
|
||||
public CustomDictionaryEditor() { |
||||
super(new DictionaryWrapper()); |
||||
this.dictPane = new CustomDictionaryPane(); |
||||
} |
||||
|
||||
protected void showEditorPane() { |
||||
if (this.dictPane == null) { |
||||
this.dictPane = new CustomDictionaryPane(); |
||||
} |
||||
|
||||
BasicDialog var1 = this.dictPane.showWindow(SwingUtilities.getWindowAncestor(this)); |
||||
var1.addDialogActionListener(new DialogActionAdapter() { |
||||
public void doOk() { |
||||
//CustomDictionaryData var1 = (CustomDictionaryData) CustomDictionaryEditor.this.dictPane.updateBean();
|
||||
//CustomDictionaryEditor.this.setValue(var1);
|
||||
CustomDictionaryEditor.this.fireStateChanged(); |
||||
} |
||||
}); |
||||
this.dictPane.populateBean((CustomWidgetConfig) this.getValue()); |
||||
var1.setVisible(true); |
||||
} |
||||
|
||||
@Override |
||||
public Object getValue() { |
||||
//System.out.println("CustomDictionaryEditor:getValue");
|
||||
return this.dictPane.updateBean(); |
||||
} |
||||
|
||||
@Override |
||||
public void setValue(Object value) { |
||||
//System.out.println("CustomDictionaryEditor:setValue");
|
||||
if (value == null) { |
||||
return; |
||||
} |
||||
if (!(value instanceof CustomWidgetConfig)) { |
||||
return; |
||||
} |
||||
CustomWidgetConfig data = (CustomWidgetConfig) value; |
||||
this.dictPane.populateBean(data); |
||||
} |
||||
|
||||
public void populateBean(CustomWidgetConfig data) { |
||||
//System.out.println("CustomDictionaryEditor:populateBean");
|
||||
this.setValue(data); |
||||
} |
||||
|
||||
public CustomWidgetConfig updateBean() { |
||||
//System.out.println("CustomDictionaryEditor:updateBean");
|
||||
return (CustomWidgetConfig)this.getValue(); |
||||
} |
||||
} |
@ -0,0 +1,90 @@
|
||||
package com.fr.plugin.third.party.xxxx.ui; |
||||
|
||||
import com.fanruan.api.design.DesignKit; |
||||
import com.fanruan.api.design.ui.component.UILabel; |
||||
import com.fanruan.api.design.ui.component.UITitledBorder; |
||||
import com.fanruan.api.design.ui.layout.TableLayoutKit; |
||||
import com.fr.design.beans.BasicBeanPane; |
||||
import com.fr.design.data.DataCreatorUI; |
||||
import com.fr.design.widget.ui.designer.component.FontSizeComboPane; |
||||
import com.fr.design.widget.ui.designer.component.UIBoundSpinner; |
||||
import com.fr.plugin.third.party.xxxx.config.CustomLevelDictionarySettings; |
||||
import com.fr.plugin.third.party.xxxx.data.CustomWidgetConfig; |
||||
|
||||
import javax.swing.*; |
||||
import java.awt.*; |
||||
|
||||
public class CustomDictionaryPane extends BasicBeanPane<CustomWidgetConfig> implements DataCreatorUI { |
||||
private CustomDictionarySettingsPane settingsPane; |
||||
|
||||
private UIBoundSpinner widthBoundSpinner = new UIBoundSpinner(0.0D, 2.147483647E9D, 1.0D, 0.0D); |
||||
private UIBoundSpinner heightBoundSpinner = new UIBoundSpinner(0.0D, 2.147483647E9D, 1.0D, 0.0D); |
||||
private FontSizeComboPane fontSizeComboPane = new FontSizeComboPane(); |
||||
|
||||
public CustomDictionaryPane() { |
||||
initLayout(); |
||||
} |
||||
|
||||
private void initLayout() { |
||||
this.setLayout(new BorderLayout(0, 4)); |
||||
double p = TableLayoutKit.PREFERRED; |
||||
double[] columnSize = new double[]{p, 400}; |
||||
double[] rowSize = new double[]{p, p}; |
||||
fontSizeComboPane.setValue(12); |
||||
Component[][] components = new Component[][]{ |
||||
//{new UILabel("宽度:"), widthBoundSpinner},
|
||||
{new UILabel("高度:"), heightBoundSpinner}, |
||||
{new UILabel("字体大小:"), fontSizeComboPane} |
||||
}; |
||||
|
||||
JPanel settingsUI1 = TableLayoutKit.createTableLayoutPane(components, rowSize, columnSize); |
||||
settingsUI1.setBorder(UITitledBorder.createBorderWithTitle(DesignKit.i18nText("FR-Plugin-Two-Way-Selection_Popup_UI"))); |
||||
|
||||
this.add(settingsUI1, "North"); |
||||
|
||||
settingsPane = new CustomDictionarySettingsPane(); |
||||
this.add(settingsPane, "Center"); |
||||
} |
||||
|
||||
|
||||
@Override |
||||
public JComponent toSwingComponent() { |
||||
return this; |
||||
} |
||||
|
||||
@Override |
||||
protected String title4PopupWindow() { |
||||
return DesignKit.i18nText("Fine-Design_Basic_Widget_Settings"); |
||||
} |
||||
|
||||
@Override |
||||
public void populateBean(CustomWidgetConfig widgetConfig) { |
||||
if (widgetConfig == null) { |
||||
return; |
||||
} |
||||
this.widthBoundSpinner.setValue(widgetConfig.getWidth()); |
||||
this.heightBoundSpinner.setValue(widgetConfig.getHeight()); |
||||
this.fontSizeComboPane.setValue(widgetConfig.getFontSize()); |
||||
|
||||
CustomLevelDictionarySettings settings = widgetConfig.getDicSettings(); |
||||
if (settings != null) { |
||||
settings.setDsName(widgetConfig.getDsName()); |
||||
this.settingsPane.populateBean(settings); |
||||
} |
||||
} |
||||
|
||||
@Override |
||||
public CustomWidgetConfig updateBean() { |
||||
CustomWidgetConfig widgetConfig = new CustomWidgetConfig(); |
||||
double width = widthBoundSpinner.getValue(); |
||||
double height = heightBoundSpinner.getValue(); |
||||
int fontSize = this.fontSizeComboPane.getValue(); |
||||
CustomLevelDictionarySettings settings = this.settingsPane.updateBean(); |
||||
widgetConfig.setDicSettings(settings); |
||||
widgetConfig.setDsName(settings.getDsName()); |
||||
widgetConfig.setWidth(width); |
||||
widgetConfig.setHeight(height); |
||||
widgetConfig.setFontSize(fontSize); |
||||
return widgetConfig; |
||||
} |
||||
} |
@ -0,0 +1,9 @@
|
||||
package com.fr.plugin.third.party.xxxx.ui; |
||||
|
||||
import com.fr.design.mainframe.widget.accessibles.AccessiblePropertyEditor; |
||||
|
||||
public class CustomDictionaryPropertyEditor extends AccessiblePropertyEditor { |
||||
public CustomDictionaryPropertyEditor() { |
||||
super(new CustomDictionaryEditor()); |
||||
} |
||||
} |
@ -0,0 +1,153 @@
|
||||
package com.fr.plugin.third.party.xxxx.ui; |
||||
|
||||
import com.fanruan.api.design.ui.component.UIComboBox; |
||||
import com.fanruan.api.design.ui.component.UILabel; |
||||
import com.fanruan.api.design.ui.component.table.UITableEditorPane; |
||||
import com.fanruan.api.log.LogKit; |
||||
import com.fr.base.TableData; |
||||
import com.fr.data.TableDataSource; |
||||
import com.fr.design.beans.BasicBeanPane; |
||||
import com.fr.design.data.DesignTableDataManager; |
||||
import com.fr.design.data.datapane.TableDataComboBox; |
||||
import com.fr.design.data.tabledata.wrapper.TableDataWrapper; |
||||
import com.fr.design.utils.gui.GUICoreUtils; |
||||
import com.fr.general.data.DataModel; |
||||
import com.fr.plugin.third.party.xxxx.config.CustomLevelDictionaryConfig; |
||||
import com.fr.plugin.third.party.xxxx.config.CustomLevelDictionarySettings; |
||||
|
||||
import javax.swing.*; |
||||
import java.awt.*; |
||||
import java.awt.event.ItemEvent; |
||||
import java.awt.event.ItemListener; |
||||
import java.util.ArrayList; |
||||
import java.util.List; |
||||
|
||||
import com.fr.script.Calculator; |
||||
|
||||
public class CustomDictionarySettingsPane extends BasicBeanPane<CustomLevelDictionarySettings> { |
||||
private TableDataComboBox tableDataComboBox; |
||||
private UITableEditorPane<CustomLevelDictionaryConfig> tableEditorPane; |
||||
private CustomLevelDictionaryConfigTableModel model = new CustomLevelDictionaryConfigTableModel(); |
||||
|
||||
public CustomDictionarySettingsPane() { |
||||
setLayout(new BorderLayout()); |
||||
this.tableEditorPane = new UITableEditorPane<>(model); |
||||
this.add(tableEditorPane, BorderLayout.CENTER); |
||||
|
||||
this.tableDataComboBox = new TableDataComboBox(this.getTableDataSource()); |
||||
this.tableDataComboBox.addItemListener(this.tableDataComboBoxListener); |
||||
|
||||
Dimension dimension = this.tableDataComboBox.getPreferredSize(); |
||||
Dimension newDimension = new Dimension(); |
||||
newDimension.setSize(dimension.getWidth() + 40, dimension.getHeight()); |
||||
this.tableDataComboBox.setPreferredSize(newDimension); |
||||
this.add(GUICoreUtils.createFlowPane(new Component[]{new UILabel("数据集名称:"), this.tableDataComboBox}, 0, 12), BorderLayout.NORTH); |
||||
} |
||||
|
||||
@Override |
||||
public void populateBean(CustomLevelDictionarySettings settings) { |
||||
model.clear(); |
||||
if (settings != null) { |
||||
this.tableDataComboBox.setSelectedTableDataByName(settings.getDsName()); |
||||
this.tableEditorPane.populate(settings.getConfigs()); |
||||
} |
||||
setColumnNames(); |
||||
} |
||||
|
||||
@Override |
||||
public CustomLevelDictionarySettings updateBean() { |
||||
CustomLevelDictionarySettings settings = new CustomLevelDictionarySettings(); |
||||
List<CustomLevelDictionaryConfig> configs = tableEditorPane.update(); |
||||
for (CustomLevelDictionaryConfig config : configs) { |
||||
settings.addConfig(config); |
||||
} |
||||
TableDataWrapper tableDataWrapper = this.tableDataComboBox.getSelectedItem(); |
||||
String dsName = ""; |
||||
if (tableDataWrapper != null) { |
||||
dsName = tableDataWrapper.getTableDataName(); |
||||
settings.setDsName(dsName); |
||||
} |
||||
return settings; |
||||
} |
||||
|
||||
private void setColumnNames() { |
||||
List<String> values = getTableDataColumnNames(); |
||||
setColumnValues(values, 0); |
||||
setColumnValues(values, 1); |
||||
} |
||||
|
||||
private void setColumnValues(List<String> values, int columnIndex) { |
||||
JTable table = model.createTable(); |
||||
//int rowCount = table.getRowCount();
|
||||
// if (rowCount <= 0) {
|
||||
// return;
|
||||
// }
|
||||
|
||||
Component comp; |
||||
UIComboBox comboBox; |
||||
DefaultComboBoxModel comboBoxModel; |
||||
|
||||
comp = table.getCellEditor(0, columnIndex).getTableCellEditorComponent(null, null, false, 0, columnIndex); |
||||
if (!(comp instanceof UIComboBox)) { |
||||
return; |
||||
} |
||||
comboBox = (UIComboBox) comp; |
||||
comboBoxModel = (DefaultComboBoxModel) comboBox.getModel(); |
||||
comboBoxModel.removeAllElements(); |
||||
comboBoxModel.addElement(""); |
||||
|
||||
if ((values == null) || (values.isEmpty())) { |
||||
return; |
||||
} |
||||
for (int i = 0, max = values.size() - 1; i <= max; i++) { |
||||
comboBoxModel.addElement(values.get(i)); |
||||
} |
||||
} |
||||
|
||||
private ItemListener tableDataComboBoxListener = new ItemListener() { |
||||
public void itemStateChanged(ItemEvent var1) { |
||||
setColumnNames(); |
||||
} |
||||
}; |
||||
|
||||
protected TableDataSource getTableDataSource() { |
||||
return DesignTableDataManager.getEditingTableDataSource(); |
||||
} |
||||
|
||||
private List<String> getTableDataColumnNames() { |
||||
TableDataWrapper tdw = this.tableDataComboBox.getSelectedItem(); |
||||
if (tdw == null) { |
||||
return new ArrayList(); |
||||
} |
||||
//List var1 = tdw.calculateColumnNameList();
|
||||
List var1 = createTableDataColNames(tdw.getTableData()); |
||||
if (var1 != null) { |
||||
return var1; |
||||
} |
||||
return new ArrayList(); |
||||
} |
||||
|
||||
private List<String> createTableDataColNames(TableData tableData) { |
||||
List<String> names = new ArrayList<>(); |
||||
if (tableData == null) { |
||||
return names; |
||||
} |
||||
try { |
||||
DataModel dataModel = tableData.createDataModel(Calculator.createCalculator()); |
||||
int count = dataModel.getColumnCount(); |
||||
for (int i = 0; i < count; i++) { |
||||
names.add(dataModel.getColumnName(i)); |
||||
} |
||||
dataModel.release(); |
||||
} catch (Exception e) { |
||||
LogKit.error(e.getMessage(), e); |
||||
} |
||||
return names; |
||||
} |
||||
|
||||
|
||||
@Override |
||||
protected String title4PopupWindow() { |
||||
return "Path"; |
||||
} |
||||
} |
@ -0,0 +1,274 @@
|
||||
package com.fr.plugin.third.party.xxxx.ui; |
||||
|
||||
import com.fanruan.api.design.ui.component.UIComboBox; |
||||
import com.fanruan.api.design.ui.component.UINumberField; |
||||
import com.fanruan.api.design.ui.component.UITextField; |
||||
import com.fanruan.api.design.ui.component.table.action.UITableEditAction; |
||||
import com.fanruan.api.design.ui.component.table.model.UITableModelAdapter; |
||||
import com.fanruan.api.util.GeneralKit; |
||||
import com.fr.base.BaseUtils; |
||||
import com.fr.plugin.third.party.xxxx.config.CustomLevelDictionaryConfig; |
||||
|
||||
import javax.swing.*; |
||||
import javax.swing.event.CellEditorListener; |
||||
import javax.swing.event.ChangeEvent; |
||||
import javax.swing.table.DefaultTableCellRenderer; |
||||
import javax.swing.table.TableCellEditor; |
||||
import java.awt.*; |
||||
import java.awt.event.ActionEvent; |
||||
|
||||
public class CustomLevelDictionaryConfigTableModel extends UITableModelAdapter<CustomLevelDictionaryConfig> { |
||||
public CustomLevelDictionaryConfigTableModel() { |
||||
super(new String[]{"实际值列名", "显示值列名", "标题", "宽度"}); |
||||
|
||||
this.setColumnClass(new Class[]{ValueColumnEditor.class, NameColumnEditor.class, TitleEditor.class,LevelWidthEditor.class}); |
||||
this.setDefaultEditor(ValueColumnEditor.class, new ValueColumnEditor()); |
||||
this.setDefaultRenderer(ValueColumnEditor.class, new SimpleRenderer()); |
||||
|
||||
this.setDefaultEditor(NameColumnEditor.class, new NameColumnEditor()); |
||||
this.setDefaultRenderer(NameColumnEditor.class, new SimpleRenderer()); |
||||
|
||||
this.setDefaultEditor(TitleEditor.class, new TitleEditor()); |
||||
this.setDefaultRenderer(TitleEditor.class, new SimpleRenderer()); |
||||
|
||||
this.setDefaultEditor(LevelWidthEditor.class, new LevelWidthEditor()); |
||||
this.setDefaultRenderer(LevelWidthEditor.class, new SimpleRenderer()); |
||||
} |
||||
|
||||
@Override |
||||
public Object getValueAt(final int row, final int column) { |
||||
final CustomLevelDictionaryConfig config = this.getList().get(row); |
||||
switch (column) { |
||||
case 0: { |
||||
return config.getValueColumnName(); |
||||
} |
||||
case 1: { |
||||
return config.getNameColumnName(); |
||||
} |
||||
case 2: { |
||||
return config.getTitle(); |
||||
} |
||||
case 3: { |
||||
return config.getLevelWidth(); |
||||
} |
||||
default: { |
||||
return null; |
||||
} |
||||
} |
||||
} |
||||
|
||||
@Override |
||||
public boolean isCellEditable(final int row, final int column) { |
||||
return true; |
||||
} |
||||
|
||||
@Override |
||||
public UITableEditAction[] createAction() { |
||||
return new UITableEditAction[]{ |
||||
new AddPathAction(), |
||||
new DeleteAction() |
||||
}; |
||||
} |
||||
|
||||
private void addPath() { |
||||
this.addRow(new CustomLevelDictionaryConfig()); |
||||
this.fireTableDataChanged(); |
||||
this.table.getSelectionModel().setSelectionInterval(this.table.getRowCount() - 1, this.table.getRowCount() - 1); |
||||
} |
||||
|
||||
private void deletePath() { |
||||
if (this.getRowCount() <= 0) { |
||||
return; |
||||
} |
||||
|
||||
int[] selectedRows = this.table.getSelectedRows(); |
||||
if ((selectedRows != null) && (selectedRows.length >= 1)) { |
||||
for (int i = 0, max = selectedRows.length - 1; i <= max; i++) { |
||||
this.removeRow(selectedRows[i]); |
||||
} |
||||
} else { |
||||
int selectedRowIndex = this.table.getRowCount() - 1; |
||||
if (selectedRowIndex >= 0) { |
||||
this.removeRow(selectedRowIndex); |
||||
} |
||||
} |
||||
|
||||
this.fireTableDataChanged(); |
||||
this.table.getSelectionModel().setSelectionInterval(this.table.getRowCount() - 1, this.table.getRowCount() - 1); |
||||
} |
||||
|
||||
|
||||
private class ValueColumnEditor extends AbstractCellEditor implements TableCellEditor { |
||||
private static final long serialVersionUID = 1L; |
||||
private UIComboBox valuesComboBox; |
||||
|
||||
public ValueColumnEditor() { |
||||
valuesComboBox = new UIComboBox(); |
||||
this.addCellEditorListener(new CellEditorListener() { |
||||
@Override |
||||
public void editingCanceled(final ChangeEvent changeEvent) { |
||||
} |
||||
|
||||
@Override |
||||
public void editingStopped(final ChangeEvent changeEvent) { |
||||
if (table.getSelectedRow() == -1) { |
||||
return; |
||||
} |
||||
CustomLevelDictionaryConfig config = getList().get(table.getSelectedRow()); |
||||
config.setValueColumnName(GeneralKit.objectToString(getCellEditorValue())); |
||||
fireTableDataChanged(); |
||||
} |
||||
}); |
||||
} |
||||
|
||||
@Override |
||||
public Component getTableCellEditorComponent(final JTable table, final Object value, final boolean isSelected, final int row, final int column) { |
||||
valuesComboBox.setSelectedItem(value); |
||||
return this.valuesComboBox; |
||||
} |
||||
|
||||
@Override |
||||
public Object getCellEditorValue() { |
||||
return this.valuesComboBox.getSelectedItem(); |
||||
} |
||||
} |
||||
|
||||
private class NameColumnEditor extends AbstractCellEditor implements TableCellEditor { |
||||
private static final long serialVersionUID = 1L; |
||||
private UIComboBox namesComboBox; |
||||
|
||||
public NameColumnEditor() { |
||||
namesComboBox = new UIComboBox(); |
||||
this.addCellEditorListener(new CellEditorListener() { |
||||
@Override |
||||
public void editingCanceled(final ChangeEvent changeEvent) { |
||||
} |
||||
|
||||
@Override |
||||
public void editingStopped(final ChangeEvent changeEvent) { |
||||
if (table.getSelectedRow() == -1) { |
||||
return; |
||||
} |
||||
CustomLevelDictionaryConfig config = getList().get(table.getSelectedRow()); |
||||
config.setNameColumnName(GeneralKit.objectToString(getCellEditorValue())); |
||||
fireTableDataChanged(); |
||||
} |
||||
}); |
||||
} |
||||
|
||||
@Override |
||||
public Component getTableCellEditorComponent(final JTable table, final Object value, final boolean isSelected, final int row, final int column) { |
||||
namesComboBox.setSelectedItem(value); |
||||
return this.namesComboBox; |
||||
} |
||||
|
||||
@Override |
||||
public Object getCellEditorValue() { |
||||
return this.namesComboBox.getSelectedItem(); |
||||
} |
||||
} |
||||
|
||||
private class TitleEditor extends AbstractCellEditor implements TableCellEditor { |
||||
private static final long serialVersionUID = 1L; |
||||
private UITextField titleTextField; |
||||
|
||||
public TitleEditor() { |
||||
titleTextField = new UITextField(); |
||||
this.addCellEditorListener(new CellEditorListener() { |
||||
@Override |
||||
public void editingCanceled(final ChangeEvent changeEvent) { |
||||
} |
||||
|
||||
@Override |
||||
public void editingStopped(final ChangeEvent changeEvent) { |
||||
if (table.getSelectedRow() == -1) { |
||||
return; |
||||
} |
||||
CustomLevelDictionaryConfig config = getList().get(table.getSelectedRow()); |
||||
config.setTitle(GeneralKit.objectToString(getCellEditorValue())); |
||||
fireTableDataChanged(); |
||||
} |
||||
}); |
||||
} |
||||
|
||||
@Override |
||||
public Component getTableCellEditorComponent(final JTable table, final Object value, final boolean isSelected, final int row, final int column) { |
||||
titleTextField.setText(GeneralKit.objectToString(value)); |
||||
return this.titleTextField; |
||||
} |
||||
|
||||
@Override |
||||
public Object getCellEditorValue() { |
||||
return this.titleTextField.getText(); |
||||
} |
||||
} |
||||
|
||||
private class LevelWidthEditor extends AbstractCellEditor implements TableCellEditor { |
||||
private static final long serialVersionUID = 1L; |
||||
private UINumberField levelWidthTextField; |
||||
|
||||
public LevelWidthEditor() { |
||||
levelWidthTextField = new UINumberField(); |
||||
this.addCellEditorListener(new CellEditorListener() { |
||||
@Override |
||||
public void editingCanceled(final ChangeEvent changeEvent) { |
||||
} |
||||
|
||||
@Override |
||||
public void editingStopped(final ChangeEvent changeEvent) { |
||||
if (table.getSelectedRow() == -1) { |
||||
return; |
||||
} |
||||
CustomLevelDictionaryConfig config = getList().get(table.getSelectedRow()); |
||||
Object value = getCellEditorValue(); |
||||
Double valueDouble = Double.valueOf(String.valueOf(value)); |
||||
Integer width = valueDouble.intValue(); |
||||
config.setLevelWidth(width); |
||||
fireTableDataChanged(); |
||||
} |
||||
}); |
||||
} |
||||
|
||||
@Override |
||||
public Component getTableCellEditorComponent(final JTable table, final Object value, final boolean isSelected, final int row, final int column) { |
||||
levelWidthTextField.setValue(Double.valueOf(String.valueOf(value))); |
||||
return this.levelWidthTextField; |
||||
} |
||||
|
||||
@Override |
||||
public Object getCellEditorValue() { |
||||
return this.levelWidthTextField.getValue(); |
||||
} |
||||
} |
||||
|
||||
private class SimpleRenderer extends DefaultTableCellRenderer { |
||||
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { |
||||
this.setText(GeneralKit.objectToString(value)); |
||||
return this; |
||||
} |
||||
} |
||||
|
||||
private class AddPathAction extends AddTableRowAction { |
||||
public AddPathAction() { |
||||
super(); |
||||
} |
||||
|
||||
public void actionPerformed(final ActionEvent actionEvent) { |
||||
super.actionPerformed(actionEvent); |
||||
CustomLevelDictionaryConfigTableModel.this.addPath(); |
||||
} |
||||
} |
||||
|
||||
private class DeleteAction extends UITableEditAction { |
||||
public DeleteAction() { |
||||
this.setName(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Delete")); |
||||
this.setSmallIcon(BaseUtils.readIcon("/com/fr/base/images/cell/control/remove.png")); |
||||
} |
||||
|
||||
public void actionPerformed(ActionEvent actionEvent) { |
||||
CustomLevelDictionaryConfigTableModel.this.deletePath(); |
||||
} |
||||
} |
||||
} |
||||
|
||||
|
@ -0,0 +1,85 @@
|
||||
package com.fr.plugin.third.party.xxxx.ui; |
||||
|
||||
import com.fr.design.gui.ibutton.UIButtonGroup; |
||||
import com.fr.design.gui.icombobox.DictionaryComboBox; |
||||
import com.fr.design.gui.icombobox.DictionaryConstants; |
||||
import com.fr.design.gui.ilable.UILabel; |
||||
import com.fr.design.layout.FRGUIPaneFactory; |
||||
import com.fr.design.layout.TableLayoutHelper; |
||||
import com.fr.plugin.third.party.xxxx.data.CustomReturnDataConfig; |
||||
|
||||
import javax.swing.*; |
||||
import java.awt.*; |
||||
import java.awt.event.ActionEvent; |
||||
import java.awt.event.ActionListener; |
||||
|
||||
public class ReturnTypePane extends JPanel { |
||||
private DictionaryComboBox delimiterComboBox; |
||||
private UIButtonGroup returnTypeComboBox; |
||||
private DictionaryComboBox startComboBox; |
||||
private DictionaryComboBox endComboBox; |
||||
private JPanel returnStringPane; |
||||
private ActionListener doChangeListener; |
||||
|
||||
public ReturnTypePane() { |
||||
this.setLayout(FRGUIPaneFactory.createBorderLayout()); |
||||
this.delimiterComboBox = new DictionaryComboBox(DictionaryConstants.delimiters, DictionaryConstants.delimiterDisplays); |
||||
this.delimiterComboBox.setEditable(true); |
||||
this.startComboBox = new DictionaryComboBox(DictionaryConstants.symbols, DictionaryConstants.symbolDisplays); |
||||
this.startComboBox.setEditable(true); |
||||
this.endComboBox = new DictionaryComboBox(DictionaryConstants.symbols, DictionaryConstants.symbolDisplays); |
||||
this.endComboBox.setEditable(true); |
||||
doChangeListener = new ActionListener() { |
||||
public void actionPerformed(ActionEvent var1) { |
||||
ReturnTypePane.this.doChange(); |
||||
} |
||||
}; |
||||
this.delimiterComboBox.addActionListener(doChangeListener); |
||||
this.startComboBox.addActionListener(doChangeListener); |
||||
this.endComboBox.addActionListener(doChangeListener); |
||||
|
||||
|
||||
Component[][] var1 = new Component[][]{{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Delimiter")), this.delimiterComboBox}, {new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Combo_CheckBox_Start_Symbol")), this.startComboBox}, {new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Combo_CheckBox_End_Symbol")), this.endComboBox}}; |
||||
this.returnStringPane = TableLayoutHelper.createGapTableLayoutPane(var1, 1, 37.0D, 10.0D); |
||||
this.returnTypeComboBox = new UIButtonGroup(new String[]{com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Widget_Array"), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_String")}); |
||||
this.returnTypeComboBox.addActionListener(new ActionListener() { |
||||
public void actionPerformed(ActionEvent var1) { |
||||
ReturnTypePane.this.checkVisible(ReturnTypePane.this.returnTypeComboBox.getSelectedIndex()); |
||||
} |
||||
}); |
||||
this.returnTypeComboBox.addActionListener(doChangeListener); |
||||
|
||||
JPanel var2 = TableLayoutHelper.createGapTableLayoutPane(new Component[][]{{ this.returnTypeComboBox}}, 1, 13.0D, 10.0D); |
||||
JPanel var3 = FRGUIPaneFactory.createBorderLayout_S_Pane(); |
||||
var3.add(var2, "North"); |
||||
var3.add(this.returnStringPane, "Center"); |
||||
this.returnStringPane.setBorder(BorderFactory.createEmptyBorder(10, 12, 0, 0)); |
||||
this.add(var3); |
||||
} |
||||
|
||||
public void checkVisible(int var1) { |
||||
this.returnStringPane.setVisible(var1 == 1); |
||||
} |
||||
|
||||
public void populate(CustomReturnDataConfig var1) { |
||||
this.delimiterComboBox.setSelectedItem(var1.getDelimiter()); |
||||
this.returnTypeComboBox.setSelectedIndex(var1.isReturnString() ? 1 : 0); |
||||
this.startComboBox.setSelectedItem(var1.getStartSymbol()); |
||||
this.endComboBox.setSelectedItem(var1.getEndSymbol()); |
||||
this.checkVisible(this.returnTypeComboBox.getSelectedIndex()); |
||||
} |
||||
|
||||
public CustomReturnDataConfig update() { |
||||
CustomReturnDataConfig var1 = new CustomReturnDataConfig(); |
||||
var1.setDelimiter((String)this.delimiterComboBox.getSelectedItem()); |
||||
var1.setReturnString(this.returnTypeComboBox.getSelectedIndex() != 0); |
||||
var1.setStartSymbol((String)this.startComboBox.getSelectedItem()); |
||||
var1.setEndSymbol((String)this.endComboBox.getSelectedItem()); |
||||
return var1; |
||||
} |
||||
|
||||
public void doChange() |
||||
{ |
||||
|
||||
} |
||||
} |
@ -0,0 +1,54 @@
|
||||
package com.fr.plugin.third.party.xxxx.ui; |
||||
|
||||
import com.fr.design.Exception.ValidationException; |
||||
import com.fr.design.mainframe.widget.editors.AbstractPropertyEditor; |
||||
import com.fr.plugin.third.party.xxxx.data.CustomReturnDataConfig; |
||||
|
||||
import java.awt.*; |
||||
|
||||
public class ReturnTypePropertyEditor extends AbstractPropertyEditor { |
||||
private ReturnTypePane returnTypePane ; |
||||
|
||||
public ReturnTypePropertyEditor() { |
||||
returnTypePane = new ReturnTypePane(){ |
||||
@Override |
||||
public void doChange() { |
||||
//System.out.println("ReturnTypePropertyEditor.doChange");
|
||||
//需要调用这个方法,否则修改属性不保存
|
||||
ReturnTypePropertyEditor.this.firePropertyChanged(); |
||||
} |
||||
}; |
||||
CustomReturnDataConfig config = new CustomReturnDataConfig(); |
||||
config.setReturnString(false); |
||||
this.returnTypePane.populate(config); |
||||
|
||||
} |
||||
|
||||
@Override |
||||
public void setValue(Object value) { |
||||
//System.out.println("ReturnTypePropertyEditor:setValue");
|
||||
if (value == null) { |
||||
return; |
||||
} |
||||
if (!(value instanceof CustomReturnDataConfig)) { |
||||
return; |
||||
} |
||||
CustomReturnDataConfig data = (CustomReturnDataConfig) value; |
||||
this.returnTypePane.populate(data); |
||||
} |
||||
|
||||
@Override |
||||
public Object getValue() { |
||||
//System.out.println("ReturnTypePropertyEditor:getValue");
|
||||
CustomReturnDataConfig data = this.returnTypePane.update(); |
||||
return data; |
||||
} |
||||
|
||||
public Component getCustomEditor() { |
||||
return this.returnTypePane; |
||||
} |
||||
|
||||
public void validateValue() throws ValidationException { |
||||
} |
||||
} |
||||
|
@ -0,0 +1,10 @@
|
||||
package com.fr.plugin.third.party.xxxx.web; |
||||
|
||||
import com.fr.stable.fun.impl.AbstractCssFileHandler; |
||||
|
||||
public class CssFileLoader extends AbstractCssFileHandler { |
||||
@Override |
||||
public String[] pathsForFiles() { |
||||
return new String[]{"/com/fr/plugin/third/party/xxxx/web/MultilevelSelectionWidget.css"}; |
||||
} |
||||
} |
@ -0,0 +1,10 @@
|
||||
package com.fr.plugin.third.party.xxxx.web; |
||||
|
||||
import com.fr.stable.fun.impl.AbstractJavaScriptFileHandler; |
||||
|
||||
public class JavaScriptFileLoader extends AbstractJavaScriptFileHandler { |
||||
@Override |
||||
public String[] pathsForFiles() { |
||||
return new String[]{"/com/fr/plugin/third/party/xxxx/web/MultilevelSelectionWidget.js"}; |
||||
} |
||||
} |
After Width: | Height: | Size: 628 B |
After Width: | Height: | Size: 1.6 KiB |
After Width: | Height: | Size: 967 B |
@ -0,0 +1,18 @@
|
||||
.two-way-selection-widget-selected { |
||||
background-color: #1dd6c1; |
||||
} |
||||
|
||||
.huawei-honor-multilevel-selection-widget-btn { |
||||
width: 50px; |
||||
height: 20px; |
||||
background: #47a8ea; |
||||
line-height: 9px; |
||||
border-width: 0px; |
||||
border-radius: 3px; |
||||
cursor: pointer; |
||||
outline: none; |
||||
color: white; |
||||
float: right; |
||||
margin-left: 10px ; |
||||
font-size: 12px; |
||||
} |
@ -0,0 +1,416 @@
|
||||
; |
||||
(function ($) { |
||||
FR.HonorMultilevelSelectionWidget = FR.extend(FR.Widget, { |
||||
_defaultConfig: function () { |
||||
return $.extend(FR.HonorMultilevelSelectionWidget.superclass._defaultConfig.apply(), {}); |
||||
}, |
||||
_init: function () { |
||||
debugger; |
||||
FR.HonorMultilevelSelectionWidget.superclass._init.apply(this, arguments); |
||||
var o = this.options; |
||||
var element = this.element; |
||||
var widget = element[0]; |
||||
|
||||
var widgetWidth = this.options.width; |
||||
var widgetHeight = this.options.height; |
||||
var fontSize = this.options.widgetConfig_fontSize; |
||||
var optionsType = this.options.type; |
||||
var inputDivWidth = widgetWidth - 24; |
||||
if (inputDivWidth <= 0) { |
||||
inputDivWidth = 0; |
||||
} |
||||
|
||||
var inputDivHeight = widgetHeight - 4; |
||||
if (inputDivHeight <= 0) { |
||||
inputDivHeight = 0; |
||||
} |
||||
|
||||
var divWidth = widgetWidth - 20; |
||||
if (divWidth <= 0) { |
||||
divWidth = 0; |
||||
} |
||||
|
||||
if (fontSize <= 0) { |
||||
fontSize = 12; |
||||
} |
||||
|
||||
var iconUrl = FR.servletURL + "?op=resource&resource=/com/fr/plugin/third/party/xxxx/images/selection_16.png"; |
||||
|
||||
var inputValueElementId = this.options.widgetName + '-input-value'; |
||||
var widgetContent = '<div id="' + this.options.widgetName + '-widget-content' + '" style="width: 100%;height: 100%;float: left;">\n' + |
||||
'<div style="width: ' + divWidth + 'px;float: left;">\n' + |
||||
'<input type="text" id="' + inputValueElementId + '" style="width: ' + inputDivWidth + 'px;border-width:1px;height:' + inputDivHeight + 'px;font-size: ' + fontSize + 'px" readonly="true">\n' + |
||||
'</div>\n' + |
||||
'<div style="width: 20px;float: left;">\n' + |
||||
'<button type="button" style="background: url(' + iconUrl + ') no-repeat center center;border-width: 1px;border-radius: 1px;border-left-style: none;cursor: pointer;width: 20px;height: ' + widgetHeight + 'px;"></button> \n' + |
||||
'</div>\n' + |
||||
'</div>'; |
||||
var $widget = $(widgetContent); |
||||
var widgetId = $widget.appendTo(element); |
||||
|
||||
var inputElement = $widget.find("input").first(); |
||||
var popupButtonElement = $widget.find("button").first(); |
||||
//inputElement.val("Hello World");
|
||||
// var showEditorEvent = this.showEditor();
|
||||
this.options.widget_value_input_element = inputElement; |
||||
|
||||
var popupWidth = this.options.widgetConfig_width; |
||||
var popupHeight = this.options.widgetConfig_height; |
||||
//默认值
|
||||
if (popupWidth <= 0) { |
||||
popupWidth = 480; |
||||
} |
||||
if (popupHeight <= 0) { |
||||
popupHeight = 400; |
||||
} |
||||
|
||||
//最小值
|
||||
if (popupWidth <= 300) { |
||||
popupWidth = 300; |
||||
} |
||||
if (popupHeight <= 200) { |
||||
popupHeight = 200; |
||||
} |
||||
|
||||
var leftValue = ($(window).width() - popupWidth) / 2; |
||||
var topValue = ($(window).height() - popupHeight) / 4; |
||||
leftValue = leftValue.toFixed(2); |
||||
topValue = topValue.toFixed(2); |
||||
if (leftValue <= 0) { |
||||
leftValue = 0; |
||||
} |
||||
if (topValue <= 0) { |
||||
topValue = 0; |
||||
} |
||||
|
||||
var tableDivHeight = popupHeight - 55; |
||||
if (tableDivHeight <= 0) { |
||||
tableDivHeight = 0; |
||||
} |
||||
var tableContentHeight = tableDivHeight - 20; |
||||
if (tableContentHeight <= 0) { |
||||
tableContentHeight = 0; |
||||
} |
||||
|
||||
var iconWidth = 20; |
||||
if (popupWidth <= iconWidth) { |
||||
iconWidth = 0; |
||||
} |
||||
var divContentWidth = (popupWidth - iconWidth) / 3; |
||||
divContentWidth = divContentWidth.toFixed(2) - 5; |
||||
if (divContentWidth <= 0) { |
||||
divContentWidth = 0; |
||||
} |
||||
|
||||
var dataDivContentWidth = divContentWidth.toFixed(0) - 2; |
||||
|
||||
popupHeight = popupHeight + 10; |
||||
debugger; |
||||
var _tempGetTableElementContent = this._getHonorMultilevelSelectionContent(); |
||||
|
||||
var dataDivId = this.options.widgetName + '-div-widget-content-data'; |
||||
|
||||
var arrowsImgUrl = FR.fineServletURL + "/resources?path=/com/fr/plugin/third/party/xxxx/images/arrows_icons.png"; |
||||
var alertBoxId = this.options.widgetName + '-popup-window-content'; |
||||
var alertBox = $('<div id="' + alertBoxId + '" style="display: none; position: absolute;top: 0%;left: 0%;width: 100%;height: 100%;background-color: #fff;z-index:1000;opacity: 0.9;" >' + |
||||
|
||||
'<div style="float: left;margin-top: 15px;border-width: 1px;position: absolute;top:60px;left:50px;">\n' + |
||||
'<button id="' + this.options.widgetName + '-popup-window-content-button-ok' + '" type="button" class="huawei-honor-multilevel-selection-widget-btn" style="font-size: ' + fontSize + 'px">确定</button>\n' + |
||||
'<button id="' + this.options.widgetName + '-popup-window-content-button-cancel' + '" type="button" class="huawei-honor-multilevel-selection-widget-btn" style="font-size: ' + fontSize + 'px">取消</button>\n' + |
||||
'</div>' + |
||||
'<div id="' + dataDivId + '" style="position: absolute;top:100px;left:50px;opacity: 1; border-radius:5px;border-width: 1px;border-style: solid;border-color: rgb(170, 170, 170);">' + |
||||
'</div>' + |
||||
'</div>'); |
||||
$('body').append(alertBox); |
||||
|
||||
var dataUrl = FR.servletURL + "?op=widget&widgetname=" + this.options.widgetName; |
||||
var levelCount = this.options.widgetConfig_levelCount; |
||||
popupButtonElement.click(function () { |
||||
var dataDivElement = alertBox.find("div#" + dataDivId); |
||||
dataDivElement.empty(); |
||||
if (levelCount <= 0) { |
||||
alert("没有层级"); |
||||
return; |
||||
} |
||||
dataDivElement.append(_tempGetTableElementContent); |
||||
alertBox.css("display", "block"); |
||||
$("body").css("overflow", "auto"); |
||||
}); |
||||
|
||||
var queryClass = this.options.widgetName + '-content-element-data-button-query'; |
||||
var dataElementId = this.options.widgetName + '-content-element-data-values-index'; |
||||
|
||||
var valueElementId = this.options.widgetName + '-value-index'; |
||||
var valueCheckboxElementId = this.options.widgetName + '-value-checkbox-index'; |
||||
var queryInputElementId = this.options.widgetName + '-content-element-data-input-query-text-index'; |
||||
var selectAllElementId = this.options.widgetName + '-content-element-data-checkbox-select-all-index'; |
||||
$("body").on("click", '.' + queryClass, function () { |
||||
debugger; |
||||
var temp = this; |
||||
var tempLevelIndex = $(this).attr("level-index"); |
||||
console.log(tempLevelIndex); |
||||
var tempDataElementId = '#' + dataElementId + tempLevelIndex; |
||||
var tempDataElement = $(tempDataElementId); |
||||
tempDataElement.empty(); |
||||
var frSessionID = FR.SessionMgr.getSessionID(); |
||||
var tempUpperValues = getUpperValues(tempLevelIndex); |
||||
var tempValueInputElementId = '#' + queryInputElementId + tempLevelIndex; |
||||
var tempCurrentValue = $(tempValueInputElementId).val(); |
||||
$.ajax({ |
||||
url: dataUrl, |
||||
//contentType: "application/json",
|
||||
type: "post", |
||||
dataType: 'json', |
||||
data: { |
||||
dataType: "VALUE", |
||||
currentValue: tempCurrentValue, |
||||
upperValue: tempUpperValues, |
||||
levelIndex: tempLevelIndex |
||||
}, |
||||
headers: {'sessionID': frSessionID}, |
||||
//async: false,
|
||||
success: function (dataJson) { |
||||
console.log(dataJson); |
||||
if ((dataJson == null) || (dataJson == undefined) || (dataJson.length <= 0)) { |
||||
return; |
||||
} |
||||
var valueJson, valueContent = ''; |
||||
for (var i = 0, max = dataJson.length - 1; i <= max; i++) { |
||||
valueJson = dataJson[i]; |
||||
valueContent = valueContent + '<div class="' + valueElementId + tempLevelIndex + '"><input type="checkbox" class="' + valueCheckboxElementId + tempLevelIndex + '" value="' + valueJson.value + '"> <a>' + valueJson.text + '</a></div>'; |
||||
} |
||||
tempDataElement.append(valueContent); |
||||
} |
||||
}); |
||||
}); |
||||
|
||||
var selectAllClass = this.options.widgetName + '-content-element-data-checkbox-select-all'; |
||||
$("body").on("click", '.' + selectAllClass, function () { |
||||
var tempLevelIndex = $(this).attr("level-index"); |
||||
var tempEleId = '.' + valueCheckboxElementId + tempLevelIndex; |
||||
if ($(this).is(':checked')) { |
||||
$(tempEleId).prop('checked', true); |
||||
return; |
||||
} |
||||
$(tempEleId).prop('checked', false); |
||||
}); |
||||
|
||||
var restClass = this.options.widgetName + '-content-element-data-button-reset'; |
||||
$("body").on("click", '.' + restClass, function () { |
||||
var tempLevelIndex = $(this).attr("level-index"); |
||||
var tempDataElementId = '#' + dataElementId + tempLevelIndex; |
||||
var tempDataElement = $(tempDataElementId); |
||||
tempDataElement.empty(); |
||||
|
||||
var tempEleId = '#' + selectAllElementId + tempLevelIndex; |
||||
$(tempEleId).prop('checked', false); |
||||
|
||||
tempEleId = '#' + queryInputElementId + tempLevelIndex; |
||||
$(tempEleId).val(""); |
||||
}); |
||||
|
||||
|
||||
var okButtonElementId = "button#" + this.options.widgetName + '-popup-window-content-button-ok'; |
||||
var cancelButtonElementId = "button#" + this.options.widgetName + '-popup-window-content-button-cancel'; |
||||
$("body").on("click", cancelButtonElementId, function () { |
||||
$('#' + alertBoxId).css("display", "none"); |
||||
$("body").css("overflow", "hidden"); |
||||
}); |
||||
|
||||
var tempOptions = this.options; |
||||
$("body").on("click", okButtonElementId, function () { |
||||
$('#' + alertBoxId).css("display", "none"); |
||||
$("body").css("overflow", "hidden"); |
||||
var parameterValues = ""; |
||||
if (levelCount <= 0) { |
||||
inputElement.val(parameterValues); |
||||
return; |
||||
} |
||||
var tempValue = _getHonorLevelValuesContent(tempOptions); |
||||
parameterValues = JSON.stringify(tempValue); |
||||
inputElement.val(parameterValues); |
||||
}); |
||||
|
||||
function getUpperValues(index) { |
||||
var tempLevelIndex = parseInt(index); |
||||
if (tempLevelIndex <= 0) { |
||||
return ""; |
||||
} |
||||
var tempLevelIndex = tempLevelIndex - 1; |
||||
var tempEleId = 'input[type=checkbox]:checked.' + valueCheckboxElementId + tempLevelIndex; |
||||
var tempEles = $(tempEleId); |
||||
if (tempEles.length <= 0) { |
||||
return ""; |
||||
} |
||||
|
||||
var tempEle, tempValue, content = ""; |
||||
for (var i = 0, max = tempEles.length - 1; i <= max; i++) { |
||||
tempEle = tempEles[i]; |
||||
tempValue = $(tempEle).val(); |
||||
if (i >= 1) { |
||||
content = content + ","; |
||||
} |
||||
content = content + tempValue; |
||||
} |
||||
return content; |
||||
} |
||||
|
||||
function _getHonorLevelValuesContent(options) { |
||||
if (levelCount <= 0) { |
||||
return ""; |
||||
} |
||||
var values = [], tempValue; |
||||
if (levelCount == 0) { |
||||
tempValue = _getHonorLevelValues(0, options); |
||||
return tempValue; |
||||
} |
||||
|
||||
for (var i = 0, max = levelCount - 1; i <= max; i++) { |
||||
tempValue = _getHonorLevelValues(i, options); |
||||
values.push(tempValue); |
||||
} |
||||
return values; |
||||
} |
||||
|
||||
function _getHonorLevelValues(levelIndex, options) { |
||||
if ((options == undefined) || (options == null)) { |
||||
return ""; |
||||
} |
||||
|
||||
var tempEleId = 'input[type=checkbox]:checked.' + valueCheckboxElementId + levelIndex; |
||||
var tempEles = $(tempEleId); |
||||
if (tempEles.length <= 0) { |
||||
return ""; |
||||
} |
||||
|
||||
var tempEle, tempValue, content = ""; |
||||
var parameterValueArray = []; |
||||
for (var i = 0, max = tempEles.length - 1; i <= max; i++) { |
||||
tempEle = tempEles[i]; |
||||
tempValue = $(tempEle).val(); |
||||
if (options.widgetConfig_returnArray) { |
||||
parameterValueArray.push(tempValue); |
||||
} else { |
||||
content = content + tempValue; |
||||
} |
||||
if ((i < max) && (!options.widgetConfig_returnArray)) { |
||||
content = content + options.widgetConfig_delimiter; |
||||
} |
||||
} |
||||
if (options.widgetConfig_returnArray) { |
||||
return parameterValueArray; |
||||
} |
||||
content = options.widgetConfig_startSymbol + content + options.widgetConfig_endSymbol; |
||||
return content; |
||||
} |
||||
}, |
||||
getValue: function () { |
||||
//__parameters__: {"TWOWAYSELECTIONWIDGET0":"1256","COMBOCHECKBOX0":[5b]"b","c"[5d],"NEWCOMBOBOXTREEEDITOR0":[5b][5d],"COMBOCHECKBOX0_C":"a,b"}
|
||||
var inputValue = this.options.widget_value_input_element.val(); |
||||
if (!(inputValue)) { |
||||
return ""; |
||||
} |
||||
if (inputValue.length <= 0) { |
||||
return ""; |
||||
} |
||||
var parameterValue = inputValue; |
||||
return parameterValue; |
||||
}, |
||||
setValue: function (value) { |
||||
this.options.widget_value_input_element.val(value); |
||||
}, |
||||
_getHonorMultilevelSelectionContent: function () { |
||||
console.log(this.options); |
||||
if (this.options.widgetConfig_levelCount <= 0) { |
||||
return ""; |
||||
} |
||||
var fontSize = this.options.widgetConfig_fontSize; |
||||
if (fontSize <= 0) { |
||||
fontSize = 12; |
||||
} |
||||
|
||||
var tableElementContent = '<table border="0" style="width: 100%;font-size: ' + fontSize + 'px">\n' + |
||||
' <tbody>\n' + |
||||
' <tr style="height: 20px;">\n' + |
||||
this._getHonorMultilevelSelectionContentTitles() + |
||||
' </tr>\n' + |
||||
' <tr>\n' + |
||||
this._getHonorMultilevelSelectionContentQuery() + |
||||
' </tr>\n' + |
||||
' <tr>\n' + |
||||
this._getHonorMultilevelSelectionContentValues() + |
||||
' </tr>\n' + |
||||
' <tr>\n' + |
||||
this._getHonorMultilevelSelectionContentOpt() + |
||||
' </tr>\n' + |
||||
' </tbody>\n' + |
||||
' </table>'; |
||||
return tableElementContent; |
||||
}, |
||||
_getHonorMultilevelSelectionContentTitles: function () { |
||||
if (this.options.widgetConfig_levelCount <= 0) { |
||||
return ""; |
||||
} |
||||
var max = this.options.widgetConfig_levelCount - 1; |
||||
var content = "", config; |
||||
for (var i = 0; i <= max; i++) { |
||||
config = this.options.widgetConfig_levelSettings[i]; |
||||
content = content + '<td>' + config.title + '</td>\n'; |
||||
} |
||||
return content; |
||||
}, |
||||
_getHonorMultilevelSelectionContentOpt: function () { |
||||
if (this.options.widgetConfig_levelCount <= 0) { |
||||
return ""; |
||||
} |
||||
var max = this.options.widgetConfig_levelCount - 1; |
||||
var content = "", config; |
||||
for (var i = 0; i <= max; i++) { |
||||
config = this.options.widgetConfig_levelSettings[i]; |
||||
content = content + '<td style="width:' + config.levelWidth + 'px;">\n' + |
||||
'<div>' + |
||||
'<input type="checkbox" class="' + this.options.widgetName + '-content-element-data-checkbox-select-all" id="' + this.options.widgetName + '-content-element-data-checkbox-select-all-index' + i + '" level-index="' + i + '">全选</input>' + |
||||
'<button type="button" class="' + this.options.widgetName + '-content-element-data-button-reset" id="' + this.options.widgetName + '-content-element-data-button-reset-index' + i + '" level-index="' + i + '">重置</button>' + |
||||
'</div>' + |
||||
'</td>\n'; |
||||
} |
||||
return content; |
||||
}, |
||||
_getHonorMultilevelSelectionContentQuery: function () { |
||||
if (this.options.widgetConfig_levelCount <= 0) { |
||||
return ""; |
||||
} |
||||
var max = this.options.widgetConfig_levelCount - 1; |
||||
var content = "", config; |
||||
var inputWidth = 0; |
||||
for (var i = 0; i <= max; i++) { |
||||
config = this.options.widgetConfig_levelSettings[i]; |
||||
inputWidth = config.levelWidth - 60; |
||||
content = content + '<td style="width:' + config.levelWidth + 'px;">\n' + |
||||
'<div>' + |
||||
'<input type="text" class="' + this.options.widgetName + '-content-element-data-input-query-text" id="' + this.options.widgetName + '-content-element-data-input-query-text-index' + i + '" level-index="' + i + '" style="width:' + inputWidth + 'px"/>' + |
||||
'<button type="button" class="' + this.options.widgetName + '-content-element-data-button-query" id="' + this.options.widgetName + '-content-element-data-button-query-index' + i + '" level-index="' + i + '">查询</button>' + |
||||
'</div>' + |
||||
'</td>\n'; |
||||
} |
||||
return content; |
||||
}, |
||||
_getHonorMultilevelSelectionContentValues: function () { |
||||
if (this.options.widgetConfig_levelCount <= 0) { |
||||
return ""; |
||||
} |
||||
var max = this.options.widgetConfig_levelCount - 1; |
||||
var content = "", config; |
||||
for (var i = 0; i <= max; i++) { |
||||
config = this.options.widgetConfig_levelSettings[i]; |
||||
content = content + '<td style="width:' + config.levelWidth + 'px;">\n' + |
||||
'<div class="' + this.options.widgetName + '-content-element-data-values" id="' + this.options.widgetName + '-content-element-data-values-index' + i + '" level-index="' + i + '" style="overflow: auto;height:' + this.options.widgetConfig_height + 'px;border-width: 1px;border-style: solid;border-color: rgb(204, 204, 204);"></div>\n' + |
||||
'</td>\n'; |
||||
} |
||||
return content; |
||||
} |
||||
}); |
||||
|
||||
/*只能小写*/ |
||||
$.shortcut("honormultilevelselectionwidget", FR.HonorMultilevelSelectionWidget); |
||||
})(jQuery); |
Loading…
Reference in new issue