Search in sources :

Example 16 with DbImportTreeNode

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

the class ColorTreeRenderer method getLogicalTreeNode.

private Node<?> getLogicalTreeNode() {
    List<Object> path = new ArrayList<>();
    DbImportTreeNode parent = node;
    while (parent != null) {
        path.add(parent.getUserObject());
        parent = parent.getParent();
    }
    Collections.reverse(path);
    Node<?> logicalParent = null;
    for (Object object : path) {
        logicalParent = toLogicalNode(getObjectType(object), getObjectValue(object), logicalParent);
    }
    return logicalParent;
}
Also used : DbImportTreeNode(org.apache.cayenne.modeler.dialog.db.load.DbImportTreeNode) ArrayList(java.util.ArrayList)

Example 17 with DbImportTreeNode

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

the class PrintColumnsBiFunction method processTable.

private void processTable(IncludeTable tableFilter, DbImportTreeNode root) {
    DbImportModel model = (DbImportModel) dbImportTree.getModel();
    DbImportTreeNode container = dbImportTree.findNodeInParent(root, tableFilter);
    if (container == null) {
        return;
    }
    if (container.getChildCount() != 0) {
        container.removeAllChildren();
    }
    dbImportTree.packColumns(tableFilter, container);
    container.setLoaded(true);
    model.reload(container);
}
Also used : DbImportTreeNode(org.apache.cayenne.modeler.dialog.db.load.DbImportTreeNode)

Example 18 with DbImportTreeNode

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

the class DraggableTreePanel method canBeMoved.

private boolean canBeMoved() {
    DbImportTreeNode selectedElement = sourceTree.getSelectedNode();
    if (selectedElement == null) {
        return false;
    }
    if (selectedElement.isIncludeColumn() || selectedElement.isExcludeColumn()) {
        DbImportTreeNode node = targetTree.findNode(targetTree.getRootNode(), selectedElement.getParent(), 0);
        if (node != null && node.isExcludeTable()) {
            return false;
        }
    }
    Class<?> draggableElementClass = selectedElement.getUserObject().getClass();
    Class<?> reverseEngineeringElementClass;
    if (targetTree.getSelectionPath() != null) {
        selectedElement = targetTree.getSelectedNode();
        DbImportTreeNode parent = selectedElement.getParent();
        if (parent != null) {
            reverseEngineeringElementClass = parent.getUserObject().getClass();
        } else {
            reverseEngineeringElementClass = selectedElement.getUserObject().getClass();
        }
    } else {
        reverseEngineeringElementClass = ReverseEngineering.class;
    }
    List<Class<?>> containsList = insertableLevels.get(reverseEngineeringElementClass);
    return containsList.contains(draggableElementClass);
}
Also used : DbImportTreeNode(org.apache.cayenne.modeler.dialog.db.load.DbImportTreeNode)

Example 19 with DbImportTreeNode

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

the class ColorTreeRenderer method getMask.

private ReverseEngineering getMask() {
    DbImportTreeNode selectedNode = reverseEngineeringTree.getSelectedNode();
    if (selectedNode == null) {
        return null;
    }
    if (selectedNode.isReverseEngineering()) {
        return reverseEngineeringTree.getReverseEngineering();
    }
    ReverseEngineering config = new ReverseEngineering();
    Object configNode = null;
    while (!selectedNode.isReverseEngineering()) {
        configNode = addToMask(configNode, selectedNode);
        selectedNode = selectedNode.getParent();
    }
    return merge(config, configNode);
}
Also used : ReverseEngineering(org.apache.cayenne.dbsync.reverse.dbimport.ReverseEngineering) DbImportTreeNode(org.apache.cayenne.modeler.dialog.db.load.DbImportTreeNode)

Example 20 with DbImportTreeNode

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

the class LoadDbSchemaAction method performAction.

public void performAction(ActionEvent e, TreePath tablePath) {
    final DbImportView rootParent = ((DbImportView) draggableTreePanel.getParent().getParent());
    rootParent.getLoadDbSchemaProgress().setVisible(true);
    rootParent.getLoadDbSchemaButton().setEnabled(false);
    Thread thread = new Thread(() -> {
        LoadDbSchemaAction.this.setEnabled(false);
        rootParent.lockToolbarButtons();
        draggableTreePanel.getMoveButton().setEnabled(false);
        draggableTreePanel.getMoveInvertButton().setEnabled(false);
        try {
            DBConnectionInfo connectionInfo = getConnectionInfo("Load Db Schema");
            if (connectionInfo == null) {
                return;
            }
            if (tablePath != null) {
                Object userObject = ((DbImportTreeNode) tablePath.getLastPathComponent()).getUserObject();
                if (userObject instanceof Catalog) {
                    Catalog catalog = (Catalog) userObject;
                    if (catalog.getSchemas().isEmpty()) {
                        loadTables(connectionInfo, tablePath, rootParent);
                    }
                } else if (userObject instanceof Schema) {
                    loadTables(connectionInfo, tablePath, rootParent);
                } else if (userObject instanceof IncludeTable) {
                    loadColumns(connectionInfo, tablePath);
                } else {
                    loadTables(connectionInfo, tablePath, rootParent);
                }
            } else {
                loadDataBase(connectionInfo);
            }
        } catch (Exception ex) {
            JOptionPane.showMessageDialog(Application.getFrame(), ex.getMessage(), "Error loading db schema", JOptionPane.ERROR_MESSAGE);
            LOGGER.warn("Error loading db schema", ex);
        } finally {
            rootParent.getLoadDbSchemaButton().setEnabled(true);
            rootParent.getLoadDbSchemaProgress().setVisible(false);
            rootParent.unlockToolbarButtons();
        }
    });
    thread.start();
}
Also used : DbImportView(org.apache.cayenne.modeler.editor.dbimport.DbImportView) 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) DBConnectionInfo(org.apache.cayenne.modeler.pref.DBConnectionInfo) Catalog(org.apache.cayenne.dbsync.reverse.dbimport.Catalog) SQLException(java.sql.SQLException)

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