use of org.apache.cayenne.modeler.action.ActionManager in project cayenne by apache.
the class EmbeddableAttributeTab method init.
private void init() {
this.setLayout(new BorderLayout());
JToolBar toolBar = new JToolBar();
toolBar.setFloatable(false);
ActionManager actionManager = Application.getInstance().getActionManager();
toolBar.add(actionManager.getAction(CreateAttributeAction.class).buildButton());
toolBar.addSeparator();
toolBar.add(actionManager.getAction(RemoveAttributeAction.class).buildButton());
toolBar.addSeparator();
toolBar.add(actionManager.getAction(CutAttributeAction.class).buildButton(1));
toolBar.add(actionManager.getAction(CopyAttributeAction.class).buildButton(2));
toolBar.add(actionManager.getAction(PasteAction.class).buildButton(3));
add(toolBar, BorderLayout.NORTH);
table = new CayenneTable();
tablePreferences = new TableColumnPreferences(this.getClass(), "embeddable/attributeTable");
// Create and install a popup
JPopupMenu popup = new JPopupMenu();
popup.add(actionManager.getAction(RemoveAttributeAction.class).buildMenu());
popup.addSeparator();
popup.add(actionManager.getAction(CutAttributeAction.class).buildMenu());
popup.add(actionManager.getAction(CopyAttributeAction.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 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 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 EmbeddableTab method initView.
private void initView() {
this.setLayout(new BorderLayout());
JToolBar toolBar = new JToolBar();
toolBar.setBorder(BorderFactory.createEmptyBorder());
toolBar.setFloatable(false);
ActionManager actionManager = Application.getInstance().getActionManager();
toolBar.add(actionManager.getAction(CreateAttributeAction.class).buildButton());
add(toolBar, BorderLayout.NORTH);
className = new TextAdapter(new JTextField()) {
@Override
protected void updateModel(String text) {
setClassName(text);
}
};
comment = new TextAdapter(new JTextField()) {
@Override
protected void updateModel(String text) {
setComment(text);
}
};
FormLayout layout = new FormLayout("right:50dlu, 3dlu, fill:150dlu, 3dlu, fill:100", "");
DefaultFormBuilder builder = new DefaultFormBuilder(layout);
builder.setDefaultDialogBorder();
builder.append("Class Name:", className.getComponent(), 3);
builder.append("Comment:", comment.getComponent(), 3);
add(builder.getPanel(), BorderLayout.CENTER);
}
use of org.apache.cayenne.modeler.action.ActionManager in project cayenne by apache.
the class ObjEntityRelationshipPanel method init.
private void init() {
this.setLayout(new BorderLayout());
ActionManager actionManager = Application.getInstance().getActionManager();
table = new CayenneTable();
table.setDefaultRenderer(String.class, new StringRenderer());
table.setDefaultRenderer(ObjEntity.class, new EntityRenderer());
tablePreferences = new TableColumnPreferences(ObjRelationshipTableModel.class, "objEntity/relationshipTable");
table.addMouseListener(new MouseAdapter() {
@Override
public void mouseReleased(MouseEvent e) {
int row = table.rowAtPoint(e.getPoint());
int col = table.columnAtPoint(e.getPoint());
ObjRelationshipTableModel tableModel = ((ObjRelationshipTableModel) table.getModel());
ObjRelationship relationship = tableModel.getRelationship(row);
int columnFromModel = table.getColumnModel().getColumn(col).getModelIndex();
if (row >= 0 && columnFromModel == ObjRelationshipTableModel.REL_NAME) {
if (relationship.getSourceEntity() != tableModel.getEntity()) {
TableCellRenderer renderer = table.getCellRenderer(row, col);
Rectangle rectangle = table.getCellRect(row, col, false);
((StringRenderer) renderer).mouseClicked(e, rectangle.x);
}
}
}
});
// 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