use of org.apache.cayenne.modeler.dialog.db.load.DbImportTreeNode in project cayenne by apache.
the class DbImportTree method findNode.
public DbImportTreeNode findNode(DbImportTreeNode rootNode, DbImportTreeNode movedNode, int depth) {
String parentName = movedNode.getSimpleNodeName();
if ((rootNode.parentsIsEqual(movedNode)) && (rootNode.getSimpleNodeName().equals(parentName))) {
return rootNode;
}
for (int i = 0; i < rootNode.getChildCount(); i++) {
DbImportTreeNode childNode = (DbImportTreeNode) rootNode.getChildAt(i);
DbImportTreeNode node = findNode(childNode, movedNode, depth++);
if (node != null) {
return node;
}
}
return null;
}
use of org.apache.cayenne.modeler.dialog.db.load.DbImportTreeNode in project cayenne by apache.
the class DbImportTree method findNodeByParentsChain.
public DbImportTreeNode findNodeByParentsChain(DbImportTreeNode rootNode, DbImportTreeNode movedNode, int depth) {
String parentName = movedNode.getParent().getSimpleNodeName();
if (rootNode.parentsIsEqual(movedNode.getParent()) && rootNode.getSimpleNodeName().equals(parentName) && (rootNode.isCatalog() || rootNode.isSchema() || rootNode.isIncludeTable())) {
return rootNode;
}
for (int i = 0; i < rootNode.getChildCount(); i++) {
DbImportTreeNode childNode = (DbImportTreeNode) rootNode.getChildAt(i);
DbImportTreeNode node = findNodeByParentsChain(childNode, movedNode, depth++);
if (node != null) {
return node;
}
}
return null;
}
use of org.apache.cayenne.modeler.dialog.db.load.DbImportTreeNode in project cayenne by apache.
the class DbImportModel method preprocessTree.
private void preprocessTree() {
DbImportTreeNode rootNode = (DbImportTreeNode) getRoot();
if (rootNode.getChildCount() == 0) {
ReverseEngineering reverseEngineering = ((ReverseEngineering) rootNode.getUserObject());
if (canBeCleaned) {
clearReverseEngineering(reverseEngineering);
}
rootNode.add(new DbImportTreeNode(("Configuration is empty.")));
}
}
use of org.apache.cayenne.modeler.dialog.db.load.DbImportTreeNode in project cayenne by apache.
the class DbImportTreeCellEditor method cancelCellEditing.
@Override
public void cancelCellEditing() {
if (tree.getSelectionPath() == null) {
return;
}
if (!Util.isEmptyString(super.getCellEditorValue().toString()) && !insertableNodeExist() && (isValidReverseEngineering())) {
EditNodeAction action = projectController.getApplication().getActionManager().getAction(EditNodeAction.class);
action.setActionName(super.getCellEditorValue().toString());
action.actionPerformed(null);
} else {
DbImportTreeNode selectedNode = (DbImportTreeNode) tree.getSelectionPath().getLastPathComponent();
if (Util.isEmptyString(selectedNode.getSimpleNodeName()) || (insertableNodeExist())) {
DeleteNodeAction action = projectController.getApplication().getActionManager().getAction(DeleteNodeAction.class);
TreePath parentPath = tree.getSelectionPath().getParentPath();
action.actionPerformed(null);
tree.setSelectionPath(parentPath);
} else {
tree.startEditingAtPath(tree.getSelectionPath());
}
}
DbImportTreeNode selectedNode = (DbImportTreeNode) tree.getSelectionPath().getLastPathComponent();
((DbImportModel) tree.getModel()).reload(selectedNode);
}
use of org.apache.cayenne.modeler.dialog.db.load.DbImportTreeNode in project cayenne by apache.
the class DbImportTreeCellEditor method insertableNodeExist.
private boolean insertableNodeExist() {
DbImportTreeNode selectedElement;
if (tree.getSelectionPath() == null) {
selectedElement = (DbImportTreeNode) tree.getModel().getRoot();
} else {
selectedElement = (DbImportTreeNode) tree.getSelectionPath().getLastPathComponent();
}
int childCount = selectedElement.getParent().getChildCount();
for (int i = 0; i < childCount; i++) {
if (equalNodes(i, (DbImportTreeNode) selectedElement.getParent(), selectedElement)) {
if (selectedElement.getParent().getChildAt(i) != selectedElement) {
return true;
}
}
}
return false;
}
Aggregations