use of org.apache.cayenne.modeler.action.ActionManager in project cayenne by apache.
the class EmbeddableTabbedView method resetRemoveButtons.
/**
* Reset the remove buttons
*/
private void resetRemoveButtons() {
ActionManager actionManager = Application.getInstance().getActionManager();
actionManager.getAction(RemoveAttributeAction.class).setEnabled(false);
actionManager.getAction(RemoveCallbackMethodAction.class).setEnabled(false);
}
use of org.apache.cayenne.modeler.action.ActionManager in project cayenne by apache.
the class DbEntityRelationshipPanel method init.
protected void init() {
this.setLayout(new BorderLayout());
ActionManager actionManager = Application.getInstance().getActionManager();
table = new CayenneTable();
table.setDefaultRenderer(DbEntity.class, CellRenderers.entityTableRendererWithIcons(mediator));
table.setDefaultRenderer(String.class, new BoardTableCellRenderer());
tablePreferences = new TableColumnPreferences(DbRelationshipTableModel.class, "relationshipTable");
// Create and install a popup
Icon ico = ModelerUtil.buildIcon("icon-edit.png");
resolveMenu = new CayenneAction.CayenneMenuItem("Database Mapping", ico);
JPopupMenu popup = new JPopupMenu();
popup.add(resolveMenu);
popup.add(actionManager.getAction(RemoveAttributeRelationshipAction.class).buildMenu());
popup.addSeparator();
popup.add(actionManager.getAction(CutAttributeRelationshipAction.class).buildMenu());
popup.add(actionManager.getAction(CopyAttributeRelationshipAction.class).buildMenu());
popup.add(actionManager.getAction(PasteAction.class).buildMenu());
TablePopupHandler.install(table, popup);
add(PanelFactory.createTablePanel(table, null), BorderLayout.CENTER);
}
use of org.apache.cayenne.modeler.action.ActionManager in project cayenne by apache.
the class DbEntityTab method initView.
private void initView() {
toolBar = new JToolBar();
toolBar.setBorder(BorderFactory.createEmptyBorder());
toolBar.setFloatable(false);
ActionManager actionManager = Application.getInstance().getActionManager();
toolBar.add(actionManager.getAction(CreateAttributeAction.class).buildButton(1));
toolBar.add(actionManager.getAction(CreateRelationshipAction.class).buildButton(3));
toolBar.addSeparator();
toolBar.add(actionManager.getAction(CreateObjEntityFromDbAction.class).buildButton(1));
toolBar.add(actionManager.getAction(DbEntitySyncAction.class).buildButton(2));
toolBar.add(actionManager.getAction(DbEntityCounterpartAction.class).buildButton(3));
toolBar.addSeparator();
toolBar.add(actionManager.getAction(ShowGraphEntityAction.class).buildButton());
// create widgets
name = new TextAdapter(new JTextField()) {
protected void updateModel(String text) {
setEntityName(text);
}
};
catalogLabel = new JLabel("Catalog:");
catalog = new TextAdapter(new JTextField()) {
protected void updateModel(String text) throws ValidationException {
setCatalog(text);
}
};
schemaLabel = new JLabel("Schema:");
schema = new TextAdapter(new JTextField()) {
protected void updateModel(String text) throws ValidationException {
setSchema(text);
}
};
qualifier = new TextAdapter(new JTextField()) {
protected void updateModel(String qualifier) {
setQualifier(qualifier);
}
};
comment = new TextAdapter(new JTextField()) {
@Override
protected void updateModel(String text) throws ValidationException {
setComment(text);
}
};
pkGeneratorType = new JComboBox<>();
pkGeneratorType.setEditable(false);
pkGeneratorType.setModel(new DefaultComboBoxModel<>(PK_GENERATOR_TYPES));
pkGeneratorDetailLayout = new CardLayout();
pkGeneratorDetail = new JPanel(pkGeneratorDetailLayout);
pkGeneratorDetail.add(new PKDefaultGeneratorPanel(mediator), PK_DEFAULT_GENERATOR);
pkGeneratorDetail.add(new PKDBGeneratorPanel(mediator), PK_DB_GENERATOR);
pkGeneratorDetail.add(new PKCustomSequenceGeneratorPanel(mediator), PK_CUSTOM_SEQUENCE_GENERATOR);
// assemble
FormLayout layout = new FormLayout("right:pref, 3dlu, fill:200dlu", "");
DefaultFormBuilder builder = new DefaultFormBuilder(layout);
builder.setDefaultDialogBorder();
builder.appendSeparator("DbEntity Configuration");
builder.append("DbEntity Name:", name.getComponent());
builder.append(catalogLabel, catalog.getComponent());
builder.append(schemaLabel, schema.getComponent());
builder.append("Qualifier:", qualifier.getComponent());
builder.append("Comment:", comment.getComponent());
builder.appendSeparator("Primary Key");
builder.append("PK Generation Strategy:", pkGeneratorType);
JPanel mainPanel = new JPanel();
mainPanel.setLayout(new BorderLayout());
mainPanel.add(builder.getPanel(), BorderLayout.NORTH);
mainPanel.add(pkGeneratorDetail, BorderLayout.CENTER);
setLayout(new BorderLayout());
add(toolBar, BorderLayout.NORTH);
add(mainPanel, BorderLayout.CENTER);
}
use of org.apache.cayenne.modeler.action.ActionManager in project cayenne by apache.
the class ModelerUtil method updateActions.
/**
* Updates MultipleObjectActions' state, depending on number of selected objects
* (attributes, rel etc.)
*/
public static void updateActions(int numSelected, Class<? extends Action>... actions) {
ActionManager actionManager = Application.getInstance().getActionManager();
for (Class<? extends Action> actionType : actions) {
Action action = actionManager.getAction(actionType);
if (action instanceof MultipleObjectsAction) {
MultipleObjectsAction multiObjectAction = (MultipleObjectsAction) action;
multiObjectAction.setEnabled(numSelected > 0);
((CayenneAction) multiObjectAction).setName(multiObjectAction.getActionName(numSelected > 1));
}
}
}
use of org.apache.cayenne.modeler.action.ActionManager in project cayenne by apache.
the class ObjEntityAttributePanel method initView.
private void initView() {
this.setLayout(new BorderLayout());
ActionManager actionManager = Application.getInstance().getActionManager();
table = new CayenneTable();
table.setDefaultRenderer(String.class, new CellRenderer());
tablePreferences = new TableColumnPreferences(ObjAttributeTableModel.class, "objEntity/attributeTable");
// go to SuperEntity from ObjEntity by inheritance icon
table.addMouseListener(new MouseAdapter() {
@Override
public void mouseReleased(MouseEvent e) {
int row = table.rowAtPoint(e.getPoint());
int col = table.columnAtPoint(e.getPoint());
if (row >= 0 && col == ObjAttributeTableModel.INHERITED) {
if (Boolean.TRUE.equals(table.getValueAt(row, col))) {
ActionManager actionManager = Application.getInstance().getActionManager();
actionManager.getAction(ObjEntityToSuperEntityAction.class).performAction(null);
}
}
}
});
// Create and install a popup
Icon ico = ModelerUtil.buildIcon("icon-edit.png");
resolveMenu = new CayenneAction.CayenneMenuItem("Database Mapping", ico);
JPopupMenu popup = new JPopupMenu();
popup.add(resolveMenu);
popup.add(actionManager.getAction(RemoveAttributeRelationshipAction.class).buildMenu());
popup.addSeparator();
popup.add(actionManager.getAction(CutAttributeRelationshipAction.class).buildMenu());
popup.add(actionManager.getAction(CopyAttributeRelationshipAction.class).buildMenu());
popup.add(actionManager.getAction(PasteAction.class).buildMenu());
TablePopupHandler.install(table, popup);
add(PanelFactory.createTablePanel(table, null), BorderLayout.CENTER);
}
Aggregations