Browse Source

Pull request #8200: KERNEL-9999 下拉树代码重构

Merge in DESIGN/design from ~YUAN.WANG/design:feature/x to feature/x

* commit '1a43b7a1c8c90f150fdc061c01aeb46d40519f04':
  KERNEL-9999 下拉树代码重构
feature/x
Yuan.Wang 3 years ago
parent
commit
215942b564
  1. 22
      designer-base/src/main/java/com/fr/design/gui/frpane/JTreeControlPane.java
  2. 150
      designer-base/src/main/java/com/fr/design/gui/frpane/TreeSettingPane.java
  3. 16
      designer-base/src/main/java/com/fr/design/gui/frpane/tree/layer/config/LayerDataControlPane.java
  4. 2
      designer-base/src/main/java/com/fr/design/mainframe/widget/accessibles/AccessibleTreeModelEditor.java
  5. 4
      designer-form/src/main/java/com/fr/design/widget/ui/designer/TreeEditorDefinePane.java
  6. 4
      designer-realize/src/main/java/com/fr/design/widget/ui/TreeComboBoxEditorDefinePane.java
  7. 4
      designer-realize/src/main/java/com/fr/design/widget/ui/TreeEditorDefinePane.java

22
designer-base/src/main/java/com/fr/design/gui/frpane/JTreeControlPane.java

