Search in sources :

Example 1 with LoadDbSchemaAction

use of org.apache.cayenne.modeler.action.LoadDbSchemaAction 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 LoadDbSchemaAction

use of org.apache.cayenne.modeler.action.LoadDbSchemaAction in project cayenne by apache.

the class DbImportView method buildForm.

private void buildForm() {
    FormLayout buttonPanelLayout = new FormLayout(BUTTON_PANEL_LAYOUT);
    DefaultFormBuilder buttonBuilder = new DefaultFormBuilder(buttonPanelLayout);
    buttonBuilder.append(draggableTreePanel.getMoveButton());
    buttonBuilder.append(draggableTreePanel.getMoveInvertButton());
    FormLayout layout = new FormLayout(MAIN_LAYOUT);
    DefaultFormBuilder builder = new DefaultFormBuilder(layout);
    builder.append(treeToolbar, ALL_LINE_SPAN);
    FormLayout headerLayout = new FormLayout(HEADER_LAYOUT);
    DefaultFormBuilder reverseEngineeringHeaderBuilder = new DefaultFormBuilder(headerLayout);
    JLabel importLabel = new JLabel("Database Import Configuration");
    importLabel.setBorder(new EmptyBorder(0, 5, 0, 0));
    reverseEngineeringHeaderBuilder.append(importLabel);
    builder.append(reverseEngineeringHeaderBuilder.getPanel());
    DefaultFormBuilder databaseHeaderBuilder = new DefaultFormBuilder(headerLayout);
    JLabel schemaLabel = new JLabel("Database Schema");
    schemaLabel.setBorder(new EmptyBorder(0, 5, 0, 0));
    databaseHeaderBuilder.append(schemaLabel);
    LoadDbSchemaAction loadDbSchemaAction = projectController.getApplication().getActionManager().getAction(LoadDbSchemaAction.class);
    loadDbSchemaAction.setDraggableTreePanel(draggableTreePanel);
    loadDbSchemaButton = (CayenneAction.CayenneToolbarButton) loadDbSchemaAction.buildButton(0);
    loadDbSchemaButton.setShowingText(false);
    loadDbSchemaButton.setText("Refresh DB Schema");
    treeToolbar.add(loadDbSchemaButton);
    ReverseEngineeringAction reverseEngineeringAction = projectController.getApplication().getActionManager().getAction(ReverseEngineeringAction.class);
    reverseEngineeringAction.setView(this);
    CayenneAction.CayenneToolbarButton reverseEngineeringButton = (CayenneAction.CayenneToolbarButton) reverseEngineeringAction.buildButton(0);
    reverseEngineeringButton.setShowingText(true);
    reverseEngineeringButton.setText("Run Import");
    JPanel reverseEngineeringButtonPanel = new JPanel();
    reverseEngineeringButtonPanel.setLayout(new FlowLayout(FlowLayout.RIGHT));
    reverseEngineeringButtonPanel.add(reverseEngineeringButton);
    treeToolbar.addSeparator();
    treeToolbar.add(reverseEngineeringButtonPanel);
    builder.append("");
    builder.append(databaseHeaderBuilder.getPanel());
    builder.append(treePanel);
    builder.append(buttonBuilder.getPanel());
    builder.append(draggableTreePanel);
    loadDbSchemaProgress = new JProgressBar();
    reverseEngineeringProgress = new JProgressBar();
    loadDbSchemaProgress.setIndeterminate(true);
    loadDbSchemaProgress.setVisible(false);
    reverseEngineeringProgress.setIndeterminate(true);
    reverseEngineeringProgress.setVisible(false);
    FormLayout progressLayout = new FormLayout(PROGRESS_PANEL_LAYOUT, "fill:10dlu");
    DefaultFormBuilder progressBarBuilder = new DefaultFormBuilder(progressLayout);
    progressBarBuilder.append(reverseEngineeringProgress);
    progressBarBuilder.append(loadDbSchemaProgress);
    builder.append(progressBarBuilder.getPanel(), ALL_LINE_SPAN);
    createAdvancedOptionsHiderPanel(builder);
    builder.append(configPanel, ALL_LINE_SPAN);
    this.setLayout(new BorderLayout());
    add(builder.getPanel(), BorderLayout.CENTER);
}
Also used : FormLayout(com.jgoodies.forms.layout.FormLayout) JPanel(javax.swing.JPanel) FlowLayout(java.awt.FlowLayout) LoadDbSchemaAction(org.apache.cayenne.modeler.action.LoadDbSchemaAction) JProgressBar(javax.swing.JProgressBar) JLabel(javax.swing.JLabel) CayenneAction(org.apache.cayenne.modeler.util.CayenneAction) ReverseEngineeringAction(org.apache.cayenne.modeler.action.ReverseEngineeringAction) BorderLayout(java.awt.BorderLayout) DefaultFormBuilder(com.jgoodies.forms.builder.DefaultFormBuilder) EmptyBorder(javax.swing.border.EmptyBorder)

Aggregations

LoadDbSchemaAction (org.apache.cayenne.modeler.action.LoadDbSchemaAction)2 DefaultFormBuilder (com.jgoodies.forms.builder.DefaultFormBuilder)1 FormLayout (com.jgoodies.forms.layout.FormLayout)1 BorderLayout (java.awt.BorderLayout)1 FlowLayout (java.awt.FlowLayout)1 JLabel (javax.swing.JLabel)1 JPanel (javax.swing.JPanel)1 JProgressBar (javax.swing.JProgressBar)1 EmptyBorder (javax.swing.border.EmptyBorder)1 TreeExpansionEvent (javax.swing.event.TreeExpansionEvent)1 TreeExpansionListener (javax.swing.event.TreeExpansionListener)1 TreePath (javax.swing.tree.TreePath)1 ReverseEngineeringAction (org.apache.cayenne.modeler.action.ReverseEngineeringAction)1 DbImportTreeNode (org.apache.cayenne.modeler.dialog.db.load.DbImportTreeNode)1 TransferableNode (org.apache.cayenne.modeler.dialog.db.load.TransferableNode)1 CayenneAction (org.apache.cayenne.modeler.util.CayenneAction)1