Search in sources :

Example 31 with DbImportTreeNode

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

Example 32 with DbImportTreeNode

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));
}
Also used : PatternParam(org.apache.cayenne.dbsync.reverse.dbimport.PatternParam) DbImportTreeNode(org.apache.cayenne.modeler.dialog.db.load.DbImportTreeNode) FilterContainer(org.apache.cayenne.dbsync.reverse.dbimport.FilterContainer) ExcludeColumn(org.apache.cayenne.dbsync.reverse.dbimport.ExcludeColumn) ExcludeProcedure(org.apache.cayenne.dbsync.reverse.dbimport.ExcludeProcedure) IncludeColumn(org.apache.cayenne.dbsync.reverse.dbimport.IncludeColumn) IncludeProcedure(org.apache.cayenne.dbsync.reverse.dbimport.IncludeProcedure) ExcludeTable(org.apache.cayenne.dbsync.reverse.dbimport.ExcludeTable)

Example 33 with DbImportTreeNode

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);
    }
}
Also used : DbImportView(org.apache.cayenne.modeler.editor.dbimport.DbImportView) TreePath(javax.swing.tree.TreePath) ReverseEngineering(org.apache.cayenne.dbsync.reverse.dbimport.ReverseEngineering) DbImportTreeNode(org.apache.cayenne.modeler.dialog.db.load.DbImportTreeNode) Schema(org.apache.cayenne.dbsync.reverse.dbimport.Schema) IncludeTable(org.apache.cayenne.dbsync.reverse.dbimport.IncludeTable) Catalog(org.apache.cayenne.dbsync.reverse.dbimport.Catalog)

Example 34 with DbImportTreeNode

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

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