Browse Source

Merge pull request #839 in BA/design from ~XIAOXIA/design:release to release

* commit 'ba60f5ad9a0efa80d8e2d5201ddedd8f634620fd':
  框选改错啦。
master
superman 8 years ago
parent
commit
b92e73fab5
  1. 31
      designer_form/src/com/fr/design/mainframe/ComponentTree.java
  2. 2
      designer_form/src/com/fr/design/mainframe/FormDesigner.java
  3. 23
      designer_form/src/com/fr/design/mainframe/widget/UITreeComboBox.java

31
designer_form/src/com/fr/design/mainframe/ComponentTree.java

@ -1,26 +1,23 @@
package com.fr.design.mainframe; 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.constants.UIConstants;
import com.fr.design.designer.creator.XCreator; import com.fr.design.designer.creator.*;
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.treeview.ComponentTreeCellRenderer; import com.fr.design.designer.treeview.ComponentTreeCellRenderer;
import com.fr.design.designer.treeview.ComponentTreeModel; import com.fr.design.designer.treeview.ComponentTreeModel;
import com.fr.stable.StringUtils; 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 { public class ComponentTree extends JTree {
private FormDesigner designer; private FormDesigner designer;
private ComponentTreeModel model; private ComponentTreeModel model;
//xiaoxia 保存框选的全部组件,只显示第一个
private TreePath[] allSelectedTreePaths;
public ComponentTree(FormDesigner designer) { public ComponentTree(FormDesigner designer) {
this.designer = designer; this.designer = designer;
@ -89,8 +86,7 @@ public class ComponentTree extends JTree {
} }
public void setAndScrollSelectionPath(TreePath[] treepath) { public void setAndScrollSelectionPath(TreePath[] treepath) {
this.setAllSelectedTreePaths(treepath); setSelectionPaths(treepath);
setSelectionPath(treepath[0]);
scrollPathToVisible(treepath[0]); scrollPathToVisible(treepath[0]);
} }
@ -214,11 +210,4 @@ public class ComponentTree extends JTree {
return new TreePath(components); return new TreePath(components);
} }
public TreePath[] getAllSelectedTreePaths() {
return allSelectedTreePaths;
}
public void setAllSelectedTreePaths(TreePath[] allSelectedTreePaths) {
this.allSelectedTreePaths = allSelectedTreePaths;
}
} }

2
designer_form/src/com/fr/design/mainframe/FormDesigner.java

@ -1008,7 +1008,7 @@ public class FormDesigner extends TargetComponent<Form> implements TreeSelection
@Override @Override
public void valueChanged(TreeSelectionEvent e) { public void valueChanged(TreeSelectionEvent e) {
ComponentTree tree = (ComponentTree) e.getSource(); ComponentTree tree = (ComponentTree) e.getSource();
TreePath[] paths = tree.getAllSelectedTreePaths(); TreePath[] paths = tree.getSelectionPaths();
if (paths != null) { if (paths != null) {
ArrayList<XCreator> selected = new ArrayList<XCreator>(); ArrayList<XCreator> selected = new ArrayList<XCreator>();

23
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. * 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.DesignerEditListener;
import com.fr.design.designer.beans.events.DesignerEvent; import com.fr.design.designer.beans.events.DesignerEvent;
import com.fr.design.designer.creator.XCreator; import com.fr.design.designer.creator.XCreator;
import com.fr.design.gui.icontainer.UIScrollPane; import com.fr.design.gui.icontainer.UIScrollPane;
import com.fr.design.mainframe.ComponentTree; import com.fr.design.mainframe.ComponentTree;
import com.sun.java.swing.plaf.motif.MotifComboBoxUI; import com.sun.java.swing.plaf.motif.*;
import com.sun.java.swing.plaf.windows.WindowsComboBoxUI; import com.sun.java.swing.plaf.windows.*;
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.*;
/** /**
* 控件树下拉列表框 * 控件树下拉列表框
@ -67,7 +65,6 @@ public class UITreeComboBox extends JComboBox{
* @param o Object * @param o Object
*/ */
public void setSelectedItem(Object o){ public void setSelectedItem(Object o){
tree.setSelectionPath((TreePath)o);
getModel().setSelectedItem(o); getModel().setSelectedItem(o);
} }

Loading…
Cancel
Save