use of org.apache.cayenne.modeler.dialog.ResolveDbRelationshipDialog in project cayenne by apache.
the class RelationshipUndoableEdit method redo.
@Override
public void redo() throws CannotRedoException {
super.redo();
ResolveDbRelationshipDialog dialog = new ResolveDbRelationshipDialog(relationship, false);
dialog.setVisible(true);
}
use of org.apache.cayenne.modeler.dialog.ResolveDbRelationshipDialog 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.dialog.ResolveDbRelationshipDialog in project cayenne by apache.
the class DbEntityRelationshipPanel method initController.
private void initController() {
this.mediator.addDbEntityDisplayListener(this);
this.mediator.addDbEntityListener(this);
this.mediator.addDbRelationshipListener(this);
resolver = new ActionListener() {
public void actionPerformed(ActionEvent e) {
int row = table.getSelectedRow();
if (row < 0) {
return;
}
// Get DbRelationship
DbRelationshipTableModel model = (DbRelationshipTableModel) table.getModel();
DbRelationship rel = model.getRelationship(row);
ResolveDbRelationshipDialog dialog = new ResolveDbRelationshipDialog(rel);
dialog.setVisible(true);
dialog.dispose();
}
};
resolveMenu.addActionListener(resolver);
table.getSelectionModel().addListSelectionListener(new DbRelationshipListSelectionListener());
mediator.getApplication().getActionManager().setupCutCopyPaste(table, CutAttributeRelationshipAction.class, CopyAttributeRelationshipAction.class);
}
use of org.apache.cayenne.modeler.dialog.ResolveDbRelationshipDialog in project cayenne by apache.
the class RelationshipUndoableEdit method undo.
@Override
public void undo() throws CannotUndoException {
super.undo();
ResolveDbRelationshipDialog dialog = new ResolveDbRelationshipDialog(relationship, false);
dialog.setVisible(true);
}
Aggregations