/** * Insert the method's description here. Creation date: (4/6/2001 3:28:16 PM) * * @param newValue * java.lang.Object */ protected Object convertValue(java.lang.Object newValue) { return getFeatureValueConverter().convertValue(newValue, getFeature()); }
/** * Insert the method's description here. Creation date: (4/6/2001 3:28:16 PM) * * @return EObject */ protected EObject getFeatureType() { return getFeature().getEType(); }
/** * 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; }
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; }
/** * 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; }
/** * 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 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; }
protected Command doCreateCommand(ModifierHelper aHelper) { if (!aHelper.isComplete()) { setStatus(ERROR); return null; } Command command = null; if (aHelper.getFeature().isMany()) command = createManyCommand(aHelper); else command = createSingleCommand(aHelper); if (null != command) { List localHelpers = ModifierHelperRegistry.getInstance().getHelpers(aHelper); if (null != localHelpers) { extendedHelpers.addAll(localHelpers); } } return command; }
/** * 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; }