Application application) {
processActionsState(MULTIPLE_OBJECTS_ACTIONS);
updateActions("Selected Objects");
CayenneAction cutAction = getAction(CutAction.class);
boolean canCopy = true; // cut/copy can be performed if selected objects are on
// the same level
if (!cutAction.enableForPath((ConfigurationNode) 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((ConfigurationNode) objects[i])) {
canCopy = false;
break;
}
}
}
cutAction.setEnabled(canCopy);
getAction(CopyAction.class).setEnabled(canCopy);
}