Search in sources :

Example 1 with MultiColumnBrowser

use of org.apache.cayenne.modeler.util.MultiColumnBrowser in project cayenne by apache.

the class SQLTemplatePrefetchTab method createSelectorPanel.

protected JPanel createSelectorPanel() {
    browser = new MultiColumnBrowser();
    browser.setPreferredColumnSize(BROWSER_CELL_DIM);
    browser.setDefaultRenderer();
    JPanel panel = new JPanel(new BorderLayout());
    panel.add(createToolbar(), BorderLayout.NORTH);
    panel.add(new JScrollPane(browser, JScrollPane.VERTICAL_SCROLLBAR_NEVER, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED), BorderLayout.CENTER);
    // setting minimal size, otherwise scrolling looks awful, because of
    // VERTICAL_SCROLLBAR_NEVER strategy
    panel.setMinimumSize(panel.getPreferredSize());
    return panel;
}
Also used : JScrollPane(javax.swing.JScrollPane) JPanel(javax.swing.JPanel) MultiColumnBrowser(org.apache.cayenne.modeler.util.MultiColumnBrowser) BorderLayout(java.awt.BorderLayout)

Example 2 with MultiColumnBrowser

use of org.apache.cayenne.modeler.util.MultiColumnBrowser in project cayenne by apache.

the class ObjRelationshipInfo method createRelationship.

/**
 * Creates a new relationship connecting currently selected source entity
 * with ObjRelationship target entity. User is allowed to edit the
 * relationship, change its name, and create joins.
 */
protected void createRelationship() {
    DbRelationship dbRel = getLastRelationship();
    DbEntity source = dbRel != null ? dbRel.getTargetEntity() : null;
    DbRelationshipTarget targetModel = new DbRelationshipTarget(mediator, getStartEntity(), source);
    targetModel.startupAction();
    if (!targetModel.isSavePressed()) {
        return;
    }
    DbRelationship dbRelationship = new DbRelationship();
    dbRelationship.setSourceEntity(targetModel.getSource());
    dbRelationship.setTargetEntityName(targetModel.getTarget());
    dbRelationship.setToMany(targetModel.isToMany());
    dbRelationship.setName(createNamingStrategy(NameGeneratorPreferences.getInstance().getLastUsedStrategies().get(0)).relationshipName(dbRelationship));
    targetModel.getSource().addRelationship(dbRelationship);
    // TODO: creating relationship outside of ResolveDbRelationshipDialog
    // confuses it to send incorrect event - CHANGE instead of ADD
    ResolveDbRelationshipDialog dialog = new ResolveDbRelationshipDialog(dbRelationship);
    dialog.setVisible(true);
    if (dialog.isCancelPressed()) {
        targetModel.getSource().removeRelationship(dbRelationship.getName());
    } else {
        MultiColumnBrowser pathBrowser = getPathBrowser();
        Object[] oldPath = targetModel.isSource1Selected() ? new Object[] { getStartEntity() } : pathBrowser.getSelectionPath().getPath();
        /**
         * Update the view
         */
        EntityTreeModel treeModel = (EntityTreeModel) pathBrowser.getModel();
        treeModel.invalidate();
        pathBrowser.setSelectionPath(new TreePath(new Object[] { getStartEntity() }));
        pathBrowser.repaint();
        Object[] path = new Object[oldPath.length + 1];
        System.arraycopy(oldPath, 0, path, 0, path.length - 1);
        path[path.length - 1] = dbRelationship;
        pathBrowser.setSelectionPath(new TreePath(path));
    }
    dialog.dispose();
}
Also used : ResolveDbRelationshipDialog(org.apache.cayenne.modeler.dialog.ResolveDbRelationshipDialog) MultiColumnBrowser(org.apache.cayenne.modeler.util.MultiColumnBrowser) DbEntity(org.apache.cayenne.map.DbEntity) TreePath(javax.swing.tree.TreePath) EntityTreeModel(org.apache.cayenne.modeler.util.EntityTreeModel) DbRelationship(org.apache.cayenne.map.DbRelationship)

Example 3 with MultiColumnBrowser

use of org.apache.cayenne.modeler.util.MultiColumnBrowser in project cayenne by apache.

the class SelectQueryOrderingTab method createSelectorPanel.

protected JPanel createSelectorPanel() {
    browser = new MultiColumnBrowser();
    browser.setPreferredColumnSize(BROWSER_CELL_DIM);
    browser.setDefaultRenderer();
    JPanel panel = new JPanel(new BorderLayout());
    panel.add(createToolbar(), BorderLayout.NORTH);
    panel.add(new JScrollPane(browser, JScrollPane.VERTICAL_SCROLLBAR_NEVER, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED), BorderLayout.CENTER);
    // setting minimal size, otherwise scrolling looks awful, because of
    // VERTICAL_SCROLLBAR_NEVER strategy
    panel.setMinimumSize(panel.getPreferredSize());
    return panel;
}
Also used : JScrollPane(javax.swing.JScrollPane) JPanel(javax.swing.JPanel) MultiColumnBrowser(org.apache.cayenne.modeler.util.MultiColumnBrowser) BorderLayout(java.awt.BorderLayout)

Aggregations

MultiColumnBrowser (org.apache.cayenne.modeler.util.MultiColumnBrowser)3 BorderLayout (java.awt.BorderLayout)2 JPanel (javax.swing.JPanel)2 JScrollPane (javax.swing.JScrollPane)2 TreePath (javax.swing.tree.TreePath)1 DbEntity (org.apache.cayenne.map.DbEntity)1 DbRelationship (org.apache.cayenne.map.DbRelationship)1 ResolveDbRelationshipDialog (org.apache.cayenne.modeler.dialog.ResolveDbRelationshipDialog)1 EntityTreeModel (org.apache.cayenne.modeler.util.EntityTreeModel)1