|
|
@ -38,29 +38,29 @@ public class ComponentTree extends JTree { |
|
|
|
this.refreshTreeRoot(); |
|
|
|
this.refreshTreeRoot(); |
|
|
|
addTreeSelectionListener(designer); |
|
|
|
addTreeSelectionListener(designer); |
|
|
|
|
|
|
|
|
|
|
|
this.addMouseListener(new MouseAdapter() { |
|
|
|
// this.addMouseListener(new MouseAdapter() {
|
|
|
|
|
|
|
|
//
|
|
|
|
@Override |
|
|
|
// @Override
|
|
|
|
public void mouseClicked(MouseEvent e) { |
|
|
|
// public void mouseClicked(MouseEvent e) {
|
|
|
|
if (e.isPopupTrigger()) { |
|
|
|
// if (e.isPopupTrigger()) {
|
|
|
|
popupMenu(e); |
|
|
|
// popupMenu(e);
|
|
|
|
} |
|
|
|
// }
|
|
|
|
} |
|
|
|
// }
|
|
|
|
|
|
|
|
//
|
|
|
|
@Override |
|
|
|
// @Override
|
|
|
|
public void mousePressed(MouseEvent e) { |
|
|
|
// public void mousePressed(MouseEvent e) {
|
|
|
|
if (e.isPopupTrigger()) { |
|
|
|
// if (e.isPopupTrigger()) {
|
|
|
|
popupMenu(e); |
|
|
|
// popupMenu(e);
|
|
|
|
} |
|
|
|
// }
|
|
|
|
} |
|
|
|
// }
|
|
|
|
|
|
|
|
//
|
|
|
|
@Override |
|
|
|
// @Override
|
|
|
|
public void mouseReleased(MouseEvent e) { |
|
|
|
// public void mouseReleased(MouseEvent e) {
|
|
|
|
if (e.isPopupTrigger()) { |
|
|
|
// if (e.isPopupTrigger()) {
|
|
|
|
popupMenu(e); |
|
|
|
// popupMenu(e);
|
|
|
|
} |
|
|
|
// }
|
|
|
|
} |
|
|
|
// }
|
|
|
|
}); |
|
|
|
// });
|
|
|
|
setEditable(true); |
|
|
|
setEditable(true); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -121,19 +121,19 @@ public class ComponentTree extends JTree { |
|
|
|
scrollPathToVisible(treepath); |
|
|
|
scrollPathToVisible(treepath); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private void popupMenu(MouseEvent e) { |
|
|
|
// private void popupMenu(MouseEvent e) {
|
|
|
|
TreePath path = this.getSelectionPath(); |
|
|
|
// TreePath path = this.getSelectionPath();
|
|
|
|
if (path == null) { |
|
|
|
// if (path == null) {
|
|
|
|
return; |
|
|
|
// return;
|
|
|
|
} |
|
|
|
// }
|
|
|
|
Component component = (Component) path.getLastPathComponent(); |
|
|
|
// Component component = (Component) path.getLastPathComponent();
|
|
|
|
if (!(component instanceof XCreator)) { |
|
|
|
// if (!(component instanceof XCreator)) {
|
|
|
|
return; |
|
|
|
// return;
|
|
|
|
} |
|
|
|
// }
|
|
|
|
ComponentAdapter adapter = AdapterBus.getComponentAdapter(designer, (XCreator) component); |
|
|
|
// ComponentAdapter adapter = AdapterBus.getComponentAdapter(designer, (XCreator) component);
|
|
|
|
JPopupMenu menu = adapter.getContextPopupMenu(e); |
|
|
|
// JPopupMenu menu = adapter.getContextPopupMenu(e);
|
|
|
|
menu.show(this, e.getX(), e.getY()); |
|
|
|
// menu.show(this, e.getX(), e.getY());
|
|
|
|
} |
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* 刷新 |
|
|
|
* 刷新 |
|
|
|