@ -42,14 +42,10 @@ public class JTreeControlPane extends ControlPane {
private JTree tree; private JTree tree;
private DefaultTreeModel defaultTreeModel; private DefaultTreeModel defaultTreeModel;
boolean isEditor = false;
private UICheckBox isPerformanceFirst; private UICheckBox isPerformanceFirst;
public JTreeControlPane(NameableCreator[] creators, BasicBeanPane updatePane, boolean isEditor) { public JTreeControlPane(NameableCreator[] creators, BasicBeanPane updatePane) {
this.initComponents(creators, updatePane); this.initComponents(creators, updatePane);
this.isEditor = isEditor;
} }
private void initComponents(NameableCreator[] creators, BasicBeanPane updatePane) { private void initComponents(NameableCreator[] creators, BasicBeanPane updatePane) {
@ -120,11 +116,7 @@ public class JTreeControlPane extends ControlPane {
if (obj instanceof TreeNodeAttr[]) { if (obj instanceof TreeNodeAttr[]) {
treeNodeAttr = ((TreeNodeAttr[]) obj); treeNodeAttr = ((TreeNodeAttr[]) obj);
isPerformanceFirst.setSelected(false); isPerformanceFirst.setSelected(false);
} else if (obj instanceof TreeEditor) { }else if (obj instanceof TreeNodeWrapper) {
TreeEditor treeEditor = (TreeEditor) obj;
treeNodeAttr = treeEditor.getTreeNodeAttr();
isPerformanceFirst.setSelected(treeEditor.isPerformanceFirst());
} else if (obj instanceof TreeNodeWrapper) {
treeNodeAttr = ((TreeNodeWrapper) obj).getTreeNodeAttrs(); treeNodeAttr = ((TreeNodeWrapper) obj).getTreeNodeAttrs();
isPerformanceFirst.setSelected(((TreeNodeWrapper) obj).isPerformanceFirst()); isPerformanceFirst.setSelected(((TreeNodeWrapper) obj).isPerformanceFirst());
} }
@ -146,19 +138,9 @@ public class JTreeControlPane extends ControlPane {
} }
public NameObject update() { public NameObject update() {
if (isEditor) {
TreeEditor treeEditor = new TreeEditor();
treeEditor.setTreeNodeAttr(updateTreeNodeAttr());
treeEditor.setPerformanceFirst(isPerformanceFirst.isSelected());
return new NameObject("tree", treeEditor);
} else {
TreeNodeWrapper treeNodeWrapper = new TreeNodeWrapper(isPerformanceFirst.isSelected(), updateTreeNodeAttr()); TreeNodeWrapper treeNodeWrapper = new TreeNodeWrapper(isPerformanceFirst.isSelected(), updateTreeNodeAttr());
return new NameObject("tree", treeNodeWrapper); return new NameObject("tree", treeNodeWrapper);
} }
}
public TreeNodeAttr[] updateTreeNodeAttr() { public TreeNodeAttr[] updateTreeNodeAttr() {
updatePane.updateBean(); updatePane.updateBean();

150
designer-base/src/main/java/com/fr/design/gui/frpane/TreeSettingPane.java

@ -26,12 +26,18 @@ import java.awt.event.ItemListener;
import java.util.Arrays; import java.util.Arrays;
public class TreeSettingPane extends BasicPane implements DataCreatorUI { public class TreeSettingPane extends BasicPane implements DataCreatorUI {
/**
* 普通分层构建方式
*/
private JTreeControlPane controlPane; private JTreeControlPane controlPane;
/**
* 自动构建方式
*/
private JTreeAutoBuildPane autoBuildPane; private JTreeAutoBuildPane autoBuildPane;
/** /**
* 新的分层构建方式 * 急速分层构建方式
*/ */
private LayerDataControlPane layerDataControlPane; private LayerDataControlPane layerDataControlPane;
@ -45,13 +51,13 @@ public class TreeSettingPane extends BasicPane implements DataCreatorUI {
private String[] buildWay = new String[]{com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_DataTable_Build"), 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")}; com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Auto_Build"), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Layer_Build")};
public TreeSettingPane(boolean isEditor) { public TreeSettingPane() {
this.initComponents(isEditor); this.initComponents();
} }
private void initComponents(boolean isEditor) { private void initComponents() {
this.setLayout(FRGUIPaneFactory.createBorderLayout()); this.setLayout(FRGUIPaneFactory.createBorderLayout());
JPanel buildWayPanel= FRGUIPaneFactory.createMediumHGapFlowInnerContainer_M_Pane(); JPanel buildWayPanel = FRGUIPaneFactory.createMediumHGapFlowInnerContainer_M_Pane();
buildWayPanel.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0)); buildWayPanel.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
UILabel buildWayLabel = new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Build_Way") + " :"); UILabel buildWayLabel = new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Build_Way") + " :");
buildWayPanel.add(buildWayLabel); buildWayPanel.add(buildWayLabel);
@ -65,8 +71,8 @@ public class TreeSettingPane extends BasicPane implements DataCreatorUI {
}); });
buildWayPanel.add(buildBox); buildWayPanel.add(buildBox);
controlPane = new JTreeControlPane(new NameableCreator[] { treeNode }, controlPane = new JTreeControlPane(new NameableCreator[]{treeNode},
new TreeDataCardPane(), isEditor); new TreeDataCardPane());
autoBuildPane = new JTreeAutoBuildPane(); autoBuildPane = new JTreeAutoBuildPane();
layerDataControlPane = new LayerDataControlPane(); layerDataControlPane = new LayerDataControlPane();
this.add(buildWayPanel, BorderLayout.NORTH); this.add(buildWayPanel, BorderLayout.NORTH);
@ -112,83 +118,10 @@ public class TreeSettingPane extends BasicPane implements DataCreatorUI {
"/com/fr/design/images/data/source/jdbcTableData.png", "/com/fr/design/images/data/source/jdbcTableData.png",
TreeNodeAttr.class); TreeNodeAttr.class);
/**
*
* @param treeEditor
*/
public void populate(TreeEditor 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);
TableDataDictionary dictionary = treeEditor.getDictionary();
autoBuildPane.populate(dictionary);
} else if (treeEditor.isFastLayerBuild()) {
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) {
TableDataDictionary dictionary = this.autoBuildPane.update();
te.setAutoBuild(true);
te.setFastLayerBuild(false);
te.setDictionary(dictionary);
te.setNodeOrDict(dictionary);
} else if (buildBox.getSelectedIndex() == 2) {
te.setAutoBuild(false);
te.setFastLayerBuild(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.setFastLayerBuild(true);
te.setLayerConfigs(Arrays.asList(configs));
}
return te;
}
/** /**
* 树节点属性的update * 树节点属性的update
*
* @return * @return
*/ */
public Object updateTreeNodeAttrs() { public Object updateTreeNodeAttrs() {
@ -207,64 +140,19 @@ public class TreeSettingPane extends BasicPane implements DataCreatorUI {
} }
/** /**
* 下拉树的update
* @return
*/
public TreeComboBoxEditor updateTreeComboBox() {
TreeComboBoxEditor tcb = new TreeComboBoxEditor();
if (buildBox.getSelectedIndex() == 1) {
TableDataDictionary dictionary = this.autoBuildPane.update();
tcb.setAutoBuild(true);
tcb.setFastLayerBuild(false);
tcb.setDictionary(dictionary);
tcb.setNodeOrDict(dictionary);
} else if (buildBox.getSelectedIndex() == 2) {
tcb.setAutoBuild(false);
tcb.setFastLayerBuild(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.setFastLayerBuild(true);
tcb.setLayerConfigs(Arrays.asList(configs));
}
return tcb;
}
/**
*
* @param nodeOrDict * @param nodeOrDict
*/ */
public void populate(Object nodeOrDict) { public void populate(Object nodeOrDict) {
if(nodeOrDict instanceof TreeNodeAttr[] || nodeOrDict instanceof TreeNodeWrapper) { if (nodeOrDict instanceof TreeNodeAttr[] || nodeOrDict instanceof TreeNodeWrapper) {
buildBox.setSelectedIndex(2); buildBox.setSelectedIndex(2);
NameObject no = new NameObject("name", nodeOrDict); NameObject no = new NameObject("name", nodeOrDict);
controlPane.populate(no); controlPane.populate(no);
} else if(nodeOrDict instanceof TableDataDictionary) { } else if (nodeOrDict instanceof TableDataDictionary) {
buildBox.setSelectedIndex(1); buildBox.setSelectedIndex(1);
autoBuildPane.populate((TableDataDictionary)nodeOrDict); autoBuildPane.populate((TableDataDictionary) nodeOrDict);
} else if (nodeOrDict instanceof NameObject) { } else if (nodeOrDict instanceof LayerConfig[]) {
buildBox.setSelectedIndex(0); buildBox.setSelectedIndex(0);
layerDataControlPane.populate((NameObject) nodeOrDict); layerDataControlPane.populate((LayerConfig[]) nodeOrDict);
} }
} }
} }

