diff options
| author | Peter Cigehn | 2016-03-04 16:08:07 +0000 |
|---|---|---|
| committer | Gerrit Code Review @ Eclipse.org | 2016-03-17 08:12:02 +0000 |
| commit | bb22c53bbc48ef6b3cf71af88b94f4bdee1aa716 (patch) | |
| tree | fd5896c4dffdcb453368b23531400a0bac09918e | |
| parent | bde68ba747fb253542fbff395631d10250844111 (diff) | |
| download | org.eclipse.papyrus-rt-bb22c53bbc48ef6b3cf71af88b94f4bdee1aa716.tar.gz org.eclipse.papyrus-rt-bb22c53bbc48ef6b3cf71af88b94f4bdee1aa716.tar.xz org.eclipse.papyrus-rt-bb22c53bbc48ef6b3cf71af88b94f4bdee1aa716.zip | |
Bug 484591: [Tooling] Remove the superfluous multiplicity check of
capsule parts in the tooling
https://bugs.eclipse.org/bugs/show_bug.cgi?id=484591
Remove superfluous checks for multiplicity and aggregation for capsule
parts which should be covered by constraints in the UML-RT profile
instead. Since there are "loop holes" in the current checks in the
tooling (invalid models can still be created, e.g. using the advanced
properties view, or programatically) it is better to have a clean and
simple tooling code and instead have the checks made by constraints in
the UML-RT profile.
Also change the definition of a fixed capsule part to check that it has
aggregation composite and lower larger than 0 to cover for more invalid
cases, in which you want none of the radio buttons to be selected for
the kind of capsule part. Then an incorrectly configured capsule part,
can easily be fixed by pressing any of the radio buttons (since none is
selected in that case).
Change-Id: Ifbb98bcd64cd3aff12c9c6e1aadb37088d1b1ba3
Signed-off-by: Peter Cigehn <peter.cigehn@tieto.com>
8 files changed, 6 insertions, 282 deletions
diff --git a/plugins/umlrt/core/org.eclipse.papyrusrt.umlrt.core/build.properties b/plugins/umlrt/core/org.eclipse.papyrusrt.umlrt.core/build.properties index 079a73fb5..86b4a1978 100644 --- a/plugins/umlrt/core/org.eclipse.papyrusrt.umlrt.core/build.properties +++ b/plugins/umlrt/core/org.eclipse.papyrusrt.umlrt.core/build.properties @@ -5,5 +5,4 @@ bin.includes = META-INF/,\ plugin.xml,\ elementtypes/,\ about.html,\ - messages.properties,\ schema/ diff --git a/plugins/umlrt/core/org.eclipse.papyrusrt.umlrt.core/messages.properties b/plugins/umlrt/core/org.eclipse.papyrusrt.umlrt.core/messages.properties deleted file mode 100644 index 6d41295c7..000000000 --- a/plugins/umlrt/core/org.eclipse.papyrusrt.umlrt.core/messages.properties +++ /dev/null @@ -1,16 +0,0 @@ -########################################################################################## - # Copyright (c) 2015 CEA LIST and others. - # - # All rights reserved. This program and the accompanying materials - # are made available under the terms of the Eclipse Public License v1.0 - # which accompanies this distribution, and is available at - # http://www.eclipse.org/legal/epl-v10.html - # - # Contributors: - # Celine JANSSENS (ALL4TEC) celine.janssens@all4tec.net - Initial API and implementation - # -########################################################################################## - NotAllowedMultiplicity=This multiplicity is not allowed for Capsule Part! - ReadOnlyAggregationForCapsulePart=The aggregation for Capsule Part cannot be modified. It is derived from the kind of the Capsule Part. - WarningMessageDialog=WARNING ! - OK_Button_Label = OK
\ No newline at end of file diff --git a/plugins/umlrt/core/org.eclipse.papyrusrt.umlrt.core/src/org/eclipse/papyrusrt/umlrt/core/Messages.java b/plugins/umlrt/core/org.eclipse.papyrusrt.umlrt.core/src/org/eclipse/papyrusrt/umlrt/core/Messages.java deleted file mode 100644 index d08ebc18a..000000000 --- a/plugins/umlrt/core/org.eclipse.papyrusrt.umlrt.core/src/org/eclipse/papyrusrt/umlrt/core/Messages.java +++ /dev/null @@ -1,37 +0,0 @@ -/***************************************************************************** - * Copyright (c) 2015 CEA LIST and others. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Celine JANSSENS (ALL4TEC) celine.janssens@all4tec.net - Initial API and implementation - * - *****************************************************************************/ - -package org.eclipse.papyrusrt.umlrt.core; - -import org.eclipse.osgi.util.NLS; - -public class Messages extends NLS { - - private static final String BUNDLE_NAME = "messages"; //$NON-NLS-1$ - - public static String ReadOnlyAggregationForCapsulePart; - - public static String NotAllowedMultiplicity; - - public static String WarningMessageDialog; - - public static String OK_Button_Label; - - static { - // initialize resource bundle - NLS.initializeMessages(BUNDLE_NAME, Messages.class); - } - - private Messages() { - } -}
\ No newline at end of file diff --git a/plugins/umlrt/core/org.eclipse.papyrusrt.umlrt.core/src/org/eclipse/papyrusrt/umlrt/core/types/advice/CapsulePartEditHelperAdvice.java b/plugins/umlrt/core/org.eclipse.papyrusrt.umlrt.core/src/org/eclipse/papyrusrt/umlrt/core/types/advice/CapsulePartEditHelperAdvice.java index 4c752d39f..ca7563b75 100644 --- a/plugins/umlrt/core/org.eclipse.papyrusrt.umlrt.core/src/org/eclipse/papyrusrt/umlrt/core/types/advice/CapsulePartEditHelperAdvice.java +++ b/plugins/umlrt/core/org.eclipse.papyrusrt.umlrt.core/src/org/eclipse/papyrusrt/umlrt/core/types/advice/CapsulePartEditHelperAdvice.java @@ -16,12 +16,9 @@ import org.eclipse.core.runtime.IAdaptable; import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.emf.ecore.EObject; import org.eclipse.emf.ecore.EStructuralFeature; -import org.eclipse.gef.commands.UnexecutableCommand; import org.eclipse.gmf.runtime.common.core.command.CommandResult; import org.eclipse.gmf.runtime.common.core.command.CompositeCommand; import org.eclipse.gmf.runtime.common.core.command.ICommand; -import org.eclipse.gmf.runtime.common.ui.util.DisplayUtils; -import org.eclipse.gmf.runtime.diagram.ui.commands.CommandProxy; import org.eclipse.gmf.runtime.emf.type.core.commands.ConfigureElementCommand; import org.eclipse.gmf.runtime.emf.type.core.commands.SetValueCommand; import org.eclipse.gmf.runtime.emf.type.core.edithelper.AbstractEditHelperAdvice; @@ -29,11 +26,9 @@ import org.eclipse.gmf.runtime.emf.type.core.requests.ConfigureRequest; import org.eclipse.gmf.runtime.emf.type.core.requests.CreateRelationshipRequest; import org.eclipse.gmf.runtime.emf.type.core.requests.IEditCommandRequest; import org.eclipse.gmf.runtime.emf.type.core.requests.SetRequest; -import org.eclipse.jface.dialogs.MessageDialog; import org.eclipse.papyrus.infra.services.edit.service.ElementEditServiceUtils; import org.eclipse.papyrus.infra.services.edit.service.IElementEditService; import org.eclipse.papyrus.infra.services.edit.utils.RequestParameterConstants; -import org.eclipse.papyrusrt.umlrt.core.Messages; import org.eclipse.papyrusrt.umlrt.core.utils.CapsuleUtils; import org.eclipse.papyrusrt.umlrt.profile.UMLRealTime.CapsulePart; import org.eclipse.uml2.uml.AggregationKind; @@ -51,24 +46,8 @@ import org.eclipse.uml2.uml.VisibilityKind; */ public class CapsulePartEditHelperAdvice extends AbstractEditHelperAdvice { - /** Lower bound of multiplicity */ - protected int lower = -1; - - /** Upper Bound of Multiplicity */ - protected int upper = -1; - - /** Multiplicity Dialog */ - protected static MessageDialog multiplicityDialog; - - /** Aggregation Dialog */ - protected static MessageDialog aggregationDialog; - public CapsulePartEditHelperAdvice() { super(); - // Create the Dialog at the Advice construction to be created only once. - multiplicityDialog = new MessageDialog(DisplayUtils.getDefaultShell(), Messages.WarningMessageDialog, null, Messages.NotAllowedMultiplicity, MessageDialog.WARNING, new String[] { Messages.OK_Button_Label }, 0); - aggregationDialog = new MessageDialog(DisplayUtils.getDefaultShell(), Messages.WarningMessageDialog, null, Messages.ReadOnlyAggregationForCapsulePart, MessageDialog.WARNING, new String[] { Messages.OK_Button_Label }, 0); - } /** @@ -164,19 +143,6 @@ public class CapsulePartEditHelperAdvice extends AbstractEditHelperAdvice { command = new SetValueCommand(new SetRequest(request.getElementToEdit(), UMLPackage.eINSTANCE.getNamedElement_Name(), newName)); } } - } else if (UMLPackage.eINSTANCE.getProperty_Aggregation().equals(feature)) { // Aggregation is in Read Only for Capsule part - aggregationDialog.open(); - command = new CommandProxy(UnexecutableCommand.INSTANCE); - } else if (UMLPackage.eINSTANCE.getMultiplicityElement_Lower().equals(feature)) { // Prepare Lower Value for multiplicity check - lower = (Integer) request.getValue(); - } else if (UMLPackage.eINSTANCE.getMultiplicityElement_Upper().equals(feature)) { // Check the multiplicity in UML. - upper = (Integer) request.getValue(); - if (!((lower > 0 && lower == upper) || (lower == 0 && upper > 0))) {// Allow only n..n or 0..n - - // Display message if multiplicity is not allowed - multiplicityDialog.open(); - command = new CommandProxy(UnexecutableCommand.INSTANCE); - } } else { command = super.getAfterSetCommand(request); } diff --git a/plugins/umlrt/tooling/org.eclipse.papyrusrt.umlrt.tooling.ui/src/org/eclipse/papyrusrt/umlrt/tooling/ui/modelelement/UMLRTExtModelElement.java b/plugins/umlrt/tooling/org.eclipse.papyrusrt.umlrt.tooling.ui/src/org/eclipse/papyrusrt/umlrt/tooling/ui/modelelement/UMLRTExtModelElement.java index 0e7c0c4f2..38039130d 100644 --- a/plugins/umlrt/tooling/org.eclipse.papyrusrt.umlrt.tooling.ui/src/org/eclipse/papyrusrt/umlrt/tooling/ui/modelelement/UMLRTExtModelElement.java +++ b/plugins/umlrt/tooling/org.eclipse.papyrusrt.umlrt.tooling.ui/src/org/eclipse/papyrusrt/umlrt/tooling/ui/modelelement/UMLRTExtModelElement.java @@ -42,6 +42,7 @@ import org.eclipse.papyrus.infra.widgets.providers.IStaticContentProvider; import org.eclipse.papyrus.infra.widgets.providers.StaticContentProvider; import org.eclipse.papyrus.uml.properties.creation.UMLPropertyEditorFactory; import org.eclipse.papyrus.uml.properties.modelelement.UMLModelElement; +import org.eclipse.papyrus.uml.tools.databinding.ExtendedMultiplicityObservableValue; import org.eclipse.papyrus.uml.tools.providers.UMLContainerContentProvider; import org.eclipse.papyrus.uml.tools.providers.UMLFilteredLabelProvider; import org.eclipse.papyrus.views.properties.providers.FeatureContentProvider; @@ -54,7 +55,6 @@ import org.eclipse.papyrusrt.umlrt.profile.UMLRealTime.RTMessageSet; import org.eclipse.papyrusrt.umlrt.profile.UMLRealTime.RTPort; import org.eclipse.papyrusrt.umlrt.tooling.ui.Activator; import org.eclipse.papyrusrt.umlrt.tooling.ui.internal.modelelement.ChangeListenerUtils; -import org.eclipse.papyrusrt.umlrt.tooling.ui.widgets.CapsulePartExtendedObservableValue; import org.eclipse.papyrusrt.umlrt.tooling.ui.widgets.CapsulePartTypeValueFactory; import org.eclipse.papyrusrt.umlrt.tooling.ui.widgets.MessageSetOwnedProtocolMessageValueFactory; import org.eclipse.papyrusrt.umlrt.tooling.ui.widgets.RTPortTypeValueFactory; @@ -216,7 +216,7 @@ public class UMLRTExtModelElement extends UMLModelElement { if (intf != null) { observable = getDelegationModelElement(intf).doGetObservable(OWNED_OPERATION); } else if (IRealTimeConstants.CAPSULE_PART_MULTIPLICITY.equals(propertyPath)) { - observable = new CapsulePartExtendedObservableValue(source, domain); + observable = new ExtendedMultiplicityObservableValue(source, domain); } else { observable = super.doGetObservable(propertyPath); } diff --git a/plugins/umlrt/tooling/org.eclipse.papyrusrt.umlrt.tooling.ui/src/org/eclipse/papyrusrt/umlrt/tooling/ui/widgets/CapsulePartExtendedObservableValue.java b/plugins/umlrt/tooling/org.eclipse.papyrusrt.umlrt.tooling.ui/src/org/eclipse/papyrusrt/umlrt/tooling/ui/widgets/CapsulePartExtendedObservableValue.java deleted file mode 100644 index cd9cb1071..000000000 --- a/plugins/umlrt/tooling/org.eclipse.papyrusrt.umlrt.tooling.ui/src/org/eclipse/papyrusrt/umlrt/tooling/ui/widgets/CapsulePartExtendedObservableValue.java +++ /dev/null @@ -1,101 +0,0 @@ -package org.eclipse.papyrusrt.umlrt.tooling.ui.widgets; - -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; - -import org.eclipse.core.databinding.observable.IObservable; -import org.eclipse.core.databinding.observable.value.IObservableValue; -import org.eclipse.emf.ecore.EObject; -import org.eclipse.emf.ecore.EStructuralFeature; -import org.eclipse.emf.edit.domain.EditingDomain; -import org.eclipse.papyrus.infra.tools.databinding.AggregatedObservable; -import org.eclipse.papyrus.infra.tools.databinding.DelegatingObservable; -import org.eclipse.papyrus.uml.tools.databinding.AggregatedPapyrusObservableValue; -import org.eclipse.papyrus.uml.tools.databinding.ExtendedMultiplicityObservableValue; -import org.eclipse.papyrus.uml.tools.helper.UMLDatabindingHelper; -import org.eclipse.uml2.uml.UMLPackage; - -public class CapsulePartExtendedObservableValue extends ExtendedMultiplicityObservableValue { - - /** - * The number of ObservableValue in the ObservableList. - */ - private static final int NUMBER_OBSERVABLE_VALUES = 3; - - private EditingDomain domain; - private ArrayList<IObservableValue> observableValues; - - public CapsulePartExtendedObservableValue(final EObject eObject, final EditingDomain domain) { - super(eObject, domain); - this.domain = domain; - this.observableValues = new ArrayList<IObservableValue>(NUMBER_OBSERVABLE_VALUES); - if (null != eObject) { - - observableValues.add(new CapsulePartMultiplicityObservableValue(eObject, domain)); - - // Get the lower and upper values features - final EStructuralFeature lowerValueFeature = UMLPackage.eINSTANCE.getMultiplicityElement_LowerValue(); - final EStructuralFeature upperValueFeature = UMLPackage.eINSTANCE.getMultiplicityElement_UpperValue(); - - // Add the ObservableValues - observableValues.add(UMLDatabindingHelper.getObservableValue(eObject, lowerValueFeature, domain)); - observableValues.add(UMLDatabindingHelper.getObservableValue(eObject, upperValueFeature, domain)); - } - } - - public CapsulePartExtendedObservableValue(EditingDomain domain) { - super(domain); - } - - /** - * {@inheritDoc} - * - * @see org.eclipse.papyrus.infra.tools.databinding.AggregatedObservable#aggregate(org.eclipse.core.databinding.observable.IObservable) - */ - @SuppressWarnings("unchecked") - @Override - public AggregatedObservable aggregate(final IObservable observable) { - if (observable instanceof IObservableValue) { - final Object value = ((IObservableValue) observable).getValue(); - if (value instanceof List<?> && NUMBER_OBSERVABLE_VALUES == ((List<?>) value).size() && isAllIObservableValueType((List<?>) value)) { - final ExtendedMultiplicityObservableValue result = new CapsulePartExtendedObservableValue(domain); - - int count = 0; - while (count < NUMBER_OBSERVABLE_VALUES) { - final IObservableValue existingMultiplicityValues = observableValues.get(count); - final IObservableValue multiplicityValueToAggregate = ((List<IObservableValue>) value).get(count); - if (existingMultiplicityValues instanceof AggregatedObservable) { - final IObservableValue aggregatedObservable = (IObservableValue) ((AggregatedObservable) existingMultiplicityValues).aggregate(multiplicityValueToAggregate); - result.getObservableValues().add((IObservableValue) DelegatingObservable.wrap(aggregatedObservable)); - } - count++; - } - - return result; - } - } - return new AggregatedPapyrusObservableValue(domain, this, observable); - } - - /** - * Get if all the elements of the list are observable values. - * - * @param values - * The values list. - * @return <code>true</code> if all the elements are observable values, <code>false</code> otherwise. - */ - private boolean isAllIObservableValueType(final List<?> values) { - boolean result = true; - final Iterator<?> value = values.iterator(); - - while (result && value.hasNext()) { - if (!(value.next() instanceof IObservableValue)) { - result = false; - } - } - - return result; - } - -} diff --git a/plugins/umlrt/tooling/org.eclipse.papyrusrt.umlrt.tooling.ui/src/org/eclipse/papyrusrt/umlrt/tooling/ui/widgets/CapsulePartKindObservableValue.java b/plugins/umlrt/tooling/org.eclipse.papyrusrt.umlrt.tooling.ui/src/org/eclipse/papyrusrt/umlrt/tooling/ui/widgets/CapsulePartKindObservableValue.java index f1f57319e..04db9fbdd 100644 --- a/plugins/umlrt/tooling/org.eclipse.papyrusrt.umlrt.tooling.ui/src/org/eclipse/papyrusrt/umlrt/tooling/ui/widgets/CapsulePartKindObservableValue.java +++ b/plugins/umlrt/tooling/org.eclipse.papyrusrt.umlrt.tooling.ui/src/org/eclipse/papyrusrt/umlrt/tooling/ui/widgets/CapsulePartKindObservableValue.java @@ -111,8 +111,10 @@ public class CapsulePartKindObservableValue extends PapyrusObservableValue imple setUMLPropertiesValue(); // Define what is the kind of the capsulePart based on the multiplicity and the aggregation value - if (capsulePartElement.getLower() == capsulePartElement.getUpper()) { - kind = CapsulePartKindEnum.FIXED; + if (0 < capsulePartElement.getLower()) { + if (AggregationKind.COMPOSITE_LITERAL.equals(aggregation)) { + kind = CapsulePartKindEnum.FIXED; + } } else if (0 == capsulePartElement.getLower()) { if (AggregationKind.COMPOSITE_LITERAL.equals(aggregation)) { kind = CapsulePartKindEnum.OPTIONAL; diff --git a/plugins/umlrt/tooling/org.eclipse.papyrusrt.umlrt.tooling.ui/src/org/eclipse/papyrusrt/umlrt/tooling/ui/widgets/CapsulePartMultiplicityObservableValue.java b/plugins/umlrt/tooling/org.eclipse.papyrusrt.umlrt.tooling.ui/src/org/eclipse/papyrusrt/umlrt/tooling/ui/widgets/CapsulePartMultiplicityObservableValue.java deleted file mode 100644 index e601dbfdc..000000000 --- a/plugins/umlrt/tooling/org.eclipse.papyrusrt.umlrt.tooling.ui/src/org/eclipse/papyrusrt/umlrt/tooling/ui/widgets/CapsulePartMultiplicityObservableValue.java +++ /dev/null @@ -1,89 +0,0 @@ -/***************************************************************************** - * Copyright (c) 2015 CEA LIST and others. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * - * Celine JANSSENS (ALL4TEC) celine.janssens@all4tec.net - Initial API and implementation - * - *****************************************************************************/ - -package org.eclipse.papyrusrt.umlrt.tooling.ui.widgets; - -import org.eclipse.emf.common.command.Command; -import org.eclipse.emf.common.command.UnexecutableCommand; -import org.eclipse.emf.ecore.EObject; -import org.eclipse.emf.edit.domain.EditingDomain; -import org.eclipse.papyrus.uml.tools.Activator; -import org.eclipse.papyrus.uml.tools.databinding.MultiplicityObservableValue; -import org.eclipse.papyrus.uml.tools.util.MultiplicityParser; -import org.eclipse.papyrusrt.umlrt.profile.UMLRealTime.CapsulePart; -import org.eclipse.uml2.uml.Element; -import org.eclipse.uml2.uml.util.UMLUtil; - -/** - * Observable Value for the Capsule Part Multiplicity - * TODO Update this Class when replication field will be in place. - * - * @author Céline JANSSENS - * - */ -public class CapsulePartMultiplicityObservableValue extends MultiplicityObservableValue { - - /** - * Message in case of invalid Multiplicity String - */ - private static final String NON_VALID_MULTIPLICITY_MSG = "The multiplicity %s is not valid for a CapsulePart"; - /** - * Real Time Stereotype Application - */ - private EObject application; - - /** - * - * Constructor. - * - * @param source - * the EObject source of the Observable Value - * @param domain - * The Editing Domain for the Observable Value - */ - public CapsulePartMultiplicityObservableValue(final EObject source, final EditingDomain domain) { - super(source, domain); - this.application = UMLUtil.getStereotypeApplication((Element) source, CapsulePart.class); - - } - - - /** - * {@inheritDoc} - * - * @see org.eclipse.papyrus.uml.tools.databinding.MultiplicityObservableValue#getCommand(java.lang.Object) - */ - @Override - public Command getCommand(final Object multiplicityValue) { - - Command command = null; - if ((application instanceof CapsulePart) && (multiplicityValue instanceof String)) { - int[] multiBounds = MultiplicityParser.getBounds((String) multiplicityValue); - int lower = multiBounds[0]; - int upper = multiBounds[1]; - - // the allowed multiplicity are n..n or 0..n with n greater than 0. - if ((0 < lower && lower == upper) || (0 == lower && 0 != upper)) { - command = super.getCommand(multiplicityValue); - } else { - command = UnexecutableCommand.INSTANCE; - Activator.log.warn(String.format(NON_VALID_MULTIPLICITY_MSG, multiplicityValue)); - } - } - - - return command; - } - -} |
