xiaoxia 8 years ago
parent
commit
c3ba1c7e3a
  1. 72
      designer_form/src/com/fr/design/mainframe/ComponentTree.java

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

@ -38,29 +38,29 @@ public class ComponentTree extends JTree {
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);
}
}
});
// 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);
}
@ -121,19 +121,19 @@ public class ComponentTree extends JTree {
scrollPathToVisible(treepath);
}
private void popupMenu(MouseEvent e) {
TreePath path = this.getSelectionPath();
if (path == null) {
return;
}
Component component = (Component) path.getLastPathComponent();
if (!(component instanceof XCreator)) {
return;
}
ComponentAdapter adapter = AdapterBus.getComponentAdapter(designer, (XCreator) component);
JPopupMenu menu = adapter.getContextPopupMenu(e);
menu.show(this, e.getX(), e.getY());
}
// private void popupMenu(MouseEvent e) {
// TreePath path = this.getSelectionPath();
// if (path == null) {
// return;
// }
// Component component = (Component) path.getLastPathComponent();
// if (!(component instanceof XCreator)) {
// return;
// }
// ComponentAdapter adapter = AdapterBus.getComponentAdapter(designer, (XCreator) component);
// JPopupMenu menu = adapter.getContextPopupMenu(e);
// menu.show(this, e.getX(), e.getY());
// }
/**
* 刷新

Loading…
Cancel
Save