From ba60f5ad9a0efa80d8e2d5201ddedd8f634620fd Mon Sep 17 00:00:00 2001 From: XiaXiang Date: Thu, 27 Apr 2017 17:08:36 +0800 Subject: [PATCH] =?UTF-8?q?=E6=A1=86=E9=80=89=E6=94=B9=E9=94=99=E5=95=A6?= =?UTF-8?q?=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fr/design/mainframe/ComponentTree.java | 31 ++++++------------- .../com/fr/design/mainframe/FormDesigner.java | 2 +- .../mainframe/widget/UITreeComboBox.java | 23 ++++++-------- 3 files changed, 21 insertions(+), 35 deletions(-) diff --git a/designer_form/src/com/fr/design/mainframe/ComponentTree.java b/designer_form/src/com/fr/design/mainframe/ComponentTree.java index 67894b991e..1ceab13c0a 100644 --- a/designer_form/src/com/fr/design/mainframe/ComponentTree.java +++ b/designer_form/src/com/fr/design/mainframe/ComponentTree.java @@ -1,26 +1,23 @@ package com.fr.design.mainframe; +import java.awt.Component; +import java.util.ArrayList; + +import javax.swing.DropMode; +import javax.swing.JTree; +import javax.swing.tree.TreePath; +import javax.swing.tree.TreeSelectionModel; + import com.fr.design.constants.UIConstants; -import com.fr.design.designer.creator.XCreator; -import com.fr.design.designer.creator.XLayoutContainer; -import com.fr.design.designer.creator.XWAbsoluteBodyLayout; -import com.fr.design.designer.creator.XWFitLayout; +import com.fr.design.designer.creator.*; import com.fr.design.designer.treeview.ComponentTreeCellRenderer; import com.fr.design.designer.treeview.ComponentTreeModel; import com.fr.stable.StringUtils; -import javax.swing.*; -import javax.swing.tree.TreePath; -import javax.swing.tree.TreeSelectionModel; -import java.awt.*; -import java.util.ArrayList; - public class ComponentTree extends JTree { private FormDesigner designer; private ComponentTreeModel model; - //xiaoxia 保存框选的全部组件,只显示第一个 - private TreePath[] allSelectedTreePaths; public ComponentTree(FormDesigner designer) { this.designer = designer; @@ -89,8 +86,7 @@ public class ComponentTree extends JTree { } public void setAndScrollSelectionPath(TreePath[] treepath) { - this.setAllSelectedTreePaths(treepath); - setSelectionPath(treepath[0]); + setSelectionPaths(treepath); scrollPathToVisible(treepath[0]); } @@ -214,11 +210,4 @@ public class ComponentTree extends JTree { return new TreePath(components); } - public TreePath[] getAllSelectedTreePaths() { - return allSelectedTreePaths; - } - - public void setAllSelectedTreePaths(TreePath[] allSelectedTreePaths) { - this.allSelectedTreePaths = allSelectedTreePaths; - } } \ No newline at end of file diff --git a/designer_form/src/com/fr/design/mainframe/FormDesigner.java b/designer_form/src/com/fr/design/mainframe/FormDesigner.java index 3e29f41281..3aa9e24ee1 100644 --- a/designer_form/src/com/fr/design/mainframe/FormDesigner.java +++ b/designer_form/src/com/fr/design/mainframe/FormDesigner.java @@ -1008,7 +1008,7 @@ public class FormDesigner extends TargetComponent
implements TreeSelection @Override public void valueChanged(TreeSelectionEvent e) { ComponentTree tree = (ComponentTree) e.getSource(); - TreePath[] paths = tree.getAllSelectedTreePaths(); + TreePath[] paths = tree.getSelectionPaths(); if (paths != null) { ArrayList selected = new ArrayList(); 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 258fd15d31..62c9aa0678 100644 --- a/designer_form/src/com/fr/design/mainframe/widget/UITreeComboBox.java +++ b/designer_form/src/com/fr/design/mainframe/widget/UITreeComboBox.java @@ -3,24 +3,22 @@ package com.fr.design.mainframe.widget; /** * Created by xiaxiang on 2016/9/30. */ +import java.awt.*; +import java.awt.event.*; +import javax.swing.*; +import javax.swing.plaf.*; +import javax.swing.plaf.basic.*; +import javax.swing.plaf.metal.*; +import javax.swing.tree.*; -import com.fr.design.designer.beans.AdapterBus; +import com.fr.design.designer.beans.*; 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.gui.icontainer.UIScrollPane; import com.fr.design.mainframe.ComponentTree; -import com.sun.java.swing.plaf.motif.MotifComboBoxUI; -import com.sun.java.swing.plaf.windows.WindowsComboBoxUI; - -import javax.swing.*; -import javax.swing.plaf.ComboBoxUI; -import javax.swing.plaf.basic.ComboPopup; -import javax.swing.plaf.metal.MetalComboBoxUI; -import javax.swing.tree.TreeCellRenderer; -import javax.swing.tree.TreePath; -import java.awt.*; -import java.awt.event.*; +import com.sun.java.swing.plaf.motif.*; +import com.sun.java.swing.plaf.windows.*; /** * 控件树下拉列表框 @@ -67,7 +65,6 @@ public class UITreeComboBox extends JComboBox{ * @param o Object */ public void setSelectedItem(Object o){ - tree.setSelectionPath((TreePath)o); getModel().setSelectedItem(o); }