16
designer-base/src/main/java/com/fr/design/gui/frpane/tree/layer/config/LayerDataControlPane.java

@ -193,17 +193,14 @@ public class LayerDataControlPane extends ControlPane {
} }
} }
public void populate(NameObject nameObject) { public void populate(LayerConfig[] layerConfigs) {
// 重新添加tree节点的时候需要remove掉原来的所有子节点 // 重新添加tree节点的时候需要remove掉原来的所有子节点
((DefaultMutableTreeNode) defaultTreeModel.getRoot()).removeAllChildren(); ((DefaultMutableTreeNode) defaultTreeModel.getRoot()).removeAllChildren();
if (BEAN_NAME.equals(nameObject.getName())) { if (layerConfigs == null) {
Object obj = nameObject.getObject(); return;
LayerConfig[] layerConfigs = null;
if (obj instanceof LayerConfig[]) {
layerConfigs = ((LayerConfig[]) obj);
} }
int count = layerConfigs == null ? 0 : layerConfigs.length; int count = layerConfigs.length;
//将树的层次一层一层的加上去 //将树的层次一层一层的加上去
DefaultMutableTreeNode node4root = (DefaultMutableTreeNode) defaultTreeModel.getRoot(); DefaultMutableTreeNode node4root = (DefaultMutableTreeNode) defaultTreeModel.getRoot();
for (int i = 0; i < count; i++) { for (int i = 0; i < count; i++) {
@ -218,11 +215,10 @@ public class LayerDataControlPane extends ControlPane {
expandAll(tree, true); expandAll(tree, true);
tree.setSelectionRow(0); tree.setSelectionRow(0);
} }
}
public NameObject update() { public LayerConfig[] update() {
return new NameObject(BEAN_NAME, updateLayerDatas()); return updateLayerDatas();
} }
private LayerConfig[] updateLayerDatas() { private LayerConfig[] updateLayerDatas() {

2
designer-base/src/main/java/com/fr/design/mainframe/widget/accessibles/AccessibleTreeModelEditor.java

@ -23,7 +23,7 @@ public class AccessibleTreeModelEditor extends UneditableAccessibleEditor {
@Override @Override
protected void showEditorPane() { protected void showEditorPane() {
if (treeSettingPane == null) { if (treeSettingPane == null) {
treeSettingPane = new TreeSettingPane(false); treeSettingPane = new TreeSettingPane();
} }
BasicDialog dlg = treeSettingPane.showWindow(SwingUtilities.getWindowAncestor(this)); BasicDialog dlg = treeSettingPane.showWindow(SwingUtilities.getWindowAncestor(this));
treeSettingPane.populate(getValue()); treeSettingPane.populate(getValue());

4
designer-form/src/main/java/com/fr/design/widget/ui/designer/TreeEditorDefinePane.java

@ -76,7 +76,7 @@ public class TreeEditorDefinePane extends CustomWritableRepeatEditorPane<TreeEdi
@Override @Override
protected void populateSubCustomWritableRepeatEditorBean(TreeEditor e) { protected void populateSubCustomWritableRepeatEditorBean(TreeEditor e) {
accessibleTreeModelEditor.setValue(e.getNodeOrDict()); accessibleTreeModelEditor.setValue(e.getBuildModelConfig());
formWidgetValuePane.populate(e); formWidgetValuePane.populate(e);
treeRootPane.populate(e.getTreeAttr()); treeRootPane.populate(e.getTreeAttr());
mutiSelect.setSelected(e.isMultipleSelection()); mutiSelect.setSelected(e.isMultipleSelection());
@ -95,7 +95,7 @@ public class TreeEditorDefinePane extends CustomWritableRepeatEditorPane<TreeEdi
editor.setAjax(loadAsync.isSelected()); editor.setAjax(loadAsync.isSelected());
editor.setSelectLeafOnly(returnLeaf.isSelected()); editor.setSelectLeafOnly(returnLeaf.isSelected());
editor.setReturnFullPath(returnPath.isSelected()); editor.setReturnFullPath(returnPath.isSelected());
editor.setNodeOrDict(accessibleTreeModelEditor.getValue()); editor.setBuildModelConfig(accessibleTreeModelEditor.getValue());
return editor; return editor;
} }

4
designer-realize/src/main/java/com/fr/design/widget/ui/TreeComboBoxEditorDefinePane.java

@ -56,14 +56,14 @@ public class TreeComboBoxEditorDefinePane extends CustomWritableRepeatEditorPane
@Override @Override
protected void populateSubCustomWritableRepeatEditorBean(TreeEditor e) { protected void populateSubCustomWritableRepeatEditorBean(TreeEditor e) {
treeSettingPane.setValue(e.getNodeOrDict()); treeSettingPane.setValue(e.getBuildModelConfig());
treeRootPane.populate(e.getTreeAttr()); treeRootPane.populate(e.getTreeAttr());
} }
@Override @Override
protected TreeComboBoxEditor updateSubCustomWritableRepeatEditorBean() { protected TreeComboBoxEditor updateSubCustomWritableRepeatEditorBean() {
TreeComboBoxEditor editor = new TreeComboBoxEditor(); TreeComboBoxEditor editor = new TreeComboBoxEditor();
editor.setNodeOrDict(treeSettingPane.getValue()); editor.setBuildModelConfig(treeSettingPane.getValue());
editor.setTreeAttr(treeRootPane.update()); editor.setTreeAttr(treeRootPane.update());
return editor; return editor;
} }

4
designer-realize/src/main/java/com/fr/design/widget/ui/TreeEditorDefinePane.java

@ -30,7 +30,7 @@ public class TreeEditorDefinePane extends FieldEditorDefinePane<TreeEditor> {
@Override @Override
protected void populateSubFieldEditorBean(TreeEditor e) { protected void populateSubFieldEditorBean(TreeEditor e) {
this.accessibleTreeModelEditor.setValue(e.getNodeOrDict()); this.accessibleTreeModelEditor.setValue(e.getBuildModelConfig());
treeRootPane.populate(e.getTreeAttr()); treeRootPane.populate(e.getTreeAttr());
if (this.removeRepeatCheckBox != null) { if (this.removeRepeatCheckBox != null) {
this.removeRepeatCheckBox.setSelected(e.isRemoveRepeat()); this.removeRepeatCheckBox.setSelected(e.isRemoveRepeat());
@ -40,7 +40,7 @@ public class TreeEditorDefinePane extends FieldEditorDefinePane<TreeEditor> {
@Override @Override
protected TreeEditor updateSubFieldEditorBean() { protected TreeEditor updateSubFieldEditorBean() {
TreeEditor editor = new TreeEditor(); TreeEditor editor = new TreeEditor();
editor.setNodeOrDict(accessibleTreeModelEditor.getValue()); editor.setBuildModelConfig(accessibleTreeModelEditor.getValue());
editor.setTreeAttr(treeRootPane.update()); editor.setTreeAttr(treeRootPane.update());
if (this.removeRepeatCheckBox != null) { if (this.removeRepeatCheckBox != null) {
editor.setRemoveRepeat(this.removeRepeatCheckBox.isSelected()); editor.setRemoveRepeat(this.removeRepeatCheckBox.isSelected());

Loading…
Cancel
Save