diff --git a/designer_form/src/com/fr/design/mainframe/ComponentTree.java b/designer_form/src/com/fr/design/mainframe/ComponentTree.java
index a3452f602f..ab1f2a980f 100644
--- a/designer_form/src/com/fr/design/mainframe/ComponentTree.java
+++ b/designer_form/src/com/fr/design/mainframe/ComponentTree.java
@@ -1,255 +1,303 @@
-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.designer.beans.AdapterBus;
-import com.fr.design.designer.beans.ComponentAdapter;
+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.*;
import com.fr.design.designer.beans.events.DesignerEditListener;
import com.fr.design.designer.beans.events.DesignerEvent;
-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;
-
-public class ComponentTree extends JTree {
-
- private FormDesigner designer;
- private ComponentTreeModel model;
-
- public ComponentTree(FormDesigner designer) {
- this.designer = designer;
- this.setBackground(UIConstants.NORMAL_BACKGROUND);
- setRootVisible(true);
- setCellRenderer(new ComponentTreeCellRenderer());
- getSelectionModel().setSelectionMode(TreeSelectionModel.DISCONTIGUOUS_TREE_SELECTION);
- this.setDragEnabled(false);
- this.setDropMode(DropMode.ON_OR_INSERT);
- this.setTransferHandler(new TreeTransferHandler());
- this.refreshTreeRoot();
- addTreeSelectionListener(designer);
-
-// this.addMouseListener(new MouseAdapter() {
-//
-// @Override
-// public void mouseClicked(MouseEvent e) {
-// if (e.isPopupTrigger()) {
-// popupMenu(e);
-// }
-// }
-//
-// @Override
-// public void mousePressed(MouseEvent e) {
-// if (e.isPopupTrigger()) {
-// popupMenu(e);
-// }
-// }
-//
-// @Override
-// public void mouseReleased(MouseEvent e) {
-// if (e.isPopupTrigger()) {
-// popupMenu(e);
-// }
-// }
-// });
- setEditable(true);
- }
-
- public FormDesigner getDesigner() {
- return designer;
+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.*;
+import com.sun.java.swing.plaf.windows.*;
+
+/**
+ * 控件树下拉列表框
+ */
+public class UITreeComboBox extends JComboBox{
+ /**
+ * 显示用的树
+ */
+ private ComponentTree tree;
+
+ public UITreeComboBox(ComponentTree componentTree){
+ this.setTree(componentTree);
+ tree.getDesigner().addDesignerEditListener(new TreeComboBoxDesignerEditAdapter());
+// for(int i=0; i
Description: 树形结构而来的DefaultListCellRenderer
+ */ + class UITreeComboBoxRenderer extends DefaultListCellRenderer { + public Component getListCellRendererComponent(JList list, Object value, + int index, boolean isSelected, boolean cellHasFocus){ + if(tree != null && tree.getSelectedTreePath().length > 0){ + 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, + isSelected, cellHasFocus); + } + } + private class TreeComboBoxDesignerEditAdapter implements DesignerEditListener { + + @Override + public void fireCreatorModified(DesignerEvent evt) { + if (evt.getCreatorEventID() == DesignerEvent.CREATOR_SELECTED) { + TreePath[] paths = tree.getSelectedTreePath(); + if (tree != null && paths.length > 0) { + tree.setAndScrollSelectionPath(paths[0]); + setSelectedItem(paths[0]); + MenuSelectionManager.defaultManager().clearSelectedPath(); + } + + } else if (evt.getCreatorEventID() == DesignerEvent.CREATOR_PASTED) { + tree.refreshUI(); + TreePath[] paths = tree.getSelectedTreePath(); + if (tree != null && paths.length > 0) { + tree.setAndScrollSelectionPath(paths[0]); + setSelectedItem(paths[0]); + MenuSelectionManager.defaultManager().clearSelectedPath(); + } + } else if (evt.getCreatorEventID() == DesignerEvent.CREATOR_CUTED) { + tree.refreshUI(); + setSelectedItem(null); + MenuSelectionManager.defaultManager().clearSelectedPath(); + } else { + tree.refreshUI(); + repaint(); + } - public TreePath[] getSelectedTreePath() { - XCreator[] creators = designer.getSelectionModel().getSelection().getSelectedCreators(); - TreePath[] paths = new TreePath[creators.length]; + } - for (int i = 0; i < paths.length; i++) { - paths[i] = buildTreePath(creators[i]); + @Override + public boolean equals(Object o) { + return o.getClass() == this.getClass(); } - return paths; } + /** + * 测试 + */ +// public static void main(String args[]){ +// JFrame frame = new JFrame("UITreeComboBox"); +// final UITreeComboBox box = new UITreeComboBox(new ComponentTree(new FormDesigner())); +// box.setPreferredSize(new Dimension(300, 28)); +// frame.getContentPane().add(box); +// frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); +// frame.pack(); +// frame.setVisible(true); +// } +} +/** + *Title: UITreeComboBox
+ *Description: TreePopup
+ */ +class TreePopup extends JPopupMenu implements ComboPopup{ + protected UITreeComboBox comboBox; + protected JScrollPane scrollPane; + protected MouseMotionListener mouseMotionListener; + protected MouseListener mouseListener; - /** - *搜索指定名称的路径 - * - * @param text 名称 - * @return 树路径 - */ - public TreePath[] search(String text) { - if (StringUtils.isNotEmpty(text)) { - text = text.toLowerCase(); - } - ArrayListMouseListener
or null
+ * @see ComboPopup#getMouseListener
*/
- public void refreshTreeRoot() {
- model = new ComponentTreeModel(designer, designer.getTopContainer());
- setModel(model);
- setDragEnabled(false);
- setDropMode(DropMode.ON_OR_INSERT);
- setTransferHandler(new TreeTransferHandler());
- repaint();
- }
-
- private TreePath buildTreePath(Component comp) {
- ArrayList