Search in sources :

Example 11 with DbImportTreeNode

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;
}
Also used : DbImportTreeNode(org.apache.cayenne.modeler.dialog.db.load.DbImportTreeNode)

Example 12 with DbImportTreeNode

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;
}
Also used : DbImportTreeNode(org.apache.cayenne.modeler.dialog.db.load.DbImportTreeNode)

Example 13 with DbImportTreeNode

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.")));
    }
}
Also used : ReverseEngineering(org.apache.cayenne.dbsync.reverse.dbimport.ReverseEngineering) DbImportTreeNode(org.apache.cayenne.modeler.dialog.db.load.DbImportTreeNode)

Example 14 with DbImportTreeNode

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);
}
Also used : DeleteNodeAction(org.apache.cayenne.modeler.action.dbimport.DeleteNodeAction) TreePath(javax.swing.tree.TreePath) DbImportTreeNode(org.apache.cayenne.modeler.dialog.db.load.DbImportTreeNode) EditNodeAction(org.apache.cayenne.modeler.action.dbimport.EditNodeAction)

Example 15 with DbImportTreeNode

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;
}
Also used : DbImportTreeNode(org.apache.cayenne.modeler.dialog.db.load.DbImportTreeNode)

Aggregations

DbImportTreeNode (org.apache.cayenne.modeler.dialog.db.load.DbImportTreeNode)34 IncludeTable (org.apache.cayenne.dbsync.reverse.dbimport.IncludeTable)10 ReverseEngineering (org.apache.cayenne.dbsync.reverse.dbimport.ReverseEngineering)10 TreePath (javax.swing.tree.TreePath)9 Catalog (org.apache.cayenne.dbsync.reverse.dbimport.Catalog)7 Schema (org.apache.cayenne.dbsync.reverse.dbimport.Schema)7 TransferableNode (org.apache.cayenne.modeler.dialog.db.load.TransferableNode)7 IncludeColumn (org.apache.cayenne.dbsync.reverse.dbimport.IncludeColumn)5 ExcludeTable (org.apache.cayenne.dbsync.reverse.dbimport.ExcludeTable)3 FilterContainer (org.apache.cayenne.dbsync.reverse.dbimport.FilterContainer)3 PatternParam (org.apache.cayenne.dbsync.reverse.dbimport.PatternParam)3 DbImportView (org.apache.cayenne.modeler.editor.dbimport.DbImportView)3 ArrayList (java.util.ArrayList)2 TreeExpansionEvent (javax.swing.event.TreeExpansionEvent)2 TreeExpansionListener (javax.swing.event.TreeExpansionListener)2 ExcludeColumn (org.apache.cayenne.dbsync.reverse.dbimport.ExcludeColumn)2 LoadDbSchemaAction (org.apache.cayenne.modeler.action.LoadDbSchemaAction)2 FlowLayout (java.awt.FlowLayout)1 MouseAdapter (java.awt.event.MouseAdapter)1 MouseEvent (java.awt.event.MouseEvent)1