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;
}
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();
}
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;
}
Aggregations