Search in sources :

Example 6 with DbImportTreeNode

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

the class DbImportTree method findNodeInParent.

DbImportTreeNode findNodeInParent(DbImportTreeNode parent, Object object) {
    for (int i = 0; i < parent.getChildCount(); i++) {
        DbImportTreeNode node = (DbImportTreeNode) parent.getChildAt(i);
        Object userObject = node.getUserObject();
        if (object instanceof Catalog) {
            Catalog catalog = (Catalog) object;
            if (!(userObject instanceof Catalog)) {
                continue;
            }
            Catalog currentCatalog = (Catalog) userObject;
            if (currentCatalog.getName().equals(catalog.getName())) {
                return node;
            }
        }
        if (object instanceof Schema) {
            Schema schema = (Schema) object;
            if (!(userObject instanceof Schema)) {
                continue;
            }
            Schema currentSchema = (Schema) userObject;
            if (currentSchema.getName().equals(schema.getName())) {
                return node;
            }
        }
        if (object instanceof IncludeTable) {
            IncludeTable table = (IncludeTable) object;
            if (!(userObject instanceof IncludeTable)) {
                continue;
            }
            IncludeTable currentTable = (IncludeTable) userObject;
            if (currentTable.getPattern().equals(table.getPattern())) {
                return node;
            }
        }
        if (object instanceof ExcludeTable) {
            ExcludeTable table = (ExcludeTable) object;
            if (!(userObject instanceof ExcludeTable)) {
                continue;
            }
            ExcludeTable currentTable = (ExcludeTable) userObject;
            if (currentTable.getPattern().equals(table.getPattern())) {
                return node;
            }
        }
    }
    return null;
}
Also used : 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) ExcludeTable(org.apache.cayenne.dbsync.reverse.dbimport.ExcludeTable)

Example 7 with DbImportTreeNode

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

the class DbImportTree method expandBeginningWithNode.

private void expandBeginningWithNode(DbImportTreeNode rootNode, ArrayList<DbImportTreeNode> list) {
    for (int i = 0; i < rootNode.getChildCount(); i++) {
        DbImportTreeNode childNode = (DbImportTreeNode) rootNode.getChildAt(i);
        list.forEach((element) -> {
            if (element.equals(childNode)) {
                this.expandPath(new TreePath(childNode.getPath()));
            }
        });
        if (childNode.getChildCount() > 0) {
            expandBeginningWithNode(childNode, list);
        }
    }
}
Also used : TreePath(javax.swing.tree.TreePath) DbImportTreeNode(org.apache.cayenne.modeler.dialog.db.load.DbImportTreeNode)

Example 8 with DbImportTreeNode

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

the class DbImportTree method createTreeExpandListener.

private void createTreeExpandListener() {
    TreeExpansionListener treeExpansionListener = new TreeExpansionListener() {

        @Override
        public void treeExpanded(TreeExpansionEvent event) {
            TreePath path = event.getPath();
            Object lastPathComponent = path.getLastPathComponent();
            if (!(lastPathComponent instanceof TransferableNode)) {
                return;
            }
            DbImportTreeNode node = (DbImportTreeNode) lastPathComponent;
            if ((node.isIncludeTable() || node.isSchema() || node.isCatalog()) && !node.isLoaded()) {
                // reload tables and columns action.
                LoadDbSchemaAction action = Application.getInstance().getActionManager().getAction(LoadDbSchemaAction.class);
                action.performAction(null, path);
            }
        }

        @Override
        public void treeCollapsed(TreeExpansionEvent event) {
        }
    };
    this.addTreeExpansionListener(treeExpansionListener);
}
Also used : TreeExpansionListener(javax.swing.event.TreeExpansionListener) TreePath(javax.swing.tree.TreePath) DbImportTreeNode(org.apache.cayenne.modeler.dialog.db.load.DbImportTreeNode) LoadDbSchemaAction(org.apache.cayenne.modeler.action.LoadDbSchemaAction) TransferableNode(org.apache.cayenne.modeler.dialog.db.load.TransferableNode) TreeExpansionEvent(javax.swing.event.TreeExpansionEvent)

Example 9 with DbImportTreeNode

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

the class DbImportTree method createTreeExpandList.

// Create list of expanded elements
private ArrayList<DbImportTreeNode> createTreeExpandList(DbImportTreeNode rootNode, ArrayList<DbImportTreeNode> resultList) {
    for (int i = 0; i < rootNode.getChildCount(); i++) {
        DbImportTreeNode childNode = (DbImportTreeNode) rootNode.getChildAt(i);
        TreePath childPath = new TreePath(childNode.getPath());
        if (isExpanded(childPath)) {
            resultList.add(childNode);
        }
        if (childNode.getChildCount() > 0) {
            createTreeExpandList(childNode, resultList);
        }
    }
    return resultList;
}
Also used : TreePath(javax.swing.tree.TreePath) DbImportTreeNode(org.apache.cayenne.modeler.dialog.db.load.DbImportTreeNode)

Example 10 with DbImportTreeNode

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

the class DbImportTree method printSchemas.

private void printSchemas(Collection<Schema> schemas, DbImportTreeNode parent) {
    for (Schema schema : schemas) {
        DbImportTreeNode node = !isTransferable ? new DbImportTreeNode(schema) : new TransferableNode(schema);
        if (!"".equals(node.getSimpleNodeName())) {
            if (isTransferable && schema.getIncludeTables().isEmpty() && schema.getExcludeTables().isEmpty()) {
                printParams(Collections.singletonList(new IncludeTable("Loading...")), node);
            }
            printChildren(schema, node);
            parent.add(node);
        }
    }
}
Also used : 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) 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