34 changed files with 16546 additions and 1 deletions
@ -1,3 +1,6 @@
|
||||
# open-JSD-8035 |
||||
|
||||
JSD-8035 任务开源材料 |
||||
JSD-8035 开源任务代码\ |
||||
免责说明:该源码为第三方爱好者提供,不保证源码和方案的可靠性,也不提供任何形式的源码教学指导和协助!\ |
||||
仅作为开发者学习参考使用!禁止用于任何商业用途!\ |
||||
为保护开发者隐私,开发者信息已隐去!若原开发者希望公开自己的信息,可联系hugh处理。 |
Binary file not shown.
Binary file not shown.
@ -0,0 +1,32 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?> |
||||
<plugin> |
||||
<id>com.fr.plugin.m.tree</id> |
||||
<name><![CDATA[VUE树形选择器控件]]></name> |
||||
<active>yes</active> |
||||
<version>1.1.2</version> |
||||
<env-version>10.0</env-version> |
||||
<jartime>2020-02-02</jartime> |
||||
<vendor>fr.open</vendor> |
||||
<description><![CDATA[描述]]></description> |
||||
<change-notes><![CDATA[ |
||||
[2021-12-31]初始化插件。<br/> |
||||
]]></change-notes> |
||||
<extra-core> |
||||
</extra-core> |
||||
<lifecycle-monitor class="com.fr.plugin.VSCycleMonitor"/> |
||||
|
||||
<extra-report> |
||||
<JavaScriptFileHandler class="com.fr.plugin.VSJSFileHandler"/> |
||||
<CssFileHandler class="com.fr.plugin.VSCSSFileHandler"/> |
||||
</extra-report> |
||||
<extra-core> |
||||
<WebService class="com.fr.plugin.VSMapService"/> |
||||
</extra-core> |
||||
<extra-designer> |
||||
<FormWidgetOptionProvider class="com.fr.plugin.provider.VueFormOptionProvider"/> |
||||
<ParameterWidgetOptionProvider class="com.fr.plugin.provider.VueParameterWidgetOptionProvider"/> |
||||
<CellWidgetOptionProvider class="com.fr.plugin.provider.VSCellWidgetOptionProvider"/> |
||||
</extra-designer> |
||||
|
||||
<function-recorder class="com.fr.plugin.VSJSFileHandler"/> |
||||
</plugin> |
@ -0,0 +1,14 @@
|
||||
package com.fr.plugin; |
||||
|
||||
import com.fr.plugin.transform.ExecuteFunctionRecord; |
||||
import com.fr.stable.fun.impl.AbstractCssFileHandler; |
||||
|
||||
public class VSCSSFileHandler extends AbstractCssFileHandler { |
||||
@Override |
||||
@ExecuteFunctionRecord |
||||
public String[] pathsForFiles() { |
||||
return new String[]{ |
||||
"com/fr/plugin/vuetree/css/ts.css" |
||||
}; |
||||
} |
||||
} |
@ -0,0 +1,16 @@
|
||||
package com.fr.plugin; |
||||
|
||||
import com.fr.plugin.context.PluginContext; |
||||
import com.fr.plugin.observer.inner.AbstractPluginLifecycleMonitor; |
||||
|
||||
public class VSCycleMonitor extends AbstractPluginLifecycleMonitor { |
||||
@Override |
||||
public void afterRun(PluginContext pluginContext) { |
||||
|
||||
} |
||||
|
||||
@Override |
||||
public void beforeStop(PluginContext pluginContext) { |
||||
|
||||
} |
||||
} |
@ -0,0 +1,25 @@
|
||||
package com.fr.plugin; |
||||
|
||||
import com.fr.plugin.transform.ExecuteFunctionRecord; |
||||
import com.fr.plugin.transform.FunctionRecorder; |
||||
import com.fr.stable.fun.impl.AbstractJavaScriptFileHandler; |
||||
|
||||
@FunctionRecorder |
||||
public class VSJSFileHandler extends AbstractJavaScriptFileHandler { |
||||
|
||||
public VSJSFileHandler() { |
||||
System.out.println("初始化TS"); |
||||
} |
||||
|
||||
@Override |
||||
@ExecuteFunctionRecord |
||||
public String[] pathsForFiles() { |
||||
System.out.println("初始化TDD"); |
||||
return new String[]{ |
||||
"/com/fr/plugin/vuetree/js/vue.js", |
||||
"/com/fr/plugin/vuetree/js/element.js", |
||||
"/com/fr/plugin/vuetree/js/el-tree-select.js", |
||||
"/com/fr/plugin/vuetree/js/vuetree.js" |
||||
}; |
||||
} |
||||
} |
@ -0,0 +1,35 @@
|
||||
package com.fr.plugin; |
||||
|
||||
import com.fanruan.api.session.SessionKit; |
||||
import com.fr.base.TableData; |
||||
import com.fr.decision.webservice.v10.plugin.helper.PluginUtils; |
||||
import com.fr.form.main.Form; |
||||
import com.fr.general.data.DataModel; |
||||
import com.fr.general.data.TableDataException; |
||||
import com.fr.json.JSONObject; |
||||
import com.fr.plugin.context.PluginMarker; |
||||
import com.fr.plugin.manage.PluginManager; |
||||
import com.fr.script.Calculator; |
||||
import com.fr.stable.fun.Service; |
||||
import com.fr.web.utils.WebUtils; |
||||
|
||||
import javax.servlet.http.HttpServletRequest; |
||||
import javax.servlet.http.HttpServletResponse; |
||||
|
||||
public class VSMapService implements Service { |
||||
@Override |
||||
public String actionOP() { |
||||
return "restartInit"; |
||||
} |
||||
|
||||
@Override |
||||
public void process(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, String op, String cmd) throws Exception { |
||||
PluginMarker pluginMarker = PluginUtils.createPluginMarker("com.fr.plugin.m.tree_1.0.0"); |
||||
PluginManager.getController().forbid(pluginMarker, pluginTaskResult -> { |
||||
}); |
||||
PluginManager.getController().enable(pluginMarker, pluginTaskResult -> { |
||||
}); |
||||
WebUtils.printAsJSON(httpServletResponse, new JSONObject()); |
||||
return; |
||||
} |
||||
} |
@ -0,0 +1,76 @@
|
||||
package com.fr.plugin; |
||||
|
||||
import java.awt.*; |
||||
|
||||
import javax.swing.BorderFactory; |
||||
import javax.swing.JPanel; |
||||
|
||||
import com.fr.design.data.DataCreatorUI; |
||||
import com.fr.design.designer.IntervalConstants; |
||||
import com.fr.design.gui.ilable.UILabel; |
||||
import com.fr.design.gui.itree.refreshabletree.TreeRootPane; |
||||
import com.fr.design.layout.FRGUIPaneFactory; |
||||
import com.fr.design.layout.TableLayoutHelper; |
||||
import com.fr.design.mainframe.widget.accessibles.AccessibleTreeModelEditor; |
||||
import com.fr.design.widget.ui.CustomWritableRepeatEditorPane; |
||||
import com.fr.form.ui.TreeComboBoxEditor; |
||||
import com.fr.form.ui.TreeEditor; |
||||
|
||||
|
||||
public class VUETreeComboBoxEditorDefinePane extends CustomWritableRepeatEditorPane<TreeEditor> { |
||||
protected AccessibleTreeModelEditor treeSettingPane; |
||||
protected TreeRootPane treeRootPane; |
||||
|
||||
public VUETreeComboBoxEditorDefinePane() { |
||||
this.initComponents(); |
||||
} |
||||
|
||||
|
||||
@Override |
||||
protected JPanel setForthContentPane() { |
||||
JPanel content = FRGUIPaneFactory.createBorderLayout_L_Pane(); |
||||
content.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0)); |
||||
treeRootPane = new TreeRootPane(); |
||||
content.add(treeRootPane, BorderLayout.NORTH); |
||||
return content; |
||||
} |
||||
|
||||
@Override |
||||
protected JPanel setFirstContentPane() { |
||||
treeSettingPane = new AccessibleTreeModelEditor(); |
||||
JPanel jPanel = FRGUIPaneFactory.createBorderLayout_S_Pane(); |
||||
JPanel north = TableLayoutHelper.createGapTableLayoutPane(new Component[][]{ |
||||
new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Create_Tree")), treeSettingPane}}, TableLayoutHelper.FILL_LASTCOLUMN, IntervalConstants.INTERVAL_W2, IntervalConstants.INTERVAL_L1); |
||||
north.setBorder(BorderFactory.createEmptyBorder(0, 0, 10, 0)); |
||||
JPanel center = super.setFirstContentPane(); |
||||
jPanel.add(north, BorderLayout.NORTH); |
||||
jPanel.add(center, BorderLayout.CENTER); |
||||
return jPanel; |
||||
} |
||||
|
||||
|
||||
|
||||
@Override |
||||
protected String title4PopupWindow() { |
||||
return "treecombobox"; |
||||
} |
||||
|
||||
@Override |
||||
protected void populateSubCustomWritableRepeatEditorBean(TreeEditor e) { |
||||
treeSettingPane.setValue(e.getNodeOrDict()); |
||||
treeRootPane.populate(e.getTreeAttr()); |
||||
} |
||||
|
||||
@Override |
||||
protected TreeComboBoxEditor updateSubCustomWritableRepeatEditorBean() { |
||||
TreeComboBoxEditor editor = new TreeComboBoxEditor(); |
||||
editor.setNodeOrDict(treeSettingPane.getValue()); |
||||
editor.setTreeAttr(treeRootPane.update()); |
||||
return editor; |
||||
} |
||||
|
||||
@Override |
||||
public DataCreatorUI dataUI() { |
||||
return null; |
||||
} |
||||
} |
@ -0,0 +1,94 @@
|
||||
package com.fr.plugin; |
||||
|
||||
import com.fr.design.data.DataCreatorUI; |
||||
import com.fr.design.designer.IntervalConstants; |
||||
import com.fr.design.gui.icheckbox.UICheckBox; |
||||
import com.fr.design.gui.ilable.UILabel; |
||||
import com.fr.design.gui.itree.refreshabletree.TreeRootPane; |
||||
import com.fr.design.layout.FRGUIPaneFactory; |
||||
import com.fr.design.layout.TableLayoutHelper; |
||||
import com.fr.design.widget.ui.FieldEditorDefinePane; |
||||
import com.fr.plugin.pane.VueAccessibleTreeModelEditor; |
||||
import com.fr.plugin.widget.VUETreeEditorWidget; |
||||
|
||||
import javax.swing.*; |
||||
import java.awt.*; |
||||
|
||||
|
||||
/* |
||||
* richer:tree editor |
||||
*/ |
||||
public class VUETreeEditorDefinePane extends FieldEditorDefinePane<VUETreeEditorWidget> { |
||||
protected TreeRootPane treeRootPane; |
||||
private VueAccessibleTreeModelEditor accessibleTreeModelEditor; |
||||
|
||||
private UICheckBox removeRepeatCheckBox; |
||||
|
||||
public VUETreeEditorDefinePane(){ |
||||
this.initComponents(); |
||||
} |
||||
|
||||
@Override |
||||
protected void populateSubFieldEditorBean(VUETreeEditorWidget e) { |
||||
this.accessibleTreeModelEditor.setValue(e.getNodeOrDict()); |
||||
treeRootPane.populate(e.getTreeAttr()); |
||||
if (this.removeRepeatCheckBox != null) { |
||||
this.removeRepeatCheckBox.setSelected(e.isRemoveRepeat()); |
||||
} |
||||
} |
||||
|
||||
@Override |
||||
protected VUETreeEditorWidget updateSubFieldEditorBean() { |
||||
VUETreeEditorWidget editor = new VUETreeEditorWidget(); |
||||
editor.setNodeOrDict(accessibleTreeModelEditor.getValue()); |
||||
editor.setTreeAttr(treeRootPane.update()); |
||||
if (this.removeRepeatCheckBox != null) { |
||||
editor.setRemoveRepeat(this.removeRepeatCheckBox.isSelected()); |
||||
} |
||||
return editor; |
||||
} |
||||
|
||||
@Override |
||||
protected JPanel setFirstContentPane() { |
||||
return this.setSecondContentPane(); |
||||
} |
||||
|
||||
protected JPanel setSecondContentPane() { |
||||
accessibleTreeModelEditor = new VueAccessibleTreeModelEditor(); |
||||
JPanel createTree = TableLayoutHelper.createGapTableLayoutPane(new Component[][]{ |
||||
new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Create_Tree")), accessibleTreeModelEditor}}, TableLayoutHelper.FILL_LASTCOLUMN, IntervalConstants.INTERVAL_W2, IntervalConstants.INTERVAL_L1); |
||||
createTree.setBorder(BorderFactory.createEmptyBorder(0, 0, 10, 0)); |
||||
JPanel contentPane = FRGUIPaneFactory.createBorderLayout_L_Pane(); |
||||
JPanel contenter = FRGUIPaneFactory.createBorderLayout_S_Pane(); |
||||
|
||||
contentPane.add(contenter,BorderLayout.NORTH); |
||||
// contentPane.add(new UILabel("tretert3543"), BorderLayout.SOUTH);
|
||||
removeRepeatCheckBox = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Remove_Repeat_Data"), false); |
||||
removeRepeatCheckBox.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0)); |
||||
contenter.add(createTree, BorderLayout.NORTH); |
||||
contenter.add(removeRepeatCheckBox, BorderLayout.CENTER); |
||||
JPanel otherContentPane = this.setThirdContentPane(); |
||||
if (otherContentPane != null) { |
||||
contentPane.add(otherContentPane,BorderLayout.CENTER); |
||||
} |
||||
return contentPane; |
||||
} |
||||
|
||||
protected JPanel setThirdContentPane() { |
||||
JPanel content = FRGUIPaneFactory.createBorderLayout_L_Pane(); |
||||
content.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0)); |
||||
treeRootPane = new TreeRootPane(); |
||||
content.add(treeRootPane, BorderLayout.NORTH); |
||||
return content; |
||||
} |
||||
|
||||
@Override |
||||
protected String title4PopupWindow() { |
||||
return "tree"; |
||||
} |
||||
|
||||
@Override |
||||
public DataCreatorUI dataUI() { |
||||
return null; |
||||
} |
||||
} |
@ -0,0 +1,451 @@
|
||||
package com.fr.plugin.data; |
||||
|
||||
import com.fr.data.Dictionary; |
||||
import com.fr.general.ComparatorUtils; |
||||
import com.fr.json.JSON; |
||||
import com.fr.json.JSONArray; |
||||
import com.fr.json.JSONFactory; |
||||
import com.fr.json.JSONObject; |
||||
import com.fr.stable.AssistUtils; |
||||
import com.fr.stable.StringUtils; |
||||
|
||||
import java.io.Serializable; |
||||
import java.util.ArrayList; |
||||
import java.util.Iterator; |
||||
import java.util.List; |
||||
|
||||
public class VueJQNode { |
||||
public static final String ID_SPLIT = "-"; |
||||
private String id; |
||||
|
||||
private String text; |
||||
private String value; |
||||
|
||||
private boolean isExpand; |
||||
private boolean hasChildren; |
||||
private boolean canSelect; |
||||
|
||||
private boolean showCheck; |
||||
private boolean complete; |
||||
private CheckStatus checkState; |
||||
|
||||
public VueJQNode(String id, String value, String text, boolean hasChildren,boolean canSelect) { |
||||
this(id, value, text, hasChildren, true,canSelect); |
||||
} |
||||
|
||||
public VueJQNode(String id, String value, String text, boolean hasChildren, boolean showCheck,boolean canSelect) { |
||||
this(id, value, text, hasChildren, showCheck, false, false, CheckStatus.NOCHECK,canSelect); |
||||
} |
||||
|
||||
public VueJQNode(String id, String value, String text, boolean hasChildren, boolean showCheck, boolean isExpand, boolean complete, CheckStatus checkState,boolean canSelect) { |
||||
this.id = id; |
||||
this.text = text; |
||||
this.value = value; |
||||
this.isExpand = isExpand; |
||||
this.hasChildren = hasChildren; |
||||
this.showCheck = showCheck; |
||||
this.complete = complete; |
||||
this.checkState = checkState; |
||||
this.canSelect = canSelect; |
||||
} |
||||
|
||||
public VueJQNode(String id, String value, String text, boolean hasChildren, boolean showCheck, boolean isExpand, boolean complete, int statusValue) { |
||||
this(id, value, text, hasChildren, showCheck, isExpand, complete, CheckStatus.parse(statusValue),true); |
||||
} |
||||
|
||||
@Override |
||||
public boolean equals(Object object) { |
||||
return object instanceof VueJQNode |
||||
&& StringUtils.equals(this.id, ((VueJQNode) object).id); |
||||
} |
||||
|
||||
@Override |
||||
public int hashCode() { |
||||
return AssistUtils.hashCode(this.id); |
||||
} |
||||
|
||||
/** |
||||
* 生成数表示树节点的JSON数组 |
||||
* |
||||
* @param nodeList 保存树节点的链表 |
||||
* @return JSON数组 |
||||
*/ |
||||
public static JSONArray toJSONArray(List<VueJQNode> nodeList) { |
||||
JSONArray result = JSONFactory.createJSON(JSON.ARRAY); |
||||
for (VueJQNode node : nodeList) { |
||||
JSONObject json = JSONFactory.createJSON(JSON.OBJECT); |
||||
json.put("id", node.id); |
||||
json.put("text", node.text); |
||||
json.put("value", node.value); |
||||
json.put("canSelect", node.canSelect); |
||||
json.put("showcheck", node.showCheck); |
||||
json.put("complete", node.complete); |
||||
json.put("isexpand", node.isExpand); |
||||
json.put("checkstate", node.checkState.getStatusValue()); |
||||
json.put("hasChildren", node.hasChildren); |
||||
result.add(json); |
||||
} |
||||
return result; |
||||
} |
||||
|
||||
// richer:这是直接生成tree数据时用的数据结构,由于用的比较少,就放在这里了
|
||||
public static class QNode implements Cloneable,Serializable { |
||||
|
||||
public static final String ID_ROOT = "0"; |
||||
private static final long serialVersionUID = -2857453365131755358L; |
||||
protected String id; |
||||
protected String parentId; |
||||
// node value
|
||||
protected String text; |
||||
protected String value; |
||||
|
||||
protected boolean showCheck; |
||||
protected CheckStatus checkState; |
||||
protected boolean canSelect; |
||||
protected boolean isExpand; |
||||
|
||||
protected boolean hasChildren; |
||||
private List<QNode> children; |
||||
|
||||
public QNode(String id, String parentId) { |
||||
this(id, parentId, "root", "root",true); |
||||
} |
||||
|
||||
public QNode(String id, String parentId, String value, String text,boolean canSelect) { |
||||
this(id, parentId, value, text, false, CheckStatus.CHECK, true, true,canSelect); |
||||
} |
||||
|
||||
public QNode(String id, String parentId, String value, String text, boolean showCheck, boolean isExpand, boolean hasChildren,boolean canSelect) { |
||||
this(id, parentId, value, text, showCheck, CheckStatus.NOCHECK, isExpand, hasChildren,canSelect); |
||||
} |
||||
|
||||
public QNode(String id, String parentId, String value, String text, boolean showCheck, int checkState, boolean isExpand, boolean hasChildren,boolean canSelect) { |
||||
this(id, parentId, value, text, showCheck, CheckStatus.parse(checkState), isExpand, hasChildren,canSelect); |
||||
} |
||||
|
||||
public QNode(String id, String parentId, String value, String text, boolean showCheck, CheckStatus checkState, boolean isExpand, boolean hasChildren,boolean canSelect) { |
||||
this.id = id; |
||||
this.parentId = parentId; |
||||
this.text = text; |
||||
this.value = value; |
||||
this.showCheck = showCheck; |
||||
this.checkState = checkState; |
||||
this.isExpand = isExpand; |
||||
this.hasChildren = hasChildren; |
||||
this.canSelect = canSelect; |
||||
} |
||||
|
||||
public List<QNode> getChildren() { |
||||
return children; |
||||
} |
||||
|
||||
public void setChildren(List<QNode> children) { |
||||
this.children = children; |
||||
} |
||||
|
||||
/** |
||||
* 是否展开 |
||||
* |
||||
* @return 是否展开 |
||||
*/ |
||||
public boolean isExpand() { |
||||
return this.isExpand; |
||||
} |
||||
|
||||
/** |
||||
* @param expand expand |
||||
*/ |
||||
public void setExpand(boolean expand) { |
||||
this.isExpand = expand; |
||||
} |
||||
|
||||
/** |
||||
* @param checkState checkState |
||||
*/ |
||||
public void setCheckState(CheckStatus checkState) { |
||||
this.checkState = checkState; |
||||
} |
||||
|
||||
/** |
||||
* @return parentId |
||||
*/ |
||||
public String getParentID() { |
||||
return parentId; |
||||
} |
||||
|
||||
public CheckStatus getCheckState() { |
||||
return checkState; |
||||
} |
||||
|
||||
public String getId() { |
||||
return id; |
||||
} |
||||
|
||||
public String getText() { |
||||
return text; |
||||
} |
||||
|
||||
public String getValue() { |
||||
return value; |
||||
} |
||||
|
||||
public boolean hasChildren() { |
||||
return hasChildren; |
||||
} |
||||
|
||||
public boolean hasParent() { |
||||
return StringUtils.isNotEmpty(this.parentId) |
||||
&& !ID_ROOT.equals(this.parentId); |
||||
} |
||||
public void addChild(QNode node) { |
||||
if (children == null) { |
||||
children = new ArrayList<>(); |
||||
} |
||||
children.add(node); |
||||
} |
||||
|
||||
@Override |
||||
public boolean equals(Object o) { |
||||
if (this == o) return true; |
||||
if (!(o instanceof QNode)) return false; |
||||
QNode qNode = (QNode) o; |
||||
return AssistUtils.equals(this.showCheck, qNode.showCheck) && |
||||
AssistUtils.equals(this.isExpand, qNode.isExpand) && |
||||
AssistUtils.equals(this.hasChildren, qNode.hasChildren) && |
||||
AssistUtils.equals(this.canSelect, qNode.canSelect) && |
||||
AssistUtils.equals(this.id, qNode.id) && |
||||
AssistUtils.equals(this.parentId, qNode.parentId) && |
||||
AssistUtils.equals(this.text, qNode.text) && |
||||
AssistUtils.equals(this.value, qNode.value) && |
||||
AssistUtils.equals(this.checkState, qNode.checkState) && |
||||
AssistUtils.equals(this.children, qNode.children); |
||||
} |
||||
|
||||
@Override |
||||
public int hashCode() { |
||||
return AssistUtils.hashCode(id, parentId, text, value, showCheck, checkState, isExpand, hasChildren, children,canSelect); |
||||
} |
||||
|
||||
/** |
||||
* 构建树节点 |
||||
* |
||||
* @param list 数据 |
||||
* @return 节点JSONArray信息 |
||||
* @throws Exception e |
||||
*/ |
||||
public static JSONArray createTreeNode(List<QNode> list) throws Exception { |
||||
return createTreeNode(list, true); |
||||
} |
||||
/** |
||||
* 构建树节点(全量加载) |
||||
* |
||||
* @param list 数据 |
||||
* @return 节点JSONArray信息 |
||||
* @throws Exception e |
||||
*/ |
||||
public static JSONArray createAllTreeNodes(List<QNode> list) throws Exception { |
||||
return createTreeNode(list, false); |
||||
} |
||||
/** |
||||
* 构建树节点 |
||||
* when ajax==false should put all list items to tree data |
||||
* |
||||
* @param list 数据 |
||||
* @param isAjax 是否是异步加载 |
||||
* @return 节点JSONArray信息 |
||||
* @throws Exception |
||||
*/ |
||||
public static JSONArray createTreeNode(List<QNode> list, boolean isAjax) throws Exception { |
||||
Recursion r = new Recursion(); |
||||
String target = r.generateJSONString(list, isAjax); |
||||
return JSONFactory.createJSON(JSON.ARRAY, target); |
||||
} |
||||
|
||||
/** |
||||
* 将子节点塞到父节点的children属性 |
||||
* |
||||
* @param list |
||||
* @throws Exception |
||||
*/ |
||||
public static void pushChildrenToParent(List<QNode> list) throws Exception { |
||||
Recursion r = new Recursion(); |
||||
r.pushChildrenToParent(list); |
||||
} |
||||
|
||||
public QNode cloneWithOutChildren() throws CloneNotSupportedException { |
||||
QNode cloned = (QNode) super.clone(); |
||||
cloned.id = this.id; |
||||
cloned.parentId = this.parentId; |
||||
cloned.text = this.text; |
||||
cloned.value = this.value; |
||||
cloned.showCheck = this.showCheck; |
||||
cloned.checkState = this.checkState; |
||||
cloned.isExpand = this.isExpand; |
||||
cloned.canSelect = this.canSelect; |
||||
cloned.hasChildren = this.hasChildren; |
||||
cloned.children = null; |
||||
return cloned; |
||||
} |
||||
} |
||||
|
||||
private static class Recursion { |
||||
|
||||
/** |
||||
* 构造方法 |
||||
*/ |
||||
public Recursion() { |
||||
} |
||||
|
||||
public String generateJSONString(List<QNode> list) throws Exception { |
||||
return generateJSONString(list, true); |
||||
} |
||||
|
||||
public String generateJSONString(List<QNode> list, boolean isAjax) throws Exception { |
||||
JSONArray result = JSONFactory.createJSON(JSON.ARRAY); |
||||
for (int i = 0, len = list.size(); i < len; i++) { |
||||
QNode node = list.get(i); |
||||
if (hasParent(node)) { |
||||
continue; |
||||
} |
||||
result.add(recursionFn(list, node, isAjax)); |
||||
} |
||||
return result.toString(); |
||||
} |
||||
|
||||
public void pushChildrenToParent(List<QNode> list) throws Exception { |
||||
for (int i = 0, len = list.size(); i < len; i++) { |
||||
QNode node = list.get(i); |
||||
if (!node.hasChildren) { |
||||
continue; |
||||
} |
||||
generateAndGetChildList(list, node); |
||||
} |
||||
} |
||||
|
||||
public JSONObject recursionFn(List<QNode> list, QNode node) { |
||||
return recursionFn(list, node, true); |
||||
} |
||||
|
||||
public JSONObject recursionFn(List<QNode> list, QNode node, boolean isAjax) { |
||||
JSONObject result = JSONFactory.createJSON(JSON.OBJECT); |
||||
if (hasChild(node, isAjax)) { |
||||
// 之前是 stringbuffer 直接拼接 node.id 的,所以这边的 node.id 肯定是一个数字
|
||||
// 但是 QNode 和 JQNode 都是下拉树数据的实体类,而 JQNode 那边对于 node.id 都是当作字符串来处理的,
|
||||
// 因此这边可以判断 QNode 的 id 也是可以作为字符串来对待的。
|
||||
result.put("id", node.id); |
||||
result.put("text", node.text); |
||||
result.put("value", node.value); |
||||
result.put("showcheck", node.showCheck); |
||||
result.put("complete", true); |
||||
result.put("canSelect", node.canSelect); |
||||
result.put("isexpand", node.isExpand); |
||||
result.put("checkstate", node.checkState.getStatusValue()); |
||||
result.put("hasChildren", node.hasChildren); |
||||
JSONArray childrenNodeArray = JSONFactory.createJSON(JSON.ARRAY); |
||||
List<QNode> childList = generateAndGetChildList(list, node); |
||||
for (QNode n : childList) { |
||||
childrenNodeArray.add(recursionFn(list, n, isAjax)); |
||||
} |
||||
result.put("ChildNodes", childrenNodeArray); |
||||
} else { |
||||
result.put("id", node.id); |
||||
result.put("text", node.text); |
||||
result.put("value", node.value); |
||||
result.put("showcheck", node.showCheck); |
||||
result.put("complete", true); |
||||
result.put("canSelect", node.canSelect); |
||||
result.put("isexpand", node.isExpand); |
||||
result.put("checkstate", node.checkState.getStatusValue()); |
||||
result.put("hasChildren", node.hasChildren); |
||||
} |
||||
return result; |
||||
} |
||||
|
||||
public boolean hasChild(List list, QNode node) { //判断是否有子节点
|
||||
return node.hasChildren && node.isExpand; |
||||
} |
||||
|
||||
public boolean hasChild(QNode node, boolean isAjax) { //判断是否有子节点
|
||||
return node.hasChildren && (node.isExpand || !isAjax); |
||||
} |
||||
|
||||
public boolean hasParent(QNode node) { |
||||
return StringUtils.isNotEmpty(node.parentId) |
||||
&& !ComparatorUtils.equals("0", node.parentId); |
||||
} |
||||
|
||||
/** |
||||
* 得到子节点列表 |
||||
* |
||||
* @param list list |
||||
* @param node node |
||||
* @return 子节点列表 |
||||
*/ |
||||
public List<QNode> generateAndGetChildList(List<QNode> list, QNode node) { |
||||
List<QNode> childrenFromAttr = node.getChildren(); |
||||
if (childrenFromAttr != null) { |
||||
return childrenFromAttr; |
||||
} |
||||
childrenFromAttr = new ArrayList<QNode>(); |
||||
Iterator<QNode> it = list.iterator(); |
||||
while (it.hasNext()) { |
||||
QNode n = it.next(); |
||||
if (ComparatorUtils.equals(n.parentId, node.id)) { |
||||
childrenFromAttr.add(n); |
||||
} |
||||
} |
||||
node.setChildren(childrenFromAttr); |
||||
return childrenFromAttr; |
||||
} |
||||
} |
||||
|
||||
public static class Node { |
||||
private String layer; |
||||
private Dictionary.MV mv; |
||||
|
||||
public Node(String layer, Dictionary.MV mv) { |
||||
this.layer = layer; |
||||
this.mv = mv; |
||||
} |
||||
|
||||
/** |
||||
* 哈希吗 |
||||
* |
||||
* @return 哈希码 |
||||
*/ |
||||
@Override |
||||
public int hashCode() { |
||||
return AssistUtils.hashCode(layer, mv); |
||||
} |
||||
|
||||
@Override |
||||
public boolean equals(Object obj) { |
||||
return obj instanceof Node && ComparatorUtils.equals(((Node) obj).layer, this.layer) && ComparatorUtils.equals(((Node) obj).mv, this.mv); |
||||
} |
||||
} |
||||
|
||||
/** |
||||
* 复选状态 |
||||
*/ |
||||
public enum CheckStatus { |
||||
NOCHECK((byte) 0), CHECK((byte) 1), HALF((byte) 2); |
||||
private byte statusValue;//状态值
|
||||
|
||||
CheckStatus(byte statusValue) { |
||||
this.statusValue = statusValue; |
||||
} |
||||
|
||||
public byte getStatusValue() { |
||||
return statusValue; |
||||
} |
||||
|
||||
public static CheckStatus parse(int value) { |
||||
for (CheckStatus status : values()) { |
||||
if (status.getStatusValue() == value) { |
||||
return status; |
||||
} |
||||
} |
||||
return NOCHECK; |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,281 @@
|
||||
package com.fr.plugin.data; |
||||
|
||||
import com.fr.base.BaseScriptUtils; |
||||
import com.fr.base.ParameterHelper; |
||||
import com.fr.base.ParameterMapNameSpace; |
||||
import com.fr.base.TableData; |
||||
import com.fr.data.core.TableDataXmlUtils; |
||||
import com.fr.data.impl.DBTableData; |
||||
import com.fr.data.impl.DataCacheKey; |
||||
import com.fr.data.impl.FormulaDisplayDictionary; |
||||
import com.fr.data.impl.NameTableData; |
||||
import com.fr.general.ComparatorUtils; |
||||
import com.fr.general.GeneralUtils; |
||||
import com.fr.general.data.Condition; |
||||
import com.fr.general.data.DataModel; |
||||
import com.fr.log.FineLoggerFactory; |
||||
import com.fr.script.Calculator; |
||||
import com.fr.stable.*; |
||||
import com.fr.stable.script.CalculatorProvider; |
||||
import com.fr.stable.xml.XMLPrintWriter; |
||||
import com.fr.stable.xml.XMLReadable; |
||||
import com.fr.stable.xml.XMLableReader; |
||||
|
||||
import java.util.ArrayList; |
||||
import java.util.HashMap; |
||||
import java.util.List; |
||||
import java.util.Map; |
||||
|
||||
public class VueTableDataDictionary extends FormulaDisplayDictionary { |
||||
private TableData tableData; |
||||
protected int canColumnIndex; |
||||
protected String canColumnName; |
||||
// private transient String query;
|
||||
// private transient TableData tempTableData;
|
||||
|
||||
public VueTableDataDictionary() { |
||||
// carl:内部从0开始,到界面上 + 1
|
||||
this(TableData.EMPTY_TABLEDATA, 0, 1, 0); |
||||
} |
||||
|
||||
public VueTableDataDictionary(TableData tableData, int keyColumnIndex, int valueColumnIndex, int canColumnIndex) { |
||||
this.setTableData(tableData); |
||||
this.setKeyColumnIndex(keyColumnIndex); |
||||
this.setValueColumnIndex(valueColumnIndex); |
||||
this.setCanColumnIndex(canColumnIndex); |
||||
} |
||||
|
||||
public void setTableData(TableData tableData) { |
||||
this.tableData = tableData; |
||||
} |
||||
|
||||
public TableData getTableData() { |
||||
return this.tableData; |
||||
} |
||||
|
||||
public int getCanColumnIndex() { |
||||
return canColumnIndex; |
||||
} |
||||
|
||||
public void setCanColumnIndex(int canColumnIndex) { |
||||
this.canColumnIndex = canColumnIndex; |
||||
} |
||||
|
||||
public String getCanColumnName() { |
||||
return canColumnName; |
||||
} |
||||
|
||||
public void setCanColumnName(String canColumnName) { |
||||
this.canColumnName = canColumnName; |
||||
} |
||||
|
||||
/** |
||||
* 获取当前对象对参数的依赖关系 |
||||
* |
||||
* @param ca 当前线程的算子 |
||||
* @return 字符串参数数组 |
||||
* @date 2014-9-18-下午2:15:19 |
||||
*/ |
||||
public String[] dependence(CalculatorProvider ca) { |
||||
List<String> list = new ArrayList<String>(); |
||||
String[] superDep = super.dependence(ca); |
||||
if (superDep != null) { |
||||
for (int i = 0; i < superDep.length; i++) { |
||||
list.add(superDep[i]); |
||||
} |
||||
} |
||||
|
||||
if (this.tableData != null) { |
||||
ParameterProvider[] pars = this.tableData.getParameters((Calculator) ca); |
||||
if (pars != null && pars.length != 0) { |
||||
for (int i = 0; i < pars.length; i++) { |
||||
ParameterProvider p = pars[i]; |
||||
if (p != null && p.getName() != null) { |
||||
list.add(p.getName()); |
||||
} |
||||
} |
||||
} else if (isDBNameTableData((Calculator) ca)) { |
||||
//以前的动态sql被删了,现在参数联动用数据查询做
|
||||
DBTableData db = (DBTableData) (((NameTableData) this.getTableData()).getTableData()); |
||||
return BaseScriptUtils.getDependenceByParameter(ParameterHelper.analyze4Parameters(db.getQuery(), true)); |
||||
} |
||||
} |
||||
|
||||
return list.toArray(new String[list.size()]); |
||||
} |
||||
|
||||
private boolean isDBNameTableData(Calculator c) { |
||||
return this.getTableData() instanceof NameTableData && ((NameTableData) this.getTableData()).createTableData(c) instanceof DBTableData; |
||||
} |
||||
|
||||
public int getCanSelectColumnIndex(DataModel var1) { |
||||
int var2 = this.getCanColumnIndex(); |
||||
if (var2 == -1) { |
||||
var2 = this.getDataModelColumnIndex(var1, this.getCanColumnName()); |
||||
} |
||||
|
||||
return var2; |
||||
} |
||||
|
||||
private boolean isNameTableData(Calculator c) { |
||||
return tableData instanceof NameTableData; |
||||
} |
||||
|
||||
private boolean isDBTableData(Calculator c) { |
||||
if (isNameTableData(c)) { |
||||
return ((NameTableData) tableData).createTableData(c) instanceof DBTableData; |
||||
} |
||||
return false; |
||||
} |
||||
|
||||
protected TableData asTableData(Calculator c) { |
||||
//下拉树 分层 eg : SELECT 销售员 FROM [销量] where 地区 = '${layer1}'
|
||||
// if(isNameTableData(c)){
|
||||
//nametabledata改成从共享池获取
|
||||
// //tempTableData = ((NameTableData)this.getTableData()).getTableData();
|
||||
// if (isDBTableData(c)) {
|
||||
// DBTableData dbTableData = (DBTableData)(((NameTableData)this.getTableData()).getTableData());
|
||||
// ParameterMapNameSpace pn = getDBParameterNameSpace(c);
|
||||
// c.pushNameSpace(pn);
|
||||
// String query = TemplateUtils.renderTpl(c, dbTableData.getQuery());
|
||||
// DBTableData result = new DBTableData(dbTableData.getDatabase(), query);
|
||||
// c.removeNameSpace(pn);
|
||||
// result.setShare(dbTableData.isShare());// kunsnat: 同步确定 是否共享.
|
||||
// return result;
|
||||
// }
|
||||
// return this.getTableData();
|
||||
// }
|
||||
return this.getTableData(); |
||||
} |
||||
|
||||
@Override |
||||
protected DataCacheKey createCacheKey(Calculator c) { |
||||
if (isNameTableData(c)) { |
||||
TableData db = ((NameTableData) this.getTableData()).getTableData(); |
||||
return db != null ? db.getDataCacheKey(c) : this.getTableData().getDataCacheKey(c); |
||||
} else { |
||||
return this.getTableData().getDataCacheKey(c); |
||||
} |
||||
} |
||||
|
||||
/** |
||||
* 对于数据集参数 如果从calculator中读取不到参数值 那么尝试获取数据集参数的默认值 |
||||
* |
||||
* @param c 算子 |
||||
* @return 参数空间 |
||||
* @date 2015-1-5-下午7:36:18 |
||||
*/ |
||||
public ParameterMapNameSpace getDBParameterNameSpace(Calculator c) { |
||||
DBTableData db = (DBTableData) (((NameTableData) this.getTableData()).getTableData()); |
||||
ParameterProvider[] ps = db.getParameters(c); |
||||
Map<String, Object> paraMap = new HashMap<String, Object>(); |
||||
for (int i = 0; i < ps.length; i++) { |
||||
try { |
||||
String _key = ps[i].getName(); |
||||
Object _value = ps[i].getValue(); |
||||
|
||||
//如果c.eval(_key)有值, 说明可能web端已经筛选出数据了, 那么不需要去取参数默认值了
|
||||
if (StableUtils.isNull(c.eval(_key))) { |
||||
if (_value instanceof FormulaProvider) { |
||||
_value = c.evalValue((FormulaProvider) _value); |
||||
} |
||||
|
||||
if (StringUtils.isEmpty(GeneralUtils.objectToString(_value))) { |
||||
continue; |
||||
} |
||||
|
||||
paraMap.put(ps[i].getName(), ps[i].getValue()); |
||||
} |
||||
|
||||
} catch (UtilEvalError e) { |
||||
FineLoggerFactory.getLogger().error(e.getMessage(), e); |
||||
} |
||||
} |
||||
return ParameterMapNameSpace.create(paraMap); |
||||
} |
||||
|
||||
public void readXML(XMLableReader reader) { |
||||
super.readXML(reader); |
||||
if (reader.isChildNode()) { |
||||
String tmpName = reader.getTagName(); |
||||
String tmpVal; |
||||
|
||||
if ("TableDataDictAttr".equals(tmpName) || "TableDataMapAttr".equals(tmpName)) { |
||||
// richer:兼容6.5未发布前的一个版本
|
||||
if ((tmpVal = reader.getAttrAsString("keyColumnIndex", null)) != null) { |
||||
// carl:兼容现在的都 - 1
|
||||
this.setKeyColumnIndex(Integer.parseInt(tmpVal) - 1); |
||||
} |
||||
if ((tmpVal = reader.getAttrAsString("valueColumnIndex", null)) != null) { |
||||
this.setValueColumnIndex(Integer.parseInt(tmpVal) - 1); |
||||
} |
||||
if ((tmpVal = reader.getAttrAsString("canColumnIndex", null)) != null) { |
||||
this.setValueColumnIndex(Integer.parseInt(tmpVal) - 1); |
||||
} |
||||
//我新增的部分
|
||||
if ((tmpVal = reader.getAttrAsString("canN", null)) != null) { |
||||
this.setCanColumnName(tmpVal); |
||||
} |
||||
if ((tmpVal = reader.getAttrAsString("canI", null)) != null) { |
||||
this.setCanColumnIndex(Integer.parseInt(tmpVal) - 1); |
||||
} else { |
||||
this.setCanColumnIndex(-1); |
||||
} |
||||
|
||||
//alex:兼容6.1时只放tableDataName
|
||||
if ((tmpVal = reader.getAttrAsString("tableDataName", null)) != null) { |
||||
this.setTableData(new NameTableData(tmpVal)); |
||||
} |
||||
|
||||
reader.readXMLObject(new XMLReadable() { |
||||
public void readXML(XMLableReader reader) { |
||||
if (reader.isChildNode()) { |
||||
if (TableData.XML_TAG.equals(reader.getTagName())) { |
||||
VueTableDataDictionary.this.setTableData(TableDataXmlUtils.readXMLTableData(reader)); |
||||
} |
||||
// richer:兼容6.5未发布前的一个版本
|
||||
if (Condition.XML_TAG.equals(reader.getTagName())) { |
||||
VueTableDataDictionary.this.condition = TableDataXmlUtils.readCondition(reader); |
||||
} |
||||
} |
||||
} |
||||
}); |
||||
} |
||||
} |
||||
} |
||||
|
||||
public void writeXML(XMLPrintWriter writer) { |
||||
super.writeXML(writer); |
||||
writer.startTAG("TableDataDictAttr"); |
||||
if (StringUtils.isNotBlank(this.getCanColumnName())) { |
||||
writer.attr("canN", this.getCanColumnName()); |
||||
} else { |
||||
writer.attr("canI", this.getCanColumnIndex()); |
||||
} |
||||
TableDataXmlUtils.writeXMLTableData(writer, this.getTableData()); |
||||
writer.end(); |
||||
} |
||||
|
||||
public boolean equals(Object obj) { |
||||
if (obj == this) { |
||||
return true; |
||||
} |
||||
if (!(obj instanceof com.fr.data.impl.TableDataDictionary)) { |
||||
return false; |
||||
} |
||||
|
||||
return super.equals(obj) && ComparatorUtils.equals(this.tableData, ((VueTableDataDictionary) obj).tableData) && |
||||
ComparatorUtils.equals(this.canColumnName, ((VueTableDataDictionary) obj).canColumnName) && |
||||
ComparatorUtils.equals(this.canColumnIndex, ((VueTableDataDictionary) obj).canColumnIndex) |
||||
; |
||||
} |
||||
|
||||
@Override |
||||
public String toString() { |
||||
return "VueTableDataDictionary{" + |
||||
"tableData=" + tableData + |
||||
", canColumnIndex=" + canColumnIndex + |
||||
", canColumnName='" + canColumnName + '\'' + |
||||
"} " + super.toString(); |
||||
} |
||||
} |
@ -0,0 +1,50 @@
|
||||
package com.fr.plugin.pane; |
||||
|
||||
import com.fanruan.api.design.ui.component.UILabel; |
||||
import com.fanruan.api.design.ui.component.UITextField; |
||||
import com.fanruan.api.design.ui.layout.TableLayoutKit; |
||||
import com.fanruan.api.design.work.form.container.AbstractDataModify; |
||||
import com.fr.design.layout.TableLayout; |
||||
import com.fr.design.mainframe.widget.accessibles.AccessibleDictionaryEditor; |
||||
import com.fr.plugin.widget.VUETreeSelectWidget; |
||||
|
||||
import javax.swing.*; |
||||
import java.awt.*; |
||||
|
||||
public class VSConfigPane extends AbstractDataModify<VUETreeSelectWidget> { |
||||
UITextField ui = new UITextField(); |
||||
AccessibleDictionaryEditor editor = new AccessibleDictionaryEditor(); |
||||
|
||||
public VSConfigPane() { |
||||
//初始化配置界面
|
||||
this.setLayout(new BorderLayout()); |
||||
double f = TableLayout.FILL; |
||||
double p = TableLayout.PREFERRED; |
||||
Component[][] components = new Component[][]{ |
||||
new Component[]{new UILabel("水印文字"), ui}, |
||||
new Component[]{new UILabel("数据绑定"), editor}, |
||||
}; |
||||
double[] rowSize = {p, p}; |
||||
double[] columnSize = {p, f}; |
||||
JPanel panel = TableLayoutKit.createTableLayoutPane(components, rowSize, columnSize); |
||||
this.add(panel, BorderLayout.CENTER); |
||||
} |
||||
|
||||
@Override |
||||
public void populateBean(VUETreeSelectWidget treeSelectWidget) { |
||||
String config1 = treeSelectWidget.getWaterMarker(); |
||||
ui.setText(config1); |
||||
} |
||||
|
||||
@Override |
||||
public VUETreeSelectWidget updateBean() { |
||||
VUETreeSelectWidget treeSelectWidget = new VUETreeSelectWidget(); |
||||
treeSelectWidget.setWaterMarker(this.ui.getText()); |
||||
return treeSelectWidget; |
||||
} |
||||
|
||||
@Override |
||||
protected String title4PopupWindow() { |
||||
return "树形选择器配置"; |
||||
} |
||||
} |
@ -0,0 +1,10 @@
|
||||
package com.fr.plugin.pane; |
||||
|
||||
import com.fr.design.mainframe.widget.accessibles.AccessiblePropertyEditor; |
||||
import com.fr.design.mainframe.widget.accessibles.AccessibleTreeModelEditor; |
||||
|
||||
public class VueAccessiblePropertyEditor extends AccessiblePropertyEditor { |
||||
public VueAccessiblePropertyEditor() { |
||||
super(new VueAccessibleTreeModelEditor()); |
||||
} |
||||
} |
@ -0,0 +1,43 @@
|
||||
package com.fr.plugin.pane; |
||||
|
||||
|
||||
import javax.swing.SwingUtilities; |
||||
|
||||
import com.fr.design.mainframe.widget.accessibles.UneditableAccessibleEditor; |
||||
import com.fr.design.mainframe.widget.wrappers.TreeModelWrapper; |
||||
import com.fr.design.dialog.BasicDialog; |
||||
import com.fr.design.dialog.DialogActionAdapter; |
||||
import com.fr.design.gui.frpane.TreeSettingPane; |
||||
|
||||
|
||||
/** |
||||
* 用于TreeEdito和TreeComboBox的数据格式设置 |
||||
* @since 6.5.3 |
||||
*/ |
||||
public class VueAccessibleTreeModelEditor extends UneditableAccessibleEditor { |
||||
|
||||
private VueTreeSettingPane treeSettingPane; |
||||
|
||||
public VueAccessibleTreeModelEditor() { |
||||
super(new TreeModelWrapper()); |
||||
} |
||||
|
||||
@Override |
||||
protected void showEditorPane() { |
||||
if (treeSettingPane == null) { |
||||
treeSettingPane = new VueTreeSettingPane(false); |
||||
} |
||||
BasicDialog dlg = treeSettingPane.showWindow(SwingUtilities.getWindowAncestor(this)); |
||||
treeSettingPane.populate(getValue()); |
||||
dlg.addDialogActionListener(new DialogActionAdapter() { |
||||
|
||||
@Override |
||||
public void doOk() { |
||||
Object nodeOrDict = treeSettingPane.updateTreeNodeAttrs(); |
||||
setValue(nodeOrDict); |
||||
fireStateChanged(); |
||||
} |
||||
}); |
||||
dlg.setVisible(true); |
||||
} |
||||
} |
@ -0,0 +1,14 @@
|
||||
package com.fr.plugin.pane; |
||||
|
||||
import com.fr.plugin.widget.VUETreeEditorWidget; |
||||
|
||||
import java.awt.*; |
||||
|
||||
public class VueComboBoxTreeEditor extends VueXTreeComboBoxEditor { |
||||
|
||||
public VueComboBoxTreeEditor(VUETreeEditorWidget widget, Dimension initSize) { |
||||
super(widget, initSize); |
||||
} |
||||
|
||||
|
||||
} |
@ -0,0 +1,288 @@
|
||||
package com.fr.plugin.pane; |
||||
|
||||
import com.fr.base.BaseFormula; |
||||
import com.fr.data.impl.NameTableData; |
||||
import com.fr.data.impl.RecursionTableData; |
||||
import com.fr.design.DesignModelAdapter; |
||||
import com.fr.design.data.BasicTableDataTreePane; |
||||
import com.fr.design.data.DesignTableDataManager; |
||||
import com.fr.design.data.datapane.EditOrNewLabel; |
||||
import com.fr.design.data.datapane.TableDataTreePane; |
||||
import com.fr.design.data.datapane.TreeTableDataComboBox; |
||||
import com.fr.design.data.datapane.preview.PreviewLabel; |
||||
import com.fr.design.data.tabledata.wrapper.AbstractTableDataWrapper; |
||||
import com.fr.design.data.tabledata.wrapper.TableDataWrapper; |
||||
import com.fr.design.data.tabledata.wrapper.TemplateTableDataWrapper; |
||||
import com.fr.design.dialog.BasicPane; |
||||
import com.fr.design.editor.ValueEditorPane; |
||||
import com.fr.design.editor.ValueEditorPaneFactory; |
||||
import com.fr.design.editor.editor.ColumnIndexEditor; |
||||
import com.fr.design.editor.editor.ColumnNameEditor; |
||||
import com.fr.design.editor.editor.Editor; |
||||
import com.fr.design.editor.editor.FormulaEditor; |
||||
import com.fr.design.editor.editor.OldColumnIndexEditor; |
||||
import com.fr.design.gui.ilable.UILabel; |
||||
import com.fr.design.layout.FRGUIPaneFactory; |
||||
import com.fr.design.layout.TableLayout; |
||||
import com.fr.design.layout.TableLayoutHelper; |
||||
import com.fr.plugin.data.VueTableDataDictionary; |
||||
import com.fr.stable.StringUtils; |
||||
import java.awt.*; |
||||
import java.awt.event.ItemEvent; |
||||
import java.awt.event.ItemListener; |
||||
import java.util.List; |
||||
import javax.swing.*; |
||||
import javax.swing.event.PopupMenuEvent; |
||||
import javax.swing.event.PopupMenuListener; |
||||
|
||||
public class VueJTreeAutoBuildPane extends BasicPane implements PreviewLabel.Previewable, EditOrNewLabel.Editable { |
||||
private TreeTableDataComboBox treeTableDataComboBox; |
||||
private ValueEditorPane valuePane; |
||||
private ValueEditorPane textPane; |
||||
private ValueEditorPane canSelectPane; |
||||
private JPanel centerPane; |
||||
private JPanel selectTreeDataPanel; |
||||
|
||||
public VueJTreeAutoBuildPane() { |
||||
this.initComponent(); |
||||
} |
||||
|
||||
/** |
||||
* 初始化 |
||||
*/ |
||||
public void initComponent() { |
||||
this.setLayout(FRGUIPaneFactory.createM_BorderLayout()); |
||||
UILabel selectTreeDataLabel = new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Select_A_Tree_DataSource_To_Build") + ": "); |
||||
treeTableDataComboBox = new TreeTableDataComboBox(DesignTableDataManager.getEditingTableDataSource()); |
||||
treeTableDataComboBox.setPreferredSize(new Dimension(180, 20)); |
||||
selectTreeDataPanel = FRGUIPaneFactory.createBoxFlowInnerContainer_S_Pane(); |
||||
selectTreeDataPanel.add(selectTreeDataLabel); |
||||
treeTableDataComboBox.addItemListener(new ItemListener() { |
||||
public void itemStateChanged(ItemEvent e) { |
||||
tdChange(); |
||||
} |
||||
}); |
||||
// REPORT-38762 加一个展开监听事件,下拉框展开时刷新一下数据集
|
||||
treeTableDataComboBox.addPopupMenuListener(new PopupMenuListener() { |
||||
@Override |
||||
public void popupMenuWillBecomeVisible(PopupMenuEvent e) { |
||||
treeTableDataComboBox.refresh(DesignTableDataManager.getEditingTableDataSource()); |
||||
} |
||||
|
||||
@Override |
||||
public void popupMenuWillBecomeInvisible(PopupMenuEvent e) { |
||||
|
||||
} |
||||
|
||||
@Override |
||||
public void popupMenuCanceled(PopupMenuEvent e) { |
||||
|
||||
} |
||||
}); |
||||
selectTreeDataPanel.add(treeTableDataComboBox); |
||||
treeTableDataComboBox.setPreferredSize(new Dimension(200, 25)); |
||||
treeTableDataComboBox.setSelectedIndex(-1); |
||||
PreviewLabel pl = new PreviewLabel(this); |
||||
pl.setPreferredSize(new Dimension(25, 25)); |
||||
EditOrNewLabel enl = new EditOrNewLabel(this, this); |
||||
enl.setPreferredSize(new Dimension(25, 25)); |
||||
selectTreeDataPanel.add(pl); |
||||
selectTreeDataPanel.add(enl); |
||||
|
||||
this.add(selectTreeDataPanel, BorderLayout.NORTH); |
||||
|
||||
valuePane = ValueEditorPaneFactory.createValueEditorPane(new Editor[]{new ColumnNameEditor(), new ColumnIndexEditor()}); |
||||
|
||||
FormulaEditor formulaEditor = new FormulaEditor(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Parameter_Formula")); |
||||
formulaEditor.setEnabled(true); |
||||
|
||||
textPane = ValueEditorPaneFactory.createValueEditorPane(new Editor[]{new ColumnNameEditor(), new ColumnIndexEditor(), formulaEditor}); |
||||
|
||||
canSelectPane = ValueEditorPaneFactory.createValueEditorPane(new Editor[]{new ColumnNameEditor(), new ColumnIndexEditor()}); |
||||
Component[][] coms = { |
||||
{ |
||||
new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Actual_Value") + ":"), |
||||
valuePane |
||||
}, |
||||
{ |
||||
new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Display_Value") + ":"), |
||||
textPane |
||||
}, |
||||
{ |
||||
new UILabel( "是否可以选择:"), |
||||
canSelectPane |
||||
} |
||||
}; |
||||
|
||||
double p = TableLayout.PREFERRED; |
||||
|
||||
double[] rowSize = {p, p, p, p}; |
||||
double[] columnSize = {p, p}; |
||||
centerPane = TableLayoutHelper.createTableLayoutPane(coms, rowSize, |
||||
columnSize); |
||||
|
||||
this.add(centerPane, BorderLayout.CENTER); |
||||
tdChange(); |
||||
} |
||||
|
||||
private void tdChange() { |
||||
TableDataWrapper tableDataWrappe = this.treeTableDataComboBox.getSelectedItem(); |
||||
if (tableDataWrappe == null) { |
||||
return; |
||||
} |
||||
try { |
||||
List<String> namelist = tableDataWrappe.calculateColumnNameList(); |
||||
String[] columnNames = new String[namelist.size()]; |
||||
namelist.toArray(columnNames); |
||||
valuePane.setEditors(new Editor[]{new ColumnNameEditor(columnNames), new ColumnIndexEditor(columnNames.length)}, columnNames[0]); |
||||
canSelectPane.setEditors(new Editor[]{new ColumnNameEditor(columnNames), new ColumnIndexEditor(columnNames.length)}, columnNames[0]); |
||||
FormulaEditor formulaEditor = new FormulaEditor(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Parameter_Formula")); |
||||
formulaEditor.setEnabled(true); |
||||
textPane.setEditors(new Editor[]{new ColumnNameEditor(columnNames), new ColumnIndexEditor(columnNames.length), formulaEditor}, columnNames[0]); |
||||
} catch (Exception e) { |
||||
valuePane.setEditors(new Editor[]{new OldColumnIndexEditor(100, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Column_Name"))}, 1); |
||||
FormulaEditor formulaEditor = new FormulaEditor(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Parameter_Formula")); |
||||
formulaEditor.setEnabled(true); |
||||
textPane.setEditors(new Editor[]{new OldColumnIndexEditor(100, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Column_Name")), formulaEditor}, 1); |
||||
} |
||||
} |
||||
|
||||
public void populate(VueTableDataDictionary tableDataDict) { |
||||
if (tableDataDict == null) { |
||||
this.treeTableDataComboBox.setSelectedItem(""); |
||||
this.textPane.populate(1); |
||||
this.canSelectPane.populate(1); |
||||
this.valuePane.populate(1); |
||||
return; |
||||
} else { |
||||
String _name = ""; |
||||
if (tableDataDict.getTableData() instanceof NameTableData) { |
||||
_name = ((NameTableData) tableDataDict.getTableData()).getName(); |
||||
} |
||||
this.treeTableDataComboBox.setSelectedTableDataByName(_name); |
||||
tdChange(); |
||||
// alex:因为显示到界面上的index是以1为始的,所以要加1
|
||||
if (!StringUtils.isEmpty(tableDataDict.getKeyColumnName())) { |
||||
this.valuePane.populate(tableDataDict.getKeyColumnName()); |
||||
} else { |
||||
this.valuePane.populate(tableDataDict.getKeyColumnIndex() + 1); |
||||
} |
||||
if (!StringUtils.isEmpty(tableDataDict.getCanColumnName())) { |
||||
this.canSelectPane.populate(tableDataDict.getCanColumnName()); |
||||
} else { |
||||
this.canSelectPane.populate(tableDataDict.getCanColumnIndex() + 1); |
||||
} |
||||
Object value = null; |
||||
if ((tableDataDict).getFormula() != null) { |
||||
value = (tableDataDict).getFormula(); |
||||
} else { |
||||
if (!StringUtils.isEmpty(tableDataDict.getValueColumnName())) { |
||||
value = tableDataDict.getValueColumnName(); |
||||
} else { |
||||
value = tableDataDict.getValueColumnIndex() + 1; |
||||
} |
||||
} |
||||
|
||||
this.textPane.populate(value); |
||||
} |
||||
} |
||||
|
||||
public VueTableDataDictionary update() { |
||||
VueTableDataDictionary tableDataDict = new VueTableDataDictionary(); |
||||
Object object = this.valuePane.update(StringUtils.EMPTY); |
||||
// alex:因为显示到界面上的index是以1为始的,所以要减1
|
||||
// carl:假如这里的序号要变,请考虑6.2的兼容
|
||||
|
||||
if (object instanceof Object[]) { |
||||
Object[] temp = (Object[]) object; |
||||
tableDataDict.setKeyColumnIndex(((Integer) temp[0]).intValue() - 1); |
||||
tableDataDict.setKeyColumnName((String) temp[1]); |
||||
} else if (object instanceof Integer) { |
||||
tableDataDict.setKeyColumnIndex((Integer) object - 1); |
||||
} else if (object instanceof String) { |
||||
tableDataDict.setKeyColumnName((String) object); |
||||
} |
||||
|
||||
//我加的
|
||||
Object canObj = this.canSelectPane.update(StringUtils.EMPTY); |
||||
// alex:因为显示到界面上的index是以1为始的,所以要减1
|
||||
// carl:假如这里的序号要变,请考虑6.2的兼容
|
||||
|
||||
if (canObj instanceof Object[]) { |
||||
Object[] temp = (Object[]) canObj; |
||||
tableDataDict.setCanColumnIndex(((Integer) temp[0]).intValue() - 1); |
||||
tableDataDict.setCanColumnName((String) temp[1]); |
||||
} else if (canObj instanceof Integer) { |
||||
tableDataDict.setCanColumnIndex((Integer) canObj - 1); |
||||
} else if (canObj instanceof String) { |
||||
tableDataDict.setCanColumnName((String) canObj); |
||||
} |
||||
|
||||
|
||||
Object object_text = this.textPane.update(StringUtils.EMPTY); |
||||
if (object_text instanceof Object[]) { |
||||
Object[] temp = (Object[]) object_text; |
||||
if (temp[0] instanceof BaseFormula) { |
||||
tableDataDict.setFormula((BaseFormula) temp[0]); |
||||
} else { |
||||
tableDataDict.setValueColumnIndex(((Integer) temp[0]).intValue() - 1); |
||||
tableDataDict.setValueColumnName((String) temp[1]); |
||||
} |
||||
} else if (object_text instanceof Integer) { |
||||
tableDataDict.setValueColumnIndex((Integer) this.textPane.update() - 1); |
||||
} else if (object_text instanceof String) { |
||||
tableDataDict.setValueColumnName((String) object_text); |
||||
} else { |
||||
tableDataDict.setFormula(((BaseFormula) canObj)); |
||||
} |
||||
TableDataWrapper tableDataWrappe = this.treeTableDataComboBox.getSelectedItem(); |
||||
if (tableDataWrappe != null) { |
||||
tableDataDict.setTableData(new NameTableData(tableDataWrappe.getTableDataName())); |
||||
} |
||||
|
||||
return tableDataDict; |
||||
} |
||||
|
||||
@Override |
||||
protected String title4PopupWindow() { |
||||
return "Auto Build Tree"; |
||||
} |
||||
|
||||
/** |
||||
* 预览 |
||||
*/ |
||||
public void preview() { |
||||
TableDataWrapper tableDataWrappe = treeTableDataComboBox.getSelectedItem(); |
||||
if (tableDataWrappe == null) { |
||||
return; |
||||
} |
||||
tableDataWrappe.previewData(); |
||||
} |
||||
|
||||
/** |
||||
* 编辑 |
||||
* @param jPanel 面板 |
||||
*/ |
||||
public void edit(JPanel jPanel) { |
||||
RecursionTableData rtd = null; |
||||
String name = ""; |
||||
BasicTableDataTreePane tdtp = TableDataTreePane.getInstance(DesignModelAdapter.getCurrentModelAdapter()); |
||||
if (treeTableDataComboBox.getSelectedItem() == null) { |
||||
//新建
|
||||
rtd = new RecursionTableData(); |
||||
name = TableDataTreePane.createUnrepeatedName(tdtp.getDataTree(), "Tree"); |
||||
} else { |
||||
//编辑
|
||||
rtd = treeTableDataComboBox.getSelcetedTableData(); |
||||
name = treeTableDataComboBox.getSelectedItem().getTableDataName(); |
||||
} |
||||
AbstractTableDataWrapper atdw = new TemplateTableDataWrapper(rtd, ""); |
||||
tdtp.dgEdit(atdw.creatTableDataPane(), name); |
||||
treeTableDataComboBox.refresh(); |
||||
treeTableDataComboBox.setSelectedTableDataByName(name); |
||||
textPane.populate(1); |
||||
canSelectPane.populate(1); |
||||
valuePane.populate(1); |
||||
} |
||||
|
||||
} |
@ -0,0 +1,280 @@
|
||||
package com.fr.plugin.pane; |
||||
|
||||
|
||||
import com.fr.data.impl.TreeAttr; |
||||
import com.fr.data.impl.TreeNodeAttr; |
||||
import com.fr.data.impl.TreeNodeWrapper; |
||||
import com.fr.design.data.DataCreatorUI; |
||||
import com.fr.design.dialog.BasicPane; |
||||
import com.fr.design.gui.controlpane.NameObjectCreator; |
||||
import com.fr.design.gui.controlpane.NameableCreator; |
||||
import com.fr.design.gui.frpane.JTreeAutoBuildPane; |
||||
import com.fr.design.gui.frpane.JTreeControlPane; |
||||
import com.fr.design.gui.frpane.tree.layer.config.LayerDataControlPane; |
||||
import com.fr.design.gui.icombobox.UIComboBox; |
||||
import com.fr.design.gui.ilable.UILabel; |
||||
import com.fr.design.gui.itree.refreshabletree.TreeDataCardPane; |
||||
import com.fr.design.layout.FRGUIPaneFactory; |
||||
import com.fr.form.ui.TreeComboBoxEditor; |
||||
import com.fr.form.ui.TreeEditor; |
||||
import com.fr.form.ui.tree.LayerConfig; |
||||
|
||||
import com.fr.general.NameObject; |
||||
import com.fr.plugin.data.VueTableDataDictionary; |
||||
import com.fr.plugin.widget.VUETreeEditorWidget; |
||||
import com.fr.plugin.widget.VUETreeSelectWidget; |
||||
|
||||
import javax.swing.*; |
||||
import java.awt.*; |
||||
import java.awt.event.ItemEvent; |
||||
import java.awt.event.ItemListener; |
||||
import java.util.Arrays; |
||||
|
||||
public class VueTreeSettingPane extends BasicPane implements DataCreatorUI { |
||||
private JTreeControlPane controlPane; |
||||
|
||||
private VueJTreeAutoBuildPane autoBuildPane; |
||||
|
||||
/** |
||||
* 新的分层构建方式 |
||||
*/ |
||||
private LayerDataControlPane layerDataControlPane; |
||||
|
||||
private UIComboBox buildBox; |
||||
|
||||
/** |
||||
* |
||||
*/ |
||||
private static final long serialVersionUID = 1762889323082827111L; |
||||
|
||||
private String[] buildWay = new String[]{ |
||||
com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_DataTable_Build"), |
||||
com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Auto_Build"), |
||||
com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Layer_Build") |
||||
}; |
||||
|
||||
public VueTreeSettingPane(boolean isEditor) { |
||||
this.initComponents(isEditor); |
||||
} |
||||
|
||||
private void initComponents(boolean isEditor) { |
||||
this.setLayout(FRGUIPaneFactory.createBorderLayout()); |
||||
JPanel buildWayPanel= FRGUIPaneFactory.createMediumHGapFlowInnerContainer_M_Pane(); |
||||
buildWayPanel.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0)); |
||||
UILabel buildWayLabel = new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Build_Way") + " :"); |
||||
buildWayPanel.add(buildWayLabel); |
||||
buildBox = new UIComboBox(buildWay); |
||||
buildBox.addItemListener(new ItemListener() { |
||||
|
||||
@Override |
||||
public void itemStateChanged(ItemEvent e) { |
||||
cardChanged(buildBox.getSelectedIndex()); |
||||
} |
||||
}); |
||||
buildWayPanel.add(buildBox); |
||||
|
||||
controlPane = new JTreeControlPane(new NameableCreator[] { treeNode }, |
||||
new TreeDataCardPane(), isEditor); |
||||
autoBuildPane = new VueJTreeAutoBuildPane(); |
||||
layerDataControlPane = new LayerDataControlPane(); |
||||
this.add(buildWayPanel, BorderLayout.NORTH); |
||||
cardChanged(0); |
||||
} |
||||
|
||||
private void cardChanged(int index) { |
||||
|
||||
this.remove(controlPane); |
||||
this.remove(autoBuildPane); |
||||
this.remove(layerDataControlPane); |
||||
this.add(autoBuildPane); |
||||
//修改了这里只保留自动构建面板
|
||||
switch (index) { |
||||
case 0: |
||||
this.add(layerDataControlPane); |
||||
break; |
||||
case 1: |
||||
this.add(autoBuildPane); |
||||
break; |
||||
case 2: |
||||
this.add(controlPane); |
||||
|
||||
break; |
||||
default: |
||||
break; |
||||
} |
||||
validate(); |
||||
repaint(); |
||||
revalidate(); |
||||
} |
||||
|
||||
@Override |
||||
protected String title4PopupWindow() { |
||||
return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Create_Tree"); |
||||
} |
||||
|
||||
@Override |
||||
public JComponent toSwingComponent() { |
||||
return this; |
||||
} |
||||
|
||||
NameableCreator treeNode = new NameObjectCreator( |
||||
com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Gradation"), |
||||
"/com/fr/design/images/data/source/jdbcTableData.png", |
||||
TreeNodeAttr.class); |
||||
|
||||
/** |
||||
* |
||||
* @param treeEditor |
||||
*/ |
||||
public void populate(VUETreeEditorWidget treeEditor) { |
||||
boolean isAutoBuild = treeEditor.isAutoBuild(); |
||||
TreeAttr treeAttr = treeEditor.getTreeAttr(); |
||||
if (treeAttr != null) { |
||||
NameObject no = new NameObject("name", treeEditor); |
||||
controlPane.populate(no); |
||||
} |
||||
if (isAutoBuild) { |
||||
buildBox.setSelectedIndex(1); |
||||
VueTableDataDictionary dictionary = treeEditor.getDictionary(); |
||||
autoBuildPane.populate(dictionary); |
||||
} else if (treeEditor.isLayerBuild()) { |
||||
buildBox.setSelectedIndex(0); |
||||
java.util.List<LayerConfig> layerConfigList = treeEditor.getLayerConfigs(); |
||||
LayerConfig[] layerConfigs = new LayerConfig[layerConfigList.size()]; |
||||
int i = 0; |
||||
for (LayerConfig layerConfig : layerConfigList) { |
||||
layerConfigs[i++] = layerConfig; |
||||
} |
||||
this.layerDataControlPane.populate(new NameObject("Tree Layer Data", layerConfigs)); |
||||
} else { |
||||
buildBox.setSelectedIndex(2); |
||||
} |
||||
} |
||||
|
||||
/** |
||||
* 视图树的update |
||||
* @return |
||||
*/ |
||||
public TreeEditor updateTreeEditor() { |
||||
// NameObject no = this.controlPane.update();
|
||||
// if (no != null) {
|
||||
// return ((TreeEditor) no.getObject());
|
||||
// }
|
||||
//
|
||||
// return null;
|
||||
TreeEditor te = new TreeEditor(); |
||||
if (buildBox.getSelectedIndex() == 1) { |
||||
VueTableDataDictionary dictionary = this.autoBuildPane.update(); |
||||
te.setAutoBuild(true); |
||||
te.setLayerBuild(false); |
||||
te.setDictionary(dictionary); |
||||
te.setNodeOrDict(dictionary); |
||||
} else if (buildBox.getSelectedIndex() == 2) { |
||||
te.setAutoBuild(false); |
||||
te.setLayerBuild(false); |
||||
NameObject no = this.controlPane.update(); |
||||
if (no != null) { |
||||
TreeEditor editor = (TreeEditor) no.getObject(); |
||||
te.setAllowBlank(editor.isAllowBlank()); |
||||
te.setEnabled(editor.isEnabled()); |
||||
te.setDirectEdit(editor.isDirectEdit()); |
||||
te.setErrorMessage(editor.getErrorMessage()); |
||||
te.setWidgetName(editor.getWidgetName()); |
||||
te.setVisible(editor.isVisible()); |
||||
te.setWaterMark(editor.getWaterMark()); |
||||
te.setRemoveRepeat(editor.isRemoveRepeat()); |
||||
te.setTreeAttr(editor.getTreeAttr()); |
||||
te.setTreeNodeAttr(editor.getTreeNodeAttr()); |
||||
te.setNodeOrDict(editor.getTreeNodeAttr()); |
||||
te.setPerformanceFirst(editor.isPerformanceFirst()); |
||||
} |
||||
} else { |
||||
LayerConfig[] configs = (LayerConfig[]) layerDataControlPane.update().getObject(); |
||||
te.setAutoBuild(false); |
||||
te.setLayerBuild(true); |
||||
te.setLayerConfigs(Arrays.asList(configs)); |
||||
} |
||||
return te; |
||||
} |
||||
|
||||
/** |
||||
* 树节点属性的update |
||||
* @return |
||||
*/ |
||||
public Object updateTreeNodeAttrs() { |
||||
|
||||
if (buildBox.getSelectedIndex() == 2) { |
||||
NameObject no = controlPane.update(); |
||||
if (no != null) { |
||||
return no.getObject(); |
||||
} |
||||
} else if (buildBox.getSelectedIndex() == 0) { |
||||
return layerDataControlPane.update(); |
||||
} else { |
||||
return autoBuildPane.update(); |
||||
} |
||||
return null; |
||||
} |
||||
|
||||
/** |
||||
* 下拉树的update |
||||
* @return |
||||
*/ |
||||
public TreeComboBoxEditor updateTreeComboBox() { |
||||
TreeComboBoxEditor tcb = new TreeComboBoxEditor(); |
||||
if (buildBox.getSelectedIndex() == 1) { |
||||
VueTableDataDictionary dictionary = this.autoBuildPane.update(); |
||||
tcb.setAutoBuild(true); |
||||
tcb.setLayerBuild(false); |
||||
tcb.setDictionary(dictionary); |
||||
tcb.setNodeOrDict(dictionary); |
||||
} else if (buildBox.getSelectedIndex() == 2) { |
||||
tcb.setAutoBuild(false); |
||||
tcb.setLayerBuild(false); |
||||
NameObject no = this.controlPane.update(); |
||||
if (no != null) { |
||||
if (no.getObject() instanceof TreeComboBoxEditor) { |
||||
return (TreeComboBoxEditor) no.getObject(); |
||||
} |
||||
|
||||
TreeEditor editor = (TreeEditor) no.getObject(); |
||||
tcb.setAllowBlank(editor.isAllowBlank()); |
||||
tcb.setEnabled(editor.isEnabled()); |
||||
tcb.setDirectEdit(editor.isDirectEdit()); |
||||
tcb.setErrorMessage(editor.getErrorMessage()); |
||||
tcb.setWidgetName(editor.getWidgetName()); |
||||
tcb.setVisible(editor.isVisible()); |
||||
tcb.setWaterMark(editor.getWaterMark()); |
||||
tcb.setRemoveRepeat(editor.isRemoveRepeat()); |
||||
tcb.setTreeAttr(editor.getTreeAttr()); |
||||
tcb.setTreeNodeAttr(editor.getTreeNodeAttr()); |
||||
tcb.setNodeOrDict(editor.getTreeNodeAttr()); |
||||
tcb.setPerformanceFirst(editor.isPerformanceFirst()); |
||||
} |
||||
}else { |
||||
LayerConfig[] configs = (LayerConfig[]) layerDataControlPane.update().getObject(); |
||||
tcb.setAutoBuild(false); |
||||
tcb.setLayerBuild(true); |
||||
tcb.setLayerConfigs(Arrays.asList(configs)); |
||||
} |
||||
return tcb; |
||||
} |
||||
|
||||
/** |
||||
* |
||||
* @param nodeOrDict |
||||
*/ |
||||
public void populate(Object nodeOrDict) { |
||||
if(nodeOrDict instanceof TreeNodeAttr[] || nodeOrDict instanceof TreeNodeWrapper) { |
||||
buildBox.setSelectedIndex(2); |
||||
NameObject no = new NameObject("name", nodeOrDict); |
||||
controlPane.populate(no); |
||||
} else if(nodeOrDict instanceof VueTableDataDictionary) { |
||||
buildBox.setSelectedIndex(1); |
||||
autoBuildPane.populate((VueTableDataDictionary)nodeOrDict); |
||||
} else if (nodeOrDict instanceof NameObject) { |
||||
buildBox.setSelectedIndex(0); |
||||
layerDataControlPane.populate((NameObject) nodeOrDict); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,56 @@
|
||||
/* |
||||
* Copyright (c) 2019. 张左良 |
||||
*/ |
||||
|
||||
package com.fr.plugin.pane; |
||||
|
||||
import com.fr.design.designer.creator.CRPropertyDescriptor; |
||||
import com.fr.design.designer.creator.XWidgetCreator; |
||||
import com.fr.design.form.util.XCreatorConstants; |
||||
import com.fr.design.gui.ilable.UILabel; |
||||
import com.fr.design.mainframe.widget.editors.RegexEditor; |
||||
import com.fr.design.mainframe.widget.editors.WidgetValueEditor; |
||||
import com.fr.design.mainframe.widget.renderer.RegexCellRencerer; |
||||
import com.fr.form.ui.TextEditor; |
||||
import com.fr.form.ui.Widget; |
||||
import com.fr.form.ui.reg.RegExp; |
||||
import com.fr.general.Inter; |
||||
import com.fr.stable.ArrayUtils; |
||||
import com.fr.stable.StringUtils; |
||||
|
||||
import javax.swing.*; |
||||
import java.awt.*; |
||||
import java.beans.IntrospectionException; |
||||
|
||||
public class VueWidgetPane extends XWidgetCreator { |
||||
|
||||
public VueWidgetPane(Widget widget, Dimension dimension) { |
||||
super(widget, dimension); |
||||
} |
||||
@Override |
||||
protected String getIconName() { |
||||
return "text_pane_16.png"; |
||||
} |
||||
@Override |
||||
protected JComponent initEditor() { |
||||
UILabel l = new UILabel("VUE树形选择控件"); |
||||
l.setForeground(Color.BLUE); |
||||
l.setVerticalAlignment(SwingConstants.CENTER); |
||||
l.setHorizontalAlignment(SwingConstants.CENTER); |
||||
setBorder(DEFALUTBORDER); |
||||
return editor = l; |
||||
} |
||||
@Override |
||||
public CRPropertyDescriptor[] supportedDescriptor() throws IntrospectionException { |
||||
CRPropertyDescriptor[] sup = (CRPropertyDescriptor[]) ArrayUtils.addAll( super.supportedDescriptor()); |
||||
return sup; |
||||
} |
||||
public boolean isDisplayRegField(boolean displayRegField) { |
||||
RegExp reg = ((TextEditor) toData()).getRegex(); |
||||
if (reg == null || !StringUtils.isNotEmpty(reg.toRegText())) { |
||||
|
||||
displayRegField = false; |
||||
} |
||||
return displayRegField; |
||||
} |
||||
} |
@ -0,0 +1,117 @@
|
||||
package com.fr.plugin.pane; |
||||
|
||||
|
||||
|
||||
import com.fr.design.designer.creator.CRPropertyDescriptor; |
||||
import com.fr.design.designer.creator.XLayoutContainer; |
||||
import com.fr.design.designer.creator.XTreeEditor; |
||||
import com.fr.design.designer.creator.XWScaleLayout; |
||||
import com.fr.design.form.util.XCreatorConstants; |
||||
import com.fr.design.gui.itextfield.UITextField; |
||||
import com.fr.design.layout.FRGUIPaneFactory; |
||||
import com.fr.form.ui.TreeComboBoxEditor; |
||||
import com.fr.plugin.widget.VUETreeEditorWidget; |
||||
import com.fr.plugin.widget.VUETreeSelectWidget; |
||||
import com.fr.stable.ArrayUtils; |
||||
|
||||
import javax.swing.JComponent; |
||||
import java.awt.BorderLayout; |
||||
import java.awt.Color; |
||||
import java.awt.Dimension; |
||||
import java.beans.IntrospectionException; |
||||
|
||||
/** |
||||
* @author richer |
||||
* @since 6.5.3 |
||||
*/ |
||||
public class VueXTreeComboBoxEditor extends VueXTreeEditor { |
||||
|
||||
LimpidButton btn; |
||||
|
||||
public VueXTreeComboBoxEditor(VUETreeEditorWidget widget, Dimension initSize) { |
||||
super(widget, initSize); |
||||
} |
||||
|
||||
@Override |
||||
protected JComponent initEditor() { |
||||
if (editor == null) { |
||||
editor = FRGUIPaneFactory.createBorderLayout_S_Pane(); |
||||
UITextField textField = new UITextField(5); |
||||
textField.setOpaque(false); |
||||
editor.add(textField, BorderLayout.CENTER); |
||||
btn = new LimpidButton("", this.getIconPath(), toData().isVisible() ? FULL_OPACITY : HALF_OPACITY); |
||||
btn.setPreferredSize(new Dimension(21, 21)); |
||||
btn.setOpaque(true); |
||||
editor.add(btn, BorderLayout.EAST); |
||||
editor.setBackground(Color.WHITE); |
||||
} |
||||
return editor; |
||||
} |
||||
|
||||
protected CRPropertyDescriptor[] addWaterMark(CRPropertyDescriptor[] crp) throws IntrospectionException { |
||||
return (CRPropertyDescriptor[]) ArrayUtils.add(crp, new CRPropertyDescriptor("waterMark", this.data.getClass()).setI18NName( |
||||
com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_WaterMark")).putKeyValue( |
||||
XCreatorConstants.PROPERTY_CATEGORY, "Fine-Design_Basic_Advanced")); |
||||
} |
||||
|
||||
protected CRPropertyDescriptor[] addAllowEdit(CRPropertyDescriptor[] crp) throws IntrospectionException{ |
||||
return (CRPropertyDescriptor[])ArrayUtils.add(crp, new CRPropertyDescriptor("directEdit", this.data.getClass()) |
||||
.setI18NName(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Allow_Edit")).putKeyValue( |
||||
XCreatorConstants.PROPERTY_VALIDATE, "Fine-Design_Basic_Validate")); |
||||
} |
||||
|
||||
protected CRPropertyDescriptor[] addCustomData(CRPropertyDescriptor[] crp) throws IntrospectionException{ |
||||
return (CRPropertyDescriptor[])ArrayUtils.add(crp, new CRPropertyDescriptor("customData", this.data.getClass()) |
||||
.setI18NName(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Allow_Custom_Data")).putKeyValue( |
||||
XCreatorConstants.PROPERTY_VALIDATE, "Fine-Design_Basic_Validate")); |
||||
} |
||||
|
||||
@Override |
||||
protected String getIconName() { |
||||
return "comboboxtree.png"; |
||||
} |
||||
|
||||
protected void makeVisible(boolean visible) { |
||||
btn.makeVisible(visible); |
||||
} |
||||
|
||||
/** |
||||
* 获取当前XCreator的一个封装父容器 |
||||
* |
||||
* @param widgetName 当前组件名 |
||||
* |
||||
* @return 封装的父容器 |
||||
* |
||||
* |
||||
* @date 2014-11-25-下午4:47:23 |
||||
* |
||||
*/ |
||||
protected XLayoutContainer getCreatorWrapper(String widgetName){ |
||||
return new XWScaleLayout(); |
||||
} |
||||
|
||||
/** |
||||
* 将当前对象添加到父容器中 |
||||
* |
||||
* @param parentPanel 父容器组件 |
||||
* |
||||
* |
||||
* @date 2014-11-25-下午4:57:55 |
||||
* |
||||
*/ |
||||
protected void addToWrapper(XLayoutContainer parentPanel, int width, int minHeight){ |
||||
this.setSize(width, minHeight); |
||||
parentPanel.add(this); |
||||
} |
||||
|
||||
/** |
||||
* 此控件在自适应布局要保持原样高度 |
||||
* |
||||
* @return 是则返回true |
||||
*/ |
||||
@Override |
||||
public boolean shouldScaleCreator() { |
||||
return true; |
||||
} |
||||
|
||||
} |
@ -0,0 +1,125 @@
|
||||
package com.fr.plugin.pane; |
||||
|
||||
|
||||
import com.fr.design.designer.creator.CRPropertyDescriptor; |
||||
import com.fr.design.designer.creator.XWidgetCreator; |
||||
import com.fr.design.form.util.XCreatorConstants; |
||||
import com.fr.design.mainframe.widget.editors.InChangeBooleanEditor; |
||||
import com.fr.design.mainframe.widget.editors.TreeModelEditor; |
||||
import com.fr.design.mainframe.widget.editors.WidgetValueEditor; |
||||
import com.fr.design.mainframe.widget.renderer.TreeModelRenderer; |
||||
import com.fr.form.ui.FieldEditor; |
||||
import com.fr.form.ui.Widget; |
||||
import com.fr.plugin.widget.VUETreeEditorWidget; |
||||
import com.fr.stable.ArrayUtils; |
||||
|
||||
import java.awt.Dimension; |
||||
import java.beans.IntrospectionException; |
||||
import javax.swing.BorderFactory; |
||||
import javax.swing.JComponent; |
||||
import javax.swing.JTree; |
||||
import javax.swing.tree.DefaultMutableTreeNode; |
||||
|
||||
|
||||
public class VueXTreeEditor extends XWidgetCreator { |
||||
|
||||
public VueXTreeEditor(VUETreeEditorWidget widget, Dimension initSize) { |
||||
super(widget, initSize); |
||||
} |
||||
|
||||
@Override |
||||
/** |
||||
* 树控件的属性面板 |
||||
* @return 属性数组 |
||||
* @throws Introspection过程错误 |
||||
*/ |
||||
public CRPropertyDescriptor[] supportedDescriptor() throws IntrospectionException { |
||||
CRPropertyDescriptor[] crp = !((FieldEditor) toData()).isAllowBlank() ? |
||||
new CRPropertyDescriptor[]{ |
||||
new CRPropertyDescriptor("widgetValue", this.data.getClass()).setI18NName( |
||||
com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Widget_Value")).setEditorClass(WidgetValueEditor.class) |
||||
.putKeyValue(XCreatorConstants.PROPERTY_CATEGORY, "Fine-Design_Basic_Advanced"), |
||||
new CRPropertyDescriptor("model", this.data.getClass(), "getNodeOrDict", "setNodeOrDict").setI18NName( |
||||
com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_DS_Dictionary")).setEditorClass(TreeModelEditor.class).setRendererClass( |
||||
TreeModelRenderer.class).putKeyValue(XCreatorConstants.PROPERTY_CATEGORY, "Fine-Design_Basic_Advanced"), |
||||
new CRPropertyDescriptor("allowBlank", this.data.getClass()).setI18NName( |
||||
com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Allow_Blank")).setEditorClass(InChangeBooleanEditor.class) |
||||
.putKeyValue(XCreatorConstants.PROPERTY_VALIDATE, "Fine-Design_Basic_Validate"), |
||||
new CRPropertyDescriptor("errorMessage", this.data.getClass()).setI18NName( |
||||
com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Verify_Message")) |
||||
.putKeyValue(XCreatorConstants.PROPERTY_VALIDATE, "Fine-Design_Basic_Validate"), |
||||
} |
||||
: new CRPropertyDescriptor[]{ |
||||
new CRPropertyDescriptor("widgetValue", this.data.getClass()).setI18NName( |
||||
com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Widget_Value")).setEditorClass(WidgetValueEditor.class) |
||||
.putKeyValue(XCreatorConstants.PROPERTY_CATEGORY, "Fine-Design_Basic_Advanced"), |
||||
new CRPropertyDescriptor("model", this.data.getClass(), "getNodeOrDict", "setNodeOrDict").setI18NName( |
||||
com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_DS_Dictionary")).setEditorClass(VueAccessiblePropertyEditor.class).setRendererClass( |
||||
TreeModelRenderer.class).putKeyValue(XCreatorConstants.PROPERTY_CATEGORY, "Fine-Design_Basic_Advanced"), |
||||
new CRPropertyDescriptor("allowBlank", this.data.getClass()).setI18NName( |
||||
com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Allow_Blank")).setEditorClass(InChangeBooleanEditor.class).putKeyValue( |
||||
XCreatorConstants.PROPERTY_VALIDATE, "Fine-Design_Basic_Validate"),}; |
||||
|
||||
crp = this.addWaterMark(crp); |
||||
crp = (CRPropertyDescriptor[]) ArrayUtils.add(crp, |
||||
new CRPropertyDescriptor("fontSize", this.data.getClass(), "getFontSize", "setFontSize") |
||||
.setI18NName(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Style_Font_Size")) |
||||
.putKeyValue(XCreatorConstants.PROPERTY_CATEGORY, "Fine-Design_Basic_Advanced")); |
||||
crp = (CRPropertyDescriptor[]) ArrayUtils.add(crp, new CRPropertyDescriptor("multipleSelection", this.data.getClass()).setI18NName( |
||||
com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Tree_Mutiple_Selection_Or_Not")).putKeyValue( |
||||
XCreatorConstants.PROPERTY_CATEGORY, "Fine-Design_Basic_Advanced").setEditorClass(InChangeBooleanEditor.class)); |
||||
|
||||
crp = (CRPropertyDescriptor[]) ArrayUtils.add(crp, new CRPropertyDescriptor("ajax", this.data.getClass()).setI18NName( |
||||
com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Widget_Load_By_Async")).putKeyValue(XCreatorConstants.PROPERTY_CATEGORY, |
||||
"Fine-Design_Basic_Advanced")); |
||||
|
||||
crp = this.addAllowEdit(crp); |
||||
crp = this.addCustomData(crp); |
||||
|
||||
crp = (CRPropertyDescriptor[]) ArrayUtils.add(crp, new CRPropertyDescriptor("selectLeafOnly", this.data |
||||
.getClass()).setI18NName(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Tree_Select_Leaf_Only")).putKeyValue(XCreatorConstants.PROPERTY_CATEGORY, "Fine-Design_Basic_Advanced")); |
||||
crp = (CRPropertyDescriptor[]) ArrayUtils.add(crp, new CRPropertyDescriptor("returnFullPath", this.data |
||||
.getClass()).setI18NName(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Tree_Return_Full_Path")).putKeyValue(XCreatorConstants.PROPERTY_CATEGORY, "Fine-Design_Basic_Advanced")); |
||||
|
||||
return (CRPropertyDescriptor[]) ArrayUtils.addAll(super.supportedDescriptor(), crp); |
||||
} |
||||
|
||||
protected CRPropertyDescriptor[] addWaterMark(CRPropertyDescriptor[] crp) throws IntrospectionException { |
||||
return crp; |
||||
} |
||||
|
||||
protected CRPropertyDescriptor[] addAllowEdit(CRPropertyDescriptor[] crp) throws IntrospectionException { |
||||
return crp; |
||||
} |
||||
|
||||
protected CRPropertyDescriptor[] addCustomData(CRPropertyDescriptor[] crp) throws IntrospectionException { |
||||
return crp; |
||||
} |
||||
|
||||
@Override |
||||
protected JComponent initEditor() { |
||||
if (editor == null) { |
||||
DefaultMutableTreeNode root = new DefaultMutableTreeNode("Tree"); |
||||
root.add(new DefaultMutableTreeNode("Leaf1")); |
||||
root.add(new DefaultMutableTreeNode("Leaf2")); |
||||
editor = new JTree(root); |
||||
editor.setBorder(BorderFactory.createEmptyBorder(0, 8, 0, 0)); |
||||
} |
||||
return editor; |
||||
} |
||||
|
||||
@Override |
||||
/** |
||||
* 控件的预定义大小 |
||||
* @return 控件的预定义大小 |
||||
*/ |
||||
public Dimension initEditorSize() { |
||||
return SMALL_PREFERRED_SIZE; |
||||
} |
||||
|
||||
@Override |
||||
protected String getIconName() { |
||||
return "tree_16.png"; |
||||
} |
||||
|
||||
} |
@ -0,0 +1,29 @@
|
||||
package com.fr.plugin.provider; |
||||
|
||||
import com.fr.design.beans.BasicBeanPane; |
||||
import com.fr.design.fun.impl.AbstractCellWidgetOptionProvider; |
||||
import com.fr.form.ui.Widget; |
||||
import com.fr.plugin.VUETreeEditorDefinePane; |
||||
import com.fr.plugin.widget.VUETreeEditorWidget; |
||||
|
||||
public class VSCellWidgetOptionProvider extends AbstractCellWidgetOptionProvider { |
||||
@Override |
||||
public Class<? extends Widget> classForWidget() { |
||||
return VUETreeEditorWidget.class; |
||||
} |
||||
|
||||
@Override |
||||
public Class<? extends BasicBeanPane<? extends Widget>> appearanceForWidget() { |
||||
return VUETreeEditorDefinePane.class; |
||||
} |
||||
|
||||
@Override |
||||
public String iconPathForWidget() { |
||||
return "com/fr/design/images/buttonicon/widget/tree_16.png"; |
||||
} |
||||
|
||||
@Override |
||||
public String nameForWidget() { |
||||
return "VUE树形选择器"; |
||||
} |
||||
} |
@ -0,0 +1,36 @@
|
||||
package com.fr.plugin.provider; |
||||
|
||||
|
||||
import com.fr.design.fun.impl.AbstractFormWidgetOptionProvider; |
||||
import com.fr.form.ui.Widget; |
||||
import com.fr.plugin.pane.VueComboBoxTreeEditor; |
||||
import com.fr.plugin.transform.FunctionRecorder; |
||||
import com.fr.plugin.widget.VUETreeEditorWidget; |
||||
|
||||
@FunctionRecorder |
||||
public class VueFormOptionProvider extends AbstractFormWidgetOptionProvider { |
||||
|
||||
public VueFormOptionProvider() { |
||||
System.out.println("333333333333"); |
||||
} |
||||
|
||||
@Override |
||||
public Class<? extends Widget> classForWidget() { |
||||
return VUETreeEditorWidget.class; |
||||
} |
||||
|
||||
@Override |
||||
public Class<?> appearanceForWidget() { |
||||
return VueComboBoxTreeEditor.class; |
||||
} |
||||
|
||||
@Override |
||||
public String iconPathForWidget() { |
||||
return "com/fr/design/images/buttonicon/widget/tree_16.png"; |
||||
} |
||||
|
||||
@Override |
||||
public String nameForWidget() { |
||||
return "VUE树形选择器"; |
||||
} |
||||
} |
@ -0,0 +1,41 @@
|
||||
/* |
||||
* Copyright (c) 2019. 张左良 |
||||
*/ |
||||
|
||||
package com.fr.plugin.provider; |
||||
|
||||
import com.fr.design.fun.impl.AbstractParameterWidgetOptionProvider; |
||||
import com.fr.form.ui.Widget; |
||||
import com.fr.plugin.pane.VueComboBoxTreeEditor; |
||||
import com.fr.plugin.pane.VueWidgetPane; |
||||
import com.fr.plugin.pane.VueXTreeComboBoxEditor; |
||||
import com.fr.plugin.transform.FunctionRecorder; |
||||
import com.fr.plugin.widget.VUETreeEditorWidget; |
||||
import com.fr.plugin.widget.VUETreeSelectWidget; |
||||
|
||||
@FunctionRecorder |
||||
public class VueParameterWidgetOptionProvider extends AbstractParameterWidgetOptionProvider { |
||||
|
||||
|
||||
@Override |
||||
public Class<? extends Widget> classForWidget() { |
||||
return VUETreeEditorWidget.class; |
||||
} |
||||
|
||||
@Override |
||||
public Class<?> appearanceForWidget() { |
||||
// return VueWidgetPane.class;
|
||||
return VueComboBoxTreeEditor.class; |
||||
} |
||||
|
||||
@Override |
||||
public String iconPathForWidget() { |
||||
return "com/fr/design/images/buttonicon/widget/tree_16.png"; |
||||
} |
||||
|
||||
@Override |
||||
public String nameForWidget() { |
||||
return "VUE树形选择器"; |
||||
} |
||||
|
||||
} |
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,128 @@
|
||||
package com.fr.plugin.widget; |
||||
|
||||
import com.fanruan.api.report.form.category.TextWidget; |
||||
import com.fanruan.api.util.ArrayKit; |
||||
import com.fr.data.Dictionary; |
||||
import com.fr.data.act.Producer; |
||||
import com.fr.form.ui.Button; |
||||
import com.fr.form.ui.DataControl; |
||||
import com.fr.form.ui.concept.data.ValueInitializer; |
||||
import com.fr.json.JSONArray; |
||||
import com.fr.json.JSONException; |
||||
import com.fr.json.JSONObject; |
||||
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 javax.servlet.http.HttpServletRequest; |
||||
|
||||
/** |
||||
* 给单元格用的 |
||||
*/ |
||||
public class VUETreeSelectWidget extends TextWidget implements DataControl, Producer { |
||||
private String waterMarker; |
||||
private Dictionary dictionary; |
||||
|
||||
private ValueInitializer widgetValue; |
||||
|
||||
/** |
||||
* 控件初始值的可能类型 |
||||
* |
||||
* @return 多种类型组成的数组 |
||||
*/ |
||||
@Override |
||||
public int[] getValueType() { |
||||
return new int[]{TYPE_STRING, TYPE_DATABINDING, TYPE_FORMULA}; |
||||
} |
||||
|
||||
@Override |
||||
public String[] supportedEvents() { |
||||
return new String[]{AFTEREDIT}; |
||||
} |
||||
|
||||
@Override |
||||
public void setWidgetValue(ValueInitializer value) { |
||||
widgetValue = value; |
||||
} |
||||
|
||||
@Override |
||||
public ValueInitializer getWidgetValue() { |
||||
return widgetValue; |
||||
} |
||||
|
||||
@Override |
||||
public void createValueResult(CalculatorProvider calculatorProvider, JSONObject jsonObject) { |
||||
|
||||
} |
||||
|
||||
@Override |
||||
public String getFormatText() { |
||||
return null; |
||||
} |
||||
|
||||
@Override |
||||
public String getDataBindDefaultValue(CalculatorProvider calculatorProvider) { |
||||
return null; |
||||
} |
||||
|
||||
public String getWaterMarker() { |
||||
return waterMarker; |
||||
} |
||||
|
||||
public void setWaterMarker(String waterMarker) { |
||||
this.waterMarker = waterMarker; |
||||
} |
||||
|
||||
public Dictionary getDictionary() { |
||||
return dictionary; |
||||
} |
||||
|
||||
public void setDictionary(Dictionary dictionary) { |
||||
this.dictionary = dictionary; |
||||
} |
||||
|
||||
@Override |
||||
public void mixinJSON(Repository repository, CalculatorProvider calculatorProvider, JSONObject jsonObject) { |
||||
|
||||
} |
||||
|
||||
@Override |
||||
public String getXType() { |
||||
return "vuetree"; |
||||
} |
||||
|
||||
@Override |
||||
public String[] dependence(CalculatorProvider calculatorProvider) { |
||||
return ArrayKit.EMPTY_STRING_ARRAY; |
||||
} |
||||
@Override |
||||
public JSONArray createJSONData(SessionProvider sessionProvider, CalculatorProvider calculatorProvider, HttpServletRequest httpServletRequest) throws Exception { |
||||
return new JSONArray(); |
||||
} |
||||
@Override |
||||
public void readXML(XMLableReader reader) { |
||||
super.readXML(reader); |
||||
// if (reader.isChildNode()) {
|
||||
// String tagName = reader.getTagName();
|
||||
// if (ZTreeNode.XML_TAG.equals(tagName)) {
|
||||
// treeNode = (ZTreeNode) XmlKit.readXMLable(reader);
|
||||
// } else if (ZTreeAttr.XML_TAG.equals(tagName)) {
|
||||
// treeAttr = (ZTreeAttr) XmlKit.readXMLable(reader);
|
||||
// }
|
||||
// }
|
||||
} |
||||
@Override |
||||
public void writeXML(XMLPrintWriter writer) { |
||||
super.writeXML(writer); |
||||
// if (treeNode != null) {
|
||||
// XmlKit.writeXMLable(writer, treeNode, ZTreeNode.XML_TAG);
|
||||
// }
|
||||
// if (treeAttr != null) {
|
||||
// XmlKit.writeXMLable(writer, treeAttr, ZTreeAttr.XML_TAG);
|
||||
// }
|
||||
} |
||||
} |
File diff suppressed because one or more lines are too long
@ -0,0 +1,21 @@
|
||||
.el-tree-select .select-option { |
||||
display: none !important; |
||||
} |
||||
.el-tree-select-popper { |
||||
height: 400px; |
||||
overflow: auto; |
||||
} |
||||
.el-tree-select-popper .el-button--small { |
||||
width: 25px !important; |
||||
min-width: 25px !important; |
||||
} |
||||
.mb10 { |
||||
margin-bottom: 10px; |
||||
} |
||||
.no-data { |
||||
height: 32px; |
||||
line-height: 32px; |
||||
font-size: 14px; |
||||
color: #cccccc; |
||||
text-align: center; |
||||
} |
Binary file not shown.
Binary file not shown.
@ -0,0 +1,207 @@
|
||||
Vue.component('el-tree-select', { |
||||
template: " <div class='el-tree-select'>\n" + |
||||
" <!-- 下拉文本 -->\n" + |
||||
" <el-select\n" + |
||||
" v-model=\"labels\"\n" + |
||||
" popper-class=\"select-option\"\n" + |
||||
" ref=\"select\"\n" + |
||||
" v-bind=\"selectparams\"\n" + |
||||
" :popper-append-to-body=\"false\"\n" + |
||||
" :filterable=\"false\"\n" + |
||||
" v-popover:popover\n" + |
||||
" @clear=\"_selectClearFun\"\n" + |
||||
" ></el-select>\n" + |
||||
" <!-- 弹出框 -->\n" + |
||||
" <el-popover\n" + |
||||
" ref=\"popover\"\n" + |
||||
" :placement=\"placement\"\n" + |
||||
" popper-class=\"el-tree-select-popper\"\n" + |
||||
" :width=\"width\"\n" + |
||||
" v-model=\"visible\"\n" + |
||||
" trigger=\"click\"\n" + |
||||
" >\n" + |
||||
" <!-- 是否显示搜索框 -->\n" + |
||||
" <el-input\n" + |
||||
" v-if=\"treeparams.filterable\"\n" + |
||||
" v-model=\"keywords\"\n" + |
||||
" size=\"mini\"\n" + |
||||
" class=\"input-with-select mb10\"\n" + |
||||
" @change=\"_searchFun\"\n" + |
||||
" >\n" + |
||||
" <el-button\n" + |
||||
" slot=\"append\"\n" + |
||||
" icon=\"el-icon-search\"\n" + |
||||
" ></el-button>\n" + |
||||
" </el-input>\n" + |
||||
" <!-- 树列表 -->\n" + |
||||
" <el-tree\n" + |
||||
" ref='tree'\n" + |
||||
" v-show=\"data.length>0\"\n" + |
||||
" v-bind=\"treeparams\"\n" + |
||||
" :data=\"data\"\n" + |
||||
" :node-key=\"propsValue\"\n" + |
||||
" :draggable=\"false\"\n" + |
||||
" :current-node-key=\"ids[0]||null\"\n" + |
||||
" :show-checkbox=\"selectparams.multiple\"\n" + |
||||
" :filter-node-method=\"_filterFun\"\n" + |
||||
" @node-click=\"_treeNodeClickFun\"\n" + |
||||
" @check=\"__treeCheckClickFun\"\n" + |
||||
" @check-change=\"__changeCheckFun\"\n" + |
||||
" ></el-tree>\n" + |
||||
" <!-- 暂无数据 -->\n" + |
||||
" <div\n" + |
||||
" v-if=\"data.length===0\"\n" + |
||||
" class=\"no-data\"\n" + |
||||
" >暂无数据</div>\n" + |
||||
" </el-popover>\n" + |
||||
" </div>", |
||||
props: { |
||||
value: [String, Array], // v-model
|
||||
placement: { // 弹出框位置
|
||||
type: String, |
||||
default() { |
||||
return 'bottom' |
||||
} |
||||
}, |
||||
selectparams: { |
||||
disabled: Boolean, |
||||
placeholder: String, // 搜索框默认文字
|
||||
multiple: { // 是否多选
|
||||
type: Boolean, |
||||
default() { |
||||
return false; |
||||
} |
||||
} |
||||
}, |
||||
treeparams: { |
||||
'data': { |
||||
// 树菜单数据
|
||||
type: Array, |
||||
default() { |
||||
return []; |
||||
} |
||||
}, |
||||
'props': { |
||||
// 树菜单 默认数据设置
|
||||
type: Object, |
||||
default() { |
||||
return { |
||||
children: 'children', |
||||
label: 'name', |
||||
value: 'flowId', |
||||
disabled: 'disabled' |
||||
}; |
||||
} |
||||
} |
||||
} |
||||
}, |
||||
data:function() { |
||||
const { props, data } = this.treeparams; |
||||
const { multiple } = this.selectparams; |
||||
return { |
||||
propsValue: props.value || 'flowId', |
||||
propsLabel: props.label || 'name', |
||||
data: [...data], |
||||
keywords: '', |
||||
labels: multiple ? [] : '', // 存储名称,用于下拉框显示内容
|
||||
ids: [], // 存储id
|
||||
selectNodes: [], // 选中数据
|
||||
visible: false, |
||||
width: 150 |
||||
}; |
||||
}, |
||||
watch: { |
||||
'ids': function (val) { |
||||
this._setSelectNodeFun(); |
||||
} |
||||
}, |
||||
created() { |
||||
if (this.selectparams.multiple) { |
||||
if($.isArray(this.value)) { |
||||
this.ids = this.value; |
||||
} |
||||
} else { |
||||
if(this.value){ |
||||
this.ids = [this.value]; |
||||
} |
||||
} |
||||
}, |
||||
mounted() { |
||||
this.$nextTick(() => { |
||||
this.width = this.$refs.select.$el.getBoundingClientRect().width; |
||||
}); |
||||
}, |
||||
methods: { |
||||
// 输入文本框输入内容抛出
|
||||
_searchFun() { |
||||
this.$emit('searchfun', this.keywords); |
||||
}, |
||||
// 根据id筛选当前树名称,以及选中树列表
|
||||
_setSelectNodeFun() { |
||||
const el = this.$refs.tree; |
||||
// 长度为0,清空选择
|
||||
if (this.ids.length === 0 || this.data.length === 0) { |
||||
return; |
||||
} |
||||
el.setCurrentKey(this.ids); |
||||
if (this.selectparams.multiple) { |
||||
el.setCheckedKeys(this.ids); |
||||
this.labels = el.getCheckedNodes().map(item => item[this.propsLabel]); |
||||
} else { |
||||
this.labels = el.getCurrentNode()[this.propsLabel]; |
||||
} |
||||
}, |
||||
// 树过滤
|
||||
_filterFun(value, data, node) { |
||||
if (!value) return true; |
||||
return data[this.propsLabel].indexOf(value) !== -1; |
||||
}, |
||||
// 树点击
|
||||
_treeNodeClickFun(data, node, vm) { |
||||
this.ids = [data[this.propsValue]]; |
||||
this._emitFun(); |
||||
this.$emit('node-click', data, node, vm); |
||||
this.visible = false; |
||||
}, |
||||
// 树勾选
|
||||
__treeCheckClickFun(data, node, vm) { |
||||
this.ids = []; |
||||
node.checkedNodes.forEach(item => { |
||||
this.ids.push(item[this.propsValue]); |
||||
}); |
||||
this._emitFun(); |
||||
}, |
||||
__changeCheckFun(){ |
||||
this.$emit('hahahchange'); |
||||
}, |
||||
// 下拉框清空数据
|
||||
_selectClearFun() { |
||||
const {multiple} = this.selectparams; |
||||
const el = this.$refs.tree; |
||||
if (multiple) { |
||||
this.labels = []; |
||||
el.setCheckedKeys(this.ids); |
||||
} else { |
||||
this.labels = ''; |
||||
} |
||||
this.ids = []; |
||||
el.setCurrentKey(this.ids); |
||||
this.$emit('input', this.labels); |
||||
this.$emit('select-clear'); |
||||
}, |
||||
// 判断类型,抛出当前选中id
|
||||
_emitFun() { |
||||
const {multiple} = this.selectparams; |
||||
if (multiple) { |
||||
this.$emit('input', this.ids); |
||||
} else { |
||||
this.$emit('input', this.ids[0]); |
||||
} |
||||
}, |
||||
// 树列表更新数据
|
||||
treeDataUpdateFun(data) { |
||||
this.data = data; |
||||
} |
||||
}, |
||||
components: {} |
||||
}) |
File diff suppressed because one or more lines are too long
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,383 @@
|
||||
; |
||||
(function ($) { |
||||
var ZZL = {}; |
||||
|
||||
FR.TreeSelectEditor = FR.extend(FR.TagCheckBoxEditor, { |
||||
_defaultConfig: function () { |
||||
return $.extend(FR.TreeComboBoxEditor.superclass._defaultConfig.apply(), { |
||||
popupWidth: 200, |
||||
popupHeight: 240, |
||||
defaultWidth: 80 |
||||
}); |
||||
}, |
||||
uuid: function () { |
||||
var s = []; |
||||
var hexDigits = "0123456789abcdef"; |
||||
for (var i = 0; i < 12; i++) { |
||||
s[i] = hexDigits.substr(Math.floor(Math.random() * 0x10), 1); |
||||
} |
||||
var uuid = 'vue' + s.join(""); |
||||
return uuid; |
||||
}, |
||||
_init: function () { |
||||
try { |
||||
FR.TreeSelectEditor.superclass._init.apply(this, arguments); |
||||
this._hideView(); |
||||
//
|
||||
// this.initData();
|
||||
var opt = this.options; |
||||
FR.$defaultImport('/com/fr/plugin/vuetree/css/index.min.css', 'css'); |
||||
var dom = this.element; |
||||
var id = this.options.location = this.options.location || this.uuid(); |
||||
$(dom).attr("id", id); |
||||
var d = $("#" + id) |
||||
if (d[0]) { |
||||
this._realInit(); |
||||
} else { |
||||
this._initMe(); |
||||
} |
||||
} catch (e) { |
||||
console.error(e); |
||||
} |
||||
}, |
||||
getDep: function () { |
||||
var dep = {}; |
||||
var that = this; |
||||
var temps = this.options.resultWidgets |
||||
$.each(this.options.dependence, function (i, v) { |
||||
var name = v.toUpperCase(); |
||||
if(temps[name]){ |
||||
dep[name] = temps[name].getValue(); |
||||
} |
||||
}); |
||||
|
||||
return dep; |
||||
}, |
||||
reportEdit: function () { |
||||
var that = this; |
||||
setTimeout(function () { |
||||
that.fireEvent(FR.Events.AFTEREDIT); |
||||
}, 300) |
||||
}, |
||||
_realInit: function () { |
||||
this._showView(); |
||||
var opt = this.options; |
||||
var id = opt.location; |
||||
var dom = $('#' + id); |
||||
$(dom).html(" <el-tree-select :styles=\"styles\" v-model=\"values\"" + |
||||
" @hahahchange=\"_selectChange\" " + |
||||
" :selectparams=\"selectParams\" " + |
||||
" @check=\"_nodeClickFun\" " + |
||||
" :treeparams=\"treeParams\" " + |
||||
" :treeRenderFun=\"_renderFun\" @searchfun=\"_searchFun\"" + |
||||
" @node-click=\"_nodeClickFun\" @removeTag='removeTag'" + |
||||
" ref=\"treeSelect\"/>\n" + |
||||
" <el-select v-model=\"test\" placeholder=\"请选择\" @change=\"_selectChange\">\n" + |
||||
" <el-option v-for=\"item in treeParams.data\" :key=\"item.value\" :label=\"item.text\" :value=\"item.value\"></el-option>\n" + |
||||
" </el-select>"); |
||||
|
||||
this.options.data.setData( |
||||
{ |
||||
parameter: { |
||||
startIndex: 0, |
||||
limitIndex: 300, |
||||
dependence: this.getDep() |
||||
} |
||||
}) |
||||
debugger |
||||
var AllData = this.options.data.executeData(); |
||||
console.info(AllData); |
||||
var data = []; |
||||
if (AllData && AllData.length) { |
||||
data = $.map(AllData, function (data) { |
||||
return data.options.data; |
||||
}) |
||||
} |
||||
var that = this; |
||||
var tmpValue = undefined |
||||
if (opt.value) { |
||||
var t = opt.value.split(","); |
||||
tmpValue = $.map(t, function (i) { |
||||
return i; |
||||
}) |
||||
} |
||||
debugger |
||||
var app = window.app = this.app = new Vue({ |
||||
el: dom[0], |
||||
data: { |
||||
styles: { |
||||
width: '300px' |
||||
}, |
||||
test: '', |
||||
values: tmpValue, |
||||
selectParams: { |
||||
multiple: opt.mutiSelection, |
||||
clearable: false, |
||||
placeholder: opt.watermark ? this.options.watermark : '请输入内容' |
||||
}, |
||||
treeParams: { |
||||
includeHalfChecked: true, |
||||
// clickParent: true,
|
||||
filterable: !opt.async, |
||||
'check-strictly': !this.options.selectLeafOnly, |
||||
// 'default-expand-all': true,
|
||||
// 'expand-on-click-node': false,
|
||||
data: data, |
||||
props: { |
||||
children: 'ChildNodes', |
||||
label: 'text', |
||||
disabled: function (data, node) { |
||||
return !data.canSelect |
||||
}, |
||||
value: 'value', |
||||
isLeaf: function (data, node) { |
||||
return !data.hasChildren |
||||
} |
||||
}, |
||||
lazy: opt.async, |
||||
load: function (node, resolve) { |
||||
that.loadData(node, resolve); |
||||
} |
||||
} |
||||
}, |
||||
methods: { |
||||
_renderFun: function (h) { |
||||
return function (node, data, store) { |
||||
return " <span class='custom-tree-node'>\n" + |
||||
" <span>{node.label}</span>\n" + |
||||
" </span>" |
||||
} |
||||
}, |
||||
removeTag: function () { |
||||
console.log(val, '<-select change'); |
||||
that.reportEdit() |
||||
}, |
||||
// 下拉框修改
|
||||
_selectChange(val) { |
||||
console.log(val, '<-select change'); |
||||
that.reportEdit() |
||||
}, |
||||
// 树点击
|
||||
_nodeClickFun(data, node, vm) { |
||||
debugger |
||||
console.log('this _nodeClickFun', this.values, data, node); |
||||
if (that.events['click']) { |
||||
$.each(that.events['click'], function (i, v) { |
||||
$.isFunction(v) && v(data, node, vm) |
||||
}); |
||||
} |
||||
that.reportEdit() |
||||
}, |
||||
// 树过滤
|
||||
_searchFun(value) { |
||||
console.log(value, '<--_searchFun'); |
||||
// 自行判断 是走后台查询,还是前端过滤
|
||||
this.$refs.treeSelect.$refs.tree.filter(value); |
||||
// 后台查询
|
||||
// this.$refs.treeSelect.treeDataUpdateFun(treeData);
|
||||
}, |
||||
}, |
||||
method: { |
||||
getValue: function () { |
||||
console.info(this.$refs.treeSelect.model) |
||||
}, |
||||
} |
||||
} |
||||
) |
||||
}, |
||||
loadData: function (node, callback) { |
||||
this.allNodes = this.allNodes || {}; |
||||
if (node.id === 0) { |
||||
this.options.data.setData( |
||||
{ |
||||
parameter: { |
||||
startIndex: 0, |
||||
limitIndex: 300, |
||||
dependence: this.getDep() |
||||
} |
||||
}) |
||||
var AllData = this.options.data.executeData(); |
||||
|
||||
console.info(AllData); |
||||
var data = []; |
||||
if (AllData && AllData.length) { |
||||
data = $.map(AllData, function (data) { |
||||
return data.options.data; |
||||
}) |
||||
} |
||||
callback(data) |
||||
} else { |
||||
this.options.data.setData( |
||||
{ |
||||
parameter: node.data, |
||||
dependence: this.getDep() |
||||
}) |
||||
var AllData = this.options.data.executeData(); |
||||
console.info(AllData); |
||||
var data = []; |
||||
if (AllData && AllData.length) { |
||||
data = $.map(AllData, function (data) { |
||||
return data.options.data; |
||||
}) |
||||
} |
||||
node.data.ChildNodes = data |
||||
callback(data) |
||||
} |
||||
}, |
||||
reset: function () { |
||||
if (this.app) { |
||||
var that=this |
||||
if(that.timeInit){ |
||||
clearTimeout(that.timeInit) |
||||
} |
||||
that.timeInit=setTimeout(function (){ |
||||
that.timeInit=null; |
||||
that.options.data.setData( |
||||
{ |
||||
parameter: { |
||||
startIndex: 0, |
||||
limitIndex: 300, |
||||
dependence: that.getDep() |
||||
} |
||||
}) |
||||
var AllData = that.options.data.executeData(); |
||||
var data = []; |
||||
if (AllData && AllData.length) { |
||||
data = $.map(AllData, function (data) { |
||||
return data.options.data; |
||||
}) |
||||
} |
||||
that.app.$refs.treeSelect.treeDataUpdateFun(data); |
||||
},200) |
||||
} |
||||
}, |
||||
_initMe: function () { |
||||
var id = this.options.location; |
||||
var that = this; |
||||
var intc = setTimeout(function () { |
||||
var dom = $("#" + id); |
||||
|
||||
if (dom[0]) { |
||||
that._realInit(); |
||||
} else { |
||||
that._initMe(); |
||||
} |
||||
}, 100) |
||||
}, |
||||
setText: function (text) { |
||||
this.editComp.val(text); |
||||
}, |
||||
_hideView: function () { |
||||
if (FR.Browser.isIE8()) { |
||||
this.element.css("visibility", "hidden"); |
||||
} else { |
||||
this.element.hide(); |
||||
} |
||||
}, |
||||
_showView: function () { |
||||
if (FR.Browser.isIE8()) { |
||||
this.element.css("visibility", "show"); |
||||
} else { |
||||
var id = this.options.location; |
||||
$("#" + id).show(); |
||||
} |
||||
}, |
||||
setValue: function (value) { |
||||
try { |
||||
if (value) { |
||||
this.app.$refs.treeSelect.value = value; |
||||
} |
||||
} catch (e) { |
||||
console.error(e); |
||||
} |
||||
|
||||
|
||||
}, |
||||
startEditing: function () { |
||||
|
||||
this._showView() |
||||
}, |
||||
stopEditing: function () { |
||||
|
||||
}, |
||||
checkChildNode: function (node, result, resTmp) { |
||||
if (!node.canSelect) { |
||||
return; |
||||
} |
||||
if (!resTmp.includes(node.value)) { |
||||
resTmp.push(node.value); |
||||
} |
||||
if (!node.hasChildren) { |
||||
return; |
||||
} |
||||
if (node.ChildNodes) { |
||||
for (let child of node.ChildNodes) { |
||||
this.checkChildNode(child, result, resTmp); |
||||
} |
||||
} |
||||
}, |
||||
getCheckedNodes() { |
||||
try { |
||||
let nodes = this.app.$refs.treeSelect.$refs.tree.getCheckedNodes(); |
||||
let result = []; |
||||
let resTmp = []; |
||||
for (let node of nodes) { |
||||
if (node.canSelect) { |
||||
if (!resTmp.includes(node.value)) { |
||||
result.push(node.value); |
||||
resTmp.push(node.value); |
||||
} |
||||
this.checkChildNode(node, result, resTmp); |
||||
} |
||||
} |
||||
console.log(result); |
||||
return result; |
||||
} catch (e) { |
||||
} |
||||
return this.options.value; |
||||
}, |
||||
getValue: function () { |
||||
|
||||
return this.getCheckedNodes(); |
||||
// try {
|
||||
// if (this.options.returnFullPath) {
|
||||
// var tmp = this.app.$refs.treeSelect.$refs.tree.getCheckedNodes(false, true)
|
||||
// var t = $.map(tmp, function (v) {
|
||||
// return v.value;
|
||||
// })
|
||||
// return t;
|
||||
// } else {
|
||||
//
|
||||
// }
|
||||
// this.app.$refs.treeSelect.$refs.tree.getCheckedKeys(this.options.selectLeafOnly)
|
||||
// return this.app.$refs.treeSelect.value
|
||||
// } catch (e) {
|
||||
// }
|
||||
// return "";
|
||||
}, |
||||
getEditValue: function () { |
||||
return this.getFullPathValue(); |
||||
}, |
||||
|
||||
//获取全路径的值,
|
||||
getFullPathValue: function () { |
||||
try { |
||||
return this.app.$refs.treeSelect.value |
||||
} catch (e) { |
||||
|
||||
} |
||||
}, |
||||
_checkValueEffective: function () { |
||||
if (this.value && this.value !== "") { |
||||
if (FR.isEmptyObj(this.value)) { |
||||
return false; |
||||
} |
||||
} |
||||
return this.value !== undefined; |
||||
} |
||||
}); |
||||
/** |
||||
* 使用shortcut方法注册控件,styletext 这个是一个控件名称需要唯一而且和widget的getXType返回的值需要是一样的 |
||||
*/ |
||||
$.shortcut("vuetree", FR.TreeSelectEditor); |
||||
})(jQuery); |
Loading…
Reference in new issue