use of org.apache.cayenne.modeler.dialog.db.load.DefaultPopUpMenu in project cayenne by apache.
the class ReverseEngineeringTreePanel method initPopupMenus.
private void initPopupMenus() {
popups = new HashMap<>();
popups.put(Catalog.class, new CatalogPopUpMenu());
popups.put(Schema.class, new SchemaPopUpMenu());
popups.put(ReverseEngineering.class, new RootPopUpMenu());
popups.put(String.class, new RootPopUpMenu());
popups.put(IncludeTable.class, new IncludeTablePopUpMenu());
popups.put(ExcludeTable.class, new DefaultPopUpMenu());
popups.put(IncludeColumn.class, new DefaultPopUpMenu());
popups.put(ExcludeColumn.class, new DefaultPopUpMenu());
popups.put(IncludeProcedure.class, new DefaultPopUpMenu());
popups.put(ExcludeProcedure.class, new DefaultPopUpMenu());
}
use of org.apache.cayenne.modeler.dialog.db.load.DefaultPopUpMenu in project cayenne by apache.
the class ReverseEngineeringTreePanel method initListeners.
private void initListeners() {
reverseEngineeringTree.addTreeSelectionListener(e -> treeToolbar.lockButtons());
reverseEngineeringTree.addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
if (reverseEngineeringTree.getRowForLocation(e.getX(), e.getY()) == -1) {
reverseEngineeringTree.setSelectionRow(-1);
}
if (SwingUtilities.isRightMouseButton(e)) {
if (reverseEngineeringTree.isEditing()) {
return;
}
int row = reverseEngineeringTree.getClosestRowForLocation(e.getX(), e.getY());
reverseEngineeringTree.setSelectionRow(row);
DefaultPopUpMenu popupMenu;
DbImportTreeNode selectedElement;
if (reverseEngineeringTree.getSelectionPath() != null) {
selectedElement = reverseEngineeringTree.getSelectedNode();
popupMenu = popups.get(selectedElement.getUserObject().getClass());
} else {
selectedElement = reverseEngineeringTree.getRootNode();
popupMenu = popups.get(ReverseEngineering.class);
}
if (popupMenu != null) {
popupMenu.setProjectController(projectController);
popupMenu.setSelectedElement(selectedElement);
popupMenu.setParentElement(selectedElement.getParent());
popupMenu.setTree(reverseEngineeringTree);
popupMenu.show(e.getComponent(), e.getX(), e.getY());
}
} else if (reverseEngineeringTree.getSelectionPath() != null) {
DbImportTreeNode selectedNode = reverseEngineeringTree.getSelectedNode();
if (selectedNode.isExcludeColumn() || selectedNode.isIncludeColumn()) {
DbImportTreeNode expandNode = selectedNode.getParent();
DbImportTreeNode parentPath = dbSchemaTree.findNode(dbSchemaTree.getRootNode(), expandNode, 0);
if (parentPath != null) {
dbSchemaTree.expandPath(new TreePath((parentPath).getPath()));
scrollToNode(dbSchemaTree, parentPath);
}
} else {
DbImportTreeNode findNode = dbSchemaTree.findNode(dbSchemaTree.getRootNode(), selectedNode, 0);
if (findNode != null) {
dbSchemaTree.expandPath(new TreePath(findNode.getParent().getPath()));
scrollToNode(dbSchemaTree, findNode);
}
}
}
}
});
}
Aggregations