Search in sources :

Example 1 with CayenneAction

use of org.apache.cayenne.modeler.util.CayenneAction in project cayenne by apache.

the class DefaultActionManager method multipleObjectsSelected.

/**
 * Invoked when several objects were selected in ProjectTree at time
 */
public void multipleObjectsSelected(ConfigurationNode[] objects, Application application) {
    processActionsState(MULTIPLE_OBJECTS_ACTIONS);
    updateActions("Selected Objects");
    CayenneAction cutAction = getAction(CutAction.class);
    // cut/copy can be performed if selected objects are on
    boolean canCopy = true;
    if (!cutAction.enableForPath(objects[0])) {
        canCopy = false;
    } else {
        ConfigurationNodeParentGetter parentGetter = application.getInjector().getInstance(ConfigurationNodeParentGetter.class);
        Object parent = parentGetter.getParent(objects[0]);
        for (int i = 1; i < objects.length; i++) {
            if (parentGetter.getParent(objects[i]) != parent || !cutAction.enableForPath(objects[i])) {
                canCopy = false;
                break;
            }
        }
    }
    cutAction.setEnabled(canCopy);
    getAction(CopyAction.class).setEnabled(canCopy);
}
Also used : ConfigurationNodeParentGetter(org.apache.cayenne.project.ConfigurationNodeParentGetter) CayenneAction(org.apache.cayenne.modeler.util.CayenneAction)

Example 2 with CayenneAction

use of org.apache.cayenne.modeler.util.CayenneAction in project cayenne by apache.

the class CayenneUndoManager method updateUI.

private void updateUI() {
    CayenneAction undoAction = application.getActionManager().getAction(UndoAction.class);
    CayenneAction redoAction = application.getActionManager().getAction(RedoAction.class);
    undoAction.setEnabled(canUndo());
    redoAction.setEnabled(canRedo());
    undoAction.setName(getUndoPresentationName());
    redoAction.setName(getRedoPresentationName());
}
Also used : CayenneAction(org.apache.cayenne.modeler.util.CayenneAction)

Aggregations

CayenneAction (org.apache.cayenne.modeler.util.CayenneAction)2 ConfigurationNodeParentGetter (org.apache.cayenne.project.ConfigurationNodeParentGetter)1