Search in sources :

Example 1 with ActionManager

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);
}
Also used : ActionManager(org.apache.cayenne.modeler.action.ActionManager) CayenneTable(org.apache.cayenne.modeler.util.CayenneTable) BorderLayout(java.awt.BorderLayout) JToolBar(javax.swing.JToolBar) TableColumnPreferences(org.apache.cayenne.modeler.pref.TableColumnPreferences) JPopupMenu(javax.swing.JPopupMenu)

Example 2 with ActionManager

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);
}
Also used : ActionManager(org.apache.cayenne.modeler.action.ActionManager) RemoveCallbackMethodAction(org.apache.cayenne.modeler.action.RemoveCallbackMethodAction) RemoveAttributeAction(org.apache.cayenne.modeler.action.RemoveAttributeAction)

Example 3 with ActionManager

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));
        }
    }
}
Also used : ActionManager(org.apache.cayenne.modeler.action.ActionManager) Action(javax.swing.Action) MultipleObjectsAction(org.apache.cayenne.modeler.action.MultipleObjectsAction) MultipleObjectsAction(org.apache.cayenne.modeler.action.MultipleObjectsAction)

Example 4 with ActionManager

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);
}
Also used : ActionManager(org.apache.cayenne.modeler.action.ActionManager) FormLayout(com.jgoodies.forms.layout.FormLayout) BorderLayout(java.awt.BorderLayout) DefaultFormBuilder(com.jgoodies.forms.builder.DefaultFormBuilder) TextAdapter(org.apache.cayenne.modeler.util.TextAdapter) JToolBar(javax.swing.JToolBar) JTextField(javax.swing.JTextField)

Example 5 with ActionManager

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);
}
Also used : TableCellRenderer(javax.swing.table.TableCellRenderer) DefaultTableCellRenderer(javax.swing.table.DefaultTableCellRenderer) CayenneTable(org.apache.cayenne.modeler.util.CayenneTable) ObjRelationship(org.apache.cayenne.map.ObjRelationship) MouseEvent(java.awt.event.MouseEvent) MouseAdapter(java.awt.event.MouseAdapter) Rectangle(java.awt.Rectangle) TableColumnPreferences(org.apache.cayenne.modeler.pref.TableColumnPreferences) CayenneAction(org.apache.cayenne.modeler.util.CayenneAction) JPopupMenu(javax.swing.JPopupMenu) ActionManager(org.apache.cayenne.modeler.action.ActionManager) BorderLayout(java.awt.BorderLayout) Icon(javax.swing.Icon) ImageIcon(javax.swing.ImageIcon)

Aggregations

ActionManager (org.apache.cayenne.modeler.action.ActionManager)16 BorderLayout (java.awt.BorderLayout)9 JPopupMenu (javax.swing.JPopupMenu)7 JToolBar (javax.swing.JToolBar)7 Icon (javax.swing.Icon)6 TableColumnPreferences (org.apache.cayenne.modeler.pref.TableColumnPreferences)6 CayenneTable (org.apache.cayenne.modeler.util.CayenneTable)6 CayenneAction (org.apache.cayenne.modeler.util.CayenneAction)4 DefaultFormBuilder (com.jgoodies.forms.builder.DefaultFormBuilder)3 FormLayout (com.jgoodies.forms.layout.FormLayout)3 JTextField (javax.swing.JTextField)3 RemoveAttributeAction (org.apache.cayenne.modeler.action.RemoveAttributeAction)3 TextAdapter (org.apache.cayenne.modeler.util.TextAdapter)3 Rectangle (java.awt.Rectangle)2 MouseAdapter (java.awt.event.MouseAdapter)2 MouseEvent (java.awt.event.MouseEvent)2 ImageIcon (javax.swing.ImageIcon)2 DefaultTableCellRenderer (javax.swing.table.DefaultTableCellRenderer)2 TableCellRenderer (javax.swing.table.TableCellRenderer)2 CopyAttributeRelationshipAction (org.apache.cayenne.modeler.action.CopyAttributeRelationshipAction)2