/** * Return a Command that will be executed by a CommandStack. The default is to return null. * Subclasses should override this method. */ protected Command createManyCommand(ModifierHelper aHelper) { if (aHelper.shouldUnsetValue()) return createRemoveCommand(aHelper); return createAddCommand(aHelper); }
public boolean mustCreateValue() { return getValue() == null && getFeature() != null && !shouldUnsetValue(); }
/** * returns a list of ModifierHelpers * * @param baseHelper * @param actionFlag * @return */ public List getHelpers(ModifierHelper baseHelper) { int actionFlag = baseHelper.shouldUnsetValue() ? ModifierHelper.ACTION_UNSET : ModifierHelper.ACTION_SET; EStructuralFeature feature = baseHelper.getFeature(); List factoryList = getFactories(feature, actionFlag); if (null == factoryList) { return null; } ArrayList helpers = new ArrayList(); Iterator it = factoryList.iterator(); ModifierHelperFactory factory = null; while (it.hasNext()) { factory = (ModifierHelperFactory) it.next(); Object helper = factory.getHelper(baseHelper, actionFlag); if (null != helper) { helpers.add(helper); } } return helpers; }
/** * 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 Command that will be executed by a CommandStack. The default is to return null. * Subclasses should override this method. */ protected Command primCreateCommand(ModifierHelper aHelper) { Command command = doCreateCommand(aHelper); if (aHelper.shouldUnsetValue()) { Object value = aHelper.getValue(); if (value instanceof EObject && !((EObject) value).eIsProxy()) { command = new ProxyWrappingCommand(command, (EObject) value); } } return command; }
/** * Return a Command that will be executed by a CommandStack. */ protected Command createCommand(ModifierHelper aHelper) { if (aHelper == null) return null; Command command1, command2; ModifierHelper ownerHelper = aHelper.getOwnerHelper(); if (aHelper.shouldUnsetValue() && ownerHelper != null) return null; //we are unsetting a value on an owner that does not exist so do not // create the owner command1 = createCommand(ownerHelper); command2 = primCreateCommand(aHelper); if (command1 != null) { if (command2 == null) command2 = command1; else command2 = command2.chain(command1); } return command2; }
/** * 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); }
/** * 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; }