Search in sources :

Example 26 with DbImportTreeNode

use of org.apache.cayenne.modeler.dialog.db.load.DbImportTreeNode in project cayenne by apache.

the class TreeToolbarPanel method lockButtons.

void lockButtons() {
    if ((reverseEngineeringTree.getLastSelectedPathComponent() != null) && (!isLabelSelected())) {
        DbImportTreeNode selectedNode = ((DbImportTreeNode) reverseEngineeringTree.getLastSelectedPathComponent());
        DbImportTreeNode parentNode = (DbImportTreeNode) selectedNode.getParent();
        if (parentNode != null) {
            lockButtons(parentNode.getUserObject());
        } else {
            unlockButtons();
        }
    } else {
        changeToolbarButtonsState(true);
        editButton.setEnabled(false);
        deleteButton.setEnabled(false);
    }
    if (reverseEngineeringTree.getSelectionPaths() != null) {
        if (reverseEngineeringTree.getSelectionPaths().length > 1) {
            changeToolbarButtonsState(false);
            deleteButton.setEnabled(true);
        }
    }
}
Also used : DbImportTreeNode(org.apache.cayenne.modeler.dialog.db.load.DbImportTreeNode)

Example 27 with DbImportTreeNode

use of org.apache.cayenne.modeler.dialog.db.load.DbImportTreeNode in project cayenne by apache.

the class DbImportTree method packNextFilter.

private void packNextFilter(FilterContainer filterContainer, DbImportTreeNode root, BiFunction<FilterContainer, DbImportTreeNode, Void> processor) {
    DbImportTreeNode container = findNodeInParent(root, filterContainer);
    if (container != null) {
        container.setLoaded(true);
    } else {
        if (!filterContainer.getIncludeTables().isEmpty()) {
            container = root;
        } else {
            return;
        }
    }
    processor.apply(filterContainer, container);
}
Also used : DbImportTreeNode(org.apache.cayenne.modeler.dialog.db.load.DbImportTreeNode)

Example 28 with DbImportTreeNode

use of org.apache.cayenne.modeler.dialog.db.load.DbImportTreeNode in project cayenne by apache.

the class DbImportTree method update.

public void update(ReverseEngineering reverseEngineering, BiFunction<FilterContainer, DbImportTreeNode, Void> processor) {
    DbImportModel model = (DbImportModel) this.getModel();
    DbImportTreeNode root = (DbImportTreeNode) model.getRoot();
    Collection<Catalog> catalogs = reverseEngineering.getCatalogs();
    if (!catalogs.isEmpty()) {
        catalogs.forEach(catalog -> {
            Collection<Schema> schemas = catalog.getSchemas();
            if (!schemas.isEmpty()) {
                DbImportTreeNode currentRoot = findNodeInParent(root, catalog);
                schemas.forEach(schema -> packNextFilter(schema, currentRoot, processor));
            } else {
                packNextFilter(catalog, root, processor);
            }
        });
    } else if (!reverseEngineering.getSchemas().isEmpty()) {
        reverseEngineering.getSchemas().forEach(schema -> packNextFilter(schema, root, processor));
    } else if (!reverseEngineering.getIncludeTables().isEmpty()) {
        Schema schema = new Schema();
        schema.getIncludeTables().addAll(reverseEngineering.getIncludeTables());
        packNextFilter(schema, root, processor);
    }
}
Also used : TreeExpansionEvent(javax.swing.event.TreeExpansionEvent) Schema(org.apache.cayenne.dbsync.reverse.dbimport.Schema) TreePath(javax.swing.tree.TreePath) TreeNode(javax.swing.tree.TreeNode) Collection(java.util.Collection) BiFunction(java.util.function.BiFunction) FilterContainer(org.apache.cayenne.dbsync.reverse.dbimport.FilterContainer) LoadDbSchemaAction(org.apache.cayenne.modeler.action.LoadDbSchemaAction) JTree(javax.swing.JTree) DbImportTreeNode(org.apache.cayenne.modeler.dialog.db.load.DbImportTreeNode) ArrayList(java.util.ArrayList) IncludeTable(org.apache.cayenne.dbsync.reverse.dbimport.IncludeTable) IncludeColumn(org.apache.cayenne.dbsync.reverse.dbimport.IncludeColumn) PatternParam(org.apache.cayenne.dbsync.reverse.dbimport.PatternParam) TransferableNode(org.apache.cayenne.modeler.dialog.db.load.TransferableNode) ReverseEngineering(org.apache.cayenne.dbsync.reverse.dbimport.ReverseEngineering) ExcludeTable(org.apache.cayenne.dbsync.reverse.dbimport.ExcludeTable) Catalog(org.apache.cayenne.dbsync.reverse.dbimport.Catalog) TreeExpansionListener(javax.swing.event.TreeExpansionListener) Collections(java.util.Collections) Application(org.apache.cayenne.modeler.Application) 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)

Example 29 with DbImportTreeNode

use of org.apache.cayenne.modeler.dialog.db.load.DbImportTreeNode in project cayenne by apache.

the class DbImportTree method translateReverseEngineeringToTree.

public void translateReverseEngineeringToTree(ReverseEngineering reverseEngineering, boolean isTransferable) {
    this.isTransferable = isTransferable;
    this.reverseEngineering = reverseEngineering;
    DbImportModel model = (DbImportModel) this.getModel();
    DbImportTreeNode root = (DbImportTreeNode) model.getRoot();
    root.removeAllChildren();
    root.setUserObject(reverseEngineering);
    printCatalogs(reverseEngineering.getCatalogs(), root);
    printSchemas(reverseEngineering.getSchemas(), root);
    printIncludeTables(reverseEngineering.getIncludeTables(), root);
    printParams(reverseEngineering.getExcludeTables(), root);
    printParams(reverseEngineering.getIncludeColumns(), root);
    printParams(reverseEngineering.getExcludeColumns(), root);
    printParams(reverseEngineering.getIncludeProcedures(), root);
    printParams(reverseEngineering.getExcludeProcedures(), root);
    model.reload();
}
Also used : DbImportTreeNode(org.apache.cayenne.modeler.dialog.db.load.DbImportTreeNode)

Example 30 with DbImportTreeNode

use of org.apache.cayenne.modeler.dialog.db.load.DbImportTreeNode in project cayenne by apache.

the class DbImportTree method printIncludeTables.

private void printIncludeTables(Collection<IncludeTable> collection, DbImportTreeNode parent) {
    for (IncludeTable includeTable : collection) {
        DbImportTreeNode node = !isTransferable ? new DbImportTreeNode(includeTable) : new TransferableNode(includeTable);
        if (!node.getSimpleNodeName().equals("")) {
            if (isTransferable && includeTable.getIncludeColumns().isEmpty() && includeTable.getExcludeColumns().isEmpty()) {
                printParams(Collections.singletonList(new IncludeColumn("Loading...")), node);
            }
            printParams(includeTable.getIncludeColumns(), node);
            printParams(includeTable.getExcludeColumns(), node);
            parent.add(node);
        }
    }
}
Also used : DbImportTreeNode(org.apache.cayenne.modeler.dialog.db.load.DbImportTreeNode) IncludeTable(org.apache.cayenne.dbsync.reverse.dbimport.IncludeTable) IncludeColumn(org.apache.cayenne.dbsync.reverse.dbimport.IncludeColumn) TransferableNode(org.apache.cayenne.modeler.dialog.db.load.TransferableNode)

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