use of org.apache.cayenne.modeler.dialog.db.load.DbImportTreeNode in project cayenne by apache.
the class AddSchemaAction method performAction.
@Override
public void performAction(ActionEvent e) {
ReverseEngineering reverseEngineeringOldCopy = prepareElements();
Schema newSchema = new Schema(name);
if (canBeInserted(selectedElement)) {
((SchemaContainer) selectedElement.getUserObject()).addSchema(newSchema);
selectedElement.add(new DbImportTreeNode(newSchema));
updateSelected = true;
} else if (canInsert()) {
if (parentElement.isReverseEngineering()) {
((ReverseEngineering) parentElement.getUserObject()).addSchema(newSchema);
} else {
((Catalog) parentElement.getUserObject()).addSchema(newSchema);
}
parentElement.add(new DbImportTreeNode(newSchema));
updateSelected = false;
}
completeInserting(reverseEngineeringOldCopy);
}
use of org.apache.cayenne.modeler.dialog.db.load.DbImportTreeNode in project cayenne by apache.
the class TreeManipulationAction method updateAfterInsert.
void updateAfterInsert() {
updateModel(updateSelected);
if (!movedFromDbSchema) {
if (updateSelected) {
tree.startEditingAtPath(new TreePath(((DbImportTreeNode) selectedElement.getLastChild()).getPath()));
} else {
tree.startEditingAtPath(new TreePath(((DbImportTreeNode) parentElement.getLastChild()).getPath()));
}
}
resetActionFlags();
}
use of org.apache.cayenne.modeler.dialog.db.load.DbImportTreeNode in project cayenne by apache.
the class MoveImportNodeAction method performAction.
@Override
public void performAction(ActionEvent e) {
TreePath[] paths = sourceTree.getSelectionPaths();
TreeManipulationAction action = null;
String insertableName = EMPTY_NAME;
DbImportView rootParent = (DbImportView) panel.getParent().getParent();
rootParent.getReverseEngineeringProgress().setVisible(true);
if (paths != null) {
boolean isChanged = false;
ReverseEngineering reverseEngineeringOldCopy = new ReverseEngineering(targetTree.getReverseEngineering());
try {
for (TreePath path : paths) {
DbImportTreeNode selectedElement = (DbImportTreeNode) path.getLastPathComponent();
DbImportTreeNode previousNode;
DbImportTreeNode foundNode = targetTree.findNodeByParentsChain(targetTree.getRootNode(), selectedElement, 0);
// If parent nodes from db schema doesn't exist, create it
if (foundNode == null) {
for (int i = selectedElement.getParents().size() - 2; i >= 0; i--) {
DbImportTreeNode insertedNode = selectedElement.getParents().get(i);
previousNode = targetTree.findNodeByParentsChain(targetTree.getRootNode(), insertedNode, 0);
if (previousNode == null) {
previousNode = targetTree.getRootNode();
}
TreeManipulationAction manipulationAction = panel.getActionByNodeType(insertedNode.getUserObject().getClass());
if (canInsert(new TreePath(insertedNode.getPath()), previousNode)) {
manipulationAction.setFoundNode(previousNode);
manipulationAction.setInsertableNodeName(insertedNode.getSimpleNodeName());
manipulationAction.setTree(targetTree);
manipulationAction.setMovedFromDbSchema(true);
manipulationAction.actionPerformed(e);
manipulationAction.setFoundNode(null);
manipulationAction.setMultipleAction(false);
}
}
}
// Again find node where we insert our node
foundNode = targetTree.findNodeByParentsChain(targetTree.getRootNode(), selectedElement, 0);
if (!moveInverted) {
action = panel.getActionByNodeType(selectedElement.getUserObject().getClass());
} else {
action = panel.getActionByNodeType(classMap.get(selectedElement.getUserObject().getClass()));
}
if (action != null) {
if (paths.length > 1) {
action.setMultipleAction(true);
} else {
action.setMultipleAction(false);
}
if (canInsert(path, foundNode)) {
insertableName = selectedElement.getSimpleNodeName();
action.setFoundNode(foundNode);
action.setInsertableNodeName(Matcher.quoteReplacement(insertableName));
action.setTree(targetTree);
action.setMovedFromDbSchema(true);
action.actionPerformed(e);
action.setFoundNode(null);
action.resetActionFlags();
isChanged = true;
sourceTree.setSelectionRow(-1);
panel.getMoveButton().setEnabled(false);
panel.getMoveInvertButton().setEnabled(false);
}
}
}
if ((paths.length > 1) && (targetTree.getSelectionPath() != null)) {
getProjectController().setDirty(true);
ArrayList<DbImportTreeNode> expandList = targetTree.getTreeExpandList();
targetTree.translateReverseEngineeringToTree(targetTree.getReverseEngineering(), false);
targetTree.expandTree(expandList);
}
if ((isChanged) && (!insertableName.equals(EMPTY_NAME))) {
ReverseEngineering reverseEngineeringNewCopy = new ReverseEngineering(targetTree.getReverseEngineering());
DbImportTreeUndoableEdit undoableEdit = new DbImportTreeUndoableEdit(reverseEngineeringOldCopy, reverseEngineeringNewCopy, targetTree, getProjectController());
getProjectController().getApplication().getUndoManager().addEdit(undoableEdit);
}
} finally {
rootParent.getReverseEngineeringProgress().setVisible(false);
if (action != null) {
action.resetActionFlags();
}
}
}
}
use of org.apache.cayenne.modeler.dialog.db.load.DbImportTreeNode in project cayenne by apache.
the class AddCatalogAction method performAction.
@Override
public void performAction(ActionEvent e) {
ReverseEngineering reverseEngineeringOld = prepareElements();
Catalog newCatalog = new Catalog(name);
if (canBeInserted(selectedElement)) {
((ReverseEngineering) selectedElement.getUserObject()).addCatalog(newCatalog);
selectedElement.add(new DbImportTreeNode(newCatalog));
updateSelected = true;
} else if (canInsert()) {
((ReverseEngineering) parentElement.getUserObject()).addCatalog(newCatalog);
parentElement.add(new DbImportTreeNode(newCatalog));
updateSelected = false;
}
completeInserting(reverseEngineeringOld);
}
use of org.apache.cayenne.modeler.dialog.db.load.DbImportTreeNode in project cayenne by apache.
the class AddPatternParamAction method addPatternParamToIncludeTable.
private void addPatternParamToIncludeTable(Class paramClass, Object selectedObject, String name, DbImportTreeNode node) {
IncludeTable includeTable = (IncludeTable) selectedObject;
PatternParam element = null;
if (paramClass == IncludeColumn.class) {
element = new IncludeColumn(name);
includeTable.addIncludeColumn((IncludeColumn) element);
} else if (paramClass == ExcludeColumn.class) {
element = new ExcludeColumn(name);
includeTable.addExcludeColumn((ExcludeColumn) element);
}
node.add(new DbImportTreeNode(element));
}
Aggregations