/** * This will automatically get called from the J2EEModelModifier before executing so it is not * necessary to call it directly. */ public boolean isComplete() { boolean result = true; if (getOwnerHelper() != null) result = getOwnerHelper().isComplete(); if (!mustCreateValue()) result = getValue() != null || shouldUnsetValue(); else result = getFeatureType() != null; return result && getFeature() != null && (getOwner() != null || getOwnerHelper() != null); }
private boolean isValueEqual(ModifierHelper aHelper, Object value) { return aHelper.getOwner().eGet(aHelper.getFeature()) == value; }
/** * Run using * * @aHelper. This will set a MOF attibute value to the owner of the helper. */ protected void primRun(ModifierHelper aHelper) { if (aHelper.isComplete()) { Object value = getValue(aHelper); if (valueChanged(aHelper.getOwner(), aHelper.getFeature(), value, aHelper.shouldUnsetValue())) setObjectAttribute(aHelper.getOwner(), aHelper.getFeature(), value, aHelper.shouldUnsetValue()); } }
/** * Return a Remove Command that will be executed by a CommandStack. */ protected Command createRemoveCommand(ModifierHelper aHelper) { Object value = getValue(aHelper); Command command = null; EStructuralFeature feature = aHelper.getFeature(); if (valueChanged(aHelper.getOwner(), feature, value, true)) { if (isValueEqual(aHelper, value)) { command = RemoveCommand.create(getEditingDomain(), aHelper.getOwner(), feature, (Collection) value); } else { command = RemoveCommand.create(getEditingDomain(), aHelper.getOwner(), feature, value); } ((AbstractCommand) command).setLabel(createCommandLabel(REMOVE_PATTERN, feature)); setStatus(VALUE_CHANGE); } else { setStatus(NO_VALUE_CHANGE); } return command; }
/** * Return an AddCommand that will be executed by a CommandStack. */ protected Command createAddCommand(ModifierHelper aHelper) { Object value = getValue(aHelper); Command command = null; if (valueChanged(aHelper.getOwner(), aHelper.getFeature(), value, false)) { command = AddCommand.create(getEditingDomain(), aHelper.getOwner(), aHelper.getFeature(), value); ((AbstractCommand) command).setLabel(createCommandLabel(ADD_PATTERN, aHelper.getFeature())); setStatus(VALUE_CHANGE); } else { setStatus(NO_VALUE_CHANGE); } return command; }
/** * Return a SetCommand that will be executed by a CommandStack. */ protected Command createSingleCommand(ModifierHelper aHelper) { Object value = getValue(aHelper); Command command = null; if (valueChanged(aHelper.getOwner(), aHelper.getFeature(), value, aHelper.shouldUnsetValue())) { command = SetCommand.create(getEditingDomain(), aHelper.getOwner(), aHelper.getFeature(), value); ((AbstractCommand) command).setLabel(createCommandLabel(SET_PATTERN, aHelper.getFeature())); setStatus(VALUE_CHANGE); } else { setStatus(NO_VALUE_CHANGE); } return command; }