use of org.apache.cayenne.modeler.dialog.db.load.DbImportTreeNode in project cayenne by apache.
the class DbImportTree method printCatalogs.
private void printCatalogs(Collection<Catalog> catalogs, DbImportTreeNode parent) {
for (Catalog catalog : catalogs) {
DbImportTreeNode node = !isTransferable ? new DbImportTreeNode(catalog) : new TransferableNode(catalog);
if (!"".equals(node.getSimpleNodeName())) {
if (isTransferable && catalog.getSchemas().isEmpty() && catalog.getIncludeTables().isEmpty() && catalog.getExcludeTables().isEmpty()) {
printParams(Collections.singletonList(new IncludeTable("Loading...")), node);
}
printSchemas(catalog.getSchemas(), node);
printChildren(catalog, node);
parent.add(node);
}
}
}
use of org.apache.cayenne.modeler.dialog.db.load.DbImportTreeNode in project cayenne by apache.
the class DbImportView method initFromModel.
public void initFromModel() {
DataMap map = projectController.getCurrentDataMap();
treePanel.getReverseEngineeringTree().stopEditing();
if (map != null) {
initFromModel = true;
treeToolbar.unlockButtons();
ReverseEngineering reverseEngineering = DbImportView.this.projectController.getApplication().getMetaData().get(map, ReverseEngineering.class);
if (reverseEngineering == null) {
// create config with default values
reverseEngineering = new ReverseEngineering();
DbImportView.this.projectController.getApplication().getMetaData().add(map, reverseEngineering);
}
configPanel.fillCheckboxes(reverseEngineering);
configPanel.initializeTextFields(reverseEngineering);
configPanel.initStrategy(reverseEngineering);
String[] tableTypes = reverseEngineering.getTableTypes();
if (tableTypes.length != 0) {
configPanel.getTableTypes().setText(String.join(",", tableTypes));
} else {
configPanel.getTableTypes().setText("TABLE, VIEW");
configPanel.getTableTypes().updateModel();
}
treePanel.updateTree();
DbImportTreeNode root = draggableTreePanel.getSourceTree().getRootNode();
root.removeAllChildren();
draggableTreePanel.updateTree(projectController.getCurrentDataMap());
draggableTreePanel.getMoveButton().setEnabled(false);
draggableTreePanel.getMoveInvertButton().setEnabled(false);
}
initFromModel = false;
}
use of org.apache.cayenne.modeler.dialog.db.load.DbImportTreeNode in project cayenne by apache.
the class DbImportView method initFormElements.
private void initFormElements() {
DbImportTreeNode root = new DbImportTreeNode(new ReverseEngineering());
DbImportTreeNode draggableTreeRoot = new DbImportTreeNode(new ReverseEngineering());
DbImportTree reverseEngineeringTree = new DbImportTree(root);
DbImportTree draggableTree = new DbImportTree(new TransferableNode(draggableTreeRoot));
DbImportModel model = new DbImportModel(root);
model.setCanBeCleaned(true);
DbImportModel draggableTreeModel = new DbImportModel(draggableTreeRoot);
draggableTreeModel.setCanBeCleaned(false);
draggableTree.setRootVisible(false);
draggableTree.setShowsRootHandles(true);
draggableTree.setModel(draggableTreeModel);
reverseEngineeringTree.setRootVisible(false);
reverseEngineeringTree.setModel(model);
reverseEngineeringTree.setShowsRootHandles(true);
draggableTreePanel = new DraggableTreePanel(projectController, draggableTree, reverseEngineeringTree);
treeToolbar = new TreeToolbarPanel(projectController, reverseEngineeringTree, draggableTreePanel);
treePanel = new ReverseEngineeringTreePanel(projectController, reverseEngineeringTree, draggableTree);
treePanel.setTreeToolbar(treeToolbar);
model.setDbSchemaTree(draggableTree);
draggableTreeModel.setDbSchemaTree(draggableTree);
((ColorTreeRenderer) draggableTreePanel.getSourceTree().getCellRenderer()).setReverseEngineeringTree(reverseEngineeringTree);
configPanel = new ReverseEngineeringConfigPanel(projectController, this);
configPanel.setLayout(new FlowLayout(FlowLayout.LEFT));
configPanel.setVisible(false);
}
use of org.apache.cayenne.modeler.dialog.db.load.DbImportTreeNode in project cayenne by apache.
the class PrintTablesBiFunction method apply.
@Override
public Void apply(FilterContainer filterContainer, DbImportTreeNode root) {
DbImportModel model = (DbImportModel) dbImportTree.getModel();
boolean isTransferable = dbImportTree.isTransferable();
if (root.getChildCount() != 0) {
root.removeAllChildren();
}
Collection<IncludeTable> includeTables = filterContainer.getIncludeTables();
for (IncludeTable includeTable : includeTables) {
DbImportTreeNode node = !isTransferable ? new DbImportTreeNode(includeTable) : new TransferableNode(includeTable);
if (isTransferable && includeTable.getIncludeColumns().isEmpty() && includeTable.getExcludeColumns().isEmpty()) {
dbImportTree.printParams(Collections.singletonList(new IncludeColumn("Loading...")), node);
}
root.add(node);
dbImportTree.packColumns(includeTable, node);
}
model.reload(root);
return null;
}
use of org.apache.cayenne.modeler.dialog.db.load.DbImportTreeNode 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