Search in sources :

Example 21 with DbImportTreeNode

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

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

the class DbImportView method initFromModel.

public void initFromModel() {
    DataMap map = projectController.getCurrentDataMap();
    treePanel.getReverseEngineeringTree().stopEditing();
    if (map != null) {
        initFromModel = true;
        treeToolbar.unlockButtons();
        ReverseEngineering reverseEngineering = DbImportView.this.projectController.getApplication().getMetaData().get(map, ReverseEngineering.class);
        if (reverseEngineering == null) {
            // create config with default values
            reverseEngineering = new ReverseEngineering();
            DbImportView.this.projectController.getApplication().getMetaData().add(map, reverseEngineering);
        }
        configPanel.fillCheckboxes(reverseEngineering);
        configPanel.initializeTextFields(reverseEngineering);
        configPanel.initStrategy(reverseEngineering);
        String[] tableTypes = reverseEngineering.getTableTypes();
        if (tableTypes.length != 0) {
            configPanel.getTableTypes().setText(String.join(",", tableTypes));
        } else {
            configPanel.getTableTypes().setText("TABLE, VIEW");
            configPanel.getTableTypes().updateModel();
        }
        treePanel.updateTree();
        DbImportTreeNode root = draggableTreePanel.getSourceTree().getRootNode();
        root.removeAllChildren();
        draggableTreePanel.updateTree(projectController.getCurrentDataMap());
        draggableTreePanel.getMoveButton().setEnabled(false);
        draggableTreePanel.getMoveInvertButton().setEnabled(false);
    }
    initFromModel = false;
}
Also used : ReverseEngineering(org.apache.cayenne.dbsync.reverse.dbimport.ReverseEngineering) DbImportTreeNode(org.apache.cayenne.modeler.dialog.db.load.DbImportTreeNode) DataMap(org.apache.cayenne.map.DataMap)

Example 23 with DbImportTreeNode

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

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

Example 25 with DbImportTreeNode

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

the class ReverseEngineeringTreePanel method initListeners.

private void initListeners() {
    reverseEngineeringTree.addTreeSelectionListener(e -> treeToolbar.lockButtons());
    reverseEngineeringTree.addMouseListener(new MouseAdapter() {

        @Override
        public void mouseClicked(MouseEvent e) {
            if (reverseEngineeringTree.getRowForLocation(e.getX(), e.getY()) == -1) {
                reverseEngineeringTree.setSelectionRow(-1);
            }
            if (SwingUtilities.isRightMouseButton(e)) {
                if (reverseEngineeringTree.isEditing()) {
                    return;
                }
                int row = reverseEngineeringTree.getClosestRowForLocation(e.getX(), e.getY());
                reverseEngineeringTree.setSelectionRow(row);
                DefaultPopUpMenu popupMenu;
                DbImportTreeNode selectedElement;
                if (reverseEngineeringTree.getSelectionPath() != null) {
                    selectedElement = reverseEngineeringTree.getSelectedNode();
                    popupMenu = popups.get(selectedElement.getUserObject().getClass());
                } else {
                    selectedElement = reverseEngineeringTree.getRootNode();
                    popupMenu = popups.get(ReverseEngineering.class);
                }
                if (popupMenu != null) {
                    popupMenu.setProjectController(projectController);
                    popupMenu.setSelectedElement(selectedElement);
                    popupMenu.setParentElement(selectedElement.getParent());
                    popupMenu.setTree(reverseEngineeringTree);
                    popupMenu.show(e.getComponent(), e.getX(), e.getY());
                }
            } else if (reverseEngineeringTree.getSelectionPath() != null) {
                DbImportTreeNode selectedNode = reverseEngineeringTree.getSelectedNode();
                if (selectedNode.isExcludeColumn() || selectedNode.isIncludeColumn()) {
                    DbImportTreeNode expandNode = selectedNode.getParent();
                    DbImportTreeNode parentPath = dbSchemaTree.findNode(dbSchemaTree.getRootNode(), expandNode, 0);
                    if (parentPath != null) {
                        dbSchemaTree.expandPath(new TreePath((parentPath).getPath()));
                        scrollToNode(dbSchemaTree, parentPath);
                    }
                } else {
                    DbImportTreeNode findNode = dbSchemaTree.findNode(dbSchemaTree.getRootNode(), selectedNode, 0);
                    if (findNode != null) {
                        dbSchemaTree.expandPath(new TreePath(findNode.getParent().getPath()));
                        scrollToNode(dbSchemaTree, findNode);
                    }
                }
            }
        }
    });
}
Also used : MouseEvent(java.awt.event.MouseEvent) TreePath(javax.swing.tree.TreePath) DbImportTreeNode(org.apache.cayenne.modeler.dialog.db.load.DbImportTreeNode) MouseAdapter(java.awt.event.MouseAdapter) DefaultPopUpMenu(org.apache.cayenne.modeler.dialog.db.load.DefaultPopUpMenu)

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