From cca9e317ff8a270f0ee87d330b6f648a3bdf4851 Mon Sep 17 00:00:00 2001 From: juhaoyu <2335173323@qq.com> Date: Tue, 11 Oct 2016 14:48:53 +0800 Subject: [PATCH 01/22] =?UTF-8?q?=E4=B8=8B=E6=8B=89=E6=A0=91=E6=9E=81?= =?UTF-8?q?=E9=80=9F=E5=88=86=E5=B1=82=E6=9E=84=E5=BB=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fr/design/gui/frpane/TreeSettingPane.java | 194 +++++--- .../layer/config/LayerDataConfigPane.java | 102 ++++ .../layer/config/LayerDataControlPane.java | 255 ++++++++++ .../config/LayerDependenceSettingPane.java | 443 ++++++++++++++++++ 4 files changed, 920 insertions(+), 74 deletions(-) create mode 100644 designer_base/src/com/fr/design/gui/frpane/tree/layer/config/LayerDataConfigPane.java create mode 100644 designer_base/src/com/fr/design/gui/frpane/tree/layer/config/LayerDataControlPane.java create mode 100644 designer_base/src/com/fr/design/gui/frpane/tree/layer/config/LayerDependenceSettingPane.java diff --git a/designer_base/src/com/fr/design/gui/frpane/TreeSettingPane.java b/designer_base/src/com/fr/design/gui/frpane/TreeSettingPane.java index 1039cfac6c..dd87a74a21 100644 --- a/designer_base/src/com/fr/design/gui/frpane/TreeSettingPane.java +++ b/designer_base/src/com/fr/design/gui/frpane/TreeSettingPane.java @@ -1,44 +1,53 @@ package com.fr.design.gui.frpane; -import java.awt.BorderLayout; -import java.awt.event.ItemEvent; -import java.awt.event.ItemListener; - -import com.fr.data.impl.TreeNodeWrapper; -import com.fr.design.data.DataCreatorUI; -import com.fr.design.gui.ilable.UILabel; - -import javax.swing.*; - -import com.fr.general.NameObject; import com.fr.data.impl.TableDataDictionary; 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.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.design.dialog.BasicPane; import com.fr.form.ui.TreeComboBoxEditor; import com.fr.form.ui.TreeEditor; +import com.fr.form.ui.tree.LayerConfig; import com.fr.general.Inter; +import com.fr.general.NameObject; + +import javax.swing.*; +import java.awt.*; +import java.awt.event.ItemEvent; +import java.awt.event.ItemListener; public class TreeSettingPane extends BasicPane implements DataCreatorUI { private JTreeControlPane controlPane; + private JTreeAutoBuildPane autoBuildPane; + + /** + * 新的分层构建方式 + */ + private LayerDataControlPane layerDataControlPane; + private UIComboBox buildBox; + /** - * - */ - private static final long serialVersionUID = 1762889323082827111L; + * + */ + private static final long serialVersionUID = 1762889323082827111L; - private String[] buildWay = new String[] { Inter.getLocText("FR-Designer_Layer-Build"), - Inter.getLocText("FR-Designer_Auto-Build") }; + private String[] buildWay = new String[]{Inter.getLocText("FR-Designer_DataTable-Build"), + Inter.getLocText("FR-Designer_Auto-Build"), Inter.getLocText("FR-Designer_Layer-Build")}; public TreeSettingPane(boolean isEditor) { this.initComponents(isEditor); - } + System.out.print(true); + } private void initComponents(boolean isEditor) { this.setLayout(FRGUIPaneFactory.createBorderLayout()); @@ -58,18 +67,34 @@ public class TreeSettingPane extends BasicPane implements DataCreatorUI { controlPane = new JTreeControlPane(new NameableCreator[] { treeNode }, new TreeDataCardPane(), isEditor); autoBuildPane = new JTreeAutoBuildPane(); - this.add(buildWayPanel, BorderLayout.NORTH); - cardChanged(0); - } - + layerDataControlPane = new LayerDataControlPane(); + this.add(buildWayPanel, BorderLayout.NORTH); + cardChanged(0); + } + private void cardChanged(int index) { + this.remove(controlPane); this.remove(autoBuildPane); - this.add(index == 0 ? controlPane : autoBuildPane, BorderLayout.CENTER); - validate(); - repaint(); - revalidate(); - } + this.remove(layerDataControlPane); + 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() { @@ -101,10 +126,19 @@ public class TreeSettingPane extends BasicPane implements DataCreatorUI { buildBox.setSelectedIndex(1); TableDataDictionary dictionary = treeEditor.getDictionary(); autoBuildPane.populate(dictionary); - } else { - buildBox.setSelectedIndex(0); - } - } + } else if (treeEditor.isLayerBuild()) { + buildBox.setSelectedIndex(0); + java.util.List 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", layerConfigs)); + } else { + buildBox.setSelectedIndex(2); + } + } /** * 视图树的update @@ -123,43 +157,50 @@ public class TreeSettingPane extends BasicPane implements DataCreatorUI { te.setAutoBuild(true); te.setDictionary(dictionary); te.setNodeOrDict(dictionary); - } else { - te.setAutoBuild(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()); - } - } - return te; - } + } else if (buildBox.getSelectedIndex() == 0) { + // TODO: 16/9/12 + te.setLayerBuild(true); + + } else { + te.setAutoBuild(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()); + } + } + return te; + } /** * 树节点属性的update * @return */ public Object updateTreeNodeAttrs() { - if(buildBox.getSelectedIndex() == 0) { - NameObject no = controlPane.update(); - if (no != null) { - return no.getObject(); + + if (buildBox.getSelectedIndex() == 2) { + NameObject no = controlPane.update(); + if (no != null) { + return no.getObject(); } - } else { - return autoBuildPane.update(); - } - return null; - } + } else if (buildBox.getSelectedIndex() == 0) { + return layerDataControlPane.update(); + } else { + return autoBuildPane.update(); + } + return null; + } /** * 下拉树的update @@ -172,13 +213,15 @@ public class TreeSettingPane extends BasicPane implements DataCreatorUI { tcb.setAutoBuild(true); tcb.setDictionary(dictionary); tcb.setNodeOrDict(dictionary); - } else { - tcb.setAutoBuild(false); - NameObject no = this.controlPane.update(); - if (no != null) { - if (no.getObject() instanceof TreeComboBoxEditor) { - return (TreeComboBoxEditor) no.getObject(); - } + } else if (buildBox.getSelectedIndex() == 0) { + // TODO: 16/9/12 + } else { + tcb.setAutoBuild(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()); @@ -204,12 +247,15 @@ public class TreeSettingPane extends BasicPane implements DataCreatorUI { */ public void populate(Object nodeOrDict) { if(nodeOrDict instanceof TreeNodeAttr[] || nodeOrDict instanceof TreeNodeWrapper) { - buildBox.setSelectedIndex(0); - NameObject no = new NameObject("name", nodeOrDict); - controlPane.populate(no); - } else if(nodeOrDict instanceof TableDataDictionary) { + buildBox.setSelectedIndex(2); + NameObject no = new NameObject("name", nodeOrDict); + controlPane.populate(no); + } else if(nodeOrDict instanceof TableDataDictionary) { buildBox.setSelectedIndex(1); autoBuildPane.populate((TableDataDictionary)nodeOrDict); - } - } + } else if (nodeOrDict instanceof NameObject) { + buildBox.setSelectedIndex(0); + layerDataControlPane.populate((NameObject) nodeOrDict); + } + } } \ No newline at end of file diff --git a/designer_base/src/com/fr/design/gui/frpane/tree/layer/config/LayerDataConfigPane.java b/designer_base/src/com/fr/design/gui/frpane/tree/layer/config/LayerDataConfigPane.java new file mode 100644 index 0000000000..c67dd08d9e --- /dev/null +++ b/designer_base/src/com/fr/design/gui/frpane/tree/layer/config/LayerDataConfigPane.java @@ -0,0 +1,102 @@ +package com.fr.design.gui.frpane.tree.layer.config; + +import com.fr.base.TableData; +import com.fr.data.impl.TableDataDictionary; +import com.fr.design.beans.BasicBeanPane; +import com.fr.design.data.tabledata.wrapper.TableDataWrapper; +import com.fr.design.present.dict.TableDataDictPane; +import com.fr.form.ui.tree.LayerConfig; +import com.fr.form.ui.tree.LayerDependence; + +import java.awt.*; +import java.util.*; +import java.util.List; + +/** + * Created by juhaoyu on 16/9/13. + */ +public class LayerDataConfigPane extends BasicBeanPane { + + /** + * 数据集数据字典选择panel + */ + private TableDataDictPane tableDataDictPane; + + /** + * 与父级关联的字段选择 + */ + private LayerDependenceSettingPane dependenceSettingPane; + + + /** + * 当前用户正在修改的LayerData + */ + private LayerConfig layerConfig; + + public LayerDataConfigPane() { + //初始化组件及布局 + this.tableDataDictPane = new TableDataDictPane(); + this.dependenceSettingPane = new LayerDependenceSettingPane(tableDataDictPane); + this.setLayout(new BorderLayout(2, 2)); + this.add(tableDataDictPane, BorderLayout.NORTH); + this.add(dependenceSettingPane, BorderLayout.CENTER); + } + + /** + * 1.切换层级时 + * + * @param layerConfig + */ + @Override + public void populateBean(LayerConfig layerConfig) { + + if (layerConfig != null) { + this.layerConfig = layerConfig; + TableDataDictionary ta = layerConfig.getDictionary(); + this.tableDataDictPane.populateBean(ta); + this.dependenceSettingPane.populate(layerConfig.getIndex(), layerConfig.getDependenceList()); + } + + } + + @Override + public LayerConfig updateBean() { + + if (layerConfig == null) { + return null; + + } + //从下层panel中读取数据 + TableData tableData = tableDataDictPane.updateBean().getTableData(); + TableDataWrapper wrapper = tableDataDictPane.tableDataNameComboBox.getSelectedItem(); + List columnNames; + if (wrapper != null) { + columnNames = wrapper.calculateColumnNameList(); + } else { + columnNames = new ArrayList(); + } + String viewColStr = tableDataDictPane.updateBean().getValueColumnName(); + String modelColStr = tableDataDictPane.updateBean().getKeyColumnName(); + TableDataDictionary dictionary = tableDataDictPane.updateBean(); + int viewCol = columnNames.indexOf(viewColStr); + int modelCol = columnNames.indexOf(modelColStr); + //将数据设置到当前正在修改的layerData中 + this.layerConfig.setDictionary(dictionary); + this.layerConfig.setModelColumn(modelCol); + this.layerConfig.setViewColumn(viewCol); + this.layerConfig.setTableData(tableData); + //添加依赖 + java.util.List dependenceList = dependenceSettingPane.updateLayerDependence(); + layerConfig.getDependenceList().clear(); + layerConfig.addAll(dependenceList); + return layerConfig; + } + + @Override + protected String title4PopupWindow() { + + return "Layer Data Config Panel"; + } + + +} diff --git a/designer_base/src/com/fr/design/gui/frpane/tree/layer/config/LayerDataControlPane.java b/designer_base/src/com/fr/design/gui/frpane/tree/layer/config/LayerDataControlPane.java new file mode 100644 index 0000000000..136588cf98 --- /dev/null +++ b/designer_base/src/com/fr/design/gui/frpane/tree/layer/config/LayerDataControlPane.java @@ -0,0 +1,255 @@ +package com.fr.design.gui.frpane.tree.layer.config; + +import com.fr.base.BaseUtils; +import com.fr.design.actions.UpdateAction; +import com.fr.design.gui.controlpane.ControlPane; +import com.fr.design.gui.icontainer.UIScrollPane; +import com.fr.design.gui.itoolbar.UIToolbar; +import com.fr.design.layout.FRGUIPaneFactory; +import com.fr.design.mainframe.DesignerContext; +import com.fr.design.menu.ToolBarDef; +import com.fr.form.ui.tree.LayerConfig; +import com.fr.general.ComparatorUtils; +import com.fr.general.Inter; +import com.fr.general.NameObject; + +import javax.swing.*; +import javax.swing.event.TreeSelectionEvent; +import javax.swing.event.TreeSelectionListener; +import javax.swing.tree.*; +import java.awt.*; +import java.awt.event.ActionEvent; +import java.util.ArrayList; + +/** + * Created by juhaoyu on 16/9/21. + */ +public class LayerDataControlPane extends ControlPane { + + public static final String BEAN_NAME = "Tree Layer Data"; + + // 添加一个treeNode + private AddTreeNodeAction addTreeNode; + + // 移除一个treeNode + private RemoveTreeNodeAction removeTreeNode; + + private LayerDataConfigPane configPane; + + private JTree tree; + + private DefaultTreeModel defaultTreeModel; + + public LayerDataControlPane() { + + this.setLayout(new BorderLayout(2, 2)); + //创建层编辑panel + configPane = new LayerDataConfigPane(); + //创建树结构及树控件 + JPanel leftPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); + DefaultMutableTreeNode rootNode = new DefaultMutableTreeNode(Inter.getLocText("FR-Designer_Root")); + defaultTreeModel = new DefaultTreeModel(rootNode); + DefaultMutableTreeNode firstLayer = new DefaultMutableTreeNode(new NameObject(Inter.getLocText("FR-Designer_Gradation") + 1, new LayerConfig(1))); + tree = new JTree(defaultTreeModel); + tree.setRootVisible(false); + tree.repaint(); + ((DefaultMutableTreeNode) defaultTreeModel.getRoot()).getLastLeaf().add(firstLayer); + tree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION); + leftPane.add(new UIScrollPane(tree), BorderLayout.CENTER); + + tree.setPreferredSize(new Dimension(170, 350)); + tree.setCellRenderer(renderer); + + tree.addTreeSelectionListener(new TreeSelectionListener() { + + public void valueChanged(TreeSelectionEvent e) { + + configPane.updateBean(); + refreshCurrentUpdatePane(); + checkButtonEnabled(); + } + }); + + + // JTreeControlPane控制栏 + ToolBarDef toolbarDef = new ToolBarDef(); + toolbarDef.addShortCut(addTreeNode = new AddTreeNodeAction()); + toolbarDef.addShortCut(removeTreeNode = new RemoveTreeNodeAction()); + UIToolbar toolBar = ToolBarDef.createJToolBar(); + toolbarDef.updateToolBar(toolBar); + leftPane.add(toolBar, BorderLayout.NORTH); + + + this.add(leftPane, BorderLayout.WEST); + this.add(this.configPane, BorderLayout.CENTER); + + defaultTreeModel.reload(); + TreePath path = new TreePath(defaultTreeModel.getPathToRoot(rootNode.getLastLeaf())); + tree.setSelectionPath(path); + + this.checkButtonEnabled(); + + } + + public void refreshCurrentUpdatePane() { + + TreePath selectTreePath = this.tree.getSelectionPath(); + if (selectTreePath != null) { + NameObject object = (NameObject) ((DefaultMutableTreeNode) selectTreePath.getLastPathComponent()).getUserObject(); + if (object != null && object.getObject() != null) { + configPane.populateBean((LayerConfig) object.getObject()); + } + } + } + + TreeCellRenderer renderer = new DefaultTreeCellRenderer() { + + @Override + public Component getTreeCellRendererComponent(JTree tree, Object value, boolean selected, boolean expanded, boolean leaf, int row, boolean hasFocus) { + + super.getTreeCellRendererComponent(tree, value, selected, expanded, leaf, row, hasFocus); + if (leaf) { + this.setIcon(BaseUtils.readIcon("com/fr/design/images/data/default_widget.png")); + } else { + this.setIcon(BaseUtils.readIcon("com/fr/design/images/data/arrow_branch.png")); + } + + if (value instanceof DefaultMutableTreeNode) { + DefaultMutableTreeNode node = (DefaultMutableTreeNode) value; + Object userObj = node.getUserObject(); + if (userObj instanceof NameObject) { + this.setText(((NameObject) userObj).getName()); + } + } + this.setBorder(BorderFactory.createEmptyBorder(0, 0, 2, 0)); + return this; + } + }; + + private void checkButtonEnabled() { + + this.addTreeNode.setEnabled(true); + this.removeTreeNode.setEnabled(true); + + // richer:当选择了树根节点时,不能被删除、上移和下移 + DefaultMutableTreeNode root = (DefaultMutableTreeNode) defaultTreeModel.getRoot(); + TreePath rootPath = new TreePath(defaultTreeModel.getPathToRoot(root)); + if (ComparatorUtils.equals(rootPath, tree.getSelectionPath())) { + this.removeTreeNode.setEnabled(false); + } + } + + private class AddTreeNodeAction extends UpdateAction { + + + public AddTreeNodeAction() { + + this.setName(Inter.getLocText("FR-Designer_Add")); + this.setMnemonic('A'); + this.setSmallIcon(BaseUtils.readIcon("/com/fr/base/images/cell/control/add.png")); + } + + public void actionPerformed(ActionEvent e) { + + DefaultMutableTreeNode node = (DefaultMutableTreeNode) defaultTreeModel.getRoot(); + + DefaultMutableTreeNode innerNode = node; + int nodeCount = 0; + do { + nodeCount++; + } while ((innerNode = innerNode.getNextNode()) != null); + NameObject nameable = new NameObject(Inter.getLocText("FR-Designer_Gradation") + nodeCount, new LayerConfig(nodeCount)); + + node.getLastLeaf().add(new DefaultMutableTreeNode(nameable)); + defaultTreeModel.reload(); + TreePath path = new TreePath(defaultTreeModel.getPathToRoot(node.getLastLeaf())); + tree.setSelectionPath(path); + } + } + + private class RemoveTreeNodeAction extends UpdateAction { + + public RemoveTreeNodeAction() { + + this.setName(Inter.getLocText("FR-Designer_Remove")); + this.setMnemonic('R'); + this.setSmallIcon(BaseUtils.readIcon("/com/fr/base/images/cell/control/remove.png")); + } + + public void actionPerformed(ActionEvent e) { + // TODO remove tree node + int val = JOptionPane.showConfirmDialog(DesignerContext.getDesignerFrame(), Inter.getLocText("Utils-Are_you_sure_to_remove_the_selected_item") + "?", + Inter.getLocText("FR-Designer_Remove"), JOptionPane.OK_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE); + if (val != JOptionPane.OK_OPTION) { + return; + } + TreePath selectionPath = tree.getSelectionPath(); + DefaultMutableTreeNode tmpNode = (DefaultMutableTreeNode) selectionPath.getLastPathComponent(); + tmpNode.removeFromParent(); + defaultTreeModel.reload(); + DefaultMutableTreeNode node = (DefaultMutableTreeNode) defaultTreeModel.getRoot(); + TreePath path = new TreePath(defaultTreeModel.getPathToRoot(node.getLastLeaf())); + tree.setSelectionPath(path); + } + } + + public void populate(NameObject nameObject) { + // 重新添加tree节点的时候需要remove掉原来的所有子节点 + ((DefaultMutableTreeNode) defaultTreeModel.getRoot()).removeAllChildren(); + if (BEAN_NAME.equals(nameObject.getName())) { + Object obj = nameObject.getObject(); + LayerConfig[] layerConfigs = null; + if (obj instanceof LayerConfig[]) { + layerConfigs = ((LayerConfig[]) obj); + } + + int count = layerConfigs == null ? 0 : layerConfigs.length; + //将树的层次一层一层的加上去 + DefaultMutableTreeNode node4root = (DefaultMutableTreeNode) defaultTreeModel.getRoot(); + for (int i = 0; i < count; i++) { + + DefaultMutableTreeNode node4add = new DefaultMutableTreeNode( + new NameObject(Inter.getLocText("FR-Designer_Gradation") + (i + 1), layerConfigs[i])); + node4root.add(node4add); + node4root = node4add; + } + + defaultTreeModel.reload(); + expandAll(tree, true); + tree.setSelectionRow(0); + } + } + + public NameObject update() { + + return new NameObject(BEAN_NAME, updateLayerDatas()); + } + + private LayerConfig[] updateLayerDatas() { + + //保存最后一个设置的层级 + configPane.updateBean(); + DefaultMutableTreeNode root = (DefaultMutableTreeNode) defaultTreeModel.getRoot(); + java.util.List nodeList = new ArrayList(); + + for (; root != null; root = root.getNextNode()) { + if (!(root.getUserObject() instanceof NameObject)) { + continue; + } + NameObject no = (NameObject) root.getUserObject(); + if (no.getObject() instanceof LayerConfig) { + nodeList.add((LayerConfig) no.getObject()); + } + } + + return nodeList.toArray(new LayerConfig[nodeList.size()]); + } + + + @Override + protected String title4PopupWindow() { + + return "Layer Data Control Pane"; + } + +} diff --git a/designer_base/src/com/fr/design/gui/frpane/tree/layer/config/LayerDependenceSettingPane.java b/designer_base/src/com/fr/design/gui/frpane/tree/layer/config/LayerDependenceSettingPane.java new file mode 100644 index 0000000000..ca03c96fa9 --- /dev/null +++ b/designer_base/src/com/fr/design/gui/frpane/tree/layer/config/LayerDependenceSettingPane.java @@ -0,0 +1,443 @@ +package com.fr.design.gui.frpane.tree.layer.config; + +import com.fr.design.data.tabledata.wrapper.TableDataWrapper; +import com.fr.design.present.dict.TableDataDictPane; +import com.fr.form.ui.tree.LayerDependence; +import com.fr.general.Inter; + +import javax.swing.*; +import javax.swing.table.AbstractTableModel; +import javax.swing.table.TableCellEditor; +import javax.swing.table.TableCellRenderer; +import java.awt.*; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.ItemEvent; +import java.awt.event.ItemListener; +import java.util.ArrayList; +import java.util.List; + +/** + * Created by juhaoyu on 16/9/19. + */ +public class LayerDependenceSettingPane extends JPanel implements ItemListener { + + /** + * 用户选择数据集的pane,在LayerDataConfigPane中传入 + */ + private TableDataDictPane tableDataDictPane; + + + /** + * 添加依赖按钮 + */ + private JButton addButton; + + /** + * 删除依赖按钮 + */ + private JButton delButton; + + /** + * 依赖关系编辑Table + */ + private JTable dependenceTable; + + /** + * Table的数据模型,两个按钮的操作直接对应于model + */ + private LayerDepenceTableModel model; + + /** + * 当前该panel所设置的层级 + */ + private int currentLayerIndex = 1; + + private FieldRenderer fieldRenderer; + + private LayerIndexEditor layerIndexEditor; + + private FiledEditor fieldEditor; + + + public LayerDependenceSettingPane(TableDataDictPane tableDictPane) { + //关联数据集选择,并添加监听 + this.tableDataDictPane = tableDictPane; + tableDataDictPane.tableDataNameComboBox.addItemListener(this); + + //初始化按钮对象 + addButton = new JButton(Inter.getLocText("add")); + delButton = new JButton(Inter.getLocText("Delete")); + //初始化Table对象,并添加renderer和editor + model = new LayerDepenceTableModel(); + dependenceTable = new JTable(model); + //初始化辅助组件 + fieldEditor = new FiledEditor(tableDataDictPane); + fieldRenderer = new FieldRenderer(tableDictPane); + layerIndexEditor = new LayerIndexEditor(currentLayerIndex); + //添加renderer + dependenceTable.getColumnModel().getColumn(1).setCellRenderer(fieldRenderer); + //添加第一列editor + dependenceTable.getColumnModel().getColumn(0).setCellEditor(layerIndexEditor); + //添加第二列editor + dependenceTable.getColumnModel().getColumn(1).setCellEditor(fieldEditor); + //添加add按钮监听 + addButton.addActionListener(new ActionListener() { + + @Override + public void actionPerformed(ActionEvent e) { + + LayerDependenceSettingPane.this.model.addDependence(); + } + }); + //添加del按钮监听 + delButton.addActionListener(new ActionListener() { + + @Override + public void actionPerformed(ActionEvent e) { + + if (0 == dependenceTable.getSelectedRowCount()) { + return; + } + //获取视图索引,并根据视图索引获取model索引,删除model指定行 + int selectedRow = dependenceTable.getSelectedRow(); + int selectedRowModelIndex = dependenceTable.convertRowIndexToModel(selectedRow); + model.delDependence(selectedRowModelIndex); + } + }); + + + //生成布局 + this.setLayout(new BorderLayout(2, 2)); + //添加按钮panel + JPanel buttonPanel = new JPanel(); + buttonPanel.setLayout(new FlowLayout(2)); + buttonPanel.add(addButton); + buttonPanel.add(delButton); + this.add(buttonPanel, BorderLayout.NORTH); + //添加Table的panel + JScrollPane tablePanel = new JScrollPane(dependenceTable); + this.add(tablePanel, BorderLayout.CENTER); + + + } + + + public void populate(int layerIndex, List dependenceList) { + + this.currentLayerIndex = layerIndex; + //更新Editor + this.layerIndexEditor.layerChanged(layerIndex); + this.fieldEditor.layerChanged(); + + this.model.clear(); + this.model.addAll(dependenceList); + } + + + public List updateLayerDependence() { + //保存现有编辑 + this.fieldEditor.stopCellEditing(); + this.layerIndexEditor.stopCellEditing(); + return this.model.update(); + } + + public int updateLayerIndex() { + + return this.currentLayerIndex; + } + + private String tableDataName = ""; + + /** + * 当tableDataDictPane变化时,调用该方法 + */ + + + @Override + public void itemStateChanged(ItemEvent e) { + + clearDependences(); + + } + + private boolean tableDataNameChanged() { + + String newName = tableDataDictPane.tableDataNameComboBox.getTreeName(); + if (newName != null && !newName.equals(tableDataName)) { + tableDataName = newName; + return true; + } + return false; + } + + /** + * 清楚当前设置的依赖关系 + */ + private void clearDependences() { + + this.model.clear(); + + } + + /** + * 第二列renderer + * 由于从model中获取的数据是数据集列的索引值,这里要转换为列的名称 + */ + private static final class FieldRenderer extends JLabel implements TableCellRenderer { + + //用于将字段索引转换为字段名;保存改pane,是为了当用户选择其他数据集时,renderer可同步更新 + private TableDataDictPane tableDataDictPane; + + public FieldRenderer(TableDataDictPane tableDataDictPane) { + + this.tableDataDictPane = tableDataDictPane; + } + + /** + * 由于数据是从tableDataDictPane中现取的,所以用户选择不同的数据集时,renderer同步更新; + * 此时只需要在用户选择数据集时,刷新Table即可,不需要对renderer处理 + */ + @Override + public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { + + if (value != null) { + List columnNames = getColumnNameList(this.tableDataDictPane); + //value是用户选择的字段索引值,从1开始的 + this.setText(columnNames.get(Integer.valueOf(String.valueOf(value)))); + } else { + this.setText(""); + } + if (hasFocus) { + this.setBorder(UIManager.getBorder("Table.focusCelHighlightBorder")); + } else { + this.setBorder(null); + } + return this; + } + } + + /** + * 第一列editor + * 该editor于layerIndex关联,当用户选择不同的层时,这个editor要同步更新 + */ + private static final class LayerIndexEditor extends AbstractCellEditor implements TableCellEditor { + + private int currentLayerIndex; + + private JComboBox layerChoseCombobox = new JComboBox(); + + public LayerIndexEditor(int currentLayerIndex) { + + this.currentLayerIndex = currentLayerIndex; + for (int i = 1; i < currentLayerIndex; i++) { + layerChoseCombobox.addItem(i); + } + } + + @Override + public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) { + + if (value != null) { + layerChoseCombobox.setSelectedIndex(Integer.valueOf(String.valueOf(value)) - 1); + } + return layerChoseCombobox; + } + + @Override + public Object getCellEditorValue() { + + return layerChoseCombobox.getSelectedItem(); + } + + public void layerChanged(int newLayerIndex) { + + this.currentLayerIndex = newLayerIndex; + layerChoseCombobox.removeAllItems(); + for (int i = 1; i < currentLayerIndex; i++) { + layerChoseCombobox.addItem(i); + } + } + } + + /** + * 第二列editor + */ + private static final class FiledEditor extends AbstractCellEditor implements TableCellEditor { + + private JComboBox layerChoseCombobox = new JComboBox(); + + TableDataDictPane tableDataDictPane; + + public FiledEditor(TableDataDictPane tableDataDictPane) { + + this.tableDataDictPane = tableDataDictPane; + List columnNames = getColumnNameList(this.tableDataDictPane); + for (String columnName : columnNames) { + this.layerChoseCombobox.addItem(columnName); + } + + } + + @Override + public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) { + + List columnNames = getColumnNameList(this.tableDataDictPane); + layerChoseCombobox.removeAllItems(); + for (String columnName : columnNames) { + + layerChoseCombobox.addItem(columnName); + } + if (value != null) { + layerChoseCombobox.setSelectedIndex(Integer.valueOf(String.valueOf(value))); + } + return layerChoseCombobox; + } + + @Override + public Object getCellEditorValue() { + //转化为数据集的列索引(从0开始) + return layerChoseCombobox.getSelectedIndex(); + } + + public void layerChanged() { + + List columnNames = getColumnNameList(this.tableDataDictPane); + layerChoseCombobox.removeAllItems(); + for (String columnName : columnNames) { + + layerChoseCombobox.addItem(columnName); + } + } + } + + private static List getColumnNameList(TableDataDictPane tableDataDictPane) { + + TableDataWrapper wrapper = tableDataDictPane.tableDataNameComboBox.getSelectedItem(); + if (wrapper == null) { + return new ArrayList(); + } else { + return wrapper.calculateColumnNameList(); + } + } + + private static class LayerDepenceTableModel extends AbstractTableModel { + + private List dependences; + + public LayerDepenceTableModel() { + + dependences = new ArrayList(); + } + + /** + * 添加一条数据,该方法会请求Table进行重绘(通过发送时间,告诉JTable数据更新,JTable会自动重绘) + */ + public void addDependence() { + + dependences.add(new LayerDependence()); + fireTableRowsInserted(dependences.size(), dependences.size()); + } + + /** + * 删除一条数据 + * + * @param rowIndex + */ + public void delDependence(int rowIndex) { + + if (rowIndex < 0 || rowIndex >= dependences.size()) { + return; + } + dependences.remove(rowIndex); + fireTableRowsDeleted(rowIndex + 1, rowIndex + 1); + } + + public void addAll(List dependenceList) { + + dependences.addAll(dependenceList); + fireTableRowsInserted(1, dependenceList.size()); + } + + @Override + public boolean isCellEditable(int rowIndex, int columnIndex) { + + return true; + } + + @Override + public Class getColumnClass(int column) { + + return Integer.class; + } + + @Override + public String getColumnName(int column) { + + String name; + if (column == 0) { + name = Inter.getLocText("FR-Designer_layerIndex"); + } else { + name = Inter.getLocText("FR-Designer_filedChosen"); + } + return name; + } + + @Override + public int getRowCount() { + + return dependences.size(); + } + + @Override + public int getColumnCount() { + + return 2; + } + + @Override + public Object getValueAt(int rowIndex, int columnIndex) { + + LayerDependence dependence = dependences.get(rowIndex); + Object obj; + if (columnIndex == 0) { + obj = dependence.getLayerIndex(); + } else { + obj = dependence.getThisColumnIndex(); + } + return obj; + } + + @Override + public void setValueAt(Object aValue, int rowIndex, int columnIndex) { + + LayerDependence dependence = dependences.get(rowIndex); + if (aValue != null) { + if (columnIndex == 0) { + dependence.setLayerIndex((Integer) aValue); + } else { + dependence.setThisColumnIndex((Integer) aValue); + } + } + + } + + public void clear() { + + int length = dependences.size(); + dependences.clear(); + fireTableRowsDeleted(1, length); + + } + + + public List update() { + + return this.dependences; + } + } + + +} + + From 2522e2563ee95f6a944a1181922870f354aa8e22 Mon Sep 17 00:00:00 2001 From: juhaoyu <2335173323@qq.com> Date: Tue, 11 Oct 2016 15:21:49 +0800 Subject: [PATCH 02/22] =?UTF-8?q?=E6=9E=81=E9=80=9F=E5=88=86=E5=B1=82?= =?UTF-8?q?=E6=9E=84=E5=BB=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../tree/layer/config/LayerDependenceSettingPane.java | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/designer_base/src/com/fr/design/gui/frpane/tree/layer/config/LayerDependenceSettingPane.java b/designer_base/src/com/fr/design/gui/frpane/tree/layer/config/LayerDependenceSettingPane.java index ca03c96fa9..f001af9bd2 100644 --- a/designer_base/src/com/fr/design/gui/frpane/tree/layer/config/LayerDependenceSettingPane.java +++ b/designer_base/src/com/fr/design/gui/frpane/tree/layer/config/LayerDependenceSettingPane.java @@ -161,16 +161,6 @@ public class LayerDependenceSettingPane extends JPanel implements ItemListener { } - private boolean tableDataNameChanged() { - - String newName = tableDataDictPane.tableDataNameComboBox.getTreeName(); - if (newName != null && !newName.equals(tableDataName)) { - tableDataName = newName; - return true; - } - return false; - } - /** * 清楚当前设置的依赖关系 */ From 251a5044387b4d1464d3086b0b8c25dd8205b363 Mon Sep 17 00:00:00 2001 From: juhaoyu <2335173323@qq.com> Date: Tue, 11 Oct 2016 15:27:07 +0800 Subject: [PATCH 03/22] implements DataCreatorUI --- .../src/com/fr/design/gui/frpane/TreeSettingPane.java | 1 - .../tree/layer/config/LayerDependenceSettingPane.java | 7 ------- 2 files changed, 8 deletions(-) diff --git a/designer_base/src/com/fr/design/gui/frpane/TreeSettingPane.java b/designer_base/src/com/fr/design/gui/frpane/TreeSettingPane.java index dd87a74a21..7a60e59a9a 100644 --- a/designer_base/src/com/fr/design/gui/frpane/TreeSettingPane.java +++ b/designer_base/src/com/fr/design/gui/frpane/TreeSettingPane.java @@ -46,7 +46,6 @@ public class TreeSettingPane extends BasicPane implements DataCreatorUI { public TreeSettingPane(boolean isEditor) { this.initComponents(isEditor); - System.out.print(true); } private void initComponents(boolean isEditor) { diff --git a/designer_base/src/com/fr/design/gui/frpane/tree/layer/config/LayerDependenceSettingPane.java b/designer_base/src/com/fr/design/gui/frpane/tree/layer/config/LayerDependenceSettingPane.java index f001af9bd2..9f91fe83c8 100644 --- a/designer_base/src/com/fr/design/gui/frpane/tree/layer/config/LayerDependenceSettingPane.java +++ b/designer_base/src/com/fr/design/gui/frpane/tree/layer/config/LayerDependenceSettingPane.java @@ -142,13 +142,6 @@ public class LayerDependenceSettingPane extends JPanel implements ItemListener { return this.model.update(); } - public int updateLayerIndex() { - - return this.currentLayerIndex; - } - - private String tableDataName = ""; - /** * 当tableDataDictPane变化时,调用该方法 */ From 871c2313e8e892e7a77981dcbc62cffb2f10d533 Mon Sep 17 00:00:00 2001 From: juhaoyu <2335173323@qq.com> Date: Tue, 11 Oct 2016 16:50:15 +0800 Subject: [PATCH 04/22] =?UTF-8?q?=E6=9E=81=E9=80=9F=E5=88=86=E5=B1=82?= =?UTF-8?q?=E6=9E=84=E5=BB=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../tree/layer/config/LayerDependenceSettingPane.java | 7 ++++++- .../design/mainframe/widget/wrappers/TreeModelWrapper.java | 3 +++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/designer_base/src/com/fr/design/gui/frpane/tree/layer/config/LayerDependenceSettingPane.java b/designer_base/src/com/fr/design/gui/frpane/tree/layer/config/LayerDependenceSettingPane.java index 9f91fe83c8..0814ec9422 100644 --- a/designer_base/src/com/fr/design/gui/frpane/tree/layer/config/LayerDependenceSettingPane.java +++ b/designer_base/src/com/fr/design/gui/frpane/tree/layer/config/LayerDependenceSettingPane.java @@ -86,7 +86,9 @@ public class LayerDependenceSettingPane extends JPanel implements ItemListener { @Override public void actionPerformed(ActionEvent e) { - + //先要停止编辑,然后再添加 + fieldEditor.stopCellEditing(); + layerIndexEditor.stopCellEditing(); LayerDependenceSettingPane.this.model.addDependence(); } }); @@ -102,6 +104,9 @@ public class LayerDependenceSettingPane extends JPanel implements ItemListener { //获取视图索引,并根据视图索引获取model索引,删除model指定行 int selectedRow = dependenceTable.getSelectedRow(); int selectedRowModelIndex = dependenceTable.convertRowIndexToModel(selectedRow); + //先要停止编辑,然后再删除 + fieldEditor.stopCellEditing(); + layerIndexEditor.stopCellEditing(); model.delDependence(selectedRowModelIndex); } }); diff --git a/designer_form/src/com/fr/design/mainframe/widget/wrappers/TreeModelWrapper.java b/designer_form/src/com/fr/design/mainframe/widget/wrappers/TreeModelWrapper.java index 10ab5f2729..17f9d0c891 100644 --- a/designer_form/src/com/fr/design/mainframe/widget/wrappers/TreeModelWrapper.java +++ b/designer_form/src/com/fr/design/mainframe/widget/wrappers/TreeModelWrapper.java @@ -7,6 +7,7 @@ import com.fr.design.Exception.ValidationException; import com.fr.design.designer.properties.Decoder; import com.fr.design.designer.properties.Encoder; import com.fr.general.Inter; +import com.fr.general.NameObject; import com.fr.stable.StringUtils; public class TreeModelWrapper implements Encoder, Decoder { @@ -21,6 +22,8 @@ public class TreeModelWrapper implements Encoder, Decoder { } else if (v instanceof TreeNodeWrapper) { TreeNodeAttr[] treeNodeAttrs = ((TreeNodeWrapper) v).getTreeNodeAttrs(); return TemplateUtils.render(Inter.getLocText("FR-Designer_Total_N_Grade"), new String[]{"N"}, new String[]{treeNodeAttrs.length + ""}); + } else if (v instanceof NameObject) { + return Inter.getLocText("FR-Designer_DataTable-Build"); } else { return Inter.getLocText("FR-Designer_Auto-Build"); } From 0d8e87ef311570f837299ff5e75f4f0b61c0b747 Mon Sep 17 00:00:00 2001 From: xiaoxia Date: Fri, 14 Oct 2016 18:44:58 +0800 Subject: [PATCH 05/22] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E4=B8=80=E4=B8=8B?= =?UTF-8?q?=E6=8E=A7=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/fr/design/mainframe/widget/UITreeComboBox.java | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/designer_form/src/com/fr/design/mainframe/widget/UITreeComboBox.java b/designer_form/src/com/fr/design/mainframe/widget/UITreeComboBox.java index 7f55ddeafe..a3a68ee83a 100644 --- a/designer_form/src/com/fr/design/mainframe/widget/UITreeComboBox.java +++ b/designer_form/src/com/fr/design/mainframe/widget/UITreeComboBox.java @@ -107,14 +107,16 @@ public class UITreeComboBox extends JComboBox{ class UITreeComboBoxRenderer extends DefaultListCellRenderer { public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus){ - if(value != null){ - TreePath path = (TreePath)value; + if(tree != null ){ + TreePath path = tree.getSelectedTreePath()[0]; + tree.setAndScrollSelectionPath(path); Object node = path.getLastPathComponent(); value = node; TreeCellRenderer r = tree.getCellRenderer(); JLabel lb = (JLabel)r.getTreeCellRendererComponent( tree, value, isSelected, false, false, index, cellHasFocus); + return lb; } return super.getListCellRendererComponent(list, value, index, @@ -138,6 +140,9 @@ public class UITreeComboBox extends JComboBox{ setSelectedItem(paths[0]); MenuSelectionManager.defaultManager().clearSelectedPath(); } else { + tree.refreshUI(); + tree.refreshTreeRoot(); + repaint(); return; } From eef8d94ed79723885e9fe7733b4755bd8b9c0d41 Mon Sep 17 00:00:00 2001 From: xiaoxia Date: Fri, 14 Oct 2016 18:48:05 +0800 Subject: [PATCH 06/22] rt --- .../src/com/fr/design/mainframe/widget/UITreeComboBox.java | 2 -- 1 file changed, 2 deletions(-) diff --git a/designer_form/src/com/fr/design/mainframe/widget/UITreeComboBox.java b/designer_form/src/com/fr/design/mainframe/widget/UITreeComboBox.java index a3a68ee83a..ef01c7b711 100644 --- a/designer_form/src/com/fr/design/mainframe/widget/UITreeComboBox.java +++ b/designer_form/src/com/fr/design/mainframe/widget/UITreeComboBox.java @@ -141,9 +141,7 @@ public class UITreeComboBox extends JComboBox{ MenuSelectionManager.defaultManager().clearSelectedPath(); } else { tree.refreshUI(); - tree.refreshTreeRoot(); repaint(); - return; } } From 59ec7cb7259ca8f74c4906b1e9dc5d8bb38ac227 Mon Sep 17 00:00:00 2001 From: xiaoxia Date: Fri, 14 Oct 2016 18:54:04 +0800 Subject: [PATCH 07/22] rt --- .../fr/design/mainframe/ComponentTree.java | 36 ------------------- 1 file changed, 36 deletions(-) diff --git a/designer_form/src/com/fr/design/mainframe/ComponentTree.java b/designer_form/src/com/fr/design/mainframe/ComponentTree.java index 2b490e8bef..a2c5b55e5e 100644 --- a/designer_form/src/com/fr/design/mainframe/ComponentTree.java +++ b/designer_form/src/com/fr/design/mainframe/ComponentTree.java @@ -39,11 +39,8 @@ public class ComponentTree extends JTree { this.setDropMode(DropMode.ON_OR_INSERT); this.setTransferHandler(new TreeTransferHandler()); this.refreshTreeRoot(); - TreePath[] paths = getSelectedTreePath(); addTreeSelectionListener(designer); - setSelectionPaths(paths); - designer.addDesignerEditListener(new TreeDesignerEditAdapter()); this.addMouseListener(new MouseAdapter() { @Override @@ -162,40 +159,7 @@ public class ComponentTree extends JTree { return paths; } - private class TreeDesignerEditAdapter implements DesignerEditListener { - @Override - public void fireCreatorModified(DesignerEvent evt) { - if (evt.getCreatorEventID() == DesignerEvent.CREATOR_SELECTED) { - TreePath[] paths = getSelectedTreePath(); - - if (paths.length == 1) { - setAndScrollSelectionPath(paths[0]); - } else { - setSelectionPaths(paths); - } - } else if(evt.getCreatorEventID() == DesignerEvent.CREATOR_PASTED) { - ComponentTree.this.refreshUI(); - TreePath[] paths = getSelectedTreePath(); - - if (paths.length == 1) { - setAndScrollSelectionPath(paths[0]); - } else { - setSelectionPaths(paths); - } - ComponentTree.this.repaint(); - - } else { - ComponentTree.this.refreshUI(); - ComponentTree.this.repaint(); - } - } - - @Override - public boolean equals(Object o) { - return o.getClass() == this.getClass(); - } - } /** From dfdcec7eacc3f018947d9044b1759b2db57ed02c Mon Sep 17 00:00:00 2001 From: xiaoxia Date: Fri, 14 Oct 2016 18:54:29 +0800 Subject: [PATCH 08/22] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E8=AE=BE=E8=AE=A1?= =?UTF-8?q?=E5=99=A8=E5=B8=83=E5=B1=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../design/mainframe/WidgetPropertyPane.java | 145 ++++++++++++++++-- 1 file changed, 136 insertions(+), 9 deletions(-) diff --git a/designer_form/src/com/fr/design/mainframe/WidgetPropertyPane.java b/designer_form/src/com/fr/design/mainframe/WidgetPropertyPane.java index a385aed284..67524bfbbe 100644 --- a/designer_form/src/com/fr/design/mainframe/WidgetPropertyPane.java +++ b/designer_form/src/com/fr/design/mainframe/WidgetPropertyPane.java @@ -4,17 +4,26 @@ import com.fr.base.BaseUtils; import com.fr.design.ExtraDesignClassManager; import com.fr.design.designer.beans.events.DesignerEditListener; import com.fr.design.designer.beans.events.DesignerEvent; +import com.fr.design.designer.creator.XCreator; +import com.fr.design.designer.creator.XCreatorUtils; +import com.fr.design.designer.creator.XLayoutContainer; +import com.fr.design.designer.creator.XWParameterLayout; import com.fr.design.designer.properties.EventPropertyTable; import com.fr.design.designer.properties.WidgetPropertyTable; +import com.fr.design.designer.treeview.ComponentTreeModel; import com.fr.design.fun.WidgetPropertyUIProvider; import com.fr.design.gui.frpane.UITabbedPane; import com.fr.design.gui.icontainer.UIScrollPane; +import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.itable.AbstractPropertyTable; import com.fr.design.layout.FRGUIPaneFactory; +import com.fr.design.parameter.ParameterPropertyPane; import com.fr.general.Inter; import com.fr.stable.ArrayUtils; + import javax.swing.*; +import javax.swing.border.LineBorder; import java.awt.*; import java.util.ArrayList; import java.util.List; @@ -29,6 +38,18 @@ public class WidgetPropertyPane extends FormDockView implements BaseWidgetProper private EventPropertyTable eventTable; private List widgetPropertyTables; private FormDesigner designer; + private ComponentTree componentTree; + private JPanel wsp; + private ParameterPropertyPane parameterPropertyPane; + private MobileWidgetTable mobileWidgetTable; + private MobileBodyWidgetTable mobileBodyWidgetTable; + private UIScrollPane downPanel; + private JPanel centerPane; + private CardLayout cardLayout; + public static final String PARA = "para"; + public static final String BODY = "body"; + public static final int NODE_LENGTH = 2; + public boolean isrefresh = true; public static WidgetPropertyPane getInstance() { if (HOLDER.singleton == null) { @@ -52,6 +73,37 @@ public class WidgetPropertyPane extends FormDockView implements BaseWidgetProper setLayout(FRGUIPaneFactory.createBorderLayout()); } + public class mobileWidgetDesignerAdapter implements DesignerEditListener { + + public mobileWidgetDesignerAdapter() { + } + + /** + * 响应界面改变事件 + * @param evt 事件 + */ + public void fireCreatorModified(DesignerEvent evt) { + if (evt.getCreatorEventID() == DesignerEvent.CREATOR_RESIZED + || evt.getCreatorEventID() == DesignerEvent.CREATOR_EDITED + || evt.getCreatorEventID() == DesignerEvent.CREATOR_SELECTED + || evt.getCreatorEventID() == DesignerEvent.CREATOR_ADDED) { + int value = downPanel.getVerticalScrollBar().getValue(); + if(hasSelectParaPane(getEditingFormDesigner())){ + cardLayout.show(centerPane,PARA); + mobileWidgetTable.refresh(); + } else { + cardLayout.show(centerPane,BODY); + mobileBodyWidgetTable.refresh(); + } + //出现滚动条 + downPanel.doLayout(); + //控件列表选中某组件,触发表单中选中控件,选中事件又触发列表刷新,滚动条回到0 + //此处设置滚动条值为刷新前 + downPanel.getVerticalScrollBar().setValue(value); + } + } + } + @Override public String getViewTitle() { return Inter.getLocText("Form-Widget_Property_Table"); @@ -64,12 +116,24 @@ public class WidgetPropertyPane extends FormDockView implements BaseWidgetProper @Override public void refreshDockingView() { + designer = this.getEditingFormDesigner(); removeAll(); if (designer == null) { clearDockingView(); return; } + + componentTree = new ComponentTree(designer); + + ComponentTreeModel treeModel = (ComponentTreeModel) componentTree.getModel(); + XCreator root = (XCreator)treeModel.getRoot(); + int childCount = treeModel.getChildCount(root); + //按照节点添加para在下的,但这里需要para节点在上,调整一下位置 + if(childCount == NODE_LENGTH){ + adjustPosition(treeModel, designer); + } + widgetPropertyTables = new ArrayList(); propertyTable = new WidgetPropertyTable(designer); designer.addDesignerEditListener(new WidgetPropertyDesignerAdapter(propertyTable)); @@ -81,30 +145,93 @@ public class WidgetPropertyPane extends FormDockView implements BaseWidgetProper eventTable.setBorder(null); UIScrollPane esp = new UIScrollPane(eventTable); esp.setBorder(null); -// JTabbedPane tabbedPane = new JTabbedPane(); + + wsp = FRGUIPaneFactory.createBorderLayout_S_Pane(); + wsp.setBorder(null); + mobileWidgetTable = new MobileWidgetTable(designer); + mobileBodyWidgetTable = new MobileBodyWidgetTable(designer); + designer.addDesignerEditListener(new mobileWidgetDesignerAdapter()); + centerPane = FRGUIPaneFactory.createCardLayout_S_Pane(); + cardLayout = (CardLayout) centerPane.getLayout(); + centerPane.add(mobileWidgetTable,PARA); + centerPane.add(mobileBodyWidgetTable,BODY); + if(hasSelectParaPane(designer)){ + cardLayout.show(centerPane,PARA); + + } else { + cardLayout.show(centerPane,BODY); + } + downPanel = new UIScrollPane(centerPane); + downPanel.setBorder(new LineBorder(Color.gray)); + wsp.add(downPanel,BorderLayout.CENTER); + UITabbedPane tabbedPane = new UITabbedPane(); + tabbedPane.setOpaque(true); tabbedPane.setBorder(null); tabbedPane.setTabPlacement(SwingConstants.BOTTOM); tabbedPane.addTab(Inter.getLocText("Form-Properties"), psp); tabbedPane.addTab(Inter.getLocText("Form-Events"), esp); + tabbedPane.addTab(Inter.getLocText("FR-Widget_Mobile_Terminal"), wsp); WidgetPropertyUIProvider[] widgetAttrProviders = getExtraPropertyUIProviders(); - for (WidgetPropertyUIProvider widgetAttrProvider : widgetAttrProviders) { - AbstractPropertyTable propertyTable = widgetAttrProvider.createWidgetAttrTable(); - widgetPropertyTables.add(propertyTable); - designer.addDesignerEditListener(new WidgetPropertyDesignerAdapter(propertyTable)); - UIScrollPane uiScrollPane = new UIScrollPane(propertyTable); - uiScrollPane.setBorder(null); - tabbedPane.addTab(widgetAttrProvider.tableTitle(), uiScrollPane); + if (widgetAttrProviders.length == 0) { + UILabel upLabel = new UILabel(Inter.getLocText("FR-Widget_Mobile_Table"),SwingConstants.CENTER); + upLabel.setBorder(BorderFactory.createEmptyBorder(6,0,6,0)); + wsp.add(upLabel,BorderLayout.NORTH); + } else { + for (WidgetPropertyUIProvider widgetAttrProvider : widgetAttrProviders) { + AbstractPropertyTable propertyTable = widgetAttrProvider.createWidgetAttrTable(); + widgetPropertyTables.add(propertyTable); + designer.addDesignerEditListener(new WidgetPropertyDesignerAdapter(propertyTable)); + UIScrollPane uiScrollPane = new UIScrollPane(propertyTable); + uiScrollPane.setBorder(null); + wsp.add(uiScrollPane); + + } } - add(tabbedPane, BorderLayout.CENTER); + parameterPropertyPane = ParameterPropertyPane.getInstance(designer); + parameterPropertyPane.setBorder(BorderFactory.createEmptyBorder(0, 6, 0, 4)); + add(parameterPropertyPane, BorderLayout.NORTH); + add(tabbedPane, BorderLayout.CENTER); propertyTable.initPropertyGroups(null); eventTable.refresh(); for (AbstractPropertyTable propertyTable : widgetPropertyTables) { propertyTable.initPropertyGroups(designer); } + isrefresh = false; + } + + + /** + * 调整结构树para和body的位置 + * + * @param treeModel + * @param formDesigner + */ + private void adjustPosition(ComponentTreeModel treeModel,FormDesigner formDesigner){ + XCreator root = (XCreator)treeModel.getRoot(); + if(treeModel.getChild(root,0) instanceof XWParameterLayout){ + return; + } + root.add((Component)(treeModel.getChild(root,0)),1); + treeModel.setRoot(root); + componentTree = new ComponentTree(formDesigner,treeModel); + } + // + /** + * 选中的组件是否在参数面板里 + * @param designer 设计器 + * @return 是则返回true + */ + public boolean hasSelectParaPane(FormDesigner designer){ + XCreator xCreator = designer.getSelectionModel().getSelection().getSelectedCreator(); + if(xCreator == null){ + xCreator = designer.getRootComponent(); + } + XLayoutContainer container = XCreatorUtils.getHotspotContainer(xCreator); + return xCreator.acceptType(XWParameterLayout.class) || container.acceptType(XWParameterLayout.class); } /** From 1b0ed5b2fbe6353d9ac580843fedeba8b333a1e5 Mon Sep 17 00:00:00 2001 From: xiaoxia Date: Fri, 14 Oct 2016 18:55:28 +0800 Subject: [PATCH 09/22] =?UTF-8?q?=E6=8E=A7=E4=BB=B6=E6=A0=91=E6=94=BE?= =?UTF-8?q?=E5=88=B0=E4=B8=8B=E6=8B=89=E6=A1=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../mainframe/FormHierarchyTreePane.java | 314 +++++++++--------- 1 file changed, 165 insertions(+), 149 deletions(-) diff --git a/designer_form/src/com/fr/design/mainframe/FormHierarchyTreePane.java b/designer_form/src/com/fr/design/mainframe/FormHierarchyTreePane.java index 34fb5c6014..bf88a9fc51 100644 --- a/designer_form/src/com/fr/design/mainframe/FormHierarchyTreePane.java +++ b/designer_form/src/com/fr/design/mainframe/FormHierarchyTreePane.java @@ -1,12 +1,14 @@ package com.fr.design.mainframe; -import java.awt.BorderLayout; -import java.awt.Component; +import java.awt.*; import java.awt.event.ActionEvent; import javax.swing.BorderFactory; import javax.swing.Icon; +import com.fr.design.actions.community.NeedAction; +import com.fr.design.gui.icombobox.UIComboBox; +import com.fr.design.mainframe.widget.UITreeComboBox; import com.fr.design.parameter.HierarchyTreePane; import com.fr.design.designer.creator.XCreator; import com.fr.design.designer.creator.XWParameterLayout; @@ -43,11 +45,13 @@ public class FormHierarchyTreePane extends FormDockView implements HierarchyTree public static final int NODE_LENGTH = 2; public static final int PARA = 0; public static final int BODY = 1; - + private ComponentTree componentTree; + private UITreeComboBox treeComboBox; + private JPanel widgetPane = FRGUIPaneFactory.createBorderLayout_L_Pane(); // richer:搜寻树节点的的文本框 - private UITextField searchTextField; - private SearchResultPane searchResult; +// private UITextField searchTextField; +// private SearchResultPane searchResult; public static FormHierarchyTreePane getInstance() { return HOLDER.singleton; @@ -86,8 +90,8 @@ public class FormHierarchyTreePane extends FormDockView implements HierarchyTree */ public void clearDockingView() { this.componentTree = null; - this.searchTextField = null; - this.searchResult = null; +// this.searchTextField = null; +// this.searchResult = null; add(new JScrollPane(), BorderLayout.CENTER); } @@ -103,53 +107,65 @@ public class FormHierarchyTreePane extends FormDockView implements HierarchyTree return; } componentTree = new ComponentTree(formDesigner); - + ComponentTreeModel treeModel = (ComponentTreeModel) componentTree.getModel(); XCreator root = (XCreator)treeModel.getRoot(); int childCount = treeModel.getChildCount(root); //按照节点添加para在下的,但这里需要para节点在上,调整一下位置 if(childCount == NODE_LENGTH){ - adjustPosition(treeModel,formDesigner); + adjustPosition(treeModel, formDesigner); + } + widgetPane.setBorder(BorderFactory.createEmptyBorder(3, 2, 3, 0)); + add(widgetPane, BorderLayout.NORTH); + + if(treeComboBox == null) { + widgetPane.add(new UILabel(Inter.getLocText("FR-Designer-Selected_Widget") + " ", + SwingConstants.HORIZONTAL), BorderLayout.WEST); + treeComboBox = new UITreeComboBox(componentTree); + widgetPane.add(treeComboBox, BorderLayout.CENTER); + add(widgetPane, BorderLayout.CENTER); } - UIScrollPane scrollPane = new UIScrollPane(componentTree); - scrollPane.setBorder(null); - add(scrollPane, BorderLayout.CENTER); - JPanel searchPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); - add(searchPane, BorderLayout.NORTH); - searchPane.add(new UILabel(Inter.getLocText("FR-Designer_Search") + ":", - SwingConstants.HORIZONTAL), BorderLayout.WEST); - searchTextField = new UITextField(); - searchPane.add(searchTextField, BorderLayout.CENTER); - searchTextField.getDocument().addDocumentListener(new DocumentListener() { - @Override - public void insertUpdate(DocumentEvent e) { - search(); - } - - @Override - public void removeUpdate(DocumentEvent e) { - search(); - } - - @Override - public void changedUpdate(DocumentEvent e) { - search(); - } - - private void search() { - String text = searchTextField.getText(); - if (StringUtils.isEmpty(text)) { - removeSearchResult(); - } else { - populate(componentTree.search(text)); - } - } - }); + + +// UIScrollPane scrollPane = new UIScrollPane(componentTree); +// scrollPane.setBorder(null); +// add(scrollPane, BorderLayout.CENTER); +// JPanel searchPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); +// add(searchPane, BorderLayout.NORTH); +// searchPane.add(new UILabel(Inter.getLocText("FR-Designer_Search") + ":", +// SwingConstants.HORIZONTAL), BorderLayout.WEST); +// searchTextField = new UITextField(); +// searchPane.add(searchTextField, BorderLayout.CENTER); +// searchTextField.getDocument().addDocumentListener(new DocumentListener() { +// @Override +// public void insertUpdate(DocumentEvent e) { +// search(); +// } +// +// @Override +// public void removeUpdate(DocumentEvent e) { +// search(); +// } +// +// @Override +// public void changedUpdate(DocumentEvent e) { +// search(); +// } +// +// private void search() { +// String text = searchTextField.getText(); +// if (StringUtils.isEmpty(text)) { +// removeSearchResult(); +// } else { +// populate(componentTree.search(text)); +// } +// } +// }); } - + /** * 调整结构树para和body的位置 - * + * * @param treeModel * @param formDesigner */ @@ -176,114 +192,114 @@ public class FormHierarchyTreePane extends FormDockView implements HierarchyTree /** * 删除搜索结果 */ - public void removeSearchResult() { - componentTree.setSelectionPath(null); - if (searchResult != null) { - this.remove(searchResult); - } - } - - public void populate(TreePath[] treepath) { - if (this.searchResult == null) { - searchResult = new SearchResultPane(); - } - if (((BorderLayout) getLayout()).getLayoutComponent(BorderLayout.SOUTH) == null) { - add(searchResult, BorderLayout.SOUTH); - } - searchResult.populate(treepath); - } - - private class SearchResultPane extends JPanel { - private UILabel resultLabel = new UILabel(); - private BackAction backAction = new BackAction(); - private ForWardAction forwardAction = new ForWardAction(); - private TreePath[] tree; - private int number = 0; - - SearchResultPane() { - this.setLayout(FRGUIPaneFactory.createBorderLayout()); - JPanel actionJPanel = FRGUIPaneFactory.createCenterFlowInnerContainer_S_Pane(); - addButtonToJPanel(actionJPanel, backAction.createToolBarComponent()); - addButtonToJPanel(actionJPanel, forwardAction.createToolBarComponent()); - - this.add(actionJPanel, BorderLayout.EAST); - this.add(resultLabel, BorderLayout.WEST); - } - - private void addButtonToJPanel(JPanel actionLabel, - JComponent toolBarComponent) { - actionLabel.add(toolBarComponent); - if (toolBarComponent instanceof UIButton) { - toolBarComponent.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0)); - } - } - - public void populate(TreePath[] search) { - tree = search; - resultLabel.setText(Inter.getLocText("FR-Designer_Total") + ":" + tree.length); - number = 0; - check(); - } - - public void next() { - if (number < tree.length - 1) { - componentTree.setAndScrollSelectionPath(tree[++number]); - } - check(); - } - - public void last() { - if (number > 0) { - componentTree.setAndScrollSelectionPath(tree[--number]); - } - check(); - } - - public void check() { - if (tree.length < 1) { - backAction.setEnabled(false); - forwardAction.setEnabled(false); - } else { - backAction.setEnabled(number > 0); - forwardAction.setEnabled(number < tree.length - 1); - } - - } - - } - - private class BackAction extends UpdateAction { - - public BackAction() { - this.setName(Inter.getLocText("Form-Hierarchy_Tree_Last")); - this.setSmallIcon(BaseUtils - .readIcon("com/fr/design/images/m_help/back.png")); - this.setEnabled(false); - } - - public void actionPerformed(ActionEvent e) { - searchResult.last(); - } - } - - private class ForWardAction extends UpdateAction { - - public ForWardAction() { - this.setName(Inter.getLocText("Form-Hierarchy_Tree_Next")); - this.setSmallIcon(BaseUtils - .readIcon("com/fr/design/images/m_help/forward.png")); - this.setEnabled(false); - } - - public void actionPerformed(ActionEvent e) { - searchResult.next(); - } - } +// public void removeSearchResult() { +// componentTree.setSelectionPath(null); +// if (searchResult != null) { +// this.remove(searchResult); +// } +// } +// +// public void populate(TreePath[] treepath) { +// if (this.searchResult == null) { +// searchResult = new SearchResultPane(); +// } +// if (((BorderLayout) getLayout()).getLayoutComponent(BorderLayout.SOUTH) == null) { +// add(searchResult, BorderLayout.SOUTH); +// } +// searchResult.populate(treepath); +// } + +// private class SearchResultPane extends JPanel { +// private UILabel resultLabel = new UILabel(); +// private BackAction backAction = new BackAction(); +// private ForWardAction forwardAction = new ForWardAction(); +// private TreePath[] tree; +// private int number = 0; +// +// SearchResultPane() { +// this.setLayout(FRGUIPaneFactory.createBorderLayout()); +// JPanel actionJPanel = FRGUIPaneFactory.createCenterFlowInnerContainer_S_Pane(); +// addButtonToJPanel(actionJPanel, backAction.createToolBarComponent()); +// addButtonToJPanel(actionJPanel, forwardAction.createToolBarComponent()); +// +// this.add(actionJPanel, BorderLayout.EAST); +// this.add(resultLabel, BorderLayout.WEST); +// } +// +// private void addButtonToJPanel(JPanel actionLabel, +// JComponent toolBarComponent) { +// actionLabel.add(toolBarComponent); +// if (toolBarComponent instanceof UIButton) { +// toolBarComponent.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0)); +// } +// } +// +// public void populate(TreePath[] search) { +// tree = search; +// resultLabel.setText(Inter.getLocText("FR-Designer_Total") + ":" + tree.length); +// number = 0; +// check(); +// } +// +// public void next() { +// if (number < tree.length - 1) { +// componentTree.setAndScrollSelectionPath(tree[++number]); +// } +// check(); +// } +// +// public void last() { +// if (number > 0) { +// componentTree.setAndScrollSelectionPath(tree[--number]); +// } +// check(); +// } +// +// public void check() { +// if (tree.length < 1) { +// backAction.setEnabled(false); +// forwardAction.setEnabled(false); +// } else { +// backAction.setEnabled(number > 0); +// forwardAction.setEnabled(number < tree.length - 1); +// } +// +// } + + //} + +// private class BackAction extends UpdateAction { +// +// public BackAction() { +// this.setName(Inter.getLocText("Form-Hierarchy_Tree_Last")); +// this.setSmallIcon(BaseUtils +// .readIcon("com/fr/design/images/m_help/back.png")); +// this.setEnabled(false); +// } +// +// public void actionPerformed(ActionEvent e) { +// searchResult.last(); +// } +// } +// +// private class ForWardAction extends UpdateAction { +// +// public ForWardAction() { +// this.setName(Inter.getLocText("Form-Hierarchy_Tree_Next")); +// this.setSmallIcon(BaseUtils +// .readIcon("com/fr/design/images/m_help/forward.png")); +// this.setEnabled(false); +// } +// +// public void actionPerformed(ActionEvent e) { +// searchResult.next(); +// } +// } @Override /** * 位置 - * + * * @return 位置 */ public Location preferredLocation() { From c50f5ba51323911f1a0d46e27ea8aff273f41e53 Mon Sep 17 00:00:00 2001 From: xiaoxia Date: Fri, 14 Oct 2016 18:56:58 +0800 Subject: [PATCH 10/22] rt --- .../com/fr/design/mainframe/ShareWidgetButton.java | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/designer_form/src/com/fr/design/mainframe/ShareWidgetButton.java b/designer_form/src/com/fr/design/mainframe/ShareWidgetButton.java index 3054bea328..e1e1844671 100644 --- a/designer_form/src/com/fr/design/mainframe/ShareWidgetButton.java +++ b/designer_form/src/com/fr/design/mainframe/ShareWidgetButton.java @@ -46,16 +46,18 @@ public class ShareWidgetButton extends JPanel implements MouseListener, MouseMot private void initUI() { this.setBackground(Color.WHITE); this.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0)); - setPreferredSize(new Dimension(110, 70)); + setPreferredSize(new Dimension(108, 72)); setLayout(FRGUIPaneFactory.createBorderLayout()); ImagePanel imagePanel = new ImagePanel((BufferedImage) bindInfo.getCover()); + imagePanel.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0)); this.add(imagePanel, BorderLayout.NORTH); JPanel panel = new JPanel(); + panel.setPreferredSize(new Dimension(108, 20)); UILabel label = new UILabel(bindInfo.getName(), SwingConstants.HORIZONTAL); - panel.setBackground(new Color(184, 220, 242)); - panel.add(label); - this.add(panel, BorderLayout.SOUTH); + label.setOpaque(true); + label.setBackground(new Color(184, 220, 242)); + this.add(label, BorderLayout.SOUTH); } private class ImagePanel extends JPanel { @@ -64,12 +66,12 @@ public class ShareWidgetButton extends JPanel implements MouseListener, MouseMot public ImagePanel(BufferedImage image) { this.image = image; - this.setPreferredSize(new Dimension(110, 50)); + this.setPreferredSize(new Dimension(108, 52)); } @Override public void paintComponent(Graphics g) { - g.drawImage(image, 0, 0, 110, 70, null); + g.drawImage(image, 0, 0, null); } } From 26b940e0e201924d82d5eb070869d84104b59d5e Mon Sep 17 00:00:00 2001 From: xiaoxia Date: Fri, 14 Oct 2016 19:26:22 +0800 Subject: [PATCH 11/22] rt --- .../mainframe/FormHierarchyTreePane.java | 2 +- .../mainframe/FormWidgetDetailPane.java | 147 +++++++----------- 2 files changed, 57 insertions(+), 92 deletions(-) diff --git a/designer_form/src/com/fr/design/mainframe/FormHierarchyTreePane.java b/designer_form/src/com/fr/design/mainframe/FormHierarchyTreePane.java index bf88a9fc51..410519cafb 100644 --- a/designer_form/src/com/fr/design/mainframe/FormHierarchyTreePane.java +++ b/designer_form/src/com/fr/design/mainframe/FormHierarchyTreePane.java @@ -68,7 +68,7 @@ public class FormHierarchyTreePane extends FormDockView implements HierarchyTree } private FormHierarchyTreePane() { - setLayout(new BorderLayout(0, 6)); + setLayout(new BorderLayout(0, 0)); } @Override diff --git a/designer_form/src/com/fr/design/mainframe/FormWidgetDetailPane.java b/designer_form/src/com/fr/design/mainframe/FormWidgetDetailPane.java index b412f42026..9f1983f31d 100644 --- a/designer_form/src/com/fr/design/mainframe/FormWidgetDetailPane.java +++ b/designer_form/src/com/fr/design/mainframe/FormWidgetDetailPane.java @@ -1,28 +1,22 @@ package com.fr.design.mainframe; -import java.awt.BorderLayout; -import java.awt.CardLayout; -import java.awt.Color; - -import javax.swing.BorderFactory; -import javax.swing.Icon; -import javax.swing.JPanel; -import javax.swing.JScrollPane; -import javax.swing.SwingConstants; +import java.awt.*; +import java.awt.event.ItemEvent; +import java.awt.event.ItemListener; +import java.util.ArrayList; + +import javax.swing.*; import javax.swing.border.LineBorder; import com.fr.base.BaseUtils; import com.fr.design.gui.frpane.UITabbedPane; +import com.fr.design.gui.ibutton.UIButton; +import com.fr.design.gui.icombobox.UIComboBox; import com.fr.design.gui.icontainer.UIScrollPane; import com.fr.design.gui.ilable.UILabel; import com.fr.design.layout.FRGUIPaneFactory; -import com.fr.design.parameter.ParameterPropertyPane; -import com.fr.design.designer.beans.events.DesignerEditListener; -import com.fr.design.designer.beans.events.DesignerEvent; -import com.fr.design.designer.creator.XCreator; -import com.fr.design.designer.creator.XCreatorUtils; -import com.fr.design.designer.creator.XLayoutContainer; -import com.fr.design.designer.creator.XWParameterLayout; +import com.fr.form.share.ShareLoader; +import com.fr.form.ui.ElCaseBindInfo; import com.fr.general.Inter; /** @@ -32,16 +26,11 @@ import com.fr.general.Inter; * Time: 下午8:18 */ public class FormWidgetDetailPane extends FormDockView{ - public static final String PARA = "para"; - public static final String BODY = "body"; private UITabbedPane tabbedPane; - private ParameterPropertyPane parameterPropertyPane; - private MobileWidgetTable mobileWidgetTable; - private MobileBodyWidgetTable mobileBodyWidgetTable; - private UIScrollPane downPanel; - private JPanel centerPane; - private CardLayout cardLayout; + private JScrollPane downPanel; + private JPanel reuWidgetPanel; + private ArrayList elCaseBindInfoList; public static FormWidgetDetailPane getInstance() { if (HOLDER.singleton == null) { @@ -84,100 +73,76 @@ public class FormWidgetDetailPane extends FormDockView{ clearDockingView(); return; } - parameterPropertyPane = ParameterPropertyPane.getInstance(designer); - parameterPropertyPane.setBorder(BorderFactory.createEmptyBorder(6, 6, 6, 6)); JPanel esp = FRGUIPaneFactory.createBorderLayout_S_Pane(); esp.setBorder(null); - mobileWidgetTable = new MobileWidgetTable(designer); - mobileBodyWidgetTable = new MobileBodyWidgetTable(designer); - designer.addDesignerEditListener(new mobileWidgetDesignerAdapter()); - centerPane = FRGUIPaneFactory.createCardLayout_S_Pane(); - cardLayout = (CardLayout) centerPane.getLayout(); - centerPane.add(mobileWidgetTable,PARA); - centerPane.add(mobileBodyWidgetTable,BODY); - if(hasSelectParaPane(designer)){ - cardLayout.show(centerPane,PARA); - - } else { - cardLayout.show(centerPane,BODY); + if (elCaseBindInfoList == null) { + elCaseBindInfoList = ShareLoader.getLoader().getAllBindInfoList(); } - downPanel = new UIScrollPane(centerPane); - downPanel.setBorder(new LineBorder(Color.gray)); - esp.add(downPanel,BorderLayout.CENTER); - UILabel upLabel = new UILabel(Inter.getLocText("FR-Widget_Mobile_Table"),SwingConstants.CENTER); - upLabel.setBorder(BorderFactory.createEmptyBorder(6,0,6,0)); - esp.add(upLabel,BorderLayout.NORTH); - + downPanel = new UIScrollPane(new ShareWidgetPane(elCaseBindInfoList)); + downPanel.setPreferredSize(new Dimension(240, 400)); + reuWidgetPanel = FRGUIPaneFactory.createCenterFlowInnerContainer_S_Pane(); + UIComboBox comboBox = new UIComboBox(getCategories()); + comboBox.setPreferredSize(new Dimension(240, 30)); + comboBox.addItemListener(new ItemListener() { + @Override + public void itemStateChanged(ItemEvent e) { + String filterName = (String) e.getItem(); + elCaseBindInfoList = ShareLoader.getLoader().getFilterBindInfoList(filterName); + refreshUI(); + reuWidgetPanel.repaint(); + } + }); + reuWidgetPanel.add(comboBox, BorderLayout.NORTH); + reuWidgetPanel.add(downPanel, BorderLayout.SOUTH); + reuWidgetPanel.setBorder(new LineBorder(Color.gray)); + esp.add(reuWidgetPanel, BorderLayout.CENTER); + UIButton button = new UIButton(); + button.setIcon(BaseUtils.readIcon("/com/fr/design/images/control/download.png")); + button.set4ToolbarButton(); + JPanel widgetPane = FRGUIPaneFactory.createBorderLayout_L_Pane(); + widgetPane.setBorder(BorderFactory.createEmptyBorder(3, 10, 3, 3)); + widgetPane.add(new UILabel(Inter.getLocText("FR-Designer_LocalWidget"), + SwingConstants.HORIZONTAL), BorderLayout.WEST); + widgetPane.add(button, BorderLayout.EAST); + esp.add(widgetPane,BorderLayout.NORTH); tabbedPane = new UITabbedPane(); tabbedPane.setOpaque(true); tabbedPane.setBorder(null); tabbedPane.setTabPlacement(SwingConstants.BOTTOM); - tabbedPane.addTab(Inter.getLocText("FR-Widget_Mobile_Tree"), parameterPropertyPane); - tabbedPane.addTab(Inter.getLocText("FR-Widget_Mobile_Terminal"), esp); + tabbedPane.addTab(Inter.getLocText("FR-Engine_Report"), esp); + tabbedPane.addTab(Inter.getLocText("FR-Designer-Form-ToolBar_Chart"), new JPanel()); add(tabbedPane, BorderLayout.CENTER); } + public String[] getCategories() { + return new String[]{Inter.getLocText("FR-Designer_AllCategories"), "" }; + } + + public void refreshUI() { + reuWidgetPanel.remove(downPanel); + downPanel = new JScrollPane(new ShareWidgetPane(elCaseBindInfoList), JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); + reuWidgetPanel.add(downPanel); + + } + + public void setSelectedIndex(int index){ tabbedPane.setSelectedIndex(index); } - /** - * 选中的组件是否在参数面板里 - * @param designer 设计器 - * @return 是则返回true - */ - public boolean hasSelectParaPane(FormDesigner designer){ - XCreator xCreator = designer.getSelectionModel().getSelection().getSelectedCreator(); - if(xCreator == null){ - xCreator = designer.getRootComponent(); - } - XLayoutContainer container = XCreatorUtils.getHotspotContainer(xCreator); - return xCreator.acceptType(XWParameterLayout.class) || container.acceptType(XWParameterLayout.class); - } /** * 清除数据 */ public void clearDockingView() { - parameterPropertyPane = null; - mobileWidgetTable = null; JScrollPane psp = new JScrollPane(); psp.setBorder(null); this.add(psp, BorderLayout.CENTER); } - public class mobileWidgetDesignerAdapter implements DesignerEditListener { - public mobileWidgetDesignerAdapter() { - } - - /** - * 响应界面改变事件 - * @param evt 事件 - */ - public void fireCreatorModified(DesignerEvent evt) { - if (evt.getCreatorEventID() == DesignerEvent.CREATOR_RESIZED - || evt.getCreatorEventID() == DesignerEvent.CREATOR_EDITED - || evt.getCreatorEventID() == DesignerEvent.CREATOR_SELECTED - || evt.getCreatorEventID() == DesignerEvent.CREATOR_ADDED) { - int value = downPanel.getVerticalScrollBar().getValue(); - if(hasSelectParaPane(getEditingFormDesigner())){ - cardLayout.show(centerPane,PARA); - mobileWidgetTable.refresh(); - } else { - cardLayout.show(centerPane,BODY); - mobileBodyWidgetTable.refresh(); - } - //出现滚动条 - downPanel.doLayout(); - //控件列表选中某组件,触发表单中选中控件,选中事件又触发列表刷新,滚动条回到0 - //此处设置滚动条值为刷新前 - downPanel.getVerticalScrollBar().setValue(value); - } - } - } /** * 定位 From 366f89956b12dafaeccdb23d1fcb8020226b9231 Mon Sep 17 00:00:00 2001 From: xiaoxia Date: Sun, 16 Oct 2016 22:18:16 +0800 Subject: [PATCH 12/22] rt --- .../mainframe/FormWidgetDetailPane.java | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/designer_form/src/com/fr/design/mainframe/FormWidgetDetailPane.java b/designer_form/src/com/fr/design/mainframe/FormWidgetDetailPane.java index 9f1983f31d..efd6c0b7e4 100644 --- a/designer_form/src/com/fr/design/mainframe/FormWidgetDetailPane.java +++ b/designer_form/src/com/fr/design/mainframe/FormWidgetDetailPane.java @@ -80,7 +80,7 @@ public class FormWidgetDetailPane extends FormDockView{ elCaseBindInfoList = ShareLoader.getLoader().getAllBindInfoList(); } downPanel = new UIScrollPane(new ShareWidgetPane(elCaseBindInfoList)); - downPanel.setPreferredSize(new Dimension(240, 400)); + downPanel.setPreferredSize(new Dimension(235, 480)); reuWidgetPanel = FRGUIPaneFactory.createCenterFlowInnerContainer_S_Pane(); UIComboBox comboBox = new UIComboBox(getCategories()); comboBox.setPreferredSize(new Dimension(240, 30)); @@ -89,12 +89,11 @@ public class FormWidgetDetailPane extends FormDockView{ public void itemStateChanged(ItemEvent e) { String filterName = (String) e.getItem(); elCaseBindInfoList = ShareLoader.getLoader().getFilterBindInfoList(filterName); - refreshUI(); - reuWidgetPanel.repaint(); + refreshDownPanel(); } }); reuWidgetPanel.add(comboBox, BorderLayout.NORTH); - reuWidgetPanel.add(downPanel, BorderLayout.SOUTH); + reuWidgetPanel.add(downPanel, BorderLayout.CENTER); reuWidgetPanel.setBorder(new LineBorder(Color.gray)); esp.add(reuWidgetPanel, BorderLayout.CENTER); UIButton button = new UIButton(); @@ -120,11 +119,19 @@ public class FormWidgetDetailPane extends FormDockView{ return new String[]{Inter.getLocText("FR-Designer_AllCategories"), "" }; } - public void refreshUI() { + public void refreshDownPanel() { reuWidgetPanel.remove(downPanel); - downPanel = new JScrollPane(new ShareWidgetPane(elCaseBindInfoList), JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); + downPanel = new UIScrollPane(new ShareWidgetPane(elCaseBindInfoList)); + downPanel.setPreferredSize(new Dimension(235, 480)); reuWidgetPanel.add(downPanel); + repaintContainer(); + + } + public void repaintContainer() { + validate(); + repaint(); + revalidate(); } From e9647900600721ecd7178c2a8d65fe41b5a2dc3a Mon Sep 17 00:00:00 2001 From: xiaoxia Date: Sun, 16 Oct 2016 23:54:38 +0800 Subject: [PATCH 13/22] rt --- .../src/com/fr/design/form/images/download.png | Bin 0 -> 98 bytes .../fr/design/mainframe/FormWidgetDetailPane.java | 2 +- .../fr/design/parameter/ParameterPropertyPane.java | 6 +++--- 3 files changed, 4 insertions(+), 4 deletions(-) create mode 100644 designer_form/src/com/fr/design/form/images/download.png diff --git a/designer_form/src/com/fr/design/form/images/download.png b/designer_form/src/com/fr/design/form/images/download.png new file mode 100644 index 0000000000000000000000000000000000000000..fa7b09dea32a9cce0962b2da23a6cfa34bc59baf GIT binary patch literal 98 zcmeAS@N?(olHy`uVBq!ia0vp^JV4CF!3HE7boT!OQjEnx?oJHr&dIz4a%4PR977}| vlh;Iier3 Date: Mon, 17 Oct 2016 00:03:56 +0800 Subject: [PATCH 14/22] rt --- .../src/com/fr/design/parameter/ParameterPropertyPane.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/designer_form/src/com/fr/design/parameter/ParameterPropertyPane.java b/designer_form/src/com/fr/design/parameter/ParameterPropertyPane.java index 37dc0d4e65..3ecfd53eda 100644 --- a/designer_form/src/com/fr/design/parameter/ParameterPropertyPane.java +++ b/designer_form/src/com/fr/design/parameter/ParameterPropertyPane.java @@ -47,7 +47,7 @@ public class ParameterPropertyPane extends JPanel{ initParameterListener(); this.setLayout(new BorderLayout(0, 6)); - this.setBorder(BorderFactory.createEmptyBorder(0, 10, 0, 10)); + this.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10)); this.add(toolbarPane, BorderLayout.CENTER); } From b836a64de09f429510c21872df7db1c385447e1f Mon Sep 17 00:00:00 2001 From: juhaoyu <2335173323@qq.com> Date: Mon, 17 Oct 2016 08:52:10 +0800 Subject: [PATCH 15/22] implements DataCreatorUI --- .../fr/design/gui/frpane/TreeSettingPane.java | 30 ++++++++----------- .../layer/config/LayerDataControlPane.java | 3 +- .../config/LayerDependenceSettingPane.java | 9 +++--- 3 files changed, 18 insertions(+), 24 deletions(-) diff --git a/designer_base/src/com/fr/design/gui/frpane/TreeSettingPane.java b/designer_base/src/com/fr/design/gui/frpane/TreeSettingPane.java index 7a60e59a9a..8bf384b313 100644 --- a/designer_base/src/com/fr/design/gui/frpane/TreeSettingPane.java +++ b/designer_base/src/com/fr/design/gui/frpane/TreeSettingPane.java @@ -156,15 +156,11 @@ public class TreeSettingPane extends BasicPane implements DataCreatorUI { te.setAutoBuild(true); te.setDictionary(dictionary); te.setNodeOrDict(dictionary); - } else if (buildBox.getSelectedIndex() == 0) { - // TODO: 16/9/12 - te.setLayerBuild(true); - - } else { - te.setAutoBuild(false); - NameObject no = this.controlPane.update(); - if (no != null) { - TreeEditor editor = (TreeEditor) no.getObject(); + } else if (buildBox.getSelectedIndex() == 2) { + te.setAutoBuild(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()); @@ -212,15 +208,13 @@ public class TreeSettingPane extends BasicPane implements DataCreatorUI { tcb.setAutoBuild(true); tcb.setDictionary(dictionary); tcb.setNodeOrDict(dictionary); - } else if (buildBox.getSelectedIndex() == 0) { - // TODO: 16/9/12 - } else { - tcb.setAutoBuild(false); - NameObject no = this.controlPane.update(); - if (no != null) { - if (no.getObject() instanceof TreeComboBoxEditor) { - return (TreeComboBoxEditor) no.getObject(); - } + } else if (buildBox.getSelectedIndex() == 2) { + tcb.setAutoBuild(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()); diff --git a/designer_base/src/com/fr/design/gui/frpane/tree/layer/config/LayerDataControlPane.java b/designer_base/src/com/fr/design/gui/frpane/tree/layer/config/LayerDataControlPane.java index 136588cf98..daba428901 100644 --- a/designer_base/src/com/fr/design/gui/frpane/tree/layer/config/LayerDataControlPane.java +++ b/designer_base/src/com/fr/design/gui/frpane/tree/layer/config/LayerDataControlPane.java @@ -49,10 +49,9 @@ public class LayerDataControlPane extends ControlPane { JPanel leftPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); DefaultMutableTreeNode rootNode = new DefaultMutableTreeNode(Inter.getLocText("FR-Designer_Root")); defaultTreeModel = new DefaultTreeModel(rootNode); - DefaultMutableTreeNode firstLayer = new DefaultMutableTreeNode(new NameObject(Inter.getLocText("FR-Designer_Gradation") + 1, new LayerConfig(1))); tree = new JTree(defaultTreeModel); + DefaultMutableTreeNode firstLayer = new DefaultMutableTreeNode(new NameObject(Inter.getLocText("FR-Designer_Gradation") + 1, new LayerConfig(1))); tree.setRootVisible(false); - tree.repaint(); ((DefaultMutableTreeNode) defaultTreeModel.getRoot()).getLastLeaf().add(firstLayer); tree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION); leftPane.add(new UIScrollPane(tree), BorderLayout.CENTER); diff --git a/designer_base/src/com/fr/design/gui/frpane/tree/layer/config/LayerDependenceSettingPane.java b/designer_base/src/com/fr/design/gui/frpane/tree/layer/config/LayerDependenceSettingPane.java index 0814ec9422..29560bf47c 100644 --- a/designer_base/src/com/fr/design/gui/frpane/tree/layer/config/LayerDependenceSettingPane.java +++ b/designer_base/src/com/fr/design/gui/frpane/tree/layer/config/LayerDependenceSettingPane.java @@ -1,6 +1,7 @@ package com.fr.design.gui.frpane.tree.layer.config; import com.fr.design.data.tabledata.wrapper.TableDataWrapper; +import com.fr.design.gui.ibutton.UIButton; import com.fr.design.present.dict.TableDataDictPane; import com.fr.form.ui.tree.LayerDependence; import com.fr.general.Inter; @@ -31,12 +32,12 @@ public class LayerDependenceSettingPane extends JPanel implements ItemListener { /** * 添加依赖按钮 */ - private JButton addButton; + private UIButton addButton; /** * 删除依赖按钮 */ - private JButton delButton; + private UIButton delButton; /** * 依赖关系编辑Table @@ -66,8 +67,8 @@ public class LayerDependenceSettingPane extends JPanel implements ItemListener { tableDataDictPane.tableDataNameComboBox.addItemListener(this); //初始化按钮对象 - addButton = new JButton(Inter.getLocText("add")); - delButton = new JButton(Inter.getLocText("Delete")); + addButton = new UIButton(Inter.getLocText("add")); + delButton = new UIButton(Inter.getLocText("Delete")); //初始化Table对象,并添加renderer和editor model = new LayerDepenceTableModel(); dependenceTable = new JTable(model); From 4bf091e613cb08ebfb5596b17caa58f03073c39d Mon Sep 17 00:00:00 2001 From: juhaoyu <2335173323@qq.com> Date: Mon, 17 Oct 2016 10:00:12 +0800 Subject: [PATCH 16/22] =?UTF-8?q?=E4=BB=A3=E7=A0=81=E4=B8=8EUITable?= =?UTF-8?q?=E6=AF=94=E8=BE=83=E9=9A=BE=E5=85=BC=E5=AE=B9,=E5=B0=86Table?= =?UTF-8?q?=E7=9A=84Renderer=E5=92=8CEditor=E6=94=B9=E4=B8=BAUI***?= =?UTF-8?q?=E6=9D=A5=E7=BB=9F=E4=B8=80=E9=A3=8E=E6=A0=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../config/LayerDependenceSettingPane.java | 35 ++++++++++++++++--- 1 file changed, 31 insertions(+), 4 deletions(-) diff --git a/designer_base/src/com/fr/design/gui/frpane/tree/layer/config/LayerDependenceSettingPane.java b/designer_base/src/com/fr/design/gui/frpane/tree/layer/config/LayerDependenceSettingPane.java index 29560bf47c..0411afd46c 100644 --- a/designer_base/src/com/fr/design/gui/frpane/tree/layer/config/LayerDependenceSettingPane.java +++ b/designer_base/src/com/fr/design/gui/frpane/tree/layer/config/LayerDependenceSettingPane.java @@ -2,6 +2,8 @@ package com.fr.design.gui.frpane.tree.layer.config; import com.fr.design.data.tabledata.wrapper.TableDataWrapper; import com.fr.design.gui.ibutton.UIButton; +import com.fr.design.gui.icombobox.UIComboBox; +import com.fr.design.gui.ilable.UILabel; import com.fr.design.present.dict.TableDataDictPane; import com.fr.form.ui.tree.LayerDependence; import com.fr.general.Inter; @@ -71,12 +73,14 @@ public class LayerDependenceSettingPane extends JPanel implements ItemListener { delButton = new UIButton(Inter.getLocText("Delete")); //初始化Table对象,并添加renderer和editor model = new LayerDepenceTableModel(); - dependenceTable = new JTable(model); + dependenceTable = new JTable(); + dependenceTable.setModel(model); //初始化辅助组件 fieldEditor = new FiledEditor(tableDataDictPane); fieldRenderer = new FieldRenderer(tableDictPane); layerIndexEditor = new LayerIndexEditor(currentLayerIndex); //添加renderer + dependenceTable.getColumnModel().getColumn(0).setCellRenderer(new FirstRenderer()); dependenceTable.getColumnModel().getColumn(1).setCellRenderer(fieldRenderer); //添加第一列editor dependenceTable.getColumnModel().getColumn(0).setCellEditor(layerIndexEditor); @@ -169,11 +173,34 @@ public class LayerDependenceSettingPane extends JPanel implements ItemListener { } + /** + * 第一列renderer + */ + private static final class FirstRenderer extends UILabel implements TableCellRenderer { + + @Override + public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { + + if (value != null) { + //value是用户选择的字段索引值,从1开始的 + this.setText(String.valueOf(value)); + } else { + this.setText(""); + } + if (hasFocus) { + this.setBorder(UIManager.getBorder("Table.focusCelHighlightBorder")); + } else { + this.setBorder(null); + } + return this; + } + } + /** * 第二列renderer * 由于从model中获取的数据是数据集列的索引值,这里要转换为列的名称 */ - private static final class FieldRenderer extends JLabel implements TableCellRenderer { + private static final class FieldRenderer extends UILabel implements TableCellRenderer { //用于将字段索引转换为字段名;保存改pane,是为了当用户选择其他数据集时,renderer可同步更新 private TableDataDictPane tableDataDictPane; @@ -214,7 +241,7 @@ public class LayerDependenceSettingPane extends JPanel implements ItemListener { private int currentLayerIndex; - private JComboBox layerChoseCombobox = new JComboBox(); + private UIComboBox layerChoseCombobox = new UIComboBox(); public LayerIndexEditor(int currentLayerIndex) { @@ -254,7 +281,7 @@ public class LayerDependenceSettingPane extends JPanel implements ItemListener { */ private static final class FiledEditor extends AbstractCellEditor implements TableCellEditor { - private JComboBox layerChoseCombobox = new JComboBox(); + private UIComboBox layerChoseCombobox = new UIComboBox(); TableDataDictPane tableDataDictPane; From d96258296f4552569c10fd200855e1a8533fbb26 Mon Sep 17 00:00:00 2001 From: juhaoyu <2335173323@qq.com> Date: Mon, 17 Oct 2016 10:48:27 +0800 Subject: [PATCH 17/22] =?UTF-8?q?=E8=A7=A3=E5=86=B3=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=E4=BE=9D=E8=B5=96=E4=B9=8B=E5=90=8E,=E4=BF=9D=E5=AD=98?= =?UTF-8?q?=E6=8C=89=E9=92=AE=E4=BB=8D=E7=84=B6=E7=BD=AE=E7=81=B0=E7=9A=84?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../gui/frpane/tree/layer/config/LayerDataControlPane.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/designer_base/src/com/fr/design/gui/frpane/tree/layer/config/LayerDataControlPane.java b/designer_base/src/com/fr/design/gui/frpane/tree/layer/config/LayerDataControlPane.java index daba428901..0ff6164b67 100644 --- a/designer_base/src/com/fr/design/gui/frpane/tree/layer/config/LayerDataControlPane.java +++ b/designer_base/src/com/fr/design/gui/frpane/tree/layer/config/LayerDataControlPane.java @@ -208,7 +208,7 @@ public class LayerDataControlPane extends ControlPane { for (int i = 0; i < count; i++) { DefaultMutableTreeNode node4add = new DefaultMutableTreeNode( - new NameObject(Inter.getLocText("FR-Designer_Gradation") + (i + 1), layerConfigs[i])); + new NameObject(Inter.getLocText("FR-Designer_Gradation") + (i + 1), layerConfigs[i].clone())); node4root.add(node4add); node4root = node4add; } From c9c351c5519f395ec5d36790453dc5546219eaac Mon Sep 17 00:00:00 2001 From: xiaoxia Date: Mon, 17 Oct 2016 16:18:20 +0800 Subject: [PATCH 18/22] rt --- .../mainframe/FormWidgetDetailPane.java | 26 ++++++++++++------- .../fr/design/mainframe/ShareWidgetPane.java | 7 +++-- 2 files changed, 22 insertions(+), 11 deletions(-) diff --git a/designer_form/src/com/fr/design/mainframe/FormWidgetDetailPane.java b/designer_form/src/com/fr/design/mainframe/FormWidgetDetailPane.java index 625f9a544c..987740dffa 100644 --- a/designer_form/src/com/fr/design/mainframe/FormWidgetDetailPane.java +++ b/designer_form/src/com/fr/design/mainframe/FormWidgetDetailPane.java @@ -3,7 +3,8 @@ package com.fr.design.mainframe; import java.awt.*; import java.awt.event.ItemEvent; import java.awt.event.ItemListener; -import java.util.ArrayList; +import java.util.*; +import java.util.List; import javax.swing.*; import javax.swing.border.LineBorder; @@ -15,6 +16,7 @@ import com.fr.design.gui.icombobox.UIComboBox; import com.fr.design.gui.icontainer.UIScrollPane; import com.fr.design.gui.ilable.UILabel; import com.fr.design.layout.FRGUIPaneFactory; +import com.fr.form.share.ShareConstants; import com.fr.form.share.ShareLoader; import com.fr.form.ui.ElCaseBindInfo; import com.fr.general.Inter; @@ -30,7 +32,7 @@ public class FormWidgetDetailPane extends FormDockView{ private UITabbedPane tabbedPane; private JScrollPane downPanel; private JPanel reuWidgetPanel; - private ArrayList elCaseBindInfoList; + private List elCaseBindInfoList; public static FormWidgetDetailPane getInstance() { if (HOLDER.singleton == null) { @@ -80,16 +82,22 @@ public class FormWidgetDetailPane extends FormDockView{ elCaseBindInfoList = ShareLoader.getLoader().getAllBindInfoList(); } downPanel = new UIScrollPane(new ShareWidgetPane(elCaseBindInfoList)); - downPanel.setPreferredSize(new Dimension(235, 480)); + downPanel.setPreferredSize(new Dimension(236, 480)); reuWidgetPanel = FRGUIPaneFactory.createCenterFlowInnerContainer_S_Pane(); - UIComboBox comboBox = new UIComboBox(getCategories()); - comboBox.setPreferredSize(new Dimension(240, 30)); + final UIComboBox comboBox = new UIComboBox(getCategories()); + comboBox.setPreferredSize(new Dimension(236, 30)); comboBox.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { - String filterName = (String) e.getItem(); - elCaseBindInfoList = ShareLoader.getLoader().getFilterBindInfoList(filterName); + int filterIndex = comboBox.getSelectedIndex(); + if (filterIndex == 0) { + elCaseBindInfoList = ShareLoader.getLoader().getAllBindInfoList(); + } else { + String filterName = (String) e.getItem(); + elCaseBindInfoList = ShareLoader.getLoader().getFilterBindInfoList(filterName); + } refreshDownPanel(); + } }); reuWidgetPanel.add(comboBox, BorderLayout.NORTH); @@ -116,13 +124,13 @@ public class FormWidgetDetailPane extends FormDockView{ } public String[] getCategories() { - return new String[]{Inter.getLocText("FR-Designer_AllCategories"), "" }; + return ShareConstants.WIDGET_CATEGORIES; } public void refreshDownPanel() { reuWidgetPanel.remove(downPanel); downPanel = new UIScrollPane(new ShareWidgetPane(elCaseBindInfoList)); - downPanel.setPreferredSize(new Dimension(235, 480)); + //todo:这个地方有问题 reuWidgetPanel.add(downPanel); repaintContainer(); diff --git a/designer_form/src/com/fr/design/mainframe/ShareWidgetPane.java b/designer_form/src/com/fr/design/mainframe/ShareWidgetPane.java index 79f15b3646..d788d77e3d 100644 --- a/designer_form/src/com/fr/design/mainframe/ShareWidgetPane.java +++ b/designer_form/src/com/fr/design/mainframe/ShareWidgetPane.java @@ -6,14 +6,16 @@ import com.fr.form.ui.ElCaseBindInfo; import javax.swing.*; import java.awt.*; -import java.util.ArrayList; +import java.util.*; +import java.util.List; /** * Created by xiaxiang on 2016/10/10. */ public class ShareWidgetPane extends JPanel { - public ShareWidgetPane(ArrayList elCaseBindInfoList) { + + public ShareWidgetPane(List elCaseBindInfoList) { this.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));// 设置面板的边框 ,距离上、左、下、右 的距离 int rowCount = (elCaseBindInfoList.size() + 1)/2; this.setLayout(new GridLayout(rowCount, 2, 10, 10)); @@ -26,4 +28,5 @@ public class ShareWidgetPane extends JPanel { } } + } From bc58aa385d3acd6e99b497bbd8098fe6d5986a99 Mon Sep 17 00:00:00 2001 From: xiaoxia Date: Mon, 17 Oct 2016 16:23:13 +0800 Subject: [PATCH 19/22] rt --- .../mainframe/FormWidgetDetailPane.java | 34 +++++++++++-------- 1 file changed, 20 insertions(+), 14 deletions(-) diff --git a/designer_form/src/com/fr/design/mainframe/FormWidgetDetailPane.java b/designer_form/src/com/fr/design/mainframe/FormWidgetDetailPane.java index 987740dffa..54bd31cc9f 100644 --- a/designer_form/src/com/fr/design/mainframe/FormWidgetDetailPane.java +++ b/designer_form/src/com/fr/design/mainframe/FormWidgetDetailPane.java @@ -32,6 +32,7 @@ public class FormWidgetDetailPane extends FormDockView{ private UITabbedPane tabbedPane; private JScrollPane downPanel; private JPanel reuWidgetPanel; + private UIComboBox comboBox; private List elCaseBindInfoList; public static FormWidgetDetailPane getInstance() { @@ -84,22 +85,10 @@ public class FormWidgetDetailPane extends FormDockView{ downPanel = new UIScrollPane(new ShareWidgetPane(elCaseBindInfoList)); downPanel.setPreferredSize(new Dimension(236, 480)); reuWidgetPanel = FRGUIPaneFactory.createCenterFlowInnerContainer_S_Pane(); - final UIComboBox comboBox = new UIComboBox(getCategories()); + comboBox = new UIComboBox(getCategories()); comboBox.setPreferredSize(new Dimension(236, 30)); - comboBox.addItemListener(new ItemListener() { - @Override - public void itemStateChanged(ItemEvent e) { - int filterIndex = comboBox.getSelectedIndex(); - if (filterIndex == 0) { - elCaseBindInfoList = ShareLoader.getLoader().getAllBindInfoList(); - } else { - String filterName = (String) e.getItem(); - elCaseBindInfoList = ShareLoader.getLoader().getFilterBindInfoList(filterName); - } - refreshDownPanel(); + initComboBoxSelectedListener(); - } - }); reuWidgetPanel.add(comboBox, BorderLayout.NORTH); reuWidgetPanel.add(downPanel, BorderLayout.CENTER); reuWidgetPanel.setBorder(new LineBorder(Color.gray)); @@ -123,6 +112,23 @@ public class FormWidgetDetailPane extends FormDockView{ } + private void initComboBoxSelectedListener() { + comboBox.addItemListener(new ItemListener() { + @Override + public void itemStateChanged(ItemEvent e) { + int filterIndex = comboBox.getSelectedIndex(); + if (filterIndex == 0) { + elCaseBindInfoList = ShareLoader.getLoader().getAllBindInfoList(); + } else { + String filterName = (String) e.getItem(); + elCaseBindInfoList = ShareLoader.getLoader().getFilterBindInfoList(filterName); + } + refreshDownPanel(); + + } + }); + } + public String[] getCategories() { return ShareConstants.WIDGET_CATEGORIES; } From f68ae9af64a520dcc02a40a200b16e15eab04592 Mon Sep 17 00:00:00 2001 From: xiaoxia Date: Mon, 17 Oct 2016 16:49:28 +0800 Subject: [PATCH 20/22] rt --- .../mainframe/FormWidgetDetailPane.java | 27 ++++++++++++------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/designer_form/src/com/fr/design/mainframe/FormWidgetDetailPane.java b/designer_form/src/com/fr/design/mainframe/FormWidgetDetailPane.java index 54bd31cc9f..a293d1f0d4 100644 --- a/designer_form/src/com/fr/design/mainframe/FormWidgetDetailPane.java +++ b/designer_form/src/com/fr/design/mainframe/FormWidgetDetailPane.java @@ -82,16 +82,7 @@ public class FormWidgetDetailPane extends FormDockView{ if (elCaseBindInfoList == null) { elCaseBindInfoList = ShareLoader.getLoader().getAllBindInfoList(); } - downPanel = new UIScrollPane(new ShareWidgetPane(elCaseBindInfoList)); - downPanel.setPreferredSize(new Dimension(236, 480)); - reuWidgetPanel = FRGUIPaneFactory.createCenterFlowInnerContainer_S_Pane(); - comboBox = new UIComboBox(getCategories()); - comboBox.setPreferredSize(new Dimension(236, 30)); - initComboBoxSelectedListener(); - - reuWidgetPanel.add(comboBox, BorderLayout.NORTH); - reuWidgetPanel.add(downPanel, BorderLayout.CENTER); - reuWidgetPanel.setBorder(new LineBorder(Color.gray)); + initReuWidgetPanel(); esp.add(reuWidgetPanel, BorderLayout.CENTER); UIButton button = new UIButton(); button.setIcon(BaseUtils.readIcon("/com/fr/design/form/images/download.png")); @@ -112,6 +103,22 @@ public class FormWidgetDetailPane extends FormDockView{ } + /** + * 初始化组件共享和复用面板 + */ + private void initReuWidgetPanel() { + int rowCount = (elCaseBindInfoList.size() + 1)/2; + downPanel = new UIScrollPane(new ShareWidgetPane(elCaseBindInfoList)); + downPanel.setPreferredSize(new Dimension(236, rowCount * 82)); + reuWidgetPanel = FRGUIPaneFactory.createCenterFlowInnerContainer_S_Pane(); + comboBox = new UIComboBox(getCategories()); + comboBox.setPreferredSize(new Dimension(236, 30)); + initComboBoxSelectedListener(); + reuWidgetPanel.add(comboBox, BorderLayout.NORTH); + reuWidgetPanel.add(downPanel, BorderLayout.CENTER); + reuWidgetPanel.setBorder(new LineBorder(Color.gray)); + } + private void initComboBoxSelectedListener() { comboBox.addItemListener(new ItemListener() { @Override From c84679f2468a4f3151f5ca5acacb68f7ef2c07fc Mon Sep 17 00:00:00 2001 From: xiaoxia Date: Mon, 17 Oct 2016 17:19:49 +0800 Subject: [PATCH 21/22] rt --- .../src/com/fr/design/mainframe/FormWidgetDetailPane.java | 4 ++-- .../src/com/fr/design/mainframe/ShareWidgetPane.java | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/designer_form/src/com/fr/design/mainframe/FormWidgetDetailPane.java b/designer_form/src/com/fr/design/mainframe/FormWidgetDetailPane.java index a293d1f0d4..ae5bc069dc 100644 --- a/designer_form/src/com/fr/design/mainframe/FormWidgetDetailPane.java +++ b/designer_form/src/com/fr/design/mainframe/FormWidgetDetailPane.java @@ -33,7 +33,7 @@ public class FormWidgetDetailPane extends FormDockView{ private JScrollPane downPanel; private JPanel reuWidgetPanel; private UIComboBox comboBox; - private List elCaseBindInfoList; + private ElCaseBindInfo[] elCaseBindInfoList; public static FormWidgetDetailPane getInstance() { if (HOLDER.singleton == null) { @@ -107,7 +107,7 @@ public class FormWidgetDetailPane extends FormDockView{ * 初始化组件共享和复用面板 */ private void initReuWidgetPanel() { - int rowCount = (elCaseBindInfoList.size() + 1)/2; + int rowCount = (elCaseBindInfoList.length + 1)/2; downPanel = new UIScrollPane(new ShareWidgetPane(elCaseBindInfoList)); downPanel.setPreferredSize(new Dimension(236, rowCount * 82)); reuWidgetPanel = FRGUIPaneFactory.createCenterFlowInnerContainer_S_Pane(); diff --git a/designer_form/src/com/fr/design/mainframe/ShareWidgetPane.java b/designer_form/src/com/fr/design/mainframe/ShareWidgetPane.java index d788d77e3d..f5e8e0126f 100644 --- a/designer_form/src/com/fr/design/mainframe/ShareWidgetPane.java +++ b/designer_form/src/com/fr/design/mainframe/ShareWidgetPane.java @@ -15,15 +15,15 @@ import java.util.List; */ public class ShareWidgetPane extends JPanel { - public ShareWidgetPane(List elCaseBindInfoList) { + public ShareWidgetPane(ElCaseBindInfo[] elCaseBindInfoList) { this.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));// 设置面板的边框 ,距离上、左、下、右 的距离 - int rowCount = (elCaseBindInfoList.size() + 1)/2; + int rowCount = (elCaseBindInfoList.length + 1)/2; this.setLayout(new GridLayout(rowCount, 2, 10, 10)); for (ElCaseBindInfo rbModuleInfo : elCaseBindInfoList) { ShareWidgetButton widgetButton = new ShareWidgetButton(rbModuleInfo); this.add(widgetButton); } - if (elCaseBindInfoList.size() == 1) { + if (elCaseBindInfoList.length == 1) { this.add(new JPanel()); } From a24081dc3113edc444795b372dabdc5dd7cea269 Mon Sep 17 00:00:00 2001 From: xiaoxia Date: Mon, 17 Oct 2016 17:56:45 +0800 Subject: [PATCH 22/22] rt --- .../src/com/fr/design/mainframe/ShareWidgetButton.java | 2 -- 1 file changed, 2 deletions(-) diff --git a/designer_form/src/com/fr/design/mainframe/ShareWidgetButton.java b/designer_form/src/com/fr/design/mainframe/ShareWidgetButton.java index e1e1844671..955e54822a 100644 --- a/designer_form/src/com/fr/design/mainframe/ShareWidgetButton.java +++ b/designer_form/src/com/fr/design/mainframe/ShareWidgetButton.java @@ -52,8 +52,6 @@ public class ShareWidgetButton extends JPanel implements MouseListener, MouseMot imagePanel.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0)); this.add(imagePanel, BorderLayout.NORTH); - JPanel panel = new JPanel(); - panel.setPreferredSize(new Dimension(108, 20)); UILabel label = new UILabel(bindInfo.getName(), SwingConstants.HORIZONTAL); label.setOpaque(true); label.setBackground(new Color(184, 220, 242));