Search in sources :

Example 1 with MultipleObjectsAction

use of org.apache.cayenne.modeler.action.MultipleObjectsAction 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)

Aggregations

Action (javax.swing.Action)1 ActionManager (org.apache.cayenne.modeler.action.ActionManager)1 MultipleObjectsAction (org.apache.cayenne.modeler.action.MultipleObjectsAction)1