|
|
@ -1,30 +1,26 @@ |
|
|
|
package com.fr.design.mainframe; |
|
|
|
package com.fr.design.mainframe; |
|
|
|
|
|
|
|
|
|
|
|
import java.awt.Component; |
|
|
|
|
|
|
|
import java.awt.event.MouseAdapter; |
|
|
|
|
|
|
|
import java.awt.event.MouseEvent; |
|
|
|
|
|
|
|
import java.util.ArrayList; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import javax.swing.DropMode; |
|
|
|
|
|
|
|
import javax.swing.JPopupMenu; |
|
|
|
|
|
|
|
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.beans.AdapterBus; |
|
|
|
import com.fr.design.designer.creator.XCreator; |
|
|
|
import com.fr.design.designer.beans.ComponentAdapter; |
|
|
|
import com.fr.design.designer.creator.XLayoutContainer; |
|
|
|
import com.fr.design.designer.beans.events.DesignerEditListener; |
|
|
|
import com.fr.design.designer.creator.XWAbsoluteBodyLayout; |
|
|
|
import com.fr.design.designer.beans.events.DesignerEvent; |
|
|
|
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.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; |
|
|
@ -92,9 +88,10 @@ public class ComponentTree extends JTree { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public void setAndScrollSelectionPath(TreePath treepath) { |
|
|
|
public void setAndScrollSelectionPath(TreePath[] treepath) { |
|
|
|
setSelectionPath(treepath); |
|
|
|
this.setAllSelectedTreePaths(treepath); |
|
|
|
scrollPathToVisible(treepath); |
|
|
|
setSelectionPath(treepath[0]); |
|
|
|
|
|
|
|
scrollPathToVisible(treepath[0]); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -112,7 +109,6 @@ public class ComponentTree extends JTree { |
|
|
|
public TreePath[] getSelectedTreePath() { |
|
|
|
public TreePath[] getSelectedTreePath() { |
|
|
|
XCreator[] creators = designer.getSelectionModel().getSelection().getSelectedCreators(); |
|
|
|
XCreator[] creators = designer.getSelectionModel().getSelection().getSelectedCreators(); |
|
|
|
TreePath[] paths = new TreePath[creators.length]; |
|
|
|
TreePath[] paths = new TreePath[creators.length]; |
|
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < paths.length; i++) { |
|
|
|
for (int i = 0; i < paths.length; i++) { |
|
|
|
paths[i] = buildTreePath(creators[i]); |
|
|
|
paths[i] = buildTreePath(creators[i]); |
|
|
|
} |
|
|
|
} |
|
|
@ -141,7 +137,7 @@ public class ComponentTree extends JTree { |
|
|
|
paths[i] = buildTreePath(searchList.get(i)); |
|
|
|
paths[i] = buildTreePath(searchList.get(i)); |
|
|
|
} |
|
|
|
} |
|
|
|
if(paths.length > 0) { |
|
|
|
if(paths.length > 0) { |
|
|
|
setAndScrollSelectionPath(paths[0]); |
|
|
|
setAndScrollSelectionPath(paths); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
setSelectionPath(); |
|
|
|
setSelectionPath(); |
|
|
|
} |
|
|
|
} |
|
|
@ -217,4 +213,12 @@ public class ComponentTree extends JTree { |
|
|
|
Object[] components = path.toArray(); |
|
|
|
Object[] components = path.toArray(); |
|
|
|
return new TreePath(components); |
|
|
|
return new TreePath(components); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public TreePath[] getAllSelectedTreePaths() { |
|
|
|
|
|
|
|
return allSelectedTreePaths; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public void setAllSelectedTreePaths(TreePath[] allSelectedTreePaths) { |
|
|
|
|
|
|
|
this.allSelectedTreePaths = allSelectedTreePaths; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |