use of org.apache.cayenne.modeler.dialog.db.load.DbImportTreeNode in project cayenne by apache.
the class ColorTreeRenderer method getLogicalTreeNode.
private Node<?> getLogicalTreeNode() {
List<Object> path = new ArrayList<>();
DbImportTreeNode parent = node;
while (parent != null) {
path.add(parent.getUserObject());
parent = parent.getParent();
}
Collections.reverse(path);
Node<?> logicalParent = null;
for (Object object : path) {
logicalParent = toLogicalNode(getObjectType(object), getObjectValue(object), logicalParent);
}
return logicalParent;
}
use of org.apache.cayenne.modeler.dialog.db.load.DbImportTreeNode in project cayenne by apache.
the class PrintColumnsBiFunction method processTable.
private void processTable(IncludeTable tableFilter, DbImportTreeNode root) {
DbImportModel model = (DbImportModel) dbImportTree.getModel();
DbImportTreeNode container = dbImportTree.findNodeInParent(root, tableFilter);
if (container == null) {
return;
}
if (container.getChildCount() != 0) {
container.removeAllChildren();
}
dbImportTree.packColumns(tableFilter, container);
container.setLoaded(true);
model.reload(container);
}
use of org.apache.cayenne.modeler.dialog.db.load.DbImportTreeNode in project cayenne by apache.
the class DraggableTreePanel method canBeMoved.
private boolean canBeMoved() {
DbImportTreeNode selectedElement = sourceTree.getSelectedNode();
if (selectedElement == null) {
return false;
}
if (selectedElement.isIncludeColumn() || selectedElement.isExcludeColumn()) {
DbImportTreeNode node = targetTree.findNode(targetTree.getRootNode(), selectedElement.getParent(), 0);
if (node != null && node.isExcludeTable()) {
return false;
}
}
Class<?> draggableElementClass = selectedElement.getUserObject().getClass();
Class<?> reverseEngineeringElementClass;
if (targetTree.getSelectionPath() != null) {
selectedElement = targetTree.getSelectedNode();
DbImportTreeNode parent = selectedElement.getParent();
if (parent != null) {
reverseEngineeringElementClass = parent.getUserObject().getClass();
} else {
reverseEngineeringElementClass = selectedElement.getUserObject().getClass();
}
} else {
reverseEngineeringElementClass = ReverseEngineering.class;
}
List<Class<?>> containsList = insertableLevels.get(reverseEngineeringElementClass);
return containsList.contains(draggableElementClass);
}
use of org.apache.cayenne.modeler.dialog.db.load.DbImportTreeNode in project cayenne by apache.
the class ColorTreeRenderer method getMask.
private ReverseEngineering getMask() {
DbImportTreeNode selectedNode = reverseEngineeringTree.getSelectedNode();
if (selectedNode == null) {
return null;
}
if (selectedNode.isReverseEngineering()) {
return reverseEngineeringTree.getReverseEngineering();
}
ReverseEngineering config = new ReverseEngineering();
Object configNode = null;
while (!selectedNode.isReverseEngineering()) {
configNode = addToMask(configNode, selectedNode);
selectedNode = selectedNode.getParent();
}
return merge(config, configNode);
}
use of org.apache.cayenne.modeler.dialog.db.load.DbImportTreeNode in project cayenne by apache.
the class LoadDbSchemaAction method performAction.
public void performAction(ActionEvent e, TreePath tablePath) {
final DbImportView rootParent = ((DbImportView) draggableTreePanel.getParent().getParent());
rootParent.getLoadDbSchemaProgress().setVisible(true);
rootParent.getLoadDbSchemaButton().setEnabled(false);
Thread thread = new Thread(() -> {
LoadDbSchemaAction.this.setEnabled(false);
rootParent.lockToolbarButtons();
draggableTreePanel.getMoveButton().setEnabled(false);
draggableTreePanel.getMoveInvertButton().setEnabled(false);
try {
DBConnectionInfo connectionInfo = getConnectionInfo("Load Db Schema");
if (connectionInfo == null) {
return;
}
if (tablePath != null) {
Object userObject = ((DbImportTreeNode) tablePath.getLastPathComponent()).getUserObject();
if (userObject instanceof Catalog) {
Catalog catalog = (Catalog) userObject;
if (catalog.getSchemas().isEmpty()) {
loadTables(connectionInfo, tablePath, rootParent);
}
} else if (userObject instanceof Schema) {
loadTables(connectionInfo, tablePath, rootParent);
} else if (userObject instanceof IncludeTable) {
loadColumns(connectionInfo, tablePath);
} else {
loadTables(connectionInfo, tablePath, rootParent);
}
} else {
loadDataBase(connectionInfo);
}
} catch (Exception ex) {
JOptionPane.showMessageDialog(Application.getFrame(), ex.getMessage(), "Error loading db schema", JOptionPane.ERROR_MESSAGE);
LOGGER.warn("Error loading db schema", ex);
} finally {
rootParent.getLoadDbSchemaButton().setEnabled(true);
rootParent.getLoadDbSchemaProgress().setVisible(false);
rootParent.unlockToolbarButtons();
}
});
thread.start();
}
Aggregations