Search in sources :

Example 1 with TransferableNode

use of org.apache.cayenne.modeler.dialog.db.load.TransferableNode 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 2 with TransferableNode

use of org.apache.cayenne.modeler.dialog.db.load.TransferableNode 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)

Example 3 with TransferableNode

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

the class DbImportTree method printCatalogs.

private void printCatalogs(Collection<Catalog> catalogs, DbImportTreeNode parent) {
    for (Catalog catalog : catalogs) {
        DbImportTreeNode node = !isTransferable ? new DbImportTreeNode(catalog) : new TransferableNode(catalog);
        if (!"".equals(node.getSimpleNodeName())) {
            if (isTransferable && catalog.getSchemas().isEmpty() && catalog.getIncludeTables().isEmpty() && catalog.getExcludeTables().isEmpty()) {
                printParams(Collections.singletonList(new IncludeTable("Loading...")), node);
            }
            printSchemas(catalog.getSchemas(), node);
            printChildren(catalog, node);
            parent.add(node);
        }
    }
}
Also used : DbImportTreeNode(org.apache.cayenne.modeler.dialog.db.load.DbImportTreeNode) IncludeTable(org.apache.cayenne.dbsync.reverse.dbimport.IncludeTable) TransferableNode(org.apache.cayenne.modeler.dialog.db.load.TransferableNode) Catalog(org.apache.cayenne.dbsync.reverse.dbimport.Catalog)

Example 4 with TransferableNode

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

the class DbImportView method initFormElements.

private void initFormElements() {
    DbImportTreeNode root = new DbImportTreeNode(new ReverseEngineering());
    DbImportTreeNode draggableTreeRoot = new DbImportTreeNode(new ReverseEngineering());
    DbImportTree reverseEngineeringTree = new DbImportTree(root);
    DbImportTree draggableTree = new DbImportTree(new TransferableNode(draggableTreeRoot));
    DbImportModel model = new DbImportModel(root);
    model.setCanBeCleaned(true);
    DbImportModel draggableTreeModel = new DbImportModel(draggableTreeRoot);
    draggableTreeModel.setCanBeCleaned(false);
    draggableTree.setRootVisible(false);
    draggableTree.setShowsRootHandles(true);
    draggableTree.setModel(draggableTreeModel);
    reverseEngineeringTree.setRootVisible(false);
    reverseEngineeringTree.setModel(model);
    reverseEngineeringTree.setShowsRootHandles(true);
    draggableTreePanel = new DraggableTreePanel(projectController, draggableTree, reverseEngineeringTree);
    treeToolbar = new TreeToolbarPanel(projectController, reverseEngineeringTree, draggableTreePanel);
    treePanel = new ReverseEngineeringTreePanel(projectController, reverseEngineeringTree, draggableTree);
    treePanel.setTreeToolbar(treeToolbar);
    model.setDbSchemaTree(draggableTree);
    draggableTreeModel.setDbSchemaTree(draggableTree);
    ((ColorTreeRenderer) draggableTreePanel.getSourceTree().getCellRenderer()).setReverseEngineeringTree(reverseEngineeringTree);
    configPanel = new ReverseEngineeringConfigPanel(projectController, this);
    configPanel.setLayout(new FlowLayout(FlowLayout.LEFT));
    configPanel.setVisible(false);
}
Also used : FlowLayout(java.awt.FlowLayout) ReverseEngineering(org.apache.cayenne.dbsync.reverse.dbimport.ReverseEngineering) DbImportTreeNode(org.apache.cayenne.modeler.dialog.db.load.DbImportTreeNode) TransferableNode(org.apache.cayenne.modeler.dialog.db.load.TransferableNode) ColorTreeRenderer(org.apache.cayenne.modeler.editor.dbimport.tree.ColorTreeRenderer)

Example 5 with TransferableNode

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

the class PrintTablesBiFunction method apply.

@Override
public Void apply(FilterContainer filterContainer, DbImportTreeNode root) {
    DbImportModel model = (DbImportModel) dbImportTree.getModel();
    boolean isTransferable = dbImportTree.isTransferable();
    if (root.getChildCount() != 0) {
        root.removeAllChildren();
    }
    Collection<IncludeTable> includeTables = filterContainer.getIncludeTables();
    for (IncludeTable includeTable : includeTables) {
        DbImportTreeNode node = !isTransferable ? new DbImportTreeNode(includeTable) : new TransferableNode(includeTable);
        if (isTransferable && includeTable.getIncludeColumns().isEmpty() && includeTable.getExcludeColumns().isEmpty()) {
            dbImportTree.printParams(Collections.singletonList(new IncludeColumn("Loading...")), node);
        }
        root.add(node);
        dbImportTree.packColumns(includeTable, node);
    }
    model.reload(root);
    return null;
}
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)6 TransferableNode (org.apache.cayenne.modeler.dialog.db.load.TransferableNode)6 IncludeTable (org.apache.cayenne.dbsync.reverse.dbimport.IncludeTable)4 IncludeColumn (org.apache.cayenne.dbsync.reverse.dbimport.IncludeColumn)2 FlowLayout (java.awt.FlowLayout)1 TreeExpansionEvent (javax.swing.event.TreeExpansionEvent)1 TreeExpansionListener (javax.swing.event.TreeExpansionListener)1 TreePath (javax.swing.tree.TreePath)1 Catalog (org.apache.cayenne.dbsync.reverse.dbimport.Catalog)1 ReverseEngineering (org.apache.cayenne.dbsync.reverse.dbimport.ReverseEngineering)1 Schema (org.apache.cayenne.dbsync.reverse.dbimport.Schema)1 LoadDbSchemaAction (org.apache.cayenne.modeler.action.LoadDbSchemaAction)1 ColorTreeRenderer (org.apache.cayenne.modeler.editor.dbimport.tree.ColorTreeRenderer)1