Search in sources :

Example 6 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 7 with ActionManager

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

Example 8 with ActionManager

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

Example 9 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 10 with ActionManager

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);
}
Also used : CayenneTable(org.apache.cayenne.modeler.util.CayenneTable) MouseEvent(java.awt.event.MouseEvent) MouseAdapter(java.awt.event.MouseAdapter) DefaultTableCellRenderer(javax.swing.table.DefaultTableCellRenderer) 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 CopyAttributeRelationshipAction (org.apache.cayenne.modeler.action.CopyAttributeRelationshipAction)2 CutAttributeRelationshipAction (org.apache.cayenne.modeler.action.CutAttributeRelationshipAction)2 RemoveAttributeRelationshipAction (org.apache.cayenne.modeler.action.RemoveAttributeRelationshipAction)2 RemoveCallbackMethodAction (org.apache.cayenne.modeler.action.RemoveCallbackMethodAction)2 RemoveRelationshipAction (org.apache.cayenne.modeler.action.RemoveRelationshipAction)2 BoardTableCellRenderer (org.apache.cayenne.modeler.util.BoardTableCellRenderer)2 ValidationException (org.apache.cayenne.validation.ValidationException)2