use of org.apache.cayenne.modeler.dialog.db.load.DbImportTreeNode in project cayenne by apache.
the class AddIncludeTableAction method performAction.
@Override
public void performAction(ActionEvent e) {
ReverseEngineering reverseEngineeringOldCopy = prepareElements();
if (reverseEngineeringIsEmpty()) {
tree.getRootNode().removeAllChildren();
}
IncludeTable newTable = new IncludeTable(name);
if (canBeInserted(selectedElement)) {
((FilterContainer) selectedElement.getUserObject()).addIncludeTable(newTable);
selectedElement.add(new DbImportTreeNode(newTable));
updateSelected = true;
} else {
if (parentElement == null) {
parentElement = tree.getRootNode();
}
((FilterContainer) parentElement.getUserObject()).addIncludeTable(newTable);
parentElement.add(new DbImportTreeNode(newTable));
updateSelected = false;
}
completeInserting(reverseEngineeringOldCopy);
}
use of org.apache.cayenne.modeler.dialog.db.load.DbImportTreeNode in project cayenne by apache.
the class AddPatternParamAction method addPatternParamToContainer.
private void addPatternParamToContainer(Class paramClass, Object selectedObject, String name, DbImportTreeNode node) {
FilterContainer container = (FilterContainer) selectedObject;
PatternParam element = null;
if (paramClass == ExcludeTable.class) {
element = new ExcludeTable(name);
container.addExcludeTable((ExcludeTable) element);
} else if (paramClass == IncludeColumn.class) {
element = new IncludeColumn(name);
container.addIncludeColumn((IncludeColumn) element);
} else if (paramClass == ExcludeColumn.class) {
element = new ExcludeColumn(name);
container.addExcludeColumn((ExcludeColumn) element);
} else if (paramClass == IncludeProcedure.class) {
element = new IncludeProcedure(name);
container.addIncludeProcedure((IncludeProcedure) element);
} else if (paramClass == ExcludeProcedure.class) {
element = new ExcludeProcedure(name);
container.addExcludeProcedure((ExcludeProcedure) element);
}
node.add(new DbImportTreeNode(element));
}
use of org.apache.cayenne.modeler.dialog.db.load.DbImportTreeNode in project cayenne by apache.
the class DeleteNodeAction method performAction.
@Override
public void performAction(ActionEvent e) {
tree.stopEditing();
final TreePath[] paths = tree.getSelectionPaths();
final DbImportView rootParent = ((DbImportView) panel.getParent().getParent());
rootParent.getLoadDbSchemaButton().setEnabled(false);
rootParent.getReverseEngineeringProgress().setVisible(true);
if (paths != null) {
ReverseEngineering reverseEngineeringOldCopy = new ReverseEngineering(tree.getReverseEngineering());
rootParent.lockToolbarButtons();
for (TreePath path : paths) {
selectedElement = (DbImportTreeNode) path.getLastPathComponent();
parentElement = (DbImportTreeNode) selectedElement.getParent();
if (parentElement != null) {
Object parentUserObject = parentElement.getUserObject();
if (parentUserObject instanceof ReverseEngineering) {
ReverseEngineering reverseEngineering = (ReverseEngineering) parentUserObject;
deleteChilds(reverseEngineering);
} else if (parentUserObject instanceof Catalog) {
Catalog catalog = (Catalog) parentUserObject;
deleteChilds(catalog);
} else if (parentUserObject instanceof Schema) {
Schema schema = (Schema) parentUserObject;
deleteChilds(schema);
} else if (parentUserObject instanceof IncludeTable) {
IncludeTable includeTable = (IncludeTable) parentUserObject;
deleteChilds(includeTable);
}
}
}
if (paths.length > 1) {
getProjectController().setDirty(true);
ArrayList<DbImportTreeNode> expandList = tree.getTreeExpandList();
tree.translateReverseEngineeringToTree(tree.getReverseEngineering(), false);
tree.expandTree(expandList);
} else {
updateParentChilds();
}
putReverseEngineeringToUndoManager(reverseEngineeringOldCopy);
rootParent.getLoadDbSchemaButton().setEnabled(true);
rootParent.getReverseEngineeringProgress().setVisible(false);
}
}
use of org.apache.cayenne.modeler.dialog.db.load.DbImportTreeNode in project cayenne by apache.
the class MoveImportNodeAction method canInsert.
private boolean canInsert(TreePath path, DbImportTreeNode foundNode) {
DbImportTreeNode sourceElement = (DbImportTreeNode) path.getLastPathComponent();
DbImportTreeNode selectedElement;
if (foundNode == null) {
if (targetTree.getSelectionPath() != null) {
DbImportTreeNode node = targetTree.getSelectedNode();
if ((node.getUserObject().getClass() == Catalog.class) || (node.getUserObject().getClass() == Schema.class) || (node.getUserObject().getClass() == ReverseEngineering.class)) {
selectedElement = targetTree.getSelectedNode();
} else {
selectedElement = (DbImportTreeNode) targetTree.getSelectionPath().getParentPath().getLastPathComponent();
}
} else {
selectedElement = targetTree.getRootNode();
}
} else {
selectedElement = foundNode;
}
if ((nodeClassesIsSameTypes(sourceElement, selectedElement)) && (sourceElement.getSimpleNodeName().equals(selectedElement.getSimpleNodeName()))) {
return false;
}
int childCount = selectedElement.getChildCount();
for (int i = 0; i < childCount; i++) {
DbImportTreeNode child = (DbImportTreeNode) selectedElement.getChildAt(i);
if ((nodeClassesIsSameTypes(sourceElement, child)) && (sourceElement.getSimpleNodeName().equals(child.getSimpleNodeName()))) {
return false;
}
}
return true;
}
Aggregations