diff options
54 files changed, 2620 insertions, 134 deletions
diff --git a/plugins/uml/decoratormodel/org.eclipse.papyrus.uml.decoratormodel.properties/src/org/eclipse/papyrus/uml/decoratormodel/properties/elements/AppliedProfilesObservableList.java b/plugins/uml/decoratormodel/org.eclipse.papyrus.uml.decoratormodel.properties/src/org/eclipse/papyrus/uml/decoratormodel/properties/elements/AppliedProfilesObservableList.java index 7401996dd7f..6452ef23564 100644 --- a/plugins/uml/decoratormodel/org.eclipse.papyrus.uml.decoratormodel.properties/src/org/eclipse/papyrus/uml/decoratormodel/properties/elements/AppliedProfilesObservableList.java +++ b/plugins/uml/decoratormodel/org.eclipse.papyrus.uml.decoratormodel.properties/src/org/eclipse/papyrus/uml/decoratormodel/properties/elements/AppliedProfilesObservableList.java @@ -14,14 +14,14 @@ * Gabriel Pascual (ALL4TEC) - Bug 441511 * Christian W. Damus (CEA) - Bug 441227 * Christian W. Damus - bug 399859 - * + * *****************************************************************************/ package org.eclipse.papyrus.uml.decoratormodel.properties.elements; import org.eclipse.emf.ecore.resource.Resource; import org.eclipse.emf.edit.domain.EditingDomain; import org.eclipse.papyrus.infra.core.resource.ResourceAdapter; -import org.eclipse.papyrus.uml.tools.databinding.ProfileApplicationObservableList; +import org.eclipse.papyrus.uml.properties.databinding.ProfileApplicationObservableList; import org.eclipse.uml2.uml.Package; /** diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/util/MessageStyleElementFactory.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/util/MessageStyleElementFactory.java index cde6841fe88..d54854fcd69 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/util/MessageStyleElementFactory.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/util/MessageStyleElementFactory.java @@ -23,11 +23,11 @@ import org.eclipse.gmf.runtime.notation.Edge; import org.eclipse.gmf.runtime.notation.NotationPackage; import org.eclipse.gmf.runtime.notation.Style; import org.eclipse.gmf.runtime.notation.View; +import org.eclipse.papyrus.infra.gmfdiag.common.databinding.GMFObservableValue; import org.eclipse.papyrus.infra.gmfdiag.common.helper.NotationHelper; import org.eclipse.papyrus.infra.properties.contexts.DataContextElement; import org.eclipse.papyrus.infra.properties.ui.modelelement.AbstractModelElement; import org.eclipse.papyrus.infra.properties.ui.modelelement.AbstractModelElementFactory; -import org.eclipse.papyrus.uml.tools.databinding.PapyrusObservableValue; public class MessageStyleElementFactory extends AbstractModelElementFactory<MessageStyleElementFactory.MessageStyleModelElement> { @@ -64,14 +64,14 @@ public class MessageStyleElementFactory extends AbstractModelElementFactory<Mess protected IObservable doGetObservable(String propertyPath) { EditingDomain domain = AdapterFactoryEditingDomain.getEditingDomainFor(source); Style style = null; - if (context.getName().equals("LineStyle")) { + if (context.getName().equals("LineStyle")) { //$NON-NLS-1$ style = source.getStyle(NotationPackage.Literals.LINE_STYLE); - } else if (context.getName().equals("FontStyle")) { + } else if (context.getName().equals("FontStyle")) { //$NON-NLS-1$ style = source.getStyle(NotationPackage.Literals.FONT_STYLE); } if (style != null) { EStructuralFeature feature = style.eClass().getEStructuralFeature(propertyPath); - return new PapyrusObservableValue(style, feature, domain); + return new GMFObservableValue(style, feature, domain); } return null; } diff --git a/plugins/uml/properties/org.eclipse.papyrus.uml.properties/META-INF/MANIFEST.MF b/plugins/uml/properties/org.eclipse.papyrus.uml.properties/META-INF/MANIFEST.MF index 56b3093206d..0fed91180c7 100644 --- a/plugins/uml/properties/org.eclipse.papyrus.uml.properties/META-INF/MANIFEST.MF +++ b/plugins/uml/properties/org.eclipse.papyrus.uml.properties/META-INF/MANIFEST.MF @@ -2,6 +2,7 @@ Manifest-Version: 1.0 Export-Package: org.eclipse.papyrus.uml.properties.constraints, org.eclipse.papyrus.uml.properties.creation, org.eclipse.papyrus.uml.properties.databinding, + org.eclipse.papyrus.uml.properties.databinding.helpers, org.eclipse.papyrus.uml.properties.datatype, org.eclipse.papyrus.uml.properties.editors, org.eclipse.papyrus.uml.properties.expression, @@ -39,7 +40,7 @@ Require-Bundle: org.eclipse.papyrus.uml.profile;bundle-version="[3.0.0,4.0.0)";v org.eclipse.papyrus.uml.tools;bundle-version="[4.0.0,5.0.0)" Bundle-Vendor: %providerName Bundle-ActivationPolicy: lazy;exclude:="org.eclipse.papyrus.uml.properties.constraints" -Bundle-Version: 3.2.0.qualifier +Bundle-Version: 3.3.0.qualifier Bundle-Name: %pluginName Bundle-Localization: plugin Bundle-Activator: org.eclipse.papyrus.uml.properties.Activator diff --git a/plugins/uml/properties/org.eclipse.papyrus.uml.properties/pom.xml b/plugins/uml/properties/org.eclipse.papyrus.uml.properties/pom.xml index 5b944043e07..5181fba14ce 100644 --- a/plugins/uml/properties/org.eclipse.papyrus.uml.properties/pom.xml +++ b/plugins/uml/properties/org.eclipse.papyrus.uml.properties/pom.xml @@ -8,6 +8,6 @@ <version>0.0.1-SNAPSHOT</version> </parent> <artifactId>org.eclipse.papyrus.uml.properties</artifactId> - <version>3.2.0-SNAPSHOT</version> + <version>3.3.0-SNAPSHOT</version> <packaging>eclipse-plugin</packaging> </project>
\ No newline at end of file diff --git a/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/databinding/AbstractUMLAggregatedObservableValue.java b/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/databinding/AbstractUMLAggregatedObservableValue.java new file mode 100755 index 00000000000..f80ff29253f --- /dev/null +++ b/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/databinding/AbstractUMLAggregatedObservableValue.java @@ -0,0 +1,59 @@ +/***************************************************************************** + * Copyright (c) 2011, 2014 CEA LIST and others. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License 2.0 + * which accompanies this distribution, and is available at + * https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * Camille Letavernier (CEA LIST) camille.letavernier@cea.fr - Initial API and implementation + * Christian W. Damus (CEA) - bug 417409 + * + *****************************************************************************/ +package org.eclipse.papyrus.uml.properties.databinding; + +import org.eclipse.core.databinding.observable.IObservable; +import org.eclipse.emf.edit.domain.EditingDomain; +import org.eclipse.papyrus.infra.services.edit.ui.databinding.AggregatedPapyrusObservableValue; +import org.eclipse.papyrus.infra.tools.databinding.AggregatedObservable; +import org.eclipse.papyrus.infra.tools.databinding.CommandBasedObservableValue; +import org.eclipse.papyrus.infra.tools.databinding.ReferenceCountedObservable; + +/** + * An Abstract Class for Papyrus Command-based observable values + * + * @author Camille Letavernier + * @since 3.3 + * + */ +public abstract class AbstractUMLAggregatedObservableValue extends ReferenceCountedObservable.Value implements AggregatedObservable, CommandBasedObservableValue { + + protected EditingDomain domain; + + protected AbstractUMLAggregatedObservableValue(EditingDomain domain) { + this.domain = domain; + } + + /** + * {@inheritDoc} + */ + @Override + public AggregatedObservable aggregate(IObservable observable) { + try { + return new AggregatedPapyrusObservableValue(domain, this, observable); + } catch (IllegalArgumentException ex) { + return null; // The observable cannot be aggregated + } + } + + /** + * {@inheritDoc} + */ + @Override + public boolean hasDifferentValues() { + return false; + } +} diff --git a/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/databinding/AppliedCommentsObservableList.java b/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/databinding/AppliedCommentsObservableList.java index d007d75db67..4b6f7ebecc4 100644 --- a/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/databinding/AppliedCommentsObservableList.java +++ b/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/databinding/AppliedCommentsObservableList.java @@ -13,7 +13,7 @@ * Mickaël ADAM (ALL4TEC) mickael.adam@all4tec.net - bug 435174 * Gabriel Pascual (ALL4TEC) - Bug 441511 * Christian W. Damus (CEA) - Bug 441227 - * + * *****************************************************************************/ package org.eclipse.papyrus.uml.properties.databinding; @@ -33,7 +33,7 @@ import org.eclipse.emf.edit.domain.EditingDomain; import org.eclipse.emf.transaction.TransactionalEditingDomain; import org.eclipse.gmf.runtime.emf.type.core.requests.DestroyElementRequest; import org.eclipse.gmf.runtime.emf.type.core.requests.SetRequest; -import org.eclipse.papyrus.uml.tools.databinding.PapyrusObservableList; +import org.eclipse.papyrus.infra.gmfdiag.common.databinding.GMFObservableList; import org.eclipse.uml2.common.util.UML2Util; import org.eclipse.uml2.uml.Comment; import org.eclipse.uml2.uml.Element; @@ -42,7 +42,7 @@ import org.eclipse.uml2.uml.UMLPackage; /** * Observable list for applied comments. */ -public class AppliedCommentsObservableList extends PapyrusObservableList { +public class AppliedCommentsObservableList extends GMFObservableList { public AppliedCommentsObservableList(EditingDomain domain, Element source) { super(getAppliedCommentsList(source), domain, source, UMLPackage.eINSTANCE.getElement_OwnedComment()); @@ -56,7 +56,7 @@ public class AppliedCommentsObservableList extends PapyrusObservableList { * @return the applied comments list */ private static List<Comment> getAppliedCommentsList(Element source) { - List<Comment> result = new LinkedList<Comment>(); + List<Comment> result = new LinkedList<>(); Iterator<Setting> it = UML2Util.getNonNavigableInverseReferences(source).iterator(); while (it.hasNext()) { Setting setting = it.next(); @@ -109,7 +109,7 @@ public class AppliedCommentsObservableList extends PapyrusObservableList { /** - * @see org.eclipse.papyrus.uml.tools.databinding.PapyrusObservableList#getAddCommand(java.lang.Object) + * @see org.eclipse.papyrus.infra.gmfdiag.common.databinding.GMFObservableList#getAddCommand(java.lang.Object) * * @param value * @return @@ -138,7 +138,7 @@ public class AppliedCommentsObservableList extends PapyrusObservableList { } /** - * @see org.eclipse.papyrus.uml.tools.databinding.PapyrusObservableList#getRemoveCommand(java.lang.Object) + * @see org.eclipse.papyrus.infra.gmfdiag.common.databinding.GMFObservableList#getRemoveCommand(java.lang.Object) * * @param value * @return @@ -153,7 +153,7 @@ public class AppliedCommentsObservableList extends PapyrusObservableList { if (comment.getAnnotatedElements().size() > 1) { // Remove on link between source and comment - List<Element> values = new LinkedList<Element>(comment.getAnnotatedElements()); + List<Element> values = new LinkedList<>(comment.getAnnotatedElements()); values.remove(source); SetRequest setRequest = new SetRequest(comment, UMLPackage.eINSTANCE.getComment_AnnotatedElement(), values); removeAppliedCommentCommand = getCommandFromRequests(getProvider(), Collections.singletonList(setRequest)); @@ -170,7 +170,7 @@ public class AppliedCommentsObservableList extends PapyrusObservableList { } /** - * @see org.eclipse.papyrus.uml.tools.databinding.PapyrusObservableList#getRemoveAllCommand(java.util.Collection) + * @see org.eclipse.papyrus.infra.gmfdiag.common.databinding.GMFObservableList#getRemoveAllCommand(java.util.Collection) * * @param values * @return diff --git a/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/databinding/ElementCustomizationObservableValue.java b/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/databinding/ElementCustomizationObservableValue.java index f8fcf5d67b0..105269268fa 100644 --- a/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/databinding/ElementCustomizationObservableValue.java +++ b/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/databinding/ElementCustomizationObservableValue.java @@ -26,7 +26,6 @@ import org.eclipse.papyrus.infra.emf.utils.EMFHelper; import org.eclipse.papyrus.infra.tools.databinding.AggregatedObservable; import org.eclipse.papyrus.infra.tools.databinding.CommandBasedObservableValue; import org.eclipse.papyrus.uml.properties.Activator; -import org.eclipse.papyrus.uml.tools.databinding.AbstractUMLAggregatedObservableValue; /** * An IObservableValue for custom Papyrus properties. @@ -65,6 +64,7 @@ public class ElementCustomizationObservableValue extends AbstractUMLAggregatedOb // TODO : The value is not correctly refreshed when someone else edits it // Some listeners need to be added + @Override public Object getValueType() { switch (property) { case QUALIFIED_NAME: @@ -106,6 +106,7 @@ public class ElementCustomizationObservableValue extends AbstractUMLAggregatedOb /** * {@inheritDoc} */ + @Override public Command getCommand(Object value) { switch (property) { case ELEMENT_ICON: diff --git a/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/databinding/ExtendedMultiplicityObservableValue.java b/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/databinding/ExtendedMultiplicityObservableValue.java new file mode 100755 index 00000000000..aaf7b4894d2 --- /dev/null +++ b/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/databinding/ExtendedMultiplicityObservableValue.java @@ -0,0 +1,268 @@ +/***************************************************************************** + * Copyright (c) 2015, 2016 CEA LIST, Christian W. Damus, and others. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License 2.0 + * which accompanies this distribution, and is available at + * https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * Nicolas FAUVERGUE (ALL4TEC) nicolas.fauvergue@all4tec.net - Initial API and implementation + * Christian W. Damus - bug 491789 + * + *****************************************************************************/ + +package org.eclipse.papyrus.uml.properties.databinding; + +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; + +import org.eclipse.core.databinding.observable.Diffs; +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.services.edit.ui.databinding.AggregatedPapyrusObservableValue; +import org.eclipse.papyrus.infra.tools.databinding.AggregatedObservable; +import org.eclipse.papyrus.infra.tools.databinding.DelegatingObservable; +import org.eclipse.papyrus.infra.tools.databinding.ReferenceCountedObservable; +import org.eclipse.papyrus.uml.properties.databinding.helpers.UMLDatabindingHelper; +import org.eclipse.uml2.uml.UMLPackage; + +/** + * The multiplicity observable values contains a list of 3 observable values : The first the multiplicity lower and upper value for the 'simple' mode and the 2 following are the lower and the upper value observable value. + * + * @since 3.3 + */ +public class ExtendedMultiplicityObservableValue extends ReferenceCountedObservable.Value implements AggregatedObservable { + + /** + * The number of ObservableValue in the ObservableList. + */ + private static final int NUMBER_OBSERVABLE_VALUES = 3; + + + /** + * The list of observable values for the multiplicity editors (simple mode, lower and upper values) + */ + private final List<IObservableValue> observableValues; + + /** + * The reference counted observable support. + */ + private final ReferenceCountedObservable.Support refCount = new ReferenceCountedObservable.Support(this); + + /** + * The editing domain used. + */ + private final EditingDomain domain; + + + /** + * + * Constructor. + * + * @param domain + * The editing domain. + */ + public ExtendedMultiplicityObservableValue(final EditingDomain domain) { + this(null, domain); + } + + /** + * Constructor. + * + * @param eObject + * The object to edit. + * @param domain + * The editing domain. + */ + public ExtendedMultiplicityObservableValue(final EObject eObject, final EditingDomain domain) { + this.domain = domain; + this.observableValues = new ArrayList<>(NUMBER_OBSERVABLE_VALUES); + if (null != eObject) { + + observableValues.add(new MultiplicityObservableValue(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)); + } + } + + /** + * {@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 ExtendedMultiplicityObservableValue(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; + } + + /** + * {@inheritDoc} + * + * @see org.eclipse.core.databinding.observable.value.IObservableValue#getValueType() + */ + @Override + public Object getValueType() { + return null; + } + + /** + * {@inheritDoc} + * + * @see org.eclipse.core.databinding.observable.value.AbstractObservableValue#doGetValue() + */ + @Override + protected Object doGetValue() { + return getObservableValues(); + } + + /** + * If the input is a list of three elements that are all observable-values, + * take them. Otherwise, throw. + * + * @param value + * the value to set + * + * @throws IllegalArgumentException + * if {@code value} is not a list of three + * {@link IObservableValue}s + */ + @Override + protected void doSetValue(Object value) { + if (!(value instanceof List<?>)) { + throw new IllegalArgumentException("value is not a List"); //$NON-NLS-1$ + } + List<?> listValue = (List<?>) value; + if (listValue.size() != NUMBER_OBSERVABLE_VALUES) { + throw new IllegalArgumentException(String.format("value is not a list of %d IObservableValues", NUMBER_OBSERVABLE_VALUES)); //$NON-NLS-1$ + } + if (!listValue.stream().allMatch(IObservableValue.class::isInstance)) { + throw new IllegalArgumentException(String.format("value is not a list of %d IObservableValues", NUMBER_OBSERVABLE_VALUES)); //$NON-NLS-1$ + } + + // Only do anything if the result would be different + if (!listValue.equals(observableValues)) { + @SuppressWarnings("unchecked") + List<? extends IObservableValue<?>> newObservables = (List<? extends IObservableValue<?>>) listValue; + + // Retain the new, release the old (some may be both) + newObservables.forEach(ReferenceCountedObservable.Util::retain); + observableValues.forEach(ReferenceCountedObservable.Util::autorelease); + + List<IObservableValue<?>> oldObservables = new ArrayList<>(observableValues); + + observableValues.clear(); + observableValues.addAll(newObservables); + fireValueChange(Diffs.createValueDiff(oldObservables, newObservables)); + } + } + + /** + * Get the observable values. + * + * @return the observableValues. + */ + public List<IObservableValue> getObservableValues() { + return observableValues; + } + + /** + * {@inheritDoc} + * + * @see org.eclipse.core.databinding.observable.AbstractObservable#dispose() + */ + @Override + public synchronized void dispose() { + for (IObservableValue observableValue : observableValues) { + observableValue.dispose(); + } + observableValues.clear(); + super.dispose(); + } + + /** + * This retains the support. + */ + @Override + public void retain() { + refCount.retain(); + } + + /** + * This releases the support. + */ + @Override + public void release() { + refCount.release(); + } + + /** + * This auto-relreases the support. + */ + @Override + public void autorelease() { + refCount.autorelease(); + } + + /** + * {@inheritDoc} + * + * @see org.eclipse.papyrus.infra.tools.databinding.AggregatedObservable#hasDifferentValues() + */ + @Override + public boolean hasDifferentValues() { + return false; + } +} diff --git a/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/databinding/ExtensionEndMultiplicityObservableValue.java b/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/databinding/ExtensionEndMultiplicityObservableValue.java new file mode 100755 index 00000000000..b37abcd1dcd --- /dev/null +++ b/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/databinding/ExtensionEndMultiplicityObservableValue.java @@ -0,0 +1,48 @@ +/***************************************************************************** + * Copyright (c) 2013 CEA LIST. + * + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License 2.0 + * which accompanies this distribution, and is available at + * https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * Camille Letavernier (camille.letavernier@cea.fr) - Initial API and implementation + * + *****************************************************************************/ +package org.eclipse.papyrus.uml.properties.databinding; + +import org.eclipse.emf.common.command.Command; +import org.eclipse.emf.common.command.UnexecutableCommand; +import org.eclipse.emf.edit.domain.EditingDomain; +import org.eclipse.papyrus.uml.tools.Activator; +import org.eclipse.papyrus.uml.tools.util.MultiplicityParser; +import org.eclipse.uml2.uml.ExtensionEnd; + +/** + * An IObservableValue for handling the UML ExtensionEnd#multiplicity + * The multiplicity can only be either 1 or 0..1 + * + * @author Camille Letavernier + * @since 3.3 + * + */ +public class ExtensionEndMultiplicityObservableValue extends MultiplicityObservableValue { + + public ExtensionEndMultiplicityObservableValue(ExtensionEnd source, EditingDomain domain) { + super(source, domain); + } + + @Override + public Command getCommand(Object value) { + if (MultiplicityParser.ONE.equals(value) || MultiplicityParser.OPTIONAL.equals(value)) { + return super.getCommand(value); + } + + Activator.log.warn(String.format("The multiplicity %s is not valid for an ExtensionEnd", value)); //$NON-NLS-1$ + return UnexecutableCommand.INSTANCE; + } +} diff --git a/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/databinding/ExtensionRequiredObservableValue.java b/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/databinding/ExtensionRequiredObservableValue.java new file mode 100755 index 00000000000..eb81dd6006d --- /dev/null +++ b/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/databinding/ExtensionRequiredObservableValue.java @@ -0,0 +1,112 @@ +/***************************************************************************** + * Copyright (c) 2013, 2014 CEA LIST and others. + * + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License 2.0 + * which accompanies this distribution, and is available at + * https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * Camille Letavernier (camille.letavernier@cea.fr) - Initial API and implementation + * Christian W. Damus (CEA) - 402525 + * + *****************************************************************************/ +package org.eclipse.papyrus.uml.properties.databinding; + +import org.eclipse.core.databinding.observable.ChangeEvent; +import org.eclipse.core.databinding.observable.IChangeListener; +import org.eclipse.core.databinding.observable.IObserving; +import org.eclipse.core.databinding.observable.value.AbstractObservableValue; +import org.eclipse.core.databinding.observable.value.ValueDiff; +import org.eclipse.emf.edit.domain.EditingDomain; +import org.eclipse.papyrus.uml.tools.Activator; +import org.eclipse.papyrus.uml.tools.util.MultiplicityParser; +import org.eclipse.uml2.uml.Extension; + +/** + * An ObservableValue to edit the derived "isRequired" property for a Stereotype Extension + * The isRequired property is reverse derived to retrieve the lower bound of the extensionEnd + * + * @author Camille Letavernier + * @since 3.3 + * + */ +public class ExtensionRequiredObservableValue extends AbstractObservableValue implements IChangeListener, IObserving { + + private Extension extension; + + private MultiplicityObservableValue observable; + + private boolean currentValue; + + public ExtensionRequiredObservableValue(Extension extension, EditingDomain domain) { + this.extension = extension; + if (!this.extension.getOwnedEnds().isEmpty()) { + observable = new MultiplicityObservableValue(this.extension.getOwnedEnds().get(0), domain); + observable.addChangeListener(this); + } + currentValue = extension.isRequired(); + } + + @Override + public Object getValueType() { + return Boolean.class; + } + + @Override + protected Boolean doGetValue() { + return extension.isRequired(); + } + + @Override + protected void doSetValue(Object value) { + if (!(value instanceof Boolean)) { + return; + } + + Boolean required = (Boolean) value; + + if (extension.getOwnedEnds().isEmpty()) { + Activator.log.warn("Unable to change the extension \"isRequired\" property"); //$NON-NLS-1$ + } + + observable.setValue(required ? MultiplicityParser.ONE : MultiplicityParser.OPTIONAL); + currentValue = required; + } + + @Override + public Object getObserved() { + return extension; + } + + @Override + public void dispose() { + observable.removeChangeListener(this); + observable.dispose(); + observable = null; + super.dispose(); + } + + @Override + public void handleChange(ChangeEvent event) { + final boolean oldValue = currentValue; + final boolean newValue = doGetValue(); + currentValue = newValue; + fireValueChange(new ValueDiff() { + + @Override + public Object getOldValue() { + return oldValue; + } + + @Override + public Object getNewValue() { + return newValue; + } + }); + } + +} diff --git a/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/databinding/ImageExpressionObservableValue.java b/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/databinding/ImageExpressionObservableValue.java new file mode 100755 index 00000000000..d6051aaf155 --- /dev/null +++ b/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/databinding/ImageExpressionObservableValue.java @@ -0,0 +1,85 @@ +/***************************************************************************** + * Copyright (c) 2011, 2014 CEA LIST and others. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License 2.0 + * which accompanies this distribution, and is available at + * https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * Camille Letavernier (CEA LIST) camille.letavernier@cea.fr - Initial API and implementation + * Christian W. Damus (CEA) - 402525 + * + *****************************************************************************/ +package org.eclipse.papyrus.uml.properties.databinding; + +import org.eclipse.core.databinding.observable.IObserving; +import org.eclipse.core.databinding.observable.value.AbstractObservableValue; +import org.eclipse.emf.common.command.Command; +import org.eclipse.emf.edit.domain.EditingDomain; +import org.eclipse.papyrus.uml.tools.utils.ImageUtil; +import org.eclipse.uml2.common.edit.command.ChangeCommand; +import org.eclipse.uml2.uml.Image; + +/** + * An IObservableValue for editing Images + * + * @author Camille Letavernier + * @since 3.3 + */ +public class ImageExpressionObservableValue extends AbstractObservableValue implements IObserving { + + private Image image; + + private EditingDomain domain; + + /** + * + * Constructor. + * + * @param image + * The UML Image element to edit + * @param domain + * The editing domain on which the commands will be executed + */ + public ImageExpressionObservableValue(Image image, EditingDomain domain) { + this.image = image; + this.domain = domain; + } + + @Override + public Object getValueType() { + return String.class; + } + + @Override + protected Object doGetValue() { + return ImageUtil.getExpression(image); + } + + @Override + protected void doSetValue(Object value) { + if (value instanceof String) { + final String expression = (String) value; + + Runnable runnable = new Runnable() { + + @Override + public void run() { + + ImageUtil.setExpression(image, expression); + } + }; + + Command emfCommand = new ChangeCommand(domain, runnable); + domain.getCommandStack().execute(emfCommand); + } + } + + @Override + public Object getObserved() { + return image; + } +} diff --git a/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/databinding/ImageKindObservableValue.java b/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/databinding/ImageKindObservableValue.java new file mode 100755 index 00000000000..14b437a1bfb --- /dev/null +++ b/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/databinding/ImageKindObservableValue.java @@ -0,0 +1,110 @@ +/***************************************************************************** + * Copyright (c) 2011, 2014 CEA LIST and others. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License 2.0 + * which accompanies this distribution, and is available at + * https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * Camille Letavernier (CEA LIST) camille.letavernier@cea.fr - Initial API and implementation + * Christian W. Damus (CEA) - 402525 + * + *****************************************************************************/ +package org.eclipse.papyrus.uml.properties.databinding; + +import org.eclipse.core.databinding.observable.IObserving; +import org.eclipse.core.databinding.observable.value.AbstractObservableValue; +import org.eclipse.emf.common.command.Command; +import org.eclipse.emf.edit.domain.EditingDomain; +import org.eclipse.papyrus.uml.tools.utils.ImageUtil; +import org.eclipse.uml2.common.edit.command.ChangeCommand; +import org.eclipse.uml2.uml.Image; + +/** + * + * An IObservableValue to handle the way the image is displayed + * + * @author Camille Letavernier + * @since 3.3 + * + */ +public class ImageKindObservableValue extends AbstractObservableValue implements IObserving { + + /** + * The kind of image display + * Undefined + */ + public static final String KIND_UNDEFINED = "undefined"; //$NON-NLS-1$ + + /** + * The kind of image display + * Displays the image as an Icon in the element edit part + */ + public static final String KIND_ICON = "icon"; //$NON-NLS-1$ + + /** + * The kind of image display + * The image replaces the element edit part + */ + public static final String KIND_SHAPE = "shape"; //$NON-NLS-1$ + + private Image image; + + private EditingDomain domain; + + /** + * + * Constructor. + * + * @param image + * The UML Image element + * @param domain + * The editing domain on which the commands will be executed + */ + public ImageKindObservableValue(Image image, EditingDomain domain) { + this.image = image; + this.domain = domain; + } + + @Override + public Object getValueType() { + return String.class; + } + + /** + * {@inheritDoc} + */ + @Override + protected String doGetValue() { + return ImageUtil.getKind(image); + } + + /** + * {@inheritDoc} + */ + @Override + protected void doSetValue(Object value) { + if (value instanceof String) { + final String kind = (String) value; + + Runnable runnable = new Runnable() { + + @Override + public void run() { + ImageUtil.setKind(image, kind); + } + }; + + Command emfCommand = new ChangeCommand(domain, runnable); + domain.getCommandStack().execute(emfCommand); + } + } + + @Override + public Object getObserved() { + return image; + } +} diff --git a/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/databinding/ImageNameObservableValue.java b/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/databinding/ImageNameObservableValue.java new file mode 100755 index 00000000000..12c8c29fa47 --- /dev/null +++ b/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/databinding/ImageNameObservableValue.java @@ -0,0 +1,85 @@ +/***************************************************************************** + * Copyright (c) 2011, 2014 CEA LIST and others. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License 2.0 + * which accompanies this distribution, and is available at + * https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * Camille Letavernier (CEA LIST) camille.letavernier@cea.fr - Initial API and implementation + * Christian W. Damus (CEA) - 402525 + * + *****************************************************************************/ +package org.eclipse.papyrus.uml.properties.databinding; + +import org.eclipse.core.databinding.observable.IObserving; +import org.eclipse.core.databinding.observable.value.AbstractObservableValue; +import org.eclipse.emf.common.command.Command; +import org.eclipse.emf.edit.domain.EditingDomain; +import org.eclipse.papyrus.uml.tools.utils.ImageUtil; +import org.eclipse.uml2.common.edit.command.ChangeCommand; +import org.eclipse.uml2.uml.Image; + +/** + * An IObservableValue for editing Images + * + * @author Camille Letavernier + * @since 3.3 + */ +public class ImageNameObservableValue extends AbstractObservableValue implements IObserving { + + private Image image; + + private EditingDomain domain; + + /** + * + * Constructor. + * + * @param image + * The UML Image element to edit + * @param domain + * The editing domain on which the commands will be executed + */ + public ImageNameObservableValue(Image image, EditingDomain domain) { + this.image = image; + this.domain = domain; + } + + @Override + public Object getValueType() { + return String.class; + } + + @Override + protected Object doGetValue() { + return ImageUtil.getName(image); + } + + @Override + protected void doSetValue(Object value) { + if (value instanceof String) { + final String name = (String) value; + + Runnable runnable = new Runnable() { + + @Override + public void run() { + + ImageUtil.setName(image, name); + } + }; + + Command emfCommand = new ChangeCommand(domain, runnable); + domain.getCommandStack().execute(emfCommand); + } + } + + @Override + public Object getObserved() { + return image; + } +} diff --git a/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/databinding/MultiplicityObservableValue.java b/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/databinding/MultiplicityObservableValue.java new file mode 100755 index 00000000000..43bb8332b1e --- /dev/null +++ b/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/databinding/MultiplicityObservableValue.java @@ -0,0 +1,241 @@ +/***************************************************************************** + * Copyright (c) 2010, 2014 CEA LIST and others. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License 2.0 + * which accompanies this distribution, and is available at + * https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * Camille Letavernier (CEA LIST) camille.letavernier@cea.fr - Initial API and implementation + * Christian W. Damus (CEA) - 402525 + * Christian W. Damus (CEA) - bug 417409 + * + *****************************************************************************/ +package org.eclipse.papyrus.uml.properties.databinding; + +import org.eclipse.core.databinding.observable.ChangeEvent; +import org.eclipse.core.databinding.observable.IChangeListener; +import org.eclipse.core.databinding.observable.IObservable; +import org.eclipse.core.databinding.observable.IObserving; +import org.eclipse.core.databinding.observable.value.IObservableValue; +import org.eclipse.core.databinding.observable.value.ValueDiff; +import org.eclipse.emf.common.command.Command; +import org.eclipse.emf.common.command.UnexecutableCommand; +import org.eclipse.emf.ecore.EObject; +import org.eclipse.emf.ecore.EStructuralFeature; +import org.eclipse.emf.edit.domain.EditingDomain; +import org.eclipse.papyrus.infra.services.edit.ui.databinding.AggregatedPapyrusObservableValue; +import org.eclipse.papyrus.infra.tools.databinding.AggregatedObservable; +import org.eclipse.papyrus.infra.tools.databinding.CommandBasedObservableValue; +import org.eclipse.papyrus.infra.tools.databinding.ReferenceCountedObservable; +import org.eclipse.papyrus.uml.properties.databinding.helpers.UMLDatabindingHelper; +import org.eclipse.papyrus.uml.tools.Activator; +import org.eclipse.papyrus.uml.tools.commands.SetMultiplicityCommand; +import org.eclipse.papyrus.uml.tools.util.MultiplicityParser; +import org.eclipse.papyrus.uml.tools.utils.MultiplicityElementUtil; +import org.eclipse.uml2.uml.MultiplicityElement; +import org.eclipse.uml2.uml.UMLPackage; + +/** + * An ObservableValue for manipulating the UML Multiplicity property. + * Multiplicity is a simple, virtual property, aggregating both lowerBound and upperBound, + * and presenting them as an Enumeration with 4 values : 1, 0-1, 0-*, 1-* + * + * The values are edited with commands executed on the given editing domain. + * These commands will probably only work in a Papyrus context. + * + * @author Camille Letavernier + * @since 3.3 + */ +public class MultiplicityObservableValue extends ReferenceCountedObservable.Value implements IChangeListener, CommandBasedObservableValue, AggregatedObservable, IObserving { + + private IObservableValue lowerBound, upperBound, lowerValue, upperValue, lowerValueSpecification, upperValueSpecification; + + private EStructuralFeature lowerFeature, upperFeature; + + private EObject eObject; + + private EditingDomain domain; + + /** + * Constructor. + * + * @param eObject + * The EObject which the multiplicity is being edited + * @param domain + * The Editing Domain on which the commands will be executed + */ + public MultiplicityObservableValue(EObject eObject, EditingDomain domain) { + this.eObject = eObject; + this.domain = domain; + + lowerFeature = UMLPackage.eINSTANCE.getMultiplicityElement_Lower(); + upperFeature = UMLPackage.eINSTANCE.getMultiplicityElement_Upper(); + + EStructuralFeature lowerValueFeature, upperValueFeature, lowerValueSpecificationFeature, upperValueSpecificationFeature; + + lowerValueFeature = UMLPackage.eINSTANCE.getMultiplicityElement_LowerValue(); + upperValueFeature = UMLPackage.eINSTANCE.getMultiplicityElement_UpperValue(); + lowerValueSpecificationFeature = UMLPackage.eINSTANCE.getLiteralInteger_Value(); + upperValueSpecificationFeature = UMLPackage.eINSTANCE.getLiteralUnlimitedNatural_Value(); + + lowerBound = UMLDatabindingHelper.getObservableValue(eObject, lowerFeature, domain); + upperBound = UMLDatabindingHelper.getObservableValue(eObject, upperFeature, domain); + + lowerValue = UMLDatabindingHelper.getObservableValue(eObject, lowerValueFeature, domain); + upperValue = UMLDatabindingHelper.getObservableValue(eObject, upperValueFeature, domain); + + lowerValueSpecification = getValueSpecification(lowerValue, lowerValueSpecificationFeature, domain); + upperValueSpecification = getValueSpecification(upperValue, upperValueSpecificationFeature, domain); + + lowerValue.addChangeListener(this); + upperValue.addChangeListener(this); + + if (lowerValueSpecification != null) { + lowerValueSpecification.addChangeListener(this); + } + if (upperValueSpecification != null) { + upperValueSpecification.addChangeListener(this); + } + } + + private IObservableValue getValueSpecification(IObservableValue source, EStructuralFeature specificationFeature, EditingDomain domain) { + if (source.getValue() == null) { + return null; + } + return UMLDatabindingHelper.getObservableValue((EObject) source.getValue(), specificationFeature, domain); + + } + + /** + * @see org.eclipse.core.databinding.observable.IChangeListener#handleChange(org.eclipse.core.databinding.observable.ChangeEvent) + * + * @param event + */ + @Override + public void handleChange(ChangeEvent event) { + boolean fireChange = false; + if (event.getSource() == lowerValue || event.getSource() == upperValue) { + fireChange = true; + lowerValueSpecification = getValueSpecification(lowerValue, UMLPackage.eINSTANCE.getLiteralInteger_Value(), domain); + upperValueSpecification = getValueSpecification(upperValue, UMLPackage.eINSTANCE.getLiteralUnlimitedNatural_Value(), domain); + } + + if (event.getSource() == lowerValueSpecification || event.getSource() == upperValueSpecification) { + fireChange = true; + } + + if (fireChange) { + final Object value = getValue(); + fireValueChange(new ValueDiff() { + + @Override + public Object getOldValue() { + return null; // Unknown + } + + @Override + public Object getNewValue() { + return value; + } + + }); + } + } + + @Override + public Object getObserved() { + return eObject; + } + + @Override + public synchronized void dispose() { + lowerValue.removeChangeListener(this); + upperValue.removeChangeListener(this); + if (lowerValueSpecification != null) { + lowerValueSpecification.removeChangeListener(this); + lowerValueSpecification.dispose(); + } + if (upperValueSpecification != null) { + upperValueSpecification.removeChangeListener(this); + upperValueSpecification.dispose(); + } + + lowerValue.dispose(); + upperValue.dispose(); + + lowerBound.dispose(); + upperBound.dispose(); + + super.dispose(); + } + + @Override + public Object getValueType() { + return String.class; + } + + @Override + protected String doGetValue() { + String result = null; + if (eObject instanceof MultiplicityElement) { + result = MultiplicityElementUtil.formatMultiplicityNoBrackets((MultiplicityElement) eObject); + } else { + int upper, lower; + upper = lower = 0; + + Object lowerValue = lowerBound.getValue(); + Object upperValue = upperBound.getValue(); + lower = (Integer) lowerValue; + upper = (Integer) upperValue; + + result = MultiplicityParser.getMultiplicity(lower, upper); + } + return result; + } + + @Override + protected void doSetValue(Object value) { + Command command = getCommand(value); + domain.getCommandStack().execute(command); + } + + @Override + public Command getCommand(Object value) { + String val = (String) value; + + int[] lowerUpper = MultiplicityParser.getBounds(val); + if (lowerUpper == null || lowerUpper.length < 2) { + return UnexecutableCommand.INSTANCE; // Invalid multiplicity + } + + int lower = lowerUpper[0], upper = lowerUpper[1]; + if (MultiplicityParser.isValidMultiplicity(lower, upper)) { + try { + return new SetMultiplicityCommand((MultiplicityElement) eObject, val); + } catch (Exception ex) { + Activator.log.error(ex); + } + } + + return UnexecutableCommand.INSTANCE; + } + + @Override + public AggregatedObservable aggregate(IObservable observable) { + try { + return new AggregatedPapyrusObservableValue(domain, this, observable); + } catch (IllegalArgumentException ex) { + return null; // The observable cannot be aggregated + } + } + + @Override + public boolean hasDifferentValues() { + return false; + } + +} diff --git a/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/databinding/NavigationObservableValue.java b/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/databinding/NavigationObservableValue.java new file mode 100755 index 00000000000..70090b184ef --- /dev/null +++ b/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/databinding/NavigationObservableValue.java @@ -0,0 +1,181 @@ +/***************************************************************************** + * Copyright (c) 2010, 2014 CEA LIST and others. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License 2.0 + * which accompanies this distribution, and is available at + * https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * Camille Letavernier (CEA LIST) camille.letavernier@cea.fr - Initial API and implementation + * Christian W. Damus (CEA) - 402525 + * Christian W. Damus (CEA) - bug 417409 + * + *****************************************************************************/ +package org.eclipse.papyrus.uml.properties.databinding; + +import java.util.ArrayList; +import java.util.LinkedList; +import java.util.List; + +import org.eclipse.core.databinding.observable.ChangeEvent; +import org.eclipse.core.databinding.observable.Diffs; +import org.eclipse.core.databinding.observable.IChangeListener; +import org.eclipse.core.databinding.observable.IObservable; +import org.eclipse.core.databinding.observable.IObserving; +import org.eclipse.core.databinding.observable.list.IObservableList; +import org.eclipse.emf.common.command.Command; +import org.eclipse.emf.common.command.CompoundCommand; +import org.eclipse.emf.common.command.UnexecutableCommand; +import org.eclipse.emf.databinding.EMFProperties; +import org.eclipse.emf.ecore.EObject; +import org.eclipse.emf.ecore.EStructuralFeature; +import org.eclipse.emf.edit.domain.EditingDomain; +import org.eclipse.gmf.runtime.common.core.command.ICommand; +import org.eclipse.gmf.runtime.emf.type.core.requests.SetRequest; +import org.eclipse.papyrus.infra.emf.gmf.command.GMFtoEMFCommandWrapper; +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.ui.databinding.AggregatedPapyrusObservableValue; +import org.eclipse.papyrus.infra.tools.databinding.AggregatedObservable; +import org.eclipse.papyrus.infra.tools.databinding.CommandBasedObservableValue; +import org.eclipse.papyrus.infra.tools.databinding.ReferenceCountedObservable; +import org.eclipse.uml2.uml.Association; +import org.eclipse.uml2.uml.Classifier; +import org.eclipse.uml2.uml.Property; +import org.eclipse.uml2.uml.UMLPackage; + +/** + * An ObservableValue for manipulating the UML Navigable property. + * The navigable property is a virtual property, represented as a Boolean. + * + * @author Camille Letavernier + * @since 3.3 + */ +public class NavigationObservableValue extends ReferenceCountedObservable.Value implements IChangeListener, CommandBasedObservableValue, AggregatedObservable, IObserving { + + private Property memberEnd; + + private EditingDomain domain; + + private final IObservableList ownerObservableList; + + private boolean currentValue; + + /** + * Constructor. + * + * @param source + * The EObject (Property) which the navigability is being edited + * @param domain + * The Editing Domain on which the commands will be executed + */ + public NavigationObservableValue(EObject source, EditingDomain domain) { + memberEnd = (Property) source; + this.domain = domain; + + ownerObservableList = EMFProperties.list(UMLPackage.eINSTANCE.getAssociation_OwnedEnd()).observe(memberEnd.getAssociation()); + ownerObservableList.addChangeListener(this); + } + + @Override + public void handleChange(ChangeEvent event) { + fireValueChange(Diffs.createValueDiff(currentValue, doGetValue())); + } + + @Override + public Object getValueType() { + return Boolean.class; + } + + @Override + protected Boolean doGetValue() { + return memberEnd.isNavigable(); + } + + @Override + protected void doSetValue(Object value) { + Command command = getCommand(value); + domain.getCommandStack().execute(command); + } + + @Override + public Object getObserved() { + return memberEnd; + } + + @Override + public synchronized void dispose() { + super.dispose(); + ownerObservableList.removeChangeListener(this); + ownerObservableList.dispose(); + } + + @Override + public Command getCommand(Object value) { + if (value instanceof Boolean) { + boolean isNavigable = (Boolean) value; + if (memberEnd.isNavigable() == isNavigable) { + return UnexecutableCommand.INSTANCE; + } + + Association association = memberEnd.getAssociation(); + + List<Property> navigableEnds = new ArrayList<>(); + navigableEnds.addAll(association.getNavigableOwnedEnds()); + + List<SetRequest> setRequests = new LinkedList<>(); + + if (isNavigable) { + navigableEnds.add(memberEnd); + } else { + if (memberEnd.getOwningAssociation() == null && memberEnd.getOwner() instanceof Classifier) { + List<Property> ownedEnds = new LinkedList<>(); + ownedEnds.addAll(association.getOwnedEnds()); + ownedEnds.add(memberEnd); + setRequests.add(new SetRequest(association, UMLPackage.eINSTANCE.getAssociation_OwnedEnd(), ownedEnds)); + } + if (navigableEnds.contains(memberEnd)) { + navigableEnds.remove(memberEnd); + } + } + + EStructuralFeature navigableFeature = UMLPackage.eINSTANCE.getAssociation_NavigableOwnedEnd(); + setRequests.add(new SetRequest(association, navigableFeature, navigableEnds)); + + CompoundCommand command = null; + + IElementEditService provider = ElementEditServiceUtils.getCommandProvider(association); + if (provider != null) { + + command = new CompoundCommand(); + + for (SetRequest request : setRequests) { + ICommand createGMFCommand = provider.getEditCommand(request); + command.append(new GMFtoEMFCommandWrapper(createGMFCommand)); + } + } + + currentValue = isNavigable; + return command; + } + + return UnexecutableCommand.INSTANCE; + } + + @Override + public AggregatedObservable aggregate(IObservable observable) { + try { + return new AggregatedPapyrusObservableValue(domain, this, observable); + } catch (IllegalArgumentException ex) { + return null; // The observable cannot be aggregated + } + } + + @Override + public boolean hasDifferentValues() { + return false; + } +} diff --git a/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/databinding/OwnedCommentsObservableList.java b/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/databinding/OwnedCommentsObservableList.java index 5200e058a0e..09d625c210e 100644 --- a/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/databinding/OwnedCommentsObservableList.java +++ b/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/databinding/OwnedCommentsObservableList.java @@ -1,6 +1,6 @@ /***************************************************************************** * Copyright (c) 2014 CEA LIST. - * + * * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 * which accompanies this distribution, and is available at @@ -24,7 +24,7 @@ import org.eclipse.emf.edit.domain.EditingDomain; import org.eclipse.emf.transaction.TransactionalEditingDomain; import org.eclipse.gmf.runtime.emf.type.core.requests.DestroyElementRequest; import org.eclipse.gmf.runtime.emf.type.core.requests.SetRequest; -import org.eclipse.papyrus.uml.tools.databinding.PapyrusObservableList; +import org.eclipse.papyrus.infra.gmfdiag.common.databinding.GMFObservableList; import org.eclipse.uml2.uml.Comment; import org.eclipse.uml2.uml.Element; import org.eclipse.uml2.uml.UMLPackage; @@ -35,15 +35,15 @@ import org.eclipse.uml2.uml.UMLPackage; * * @author Gabriel Pascual */ -public class OwnedCommentsObservableList extends PapyrusObservableList { +public class OwnedCommentsObservableList extends GMFObservableList { /** * Constructor. * * @param domain - * the domain + * the domain * @param source - * the source + * the source */ public OwnedCommentsObservableList(EditingDomain domain, EObject source) { super(getOwnedComments(source), domain, source, UMLPackage.eINSTANCE.getElement_OwnedComment()); @@ -53,19 +53,19 @@ public class OwnedCommentsObservableList extends PapyrusObservableList { * Gets the owned comments. * * @param source - * the source + * the source * @return the owned comments */ private static List<Comment> getOwnedComments(EObject source) { - List<Comment> result = new LinkedList<Comment>(); + List<Comment> result = new LinkedList<>(); - if(source instanceof Element) { + if (source instanceof Element) { - EList<Comment> allOwnedComments = ((Element)source).getOwnedComments(); + EList<Comment> allOwnedComments = ((Element) source).getOwnedComments(); - // Filter owned comments list - for(Comment comment : allOwnedComments) { - if(!comment.getAnnotatedElements().contains(source)) { + // Filter owned comments list + for (Comment comment : allOwnedComments) { + if (!comment.getAnnotatedElements().contains(source)) { result.add(comment); } } @@ -80,18 +80,18 @@ public class OwnedCommentsObservableList extends PapyrusObservableList { * <p> * Redefine method to add filtered list. * </p> - * + * * @see org.eclipse.papyrus.infra.ui.emf.databinding.EMFObservableList#refreshCacheList() * */ @Override protected void refreshCacheList() { - if(isDisposed()) { - //This observable can be disposed, but the commands might still be - //in the command stack. Undo() or Redo() will call this method, which - //should be ignored. The command should probably not call refresh directly ; - //we should have listeners on the concrete list... but it is not necessarily - //observable + if (isDisposed()) { + // This observable can be disposed, but the commands might still be + // in the command stack. Undo() or Redo() will call this method, which + // should be ignored. The command should probably not call refresh directly ; + // we should have listeners on the concrete list... but it is not necessarily + // observable return; } wrappedList.clear(); @@ -100,30 +100,30 @@ public class OwnedCommentsObservableList extends PapyrusObservableList { } /** - * @see org.eclipse.papyrus.uml.tools.databinding.PapyrusObservableList#getAddCommand(java.lang.Object) + * @see org.eclipse.papyrus.infra.gmfdiag.common.databinding.GMFObservableList#getAddCommand(java.lang.Object) * * @param value * @return */ @Override public Command getAddCommand(Object value) { - assert value instanceof Comment : "Added value is not a Comment"; + assert value instanceof Comment : "Added value is not a Comment"; //$NON-NLS-1$ - SetRequest setRequest = new SetRequest((TransactionalEditingDomain)editingDomain, source, feature, value); + SetRequest setRequest = new SetRequest((TransactionalEditingDomain) editingDomain, source, feature, value); return getCommandFromRequests(getProvider(), Collections.singletonList(setRequest)); } /** - * @see org.eclipse.papyrus.uml.tools.databinding.PapyrusObservableList#getRemoveCommand(java.lang.Object) + * @see org.eclipse.papyrus.infra.gmfdiag.common.databinding.GMFObservableList#getRemoveCommand(java.lang.Object) * * @param value * @return */ @Override public Command getRemoveCommand(Object value) { - assert value instanceof Comment : "Deleted value is not a Comment"; + assert value instanceof Comment : "Deleted value is not a Comment"; //$NON-NLS-1$ - DestroyElementRequest destroyRequest = new DestroyElementRequest((TransactionalEditingDomain)editingDomain, (EObject)value, false); + DestroyElementRequest destroyRequest = new DestroyElementRequest((TransactionalEditingDomain) editingDomain, (EObject) value, false); return getCommandFromRequests(getProvider(), Collections.singletonList(destroyRequest)); } } diff --git a/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/databinding/OwnerObservableValue.java b/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/databinding/OwnerObservableValue.java new file mode 100755 index 00000000000..3b47268efd6 --- /dev/null +++ b/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/databinding/OwnerObservableValue.java @@ -0,0 +1,192 @@ +/***************************************************************************** + * Copyright (c) 2010, 2014 CEA LIST and others. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License 2.0 + * which accompanies this distribution, and is available at + * https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * Camille Letavernier (CEA LIST) camille.letavernier@cea.fr - Initial API and implementation + * Christian W. Damus (CEA) - 402525 + * Christian W. Damus (CEA) - bug 417409 + * + *****************************************************************************/ +package org.eclipse.papyrus.uml.properties.databinding; + +import java.util.ArrayList; +import java.util.List; + +import org.eclipse.core.databinding.observable.ChangeEvent; +import org.eclipse.core.databinding.observable.Diffs; +import org.eclipse.core.databinding.observable.IChangeListener; +import org.eclipse.core.databinding.observable.IObservable; +import org.eclipse.core.databinding.observable.IObserving; +import org.eclipse.core.databinding.observable.list.IObservableList; +import org.eclipse.emf.common.command.Command; +import org.eclipse.emf.common.command.UnexecutableCommand; +import org.eclipse.emf.databinding.EMFProperties; +import org.eclipse.emf.ecore.EObject; +import org.eclipse.emf.ecore.EStructuralFeature; +import org.eclipse.emf.edit.domain.EditingDomain; +import org.eclipse.gmf.runtime.common.core.command.ICommand; +import org.eclipse.gmf.runtime.emf.type.core.requests.SetRequest; +import org.eclipse.papyrus.infra.emf.gmf.command.GMFtoEMFCommandWrapper; +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.ui.databinding.AggregatedPapyrusObservableValue; +import org.eclipse.papyrus.infra.tools.databinding.AggregatedObservable; +import org.eclipse.papyrus.infra.tools.databinding.CommandBasedObservableValue; +import org.eclipse.papyrus.infra.tools.databinding.ReferenceCountedObservable; +import org.eclipse.papyrus.uml.tools.Activator; +import org.eclipse.papyrus.uml.tools.databinding.OwnedAttributeHelper; +import org.eclipse.uml2.uml.Association; +import org.eclipse.uml2.uml.Property; +import org.eclipse.uml2.uml.UMLPackage; + +/** + * An ObservableValue for manipulating the UML Owner property. + * The owner property is a virtual property, represented as an enumeration, + * which can have two values : Association (Owned by Association) or Classifier + * (Owned by Classifier) + * + * This value can be determined by the following query : + * if self.association.ownedEnd->contains(self) then 'Association' else 'Classifier' endif + * + * This value doesn't make sense for n-ary associations, when n > 2. + * + * @author Camille Letavernier + * @since 3.3 + */ +public class OwnerObservableValue extends ReferenceCountedObservable.Value implements IChangeListener, AggregatedObservable, CommandBasedObservableValue, IObserving { + + private Property memberEnd; + + private EditingDomain domain; + + private String currentValue; + + private final IObservableList navigableEndsObservableList; + + /** + * Owned by classifier + */ + public static final String CLASSIFIER = "Classifier"; //$NON-NLS-1$ + + /** + * Owned by association + */ + public static final String ASSOCIATION = "Association"; //$NON-NLS-1$ + + /** + * Constructor. + * + * @param source + * The EObject (Property) which the ownership is being edited + * @param domain + * The Editing Domain on which the commands will be executed + */ + public OwnerObservableValue(EObject source, EditingDomain domain) { + this.memberEnd = (Property) source; + this.domain = domain; + navigableEndsObservableList = EMFProperties.list(UMLPackage.eINSTANCE.getAssociation_NavigableOwnedEnd()).observe(memberEnd.getAssociation()); + navigableEndsObservableList.addChangeListener(this); + } + + @Override + public void handleChange(ChangeEvent event) { + fireValueChange(Diffs.createValueDiff(currentValue, doGetValue())); + } + + @Override + public Object getValueType() { + return String.class; + } + + @Override + protected String doGetValue() { + return memberEnd.getAssociation().getOwnedEnds().contains(memberEnd) ? "Association" : "Classifier"; //$NON-NLS-1$ //$NON-NLS-2$ + } + + @Override + protected void doSetValue(Object value) { + Command command = getCommand(value); + domain.getCommandStack().execute(command); + } + + @Override + public Object getObserved() { + return memberEnd; + } + + @Override + public synchronized void dispose() { + super.dispose(); + navigableEndsObservableList.removeChangeListener(this); + navigableEndsObservableList.dispose(); + } + + @Override + public Command getCommand(Object value) { + if (value instanceof String) { + String owner = (String) value; + boolean isOwnedByAssociation = ASSOCIATION.equals(owner); + + Association association = memberEnd.getAssociation(); + + if (association.getMemberEnds().size() > 2) { + Activator.log.warn("Cannot change End owner for n-ary associations"); //$NON-NLS-1$ + return UnexecutableCommand.INSTANCE; + } + + // Classifier classifier = memberEnd.getClass_(); + // EStructuralFeature ownedEndFeature = association.eClass().getEStructuralFeature(UMLPackage.ASSOCIATION__OWNED_END); + + ICommand command = null; + + if (isOwnedByAssociation) { // Owned by Association + IElementEditService provider = ElementEditServiceUtils.getCommandProvider(association); + if (provider != null) { + EStructuralFeature feature = UMLPackage.eINSTANCE.getAssociation_OwnedEnd(); + List<Property> attributeList = new ArrayList<>(); + attributeList.addAll(association.getOwnedEnds()); + attributeList.add(memberEnd); + // association.eSet(feature, attributeList); + + SetRequest request = new SetRequest(association, feature, attributeList); + + command = provider.getEditCommand(request); + + } + } else { // Owned by Classifier + + command = OwnedAttributeHelper.getSetTypeOwnerForAssociationAttributeCommand(association, memberEnd); + } + + if (command != null) { + this.currentValue = owner; + return new GMFtoEMFCommandWrapper(command); + } else { + Activator.log.warn("Cannot modify the memberEnd owner"); //$NON-NLS-1$ + } + } + + return UnexecutableCommand.INSTANCE; + } + + @Override + public AggregatedObservable aggregate(IObservable observable) { + try { + return new AggregatedPapyrusObservableValue(domain, this, observable); + } catch (IllegalArgumentException ex) { + return null; // The observable cannot be aggregated + } + } + + @Override + public boolean hasDifferentValues() { + return false; + } +} diff --git a/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/databinding/ProfileApplicationObservableList.java b/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/databinding/ProfileApplicationObservableList.java new file mode 100755 index 00000000000..aa4f64a7f20 --- /dev/null +++ b/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/databinding/ProfileApplicationObservableList.java @@ -0,0 +1,362 @@ +/***************************************************************************** + * Copyright (c) 2011, 2014 CEA LIST, Christian W. Damus, and others. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License 2.0 + * which accompanies this distribution, and is available at + * https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * Camille Letavernier (CEA LIST) camille.letavernier@cea.fr - Initial API and implementation + * Christian W. Damus (CEA) - 402525 + * Christian W. Damus - bug 399859 + * + *****************************************************************************/ +package org.eclipse.papyrus.uml.properties.databinding; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.LinkedList; +import java.util.List; + +import org.eclipse.core.databinding.observable.IObserving; +import org.eclipse.core.databinding.observable.list.ListDiff; +import org.eclipse.core.databinding.observable.list.ListDiffEntry; +import org.eclipse.core.databinding.observable.list.WritableList; +import org.eclipse.emf.common.command.Command; +import org.eclipse.emf.common.command.CompoundCommand; +import org.eclipse.emf.ecore.EObject; +import org.eclipse.emf.edit.domain.EditingDomain; +import org.eclipse.emf.transaction.TransactionalEditingDomain; +import org.eclipse.papyrus.infra.emf.utils.EMFHelper; +import org.eclipse.papyrus.infra.widgets.editors.AbstractEditor; +import org.eclipse.papyrus.infra.widgets.editors.ICommitListener; +import org.eclipse.papyrus.uml.tools.commands.ApplyProfileCommand; +import org.eclipse.papyrus.uml.tools.commands.UnapplyProfileCommand; +import org.eclipse.papyrus.uml.tools.databinding.AbstractStereotypeListener; +import org.eclipse.papyrus.uml.tools.helper.ProfileApplicationDelegateRegistry; +import org.eclipse.uml2.uml.Package; +import org.eclipse.uml2.uml.Profile; +import org.eclipse.uml2.uml.ProfileApplication; + +/** + * + * An IObservableList for Profile application + * + * @author Camille Letavernier + * @since 3.3 + */ +@SuppressWarnings({ "unchecked", "rawtypes" }) +public class ProfileApplicationObservableList extends WritableList implements ICommitListener, IObserving { + + private Package umlSource; + + private EditingDomain domain; + + private final List<Command> commands; + + private AbstractStereotypeListener listener; + + /** + * Initializes me with the default applied profiles provider. + * + * @param umlSource + * The Package on which the profiles are applied or unapplied + * @param domain + * The editing domain on which the commands are executed + */ + public ProfileApplicationObservableList(Package umlSource, EditingDomain domain) { + super(getAppliedProfiles(umlSource), Profile.class); + + this.umlSource = umlSource; + this.domain = domain; + + commands = new LinkedList<>(); + + listener = new AbstractStereotypeListener(umlSource) { + + @Override + protected void handleUnappliedStereotype(final EObject newValue) { + ProfileApplicationObservableList.this.fireListChange(new ListDiff() { + + @Override + public ListDiffEntry[] getDifferences() { + return new ListDiffEntry[] { new ListDiffEntry() { + + @Override + public int getPosition() { + return 0; + } + + @Override + public boolean isAddition() { + return false; + } + + @Override + public Object getElement() { + return newValue; + } + + } }; + } + + }); + } + + @Override + protected void handleAppliedStereotype(final EObject newValue) { + ProfileApplicationObservableList.this.fireListChange(new ListDiff() { + + @Override + public ListDiffEntry[] getDifferences() { + return new ListDiffEntry[] { new ListDiffEntry() { + + @Override + public int getPosition() { + return 0; + } + + @Override + public boolean isAddition() { + return true; + } + + @Override + public Object getElement() { + return newValue; + } + + } }; + } + + }); + } + }; + } + + @Override + public Object getObserved() { + return umlSource; + } + + @Override + public synchronized void dispose() { + super.dispose(); + this.listener.dispose(); + } + + @Override + public void commit(AbstractEditor editor) { + if (commands.isEmpty()) { + return; + } + + CompoundCommand compoundCommand = new CompoundCommand() { + + @Override + public void execute() { + super.execute(); + refreshCacheList(); + } + + @Override + public void undo() { + super.undo(); + refreshCacheList(); + } + + @Override + public void redo() { + super.redo(); + refreshCacheList(); + } + + /** + * We have a sequential execution : the method canExecute() in + * the command n+1 depends on the result of the command n. We can't + * check every command's canExecute() method here, so we only + * check the first one. + */ + @Override + public boolean canExecute() { + return commandList.isEmpty() ? false : commandList.get(0).canExecute(); + } + // TODO : edit the execute() method to call the remaining canExecute() checks + // during the execution + // (n).canExecute() + // (n).execute() + // (n+1).canExecute() + // (n+1).execute() + + // Problem : this is the StrictCompoundCommand's behavior. However, in the + // StrictCompoundCommand implementation, the execute() is called outside of + // the current CommandStack, which is forbidden + }; + + for (Command cmd : commands) { + compoundCommand.append(cmd); + } + + domain.getCommandStack().execute(compoundCommand); + refreshCacheList(); + commands.clear(); + } + + protected final void refreshCacheList() { + wrappedList.clear(); + wrappedList.addAll(getAppliedProfiles(umlSource)); + fireListChange(null); + } + + static Collection<Profile> getAppliedProfiles(Package package_) { + final ProfileApplicationDelegateRegistry reg = ProfileApplicationDelegateRegistry.INSTANCE; + + List<Profile> result = new ArrayList<>(); + for (ProfileApplication next : reg.getDelegate(package_).getProfileApplications(package_)) { + Profile profile = reg.getDelegate(next).getAppliedProfile(next); + if (profile != null) { + result.add(profile); + } + } + + return result; + } + + /** + * {@inheritDoc} + */ + @Override + public void clear() { + removeAll(new LinkedList<Object>(wrappedList)); + } + + /** + * {@inheritDoc} + */ + @Override + public boolean add(Object o) { + if (!(o instanceof Profile)) { + return false; + } + + Profile profile = EMFHelper.reloadIntoContext((Profile) o, umlSource); + Command command = new ApplyProfileCommand(umlSource, profile, (TransactionalEditingDomain) domain); + + commands.add(command); + + + return wrappedList.add(o); + } + + /** + * {@inheritDoc} + */ + @Override + public boolean remove(Object o) { + + if (!(o instanceof Profile)) { + return false; + } + + final Profile profile = (Profile) o; + Command command = new UnapplyProfileCommand(umlSource, profile, (TransactionalEditingDomain) domain); + + commands.add(command); + + return wrappedList.remove(o); + } + + /** + * {@inheritDoc} + */ + @Override + public boolean addAll(Collection c) { + // We only apply the profiles that are not applied yet (To avoid removing them when undo is called) + c.removeAll(wrappedList); + + Collection<Profile> profiles = new LinkedList<>(); + for (Object element : c) { + if (element instanceof Profile) { + profiles.add(EMFHelper.reloadIntoContext((Profile) element, umlSource)); + } else { + throw new IllegalArgumentException("The new value should only contain profiles"); //$NON-NLS-1$ + } + } + Command command = new ApplyProfileCommand(umlSource, profiles, (TransactionalEditingDomain) domain); + + commands.add(command); + + return wrappedList.addAll(c); + } + + /** + * {@inheritDoc} + */ + @Override + public boolean removeAll(Collection c) { + Command command = new UnapplyProfileCommand(umlSource, c, (TransactionalEditingDomain) domain); + + commands.add(command); + + return wrappedList.removeAll(c); + } + + /** + * {@inheritDoc} + */ + @Override + public boolean retainAll(Collection c) { + List<Object> objectsToRemove = new LinkedList<>(); + for (Object object : c) { + if (!contains(object)) { + objectsToRemove.add(object); + } + } + return removeAll(objectsToRemove); + } + + // Unsupported operations. Some of them have a "proxy" implementation + + /** + * {@inheritDoc} + */ + @Override + public void add(int index, Object value) { + add(value); // The list is not ordered + } + + /** + * {@inheritDoc} + */ + @Override + public boolean addAll(int index, Collection c) { + return addAll(c); // The list is not ordered + } + + /** + * {@inheritDoc} + */ + @Override + public Object set(int index, Object element) { + throw new UnsupportedOperationException(); + } + + /** + * {@inheritDoc} + */ + @Override + public Object move(int oldIndex, int newIndex) { + throw new UnsupportedOperationException(); + } + + /** + * {@inheritDoc} + */ + @Override + public Object remove(int index) { + throw new UnsupportedOperationException(); + } +} diff --git a/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/databinding/ProvidedInterfaceObservableList.java b/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/databinding/ProvidedInterfaceObservableList.java new file mode 100755 index 00000000000..87aab22cb02 --- /dev/null +++ b/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/databinding/ProvidedInterfaceObservableList.java @@ -0,0 +1,250 @@ +/***************************************************************************** + * Copyright (c) 2011 - 2014, 2018 CEA LIST. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License 2.0 + * which accompanies this distribution, and is available at + * https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * Camille Letavernier (CEA LIST) camille.letavernier@cea.fr - Initial API and implementation + * Gabriel Pascual (ALL4TEC) gabriel.pascual@all4tec.net - Initial API and implementation + * Vincent LORENZO - bug 541313 - [UML][CDO] UML calls to the method getCacheAdapter(EObject) must be replaced + *****************************************************************************/ +package org.eclipse.papyrus.uml.properties.databinding; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.HashSet; +import java.util.Iterator; +import java.util.LinkedList; +import java.util.List; +import java.util.Set; + +import org.eclipse.emf.common.command.Command; +import org.eclipse.emf.common.command.CompoundCommand; +import org.eclipse.emf.common.notify.Adapter; +import org.eclipse.emf.common.util.EList; +import org.eclipse.emf.databinding.EMFProperties; +import org.eclipse.emf.ecore.EObject; +import org.eclipse.emf.edit.domain.EditingDomain; +import org.eclipse.emf.transaction.RecordingCommand; +import org.eclipse.emf.transaction.TransactionalEditingDomain; +import org.eclipse.gmf.runtime.emf.type.core.ElementTypeRegistry; +import org.eclipse.gmf.runtime.emf.type.core.requests.CreateRelationshipRequest; +import org.eclipse.gmf.runtime.emf.type.core.requests.DestroyReferenceRequest; +import org.eclipse.gmf.runtime.emf.type.core.requests.IEditCommandRequest; +import org.eclipse.papyrus.infra.emf.gmf.command.GMFtoEMFCommandWrapper; +import org.eclipse.papyrus.infra.gmfdiag.common.databinding.GMFObservableList; +import org.eclipse.papyrus.uml.tools.adapters.PortTypeAdapter; +import org.eclipse.papyrus.uml.tools.commands.DestroyDependencyWithoutSupplierCommand; +import org.eclipse.papyrus.uml.tools.utils.ElementUtil; +import org.eclipse.uml2.common.util.CacheAdapter; +import org.eclipse.uml2.uml.Dependency; +import org.eclipse.uml2.uml.Interface; +import org.eclipse.uml2.uml.Port; +import org.eclipse.uml2.uml.Realization; +import org.eclipse.uml2.uml.UMLPackage; + +/** + * An IObservableList to edit the UML Derived feature {@link Port#getProvideds()}. + * + * @author Camille Letavernier + * @since 3.3 + */ +public class ProvidedInterfaceObservableList extends GMFObservableList { + + + /** The port. */ + protected Port port = null; + + /** Adapter for port type. */ + private Adapter portTypeAdapter = null; + + /** + * Instantiates a new provided interface observable list. + * + * @param source + * the source + * @param domain + * the domain + */ + public ProvidedInterfaceObservableList(Port source, EditingDomain domain) { + super(EMFProperties.list(UMLPackage.eINSTANCE.getPort_Provided()).observe(source), domain, source, UMLPackage.eINSTANCE.getPort_Provided()); + this.port = source; + port.eAdapters().add(portTypeAdapter = new PortTypeAdapter(port, UMLPackage.eINSTANCE.getPort_Provided(), UMLPackage.Literals.BEHAVIORED_CLASSIFIER__INTERFACE_REALIZATION)); + + } + + /** + * Gets the adds the all command. + * + * @param values + * the values + * @return the adds the all command + * @see org.eclipse.papyrus.infra.gmfdiag.common.databinding.GMFObservableList#getAddAllCommand(java.util.Collection) + */ + @Override + public Command getAddAllCommand(Collection<?> values) { + CompoundCommand returnedCommand = new CompoundCommand(); + List<IEditCommandRequest> requests = new LinkedList<>(); + List<Interface> commonInterfacesList = new ArrayList<>(); + + EList<Interface> providedInterfaceList = port.getProvideds(); + + + // Sort input values + for (Object current : values) { + + if (current instanceof Interface) { + if (!providedInterfaceList.contains(current)) { + // Added interface + IEditCommandRequest request = new CreateRelationshipRequest(port.getType(), port.getType(), (EObject) current, ElementTypeRegistry.getInstance().getType("org.eclipse.papyrus.uml.InterfaceRealization")); //$NON-NLS-1$ + requests.add(request); + } else { + // Common interfaces + commonInterfacesList.add((Interface) current); + } + } + } + + if (!requests.isEmpty()) { + returnedCommand.append(getCommandFromRequests(getProvider(), requests)); + } + + + // Handle deleted interfaces + if (providedInterfaceList.size() != commonInterfacesList.size()) { + List<Interface> removedInterfacesList = new ArrayList<>(); + + for (Interface current : providedInterfaceList) { + if (!commonInterfacesList.contains(current)) { + removedInterfacesList.add(current); + } + } + + returnedCommand.append(getRemoveAllCommand(removedInterfacesList)); + } + + + + return returnedCommand; + + } + + /** + * Gets the removes the command. + * + * @param value + * the value + * @return the removes the command + * @see org.eclipse.papyrus.infra.gmfdiag.common.databinding.GMFObservableList#getRemoveCommand(java.lang.Object) + */ + @Override + public Command getRemoveCommand(Object value) { + CompoundCommand commands = null; + Dependency realization = getRealization(value); + + if (realization != null) { + commands = new CompoundCommand(); + IEditCommandRequest request = new DestroyReferenceRequest((TransactionalEditingDomain) editingDomain, realization, UMLPackage.eINSTANCE.getDependency_Supplier(), (EObject) value, false); + commands.append(new GMFtoEMFCommandWrapper(getProvider().getEditCommand(request))); + commands.append(new GMFtoEMFCommandWrapper(new DestroyDependencyWithoutSupplierCommand((TransactionalEditingDomain) editingDomain, realization, getProvider()))); + + } + return commands; + + + } + + /** + * @see org.eclipse.papyrus.infra.gmfdiag.common.databinding.GMFObservableList#getRemoveAllCommand(java.util.Collection) + * + * @param values + * @return + */ + @Override + public Command getRemoveAllCommand(Collection<?> values) { + CompoundCommand commands = new CompoundCommand(); + Set<Dependency> dependenciesSet = new HashSet<>(); + + for (Object value : values) { + Dependency realization = getRealization(value); + if (realization != null) { + IEditCommandRequest request = new DestroyReferenceRequest((TransactionalEditingDomain) editingDomain, realization, UMLPackage.eINSTANCE.getDependency_Supplier(), (EObject) value, false); + commands.append(new GMFtoEMFCommandWrapper(getProvider().getEditCommand(request))); + dependenciesSet.add(realization); + } + } + + commands.append(new GMFtoEMFCommandWrapper(new DestroyDependencyWithoutSupplierCommand((TransactionalEditingDomain) editingDomain, dependenciesSet, getProvider()))); + + return commands; + } + + /** + * Gets the realization. + * + * @param value + * the value + * @return the realization + */ + private Dependency getRealization(Object value) { + Realization realization = null; + if (value instanceof Interface) { + Interface deletedInterface = (Interface) value; + List<Realization> realizationsList = ElementUtil.getInstancesFilteredByType(port.getModel(), Realization.class, null); + + // Parse all Realizations of model + boolean isRealization = false; + Iterator<Realization> realizationsIterator = realizationsList.iterator(); + Realization current = null; + while (realizationsIterator.hasNext() && !isRealization) { + current = realizationsIterator.next(); + + // Check if Realization links port's type to deleted interface + isRealization = current.getSuppliers().contains(deletedInterface) && current.getClients().contains(port.getType()); + if (isRealization) { + realization = current; + } + } + } + + return realization; + } + + /** + * Gets the clear command. + * + * @return the clear command + * @see org.eclipse.papyrus.infra.gmfdiag.common.databinding.GMFObservableList#getClearCommand() + */ + + @Override + public Command getClearCommand() { + + return new RecordingCommand((TransactionalEditingDomain) editingDomain) { + + @Override + protected void doExecute() { + CacheAdapter cache = CacheAdapter.getInstance(); + cache.put(port, UMLPackage.Literals.PORT__PROVIDED, null); + + } + }; + } + + + /** + * @see org.eclipse.papyrus.infra.ui.emf.databinding.EMFObservableList#dispose() + * + */ + @Override + public synchronized void dispose() { + port.eAdapters().remove(portTypeAdapter); + super.dispose(); + } + +} diff --git a/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/databinding/RequiredInterfaceObservableList.java b/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/databinding/RequiredInterfaceObservableList.java new file mode 100755 index 00000000000..c3a6beddeb2 --- /dev/null +++ b/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/databinding/RequiredInterfaceObservableList.java @@ -0,0 +1,236 @@ +/***************************************************************************** + * Copyright (c) 2011, 2018 CEA LIST. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License 2.0 + * which accompanies this distribution, and is available at + * https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * Camille Letavernier (CEA LIST) camille.letavernier@cea.fr - Initial API and implementation + * Gabriel Pascual (ALL4TEC) gabriel.pascual@all4tec.net - Initial API and implementation + * Vincent LORENZO - bug 541313 - [UML][CDO] UML calls to the method getCacheAdapter(EObject) must be replaced + *****************************************************************************/ +package org.eclipse.papyrus.uml.properties.databinding; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.HashSet; +import java.util.Iterator; +import java.util.LinkedList; +import java.util.List; +import java.util.Set; + +import org.eclipse.emf.common.command.Command; +import org.eclipse.emf.common.command.CompoundCommand; +import org.eclipse.emf.common.notify.Adapter; +import org.eclipse.emf.common.util.EList; +import org.eclipse.emf.databinding.EMFProperties; +import org.eclipse.emf.ecore.EObject; +import org.eclipse.emf.edit.domain.EditingDomain; +import org.eclipse.emf.transaction.RecordingCommand; +import org.eclipse.emf.transaction.TransactionalEditingDomain; +import org.eclipse.gmf.runtime.emf.type.core.ElementTypeRegistry; +import org.eclipse.gmf.runtime.emf.type.core.requests.CreateRelationshipRequest; +import org.eclipse.gmf.runtime.emf.type.core.requests.DestroyReferenceRequest; +import org.eclipse.gmf.runtime.emf.type.core.requests.IEditCommandRequest; +import org.eclipse.papyrus.infra.emf.gmf.command.GMFtoEMFCommandWrapper; +import org.eclipse.papyrus.infra.gmfdiag.common.databinding.GMFObservableList; +import org.eclipse.papyrus.uml.tools.adapters.PortTypeAdapter; +import org.eclipse.papyrus.uml.tools.commands.DestroyDependencyWithoutSupplierCommand; +import org.eclipse.papyrus.uml.tools.utils.ElementUtil; +import org.eclipse.uml2.common.util.CacheAdapter; +import org.eclipse.uml2.uml.Dependency; +import org.eclipse.uml2.uml.Interface; +import org.eclipse.uml2.uml.Port; +import org.eclipse.uml2.uml.UMLPackage; +import org.eclipse.uml2.uml.Usage; + +/** + * An IObservableList to edit the UML Derived feature {@link Port#getRequireds()} + * + * @author Camille Letavernier + * @since 3.3 + * + */ +public class RequiredInterfaceObservableList extends GMFObservableList { + + /** The port. */ + protected Port port = null; + + /** The port type adapter. */ + private Adapter portTypeAdapter = null; + + /** + * Instantiates a new required interface observable list. + * + * @param source + * the source + * @param domain + * the domain + */ + public RequiredInterfaceObservableList(Port source, EditingDomain domain) { + super(EMFProperties.list(UMLPackage.eINSTANCE.getPort_Required()).observe(source), domain, source, UMLPackage.eINSTANCE.getPort_Required()); + this.port = source; + port.eAdapters().add(portTypeAdapter = new PortTypeAdapter(port, UMLPackage.Literals.PORT__REQUIRED, UMLPackage.Literals.PACKAGE__PACKAGED_ELEMENT)); + } + + /** + * @see org.eclipse.papyrus.infra.gmfdiag.common.databinding.GMFObservableList#getAddAllCommand(java.util.Collection) + * + * @param values + * @return + */ + @Override + public Command getAddAllCommand(Collection<?> values) { + + CompoundCommand returnedCommand = new CompoundCommand(); + List<IEditCommandRequest> requests = new LinkedList<>(); + List<Interface> commonInterfacesList = new ArrayList<>(); + EList<Interface> requiredInterfacesList = port.getRequireds(); + + for (Object current : values) { + if (current instanceof Interface) { + + if (!requiredInterfacesList.contains(current)) { + + // Added interface + IEditCommandRequest request = new CreateRelationshipRequest(port.getType().eContainer(), port.getType(), (EObject) current, ElementTypeRegistry.getInstance().getType("org.eclipse.papyrus.uml.Usage")); //$NON-NLS-1$ + requests.add(request); + } else { + + // Conserved interface + commonInterfacesList.add((Interface) current); + } + } + } + + if (!requests.isEmpty()) { + returnedCommand.append(getCommandFromRequests(getProvider(), requests)); + } + + // Handle deleted interfaces + if (requiredInterfacesList.size() != commonInterfacesList.size()) { + List<Interface> removedInterfacesList = new ArrayList<>(); + + for (Interface current : requiredInterfacesList) { + if (!commonInterfacesList.contains(current)) { + removedInterfacesList.add(current); + } + } + + returnedCommand.append(getRemoveAllCommand(removedInterfacesList)); + } + + return returnedCommand; + } + + /** + * @see org.eclipse.papyrus.infra.gmfdiag.common.databinding.GMFObservableList#getRemoveCommand(java.lang.Object) + * + * @param value + * @return + */ + @Override + public Command getRemoveCommand(Object value) { + CompoundCommand commands = null; + Dependency usage = getUsage(value); + if (usage != null) { + commands = new CompoundCommand(); + IEditCommandRequest request = new DestroyReferenceRequest((TransactionalEditingDomain) editingDomain, usage, UMLPackage.eINSTANCE.getDependency_Supplier(), (EObject) value, false); + commands.append(new GMFtoEMFCommandWrapper(getProvider().getEditCommand(request))); + commands.append(new GMFtoEMFCommandWrapper(new DestroyDependencyWithoutSupplierCommand((TransactionalEditingDomain) editingDomain, usage, getProvider()))); + + } + + return commands; + } + + /** + * @see org.eclipse.papyrus.infra.gmfdiag.common.databinding.GMFObservableList#getRemoveAllCommand(java.util.Collection) + * + * @param values + * @return + */ + @Override + public Command getRemoveAllCommand(Collection<?> values) { + CompoundCommand commands = new CompoundCommand(); + Set<Dependency> dependenciesSet = new HashSet<>(); + + for (Object value : values) { + Dependency usage = getUsage(value); + if (usage != null) { + IEditCommandRequest request = new DestroyReferenceRequest((TransactionalEditingDomain) editingDomain, usage, UMLPackage.eINSTANCE.getDependency_Supplier(), (EObject) value, false); + commands.append(new GMFtoEMFCommandWrapper(getProvider().getEditCommand(request))); + dependenciesSet.add(usage); + } + } + + commands.append(new GMFtoEMFCommandWrapper(new DestroyDependencyWithoutSupplierCommand((TransactionalEditingDomain) editingDomain, dependenciesSet, getProvider()))); + + return commands; + } + + /** + * @see org.eclipse.papyrus.infra.gmfdiag.common.databinding.GMFObservableList#getClearCommand() + * + * @return + */ + @Override + public Command getClearCommand() { + return new RecordingCommand((TransactionalEditingDomain) editingDomain) { + + @Override + protected void doExecute() { + CacheAdapter cache = CacheAdapter.getInstance(); + cache.put(port, UMLPackage.Literals.PORT__REQUIRED, null); + + } + }; + } + + /** + * Gets the usage. + * + * @param value + * the value + * @return the usage + */ + private Dependency getUsage(Object value) { + Usage usage = null; + if (value instanceof Interface) { + Interface deletedInterface = (Interface) value; + List<Usage> usagesList = ElementUtil.getInstancesFilteredByType(port.getModel(), Usage.class, null); + + // Parse all Usages of model + boolean isUsage = false; + Iterator<Usage> usagesIterator = usagesList.iterator(); + Usage current = null; + while (usagesIterator.hasNext() && !isUsage) { + current = usagesIterator.next(); + + // Check if Usage links port's type to deleted interface + isUsage = current.getSuppliers().contains(deletedInterface) && current.getClients().contains(port.getType()); + if (isUsage) { + usage = current; + } + } + } + + return usage; + } + + /** + * @see org.eclipse.papyrus.infra.ui.emf.databinding.EMFObservableList#dispose() + * + */ + @Override + public synchronized void dispose() { + port.eAdapters().remove(portTypeAdapter); + super.dispose(); + } + + +} diff --git a/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/databinding/UnsettableStringObservableValue.java b/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/databinding/UnsettableStringObservableValue.java new file mode 100755 index 00000000000..4259e3eaf9b --- /dev/null +++ b/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/databinding/UnsettableStringObservableValue.java @@ -0,0 +1,64 @@ +/***************************************************************************** + * Copyright (c) 2014 CEA LIST and others. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License 2.0 + * which accompanies this distribution, and is available at + * https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * CEA LIST - Initial API and implementation + * Gabriel Pascual (ALL4TEC) gabriel.pascual@all4tec.net - bug 447698 + * + *****************************************************************************/ + +package org.eclipse.papyrus.uml.properties.databinding; + +import org.eclipse.core.databinding.observable.Realm; +import org.eclipse.emf.ecore.EObject; +import org.eclipse.emf.ecore.EStructuralFeature; +import org.eclipse.emf.edit.domain.EditingDomain; +import org.eclipse.emf.transaction.TransactionalEditingDomain; +import org.eclipse.gmf.runtime.emf.type.core.requests.IEditCommandRequest; +import org.eclipse.papyrus.infra.emf.requests.UnsetRequest; +import org.eclipse.papyrus.infra.gmfdiag.common.databinding.GMFObservableValue; + + +/** + * A specialized observable for string-valued attributes that are "unsettable" in the EMF sense, having a distinct unset state. + * For string features that have a {@code null} default, instead of accepting the empty string, the feature is simply unset so + * that it will be {@code null}. + * + * @since 3.3 + */ +public class UnsettableStringObservableValue extends GMFObservableValue { + + public UnsettableStringObservableValue(EObject eObject, EStructuralFeature eStructuralFeature, EditingDomain domain) { + super(eObject, eStructuralFeature, domain); + } + + public UnsettableStringObservableValue(Realm realm, EObject eObject, EStructuralFeature eStructuralFeature, EditingDomain domain) { + super(realm, eObject, eStructuralFeature, domain); + } + + + @Override + protected IEditCommandRequest createSetRequest(TransactionalEditingDomain domain, EObject owner, EStructuralFeature feature, Object value) { + + // Bug 447698 : It doesn't necessary to create UnsetRequest if the value is already null + if ("".equals(value)) {//$NON-NLS-1$ + + if ((feature.getDefaultValue() == null) && owner.eGet(eStructuralFeature) != null) { + // Unset the string attribute instead of making it an empty string + return new UnsetRequest(owner, feature); + } + + } else { + return super.createSetRequest(domain, owner, feature, value); + } + + return null; + } +} diff --git a/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/databinding/helpers/UMLDatabindingHelper.java b/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/databinding/helpers/UMLDatabindingHelper.java new file mode 100755 index 00000000000..ab4c19ef002 --- /dev/null +++ b/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/databinding/helpers/UMLDatabindingHelper.java @@ -0,0 +1,50 @@ +/***************************************************************************** + * Copyright (c) 2012 CEA LIST. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License 2.0 + * which accompanies this distribution, and is available at + * https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * Camille Letavernier (CEA LIST) camille.letavernier@cea.fr - Initial API and implementation + *****************************************************************************/ +package org.eclipse.papyrus.uml.properties.databinding.helpers; + +import org.eclipse.core.databinding.observable.value.IObservableValue; +import org.eclipse.emf.databinding.EMFProperties; +import org.eclipse.emf.ecore.EObject; +import org.eclipse.emf.ecore.EStructuralFeature; +import org.eclipse.emf.edit.domain.EditingDomain; +import org.eclipse.papyrus.infra.gmfdiag.common.databinding.GMFObservableValue; + +/** + * A Helper class for UML Databinding + * + * @author Camille Letavernier + * @since 3.3 + */ +public class UMLDatabindingHelper { + + /** + * Returns an IObservableValue for the given feature and EObject + * + * If the EditingDomain is set, the IObservableValue will use the Papyrus ServiceEdit ; + * otherwise, a standard EMFObservableValue will be used + * + * @param source + * The EObject to observe + * @param feature + * The feature to observe + * @param domain + * The editing domain on which the commands will be executed. If null, direct + * object modifications will be used. + * @return + * The IObservableValue + */ + public static IObservableValue getObservableValue(EObject source, EStructuralFeature feature, EditingDomain domain) { + return domain == null ? EMFProperties.value(feature).observe(source) : new GMFObservableValue(source, feature, domain); + } +} diff --git a/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/datatype/StringDataTypeObservableValue.java b/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/datatype/StringDataTypeObservableValue.java index ebb85ab741f..dc8020ce4d2 100644 --- a/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/datatype/StringDataTypeObservableValue.java +++ b/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/datatype/StringDataTypeObservableValue.java @@ -17,10 +17,10 @@ import org.eclipse.emf.ecore.EDataType; import org.eclipse.emf.ecore.EObject; import org.eclipse.emf.ecore.EStructuralFeature; import org.eclipse.emf.edit.domain.EditingDomain; -import org.eclipse.papyrus.uml.tools.databinding.PapyrusObservableValue; +import org.eclipse.papyrus.infra.gmfdiag.common.databinding.GMFObservableValue; -public class StringDataTypeObservableValue extends PapyrusObservableValue implements DataTypeObservableValue { +public class StringDataTypeObservableValue extends GMFObservableValue implements DataTypeObservableValue { protected EDataType type; @@ -33,6 +33,7 @@ public class StringDataTypeObservableValue extends PapyrusObservableValue implem return type.getInstanceClass(); } + @Override public void setOwner(EObject owner, EStructuralFeature feature, EditingDomain domain, EDataType type) { this.eObject = owner; this.eStructuralFeature = feature; diff --git a/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/datatype/StructuredDataTypeObservableValue.java b/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/datatype/StructuredDataTypeObservableValue.java index 0dd628d3fce..76f90e54205 100644 --- a/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/datatype/StructuredDataTypeObservableValue.java +++ b/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/datatype/StructuredDataTypeObservableValue.java @@ -18,14 +18,14 @@ import org.eclipse.emf.ecore.EDataType; import org.eclipse.emf.ecore.EObject; import org.eclipse.emf.ecore.EStructuralFeature; import org.eclipse.emf.edit.domain.EditingDomain; -import org.eclipse.papyrus.uml.tools.databinding.PapyrusObservableValue; +import org.eclipse.papyrus.infra.gmfdiag.common.databinding.GMFObservableValue; /** * Allows the manipulation of a UML DataType from a static profile (Implemented by an EMF EDataType) * * @author Camille Letavernier */ -public class StructuredDataTypeObservableValue extends PapyrusObservableValue implements IAdaptable { +public class StructuredDataTypeObservableValue extends GMFObservableValue implements IAdaptable { protected EDataType type; @@ -57,10 +57,11 @@ public class StructuredDataTypeObservableValue extends PapyrusObservableValue im @Override protected void doSetValue(Object value) { // value = dataType instance - super.doSetValue(value); // TODO : type réel de value ? compatibilité des types ? + super.doSetValue(value); // TODO : real type of the value ? type compatibility ? } + @Override public Object getAdapter(Class adapter) { throw new UnsupportedOperationException(); } diff --git a/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/modelelement/CustomImageModelElement.java b/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/modelelement/CustomImageModelElement.java index e3b87ef6c07..09719e32b9d 100644 --- a/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/modelelement/CustomImageModelElement.java +++ b/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/modelelement/CustomImageModelElement.java @@ -13,9 +13,9 @@ *****************************************************************************/ package org.eclipse.papyrus.uml.properties.modelelement; -import static org.eclipse.papyrus.uml.tools.databinding.ImageKindObservableValue.KIND_ICON; -import static org.eclipse.papyrus.uml.tools.databinding.ImageKindObservableValue.KIND_SHAPE; -import static org.eclipse.papyrus.uml.tools.databinding.ImageKindObservableValue.KIND_UNDEFINED; +import static org.eclipse.papyrus.uml.properties.databinding.ImageKindObservableValue.KIND_ICON; +import static org.eclipse.papyrus.uml.properties.databinding.ImageKindObservableValue.KIND_SHAPE; +import static org.eclipse.papyrus.uml.properties.databinding.ImageKindObservableValue.KIND_UNDEFINED; import org.eclipse.core.databinding.observable.IObservable; import org.eclipse.emf.edit.domain.EditingDomain; @@ -24,9 +24,9 @@ import org.eclipse.papyrus.infra.widgets.providers.AbstractStaticContentProvider import org.eclipse.papyrus.infra.widgets.providers.EmptyContentProvider; import org.eclipse.papyrus.infra.widgets.providers.IStaticContentProvider; import org.eclipse.papyrus.uml.properties.Activator; -import org.eclipse.papyrus.uml.tools.databinding.ImageExpressionObservableValue; -import org.eclipse.papyrus.uml.tools.databinding.ImageKindObservableValue; -import org.eclipse.papyrus.uml.tools.databinding.ImageNameObservableValue; +import org.eclipse.papyrus.uml.properties.databinding.ImageExpressionObservableValue; +import org.eclipse.papyrus.uml.properties.databinding.ImageKindObservableValue; +import org.eclipse.papyrus.uml.properties.databinding.ImageNameObservableValue; import org.eclipse.uml2.uml.Image; /** @@ -101,6 +101,7 @@ public class CustomImageModelElement extends AbstractModelElement { if (propertyPath.equals(KIND)) { return new AbstractStaticContentProvider() { + @Override public Object[] getElements() { return new String[] { KIND_UNDEFINED, KIND_ICON, KIND_SHAPE }; } diff --git a/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/modelelement/MemberEndModelElement.java b/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/modelelement/MemberEndModelElement.java index eaaf2924532..d4fb178a808 100644 --- a/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/modelelement/MemberEndModelElement.java +++ b/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/modelelement/MemberEndModelElement.java @@ -16,8 +16,8 @@ *****************************************************************************/ package org.eclipse.papyrus.uml.properties.modelelement; -import static org.eclipse.papyrus.uml.tools.databinding.OwnerObservableValue.ASSOCIATION; -import static org.eclipse.papyrus.uml.tools.databinding.OwnerObservableValue.CLASSIFIER; +import static org.eclipse.papyrus.uml.properties.databinding.OwnerObservableValue.ASSOCIATION; +import static org.eclipse.papyrus.uml.properties.databinding.OwnerObservableValue.CLASSIFIER; import static org.eclipse.papyrus.uml.tools.util.MultiplicityParser.ANY; import static org.eclipse.papyrus.uml.tools.util.MultiplicityParser.ONE; import static org.eclipse.papyrus.uml.tools.util.MultiplicityParser.ONE_OR_MORE; @@ -33,10 +33,10 @@ import org.eclipse.papyrus.infra.properties.ui.modelelement.AbstractModelElement import org.eclipse.papyrus.infra.widgets.providers.IStaticContentProvider; import org.eclipse.papyrus.infra.widgets.providers.StaticContentProvider; import org.eclipse.papyrus.uml.properties.Activator; -import org.eclipse.papyrus.uml.tools.databinding.ExtendedMultiplicityObservableValue; -import org.eclipse.papyrus.uml.tools.databinding.ExtensionEndMultiplicityObservableValue; -import org.eclipse.papyrus.uml.tools.databinding.NavigationObservableValue; -import org.eclipse.papyrus.uml.tools.databinding.OwnerObservableValue; +import org.eclipse.papyrus.uml.properties.databinding.ExtendedMultiplicityObservableValue; +import org.eclipse.papyrus.uml.properties.databinding.ExtensionEndMultiplicityObservableValue; +import org.eclipse.papyrus.uml.properties.databinding.NavigationObservableValue; +import org.eclipse.papyrus.uml.properties.databinding.OwnerObservableValue; import org.eclipse.uml2.uml.ExtensionEnd; import org.eclipse.uml2.uml.Property; import org.eclipse.uml2.uml.UMLPackage; diff --git a/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/modelelement/ProfileDefinitionObservableValue.java b/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/modelelement/ProfileDefinitionObservableValue.java index 5db5648331c..2523dc0247c 100644 --- a/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/modelelement/ProfileDefinitionObservableValue.java +++ b/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/modelelement/ProfileDefinitionObservableValue.java @@ -17,7 +17,6 @@ package org.eclipse.papyrus.uml.properties.modelelement; import java.util.List; -import org.eclipse.core.databinding.observable.IObservable; import org.eclipse.emf.common.command.Command; import org.eclipse.emf.ecore.EObject; import org.eclipse.emf.ecore.EPackage; @@ -25,9 +24,9 @@ import org.eclipse.emf.ecore.EStructuralFeature; import org.eclipse.emf.ecore.util.EcoreUtil; import org.eclipse.emf.edit.domain.EditingDomain; import org.eclipse.emf.transaction.TransactionalEditingDomain; +import org.eclipse.papyrus.infra.gmfdiag.common.databinding.GMFObservableList; import org.eclipse.papyrus.uml.tools.commands.DefineProfileCommand; import org.eclipse.papyrus.uml.tools.commands.UndefineProfileCommand; -import org.eclipse.papyrus.uml.tools.databinding.PapyrusObservableList; import org.eclipse.papyrus.uml.tools.profile.definition.IPapyrusVersionConstants; import org.eclipse.papyrus.uml.tools.profile.definition.PapyrusDefinitionAnnotation; import org.eclipse.papyrus.uml.tools.util.IPapyrusProfileDefinition; @@ -36,7 +35,7 @@ import org.eclipse.uml2.uml.Profile; /** * Observable for Profile Definition list of a profile. */ -public class ProfileDefinitionObservableValue extends PapyrusObservableList implements IObservable { +public class ProfileDefinitionObservableValue extends GMFObservableList { /** The profile which contains definitions. */ private Profile profile = null; diff --git a/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/modelelement/StereotypeApplicationModelElement.java b/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/modelelement/StereotypeApplicationModelElement.java index 083d5943015..11cff1033ef 100644 --- a/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/modelelement/StereotypeApplicationModelElement.java +++ b/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/modelelement/StereotypeApplicationModelElement.java @@ -28,8 +28,8 @@ import org.eclipse.papyrus.infra.emf.utils.ServiceUtilsForResource; import org.eclipse.papyrus.infra.properties.ui.modelelement.EMFModelElement; import org.eclipse.papyrus.infra.services.labelprovider.service.LabelProviderService; import org.eclipse.papyrus.infra.widgets.providers.IStaticContentProvider; +import org.eclipse.papyrus.uml.properties.databinding.ProfileApplicationObservableList; import org.eclipse.papyrus.uml.properties.databinding.StereotypeApplicationObservableList; -import org.eclipse.papyrus.uml.tools.databinding.ProfileApplicationObservableList; import org.eclipse.papyrus.uml.tools.providers.ApplicableStereotypeContentProvider; import org.eclipse.papyrus.uml.tools.providers.ProfileLabelProvider; import org.eclipse.papyrus.uml.tools.utils.UMLUtil; diff --git a/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/modelelement/StereotypeModelElement.java b/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/modelelement/StereotypeModelElement.java index a633cd8e8b2..2ee44a1ca7f 100644 --- a/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/modelelement/StereotypeModelElement.java +++ b/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/modelelement/StereotypeModelElement.java @@ -29,6 +29,8 @@ import org.eclipse.emf.ecore.EReference; import org.eclipse.emf.ecore.EStructuralFeature; import org.eclipse.emf.edit.domain.EditingDomain; import org.eclipse.papyrus.infra.emf.gmf.command.GMFtoEMFCommandWrapper; +import org.eclipse.papyrus.infra.gmfdiag.common.databinding.GMFObservableList; +import org.eclipse.papyrus.infra.gmfdiag.common.databinding.GMFObservableValue; import org.eclipse.papyrus.infra.properties.ui.modelelement.EMFModelElement; import org.eclipse.papyrus.infra.properties.ui.modelelement.EObjectStructuredValueFactory; import org.eclipse.papyrus.infra.properties.ui.modelelement.ILabeledModelElement; @@ -37,8 +39,6 @@ import org.eclipse.papyrus.infra.widgets.providers.IStaticContentProvider; import org.eclipse.papyrus.uml.properties.Activator; import org.eclipse.papyrus.uml.properties.datatype.DataTypeProvider; import org.eclipse.papyrus.uml.properties.datatype.StructuredDataTypeObservableValue; -import org.eclipse.papyrus.uml.tools.databinding.PapyrusObservableList; -import org.eclipse.papyrus.uml.tools.databinding.PapyrusObservableValue; import org.eclipse.papyrus.uml.tools.providers.UMLContentProvider; import org.eclipse.papyrus.uml.tools.utils.DataTypeUtil; import org.eclipse.papyrus.uml.tools.utils.StereotypeUtil; @@ -103,10 +103,10 @@ public class StereotypeModelElement extends EMFModelElement implements ILabeledM if (feature.getUpperBound() != 1) { - return new PapyrusObservableList(EMFProperties.list(featurePath).observe(source), domain, getSource(featurePath), feature); + return new GMFObservableList(EMFProperties.list(featurePath).observe(source), domain, getSource(featurePath), feature); } - return new PapyrusObservableValue(getSource(featurePath), feature, domain); + return new GMFObservableValue(getSource(featurePath), feature, domain); } /** @@ -162,7 +162,7 @@ public class StereotypeModelElement extends EMFModelElement implements ILabeledM /** * {@inheritDoc} - * + * * @see org.eclipse.papyrus.infra.properties.ui.modelelement.EMFModelElement#getValueFactory(java.lang.String) */ @Override @@ -185,7 +185,7 @@ public class StereotypeModelElement extends EMFModelElement implements ILabeledM /** * {@inheritDoc} - * + * * @see org.eclipse.papyrus.infra.properties.ui.modelelement.ILabeledModelElement#getLabel(java.lang.String) */ @Override diff --git a/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/modelelement/UMLModelElement.java b/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/modelelement/UMLModelElement.java index 1863a29c024..f96a0f9b10d 100644 --- a/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/modelelement/UMLModelElement.java +++ b/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/modelelement/UMLModelElement.java @@ -47,6 +47,8 @@ import org.eclipse.gmf.runtime.emf.core.util.EMFCoreUtil; import org.eclipse.jface.viewers.ITreeContentProvider; import org.eclipse.papyrus.infra.emf.utils.EMFHelper; import org.eclipse.papyrus.infra.emf.utils.HistoryUtil; +import org.eclipse.papyrus.infra.gmfdiag.common.databinding.GMFObservableList; +import org.eclipse.papyrus.infra.gmfdiag.common.databinding.GMFObservableValue; import org.eclipse.papyrus.infra.internationalization.common.utils.InternationalizationPreferencesUtils; import org.eclipse.papyrus.infra.internationalization.utils.utils.InternationalizationConstants; import org.eclipse.papyrus.infra.properties.ui.modelelement.EMFModelElement; @@ -63,14 +65,12 @@ import org.eclipse.papyrus.uml.properties.creation.ConnectorTypeEditorFactory; import org.eclipse.papyrus.uml.properties.creation.MessageValueSpecificationFactory; import org.eclipse.papyrus.uml.properties.creation.OwnedRuleCreationFactory; import org.eclipse.papyrus.uml.properties.creation.UMLPropertyEditorFactory; +import org.eclipse.papyrus.uml.properties.databinding.ExtensionRequiredObservableValue; import org.eclipse.papyrus.uml.properties.databinding.KeywordObservableValue; +import org.eclipse.papyrus.uml.properties.databinding.ProvidedInterfaceObservableList; +import org.eclipse.papyrus.uml.properties.databinding.RequiredInterfaceObservableList; import org.eclipse.papyrus.uml.properties.databinding.UMLLabelObservableValue; -import org.eclipse.papyrus.uml.tools.databinding.ExtensionRequiredObservableValue; -import org.eclipse.papyrus.uml.tools.databinding.PapyrusObservableList; -import org.eclipse.papyrus.uml.tools.databinding.PapyrusObservableValue; -import org.eclipse.papyrus.uml.tools.databinding.ProvidedInterfaceObservableList; -import org.eclipse.papyrus.uml.tools.databinding.RequiredInterfaceObservableList; -import org.eclipse.papyrus.uml.tools.databinding.UnsettableStringValue; +import org.eclipse.papyrus.uml.properties.databinding.UnsettableStringObservableValue; import org.eclipse.papyrus.uml.tools.providers.ConstrainedElementContentProvider; import org.eclipse.papyrus.uml.tools.providers.UMLContainerContentProvider; import org.eclipse.papyrus.uml.tools.providers.UMLContentProvider; @@ -144,13 +144,13 @@ public class UMLModelElement extends EMFModelElement { } else if (feature == null) { value = null; } else if (feature.getUpperBound() != 1) { - IObservableList list = domain == null ? EMFProperties.list(featurePath).observe(source) : new PapyrusObservableList(EMFProperties.list(featurePath).observe(source), domain, getSource(featurePath), feature); + IObservableList list = domain == null ? EMFProperties.list(featurePath).observe(source) : new GMFObservableList(EMFProperties.list(featurePath).observe(source), domain, getSource(featurePath), feature); value = list; } else if ((feature == UMLPackage.Literals.NAMED_ELEMENT__NAME) && (domain != null)) { // Empty string as a name is not useful, so we unset instead - value = new UnsettableStringValue(getSource(featurePath), feature, domain); + value = new UnsettableStringObservableValue(getSource(featurePath), feature, domain); } else { - value = domain == null ? EMFProperties.value(featurePath).observe(source) : new PapyrusObservableValue(getSource(featurePath), feature, domain); + value = domain == null ? EMFProperties.value(featurePath).observe(source) : new GMFObservableValue(getSource(featurePath), feature, domain); } } return value; @@ -296,7 +296,7 @@ public class UMLModelElement extends EMFModelElement { ITreeContentProvider contentProvider = new UMLContainerContentProvider(source, reference); ResourceSet rs = source == null ? null : source.eResource() == null ? null : source.eResource().getResourceSet(); - EMFGraphicalContentProvider provider = ProviderHelper.encapsulateProvider(contentProvider, rs, HistoryUtil.getHistoryID(source, feature, "container")); + EMFGraphicalContentProvider provider = ProviderHelper.encapsulateProvider(contentProvider, rs, HistoryUtil.getHistoryID(source, feature, "container")); //$NON-NLS-1$ factory.setContainerContentProvider(provider); factory.setReferenceContentProvider(new FeatureContentProvider(type)); diff --git a/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/widgets/EStructuralFeatureEditor.java b/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/widgets/EStructuralFeatureEditor.java index f6d334cca79..d8f66672ce5 100644 --- a/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/widgets/EStructuralFeatureEditor.java +++ b/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/widgets/EStructuralFeatureEditor.java @@ -39,6 +39,8 @@ import org.eclipse.emf.ecore.EReference; import org.eclipse.emf.ecore.EStructuralFeature; import org.eclipse.jface.viewers.ILabelProvider; import org.eclipse.papyrus.infra.emf.utils.EMFHelper; +import org.eclipse.papyrus.infra.gmfdiag.common.databinding.GMFObservableList; +import org.eclipse.papyrus.infra.gmfdiag.common.databinding.GMFObservableValue; import org.eclipse.papyrus.infra.ui.emf.providers.EMFEnumeratorContentProvider; import org.eclipse.papyrus.infra.widgets.creation.ReferenceValueFactory; import org.eclipse.papyrus.infra.widgets.editors.AbstractValueEditor; @@ -59,8 +61,6 @@ import org.eclipse.papyrus.infra.widgets.editors.StringEditor; import org.eclipse.papyrus.infra.widgets.editors.TypedMultipleStringEditor; import org.eclipse.papyrus.infra.widgets.providers.IStaticContentProvider; import org.eclipse.papyrus.uml.properties.Activator; -import org.eclipse.papyrus.uml.tools.databinding.PapyrusObservableList; -import org.eclipse.papyrus.uml.tools.databinding.PapyrusObservableValue; import org.eclipse.papyrus.uml.tools.utils.DataTypeUtil; import org.eclipse.swt.layout.GridData; import org.eclipse.swt.widgets.Composite; @@ -176,7 +176,7 @@ public class EStructuralFeatureEditor implements IValueChangeListener<Object>, I final EClassifier featureType = feature.getEType(); if (featureType instanceof EClass && DataTypeUtil.isDataTypeDefinition((EClass) featureType, element)) { final EObjectContentsEditor editor = new EObjectContentsEditor(pageBook, style, (EReference) feature); - editor.setValue(new PapyrusObservableValue(element, feature, EMFHelper.resolveEditingDomain(element))); + editor.setValue(new GMFObservableValue(element, feature, EMFHelper.resolveEditingDomain(element))); currentPage = editor; } else { final ReferenceDialog editor = new ReferenceDialog(pageBook, style); @@ -228,7 +228,7 @@ public class EStructuralFeatureEditor implements IValueChangeListener<Object>, I } protected void setValueEditorProperties(final AbstractValueEditor editor, final EObject stereotypeApplication, final String title, final EStructuralFeature feature) { - final PapyrusObservableValue observable = new PapyrusObservableValue(stereotypeApplication, feature, EMFHelper.resolveEditingDomain(stereotypeApplication)); + final GMFObservableValue observable = new GMFObservableValue(stereotypeApplication, feature, EMFHelper.resolveEditingDomain(stereotypeApplication)); observable.addValueChangeListener(this); editor.setLabel(title); editor.setReadOnly(!isEditable(stereotypeApplication, feature)); @@ -236,7 +236,7 @@ public class EStructuralFeatureEditor implements IValueChangeListener<Object>, I } protected void setMultipleValueEditorProperties(final MultipleValueEditor<?> editor, final List<?> initialList, final EObject stereotypeApplication, final String title, final EStructuralFeature feature) { - final PapyrusObservableList observable = new PapyrusObservableList(initialList, EMFHelper.resolveEditingDomain(stereotypeApplication), stereotypeApplication, feature); + final GMFObservableList observable = new GMFObservableList(initialList, EMFHelper.resolveEditingDomain(stereotypeApplication), stereotypeApplication, feature); observable.addListChangeListener(this); editor.setLabel(title); editor.setUnique(feature.isUnique()); diff --git a/plugins/uml/tools/org.eclipse.papyrus.uml.tools/META-INF/MANIFEST.MF b/plugins/uml/tools/org.eclipse.papyrus.uml.tools/META-INF/MANIFEST.MF index 4128e22f8bf..1151cb69faf 100644 --- a/plugins/uml/tools/org.eclipse.papyrus.uml.tools/META-INF/MANIFEST.MF +++ b/plugins/uml/tools/org.eclipse.papyrus.uml.tools/META-INF/MANIFEST.MF @@ -33,7 +33,7 @@ Require-Bundle: org.eclipse.uml2.uml;bundle-version="[5.3.0,6.0.0)";visibility:= org.eclipse.papyrus.infra.services.decoration;bundle-version="[2.0.0,3.0.0)" Bundle-Vendor: %Bundle-Vendor Bundle-ActivationPolicy: lazy -Bundle-Version: 4.2.0.qualifier +Bundle-Version: 4.3.0.qualifier Bundle-Name: %Bundle-Name Bundle-Activator: org.eclipse.papyrus.uml.tools.Activator Bundle-ManifestVersion: 2 diff --git a/plugins/uml/tools/org.eclipse.papyrus.uml.tools/pom.xml b/plugins/uml/tools/org.eclipse.papyrus.uml.tools/pom.xml index 6d634f293e3..969f040759f 100644 --- a/plugins/uml/tools/org.eclipse.papyrus.uml.tools/pom.xml +++ b/plugins/uml/tools/org.eclipse.papyrus.uml.tools/pom.xml @@ -9,7 +9,7 @@ <version>0.0.1-SNAPSHOT</version> </parent> <artifactId>org.eclipse.papyrus.uml.tools</artifactId> - <version>4.2.0-SNAPSHOT</version> + <version>4.3.0-SNAPSHOT</version> <packaging>eclipse-plugin</packaging> <description>This plugin contributes a set of common tools for UML</description> </project> diff --git a/plugins/uml/tools/org.eclipse.papyrus.uml.tools/src/org/eclipse/papyrus/uml/tools/databinding/AbstractUMLAggregatedObservableValue.java b/plugins/uml/tools/org.eclipse.papyrus.uml.tools/src/org/eclipse/papyrus/uml/tools/databinding/AbstractUMLAggregatedObservableValue.java index e500f7124b4..37107ae62ac 100644 --- a/plugins/uml/tools/org.eclipse.papyrus.uml.tools/src/org/eclipse/papyrus/uml/tools/databinding/AbstractUMLAggregatedObservableValue.java +++ b/plugins/uml/tools/org.eclipse.papyrus.uml.tools/src/org/eclipse/papyrus/uml/tools/databinding/AbstractUMLAggregatedObservableValue.java @@ -26,7 +26,12 @@ import org.eclipse.papyrus.infra.tools.databinding.ReferenceCountedObservable; * * @author Camille Letavernier * + * @deprecated since 3.2 + * use {@link org.eclipe.papyrus.uml.properties.databinding.AbstractUMLAggregatedObservableValue} API, instead. + * + * This class Will be removed in Papyrus 5.0, see bug 540829 */ +@Deprecated public abstract class AbstractUMLAggregatedObservableValue extends ReferenceCountedObservable.Value implements AggregatedObservable, CommandBasedObservableValue { protected EditingDomain domain; @@ -38,6 +43,7 @@ public abstract class AbstractUMLAggregatedObservableValue extends ReferenceCoun /** * {@inheritDoc} */ + @Override public AggregatedObservable aggregate(IObservable observable) { try { return new AggregatedPapyrusObservableValue(domain, this, observable); @@ -49,6 +55,7 @@ public abstract class AbstractUMLAggregatedObservableValue extends ReferenceCoun /** * {@inheritDoc} */ + @Override public boolean hasDifferentValues() { return false; } diff --git a/plugins/uml/tools/org.eclipse.papyrus.uml.tools/src/org/eclipse/papyrus/uml/tools/databinding/AggregatedPapyrusObservableValue.java b/plugins/uml/tools/org.eclipse.papyrus.uml.tools/src/org/eclipse/papyrus/uml/tools/databinding/AggregatedPapyrusObservableValue.java index 656353b78c3..845784ef874 100644 --- a/plugins/uml/tools/org.eclipse.papyrus.uml.tools/src/org/eclipse/papyrus/uml/tools/databinding/AggregatedPapyrusObservableValue.java +++ b/plugins/uml/tools/org.eclipse.papyrus.uml.tools/src/org/eclipse/papyrus/uml/tools/databinding/AggregatedPapyrusObservableValue.java @@ -11,7 +11,7 @@ * Contributors: * Camille Letavernier (CEA LIST) camille.letavernier@cea.fr - Initial API and implementation * Christian W. Damus - bug 485220 - * + * *****************************************************************************/ package org.eclipse.papyrus.uml.tools.databinding; @@ -19,7 +19,10 @@ import org.eclipse.core.databinding.observable.IObservable; import org.eclipse.emf.edit.domain.EditingDomain; /** - * @deprecated Use the {@link org.eclipse.papyrus.infra.services.edit.ui.databinding.AggregatedPapyrusObservableValue} API, instead. + * @deprecated since 1.2 + * Use the {@link org.eclipse.papyrus.infra.services.edit.ui.databinding.AggregatedPapyrusObservableValue} API, instead. + * + * This class Will be removed in Papyrus 5.0, see bug 540829 */ @Deprecated public class AggregatedPapyrusObservableValue extends org.eclipse.papyrus.infra.services.edit.ui.databinding.AggregatedPapyrusObservableValue { diff --git a/plugins/uml/tools/org.eclipse.papyrus.uml.tools/src/org/eclipse/papyrus/uml/tools/databinding/CommandBasedObservable.java b/plugins/uml/tools/org.eclipse.papyrus.uml.tools/src/org/eclipse/papyrus/uml/tools/databinding/CommandBasedObservable.java index e8b277d7825..818745f507a 100644 --- a/plugins/uml/tools/org.eclipse.papyrus.uml.tools/src/org/eclipse/papyrus/uml/tools/databinding/CommandBasedObservable.java +++ b/plugins/uml/tools/org.eclipse.papyrus.uml.tools/src/org/eclipse/papyrus/uml/tools/databinding/CommandBasedObservable.java @@ -11,12 +11,15 @@ * Contributors: * Camille Letavernier (CEA LIST) camille.letavernier@cea.fr - Initial API and implementation * Christian W. Damus - bug 485220 - * + * *****************************************************************************/ package org.eclipse.papyrus.uml.tools.databinding; /** - * @deprecated Use the {@link org.eclipse.papyrus.infra.tools.databinding.CommandBasedObservable} API, instead. + * @deprecated since 1.2.0 + * Use the {@link org.eclipse.papyrus.infra.tools.databinding.CommandBasedObservable} API, instead. + * + * This class Will be removed in Papyrus 5.0, see bug 540829 */ @Deprecated public interface CommandBasedObservable extends org.eclipse.papyrus.infra.tools.databinding.CommandBasedObservable { diff --git a/plugins/uml/tools/org.eclipse.papyrus.uml.tools/src/org/eclipse/papyrus/uml/tools/databinding/CommandBasedObservableValue.java b/plugins/uml/tools/org.eclipse.papyrus.uml.tools/src/org/eclipse/papyrus/uml/tools/databinding/CommandBasedObservableValue.java index ac5204eb313..2e2f525237c 100644 --- a/plugins/uml/tools/org.eclipse.papyrus.uml.tools/src/org/eclipse/papyrus/uml/tools/databinding/CommandBasedObservableValue.java +++ b/plugins/uml/tools/org.eclipse.papyrus.uml.tools/src/org/eclipse/papyrus/uml/tools/databinding/CommandBasedObservableValue.java @@ -11,12 +11,15 @@ * Contributors: * Camille Letavernier (CEA LIST) camille.letavernier@cea.fr - Initial API and implementation * Christian W. Damus - bug 485220 - * + * *****************************************************************************/ package org.eclipse.papyrus.uml.tools.databinding; /** - * @deprecated Use the {@link org.eclipse.papyrus.infra.tools.databinding.CommandBasedObservableValue} API, instead. + * @deprecated since 1.2.0 + * Use the {@link org.eclipse.papyrus.infra.tools.databinding.CommandBasedObservableValue} API, instead. + * + * This class Will be removed in Papyrus 5.0, see bug 540829 */ @Deprecated public interface CommandBasedObservableValue extends CommandBasedObservable, org.eclipse.papyrus.infra.tools.databinding.CommandBasedObservableValue { diff --git a/plugins/uml/tools/org.eclipse.papyrus.uml.tools/src/org/eclipse/papyrus/uml/tools/databinding/ExtendedMultiplicityObservableValue.java b/plugins/uml/tools/org.eclipse.papyrus.uml.tools/src/org/eclipse/papyrus/uml/tools/databinding/ExtendedMultiplicityObservableValue.java index abda8146a77..bbb3e2a61ca 100644 --- a/plugins/uml/tools/org.eclipse.papyrus.uml.tools/src/org/eclipse/papyrus/uml/tools/databinding/ExtendedMultiplicityObservableValue.java +++ b/plugins/uml/tools/org.eclipse.papyrus.uml.tools/src/org/eclipse/papyrus/uml/tools/databinding/ExtendedMultiplicityObservableValue.java @@ -1,6 +1,6 @@ /***************************************************************************** * Copyright (c) 2015, 2016 CEA LIST, Christian W. Damus, and others. - * + * * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 * which accompanies this distribution, and is available at @@ -11,7 +11,7 @@ * Contributors: * Nicolas FAUVERGUE (ALL4TEC) nicolas.fauvergue@all4tec.net - Initial API and implementation * Christian W. Damus - bug 491789 - * + * *****************************************************************************/ package org.eclipse.papyrus.uml.tools.databinding; @@ -22,7 +22,6 @@ import java.util.List; import org.eclipse.core.databinding.observable.Diffs; import org.eclipse.core.databinding.observable.IObservable; -import org.eclipse.core.databinding.observable.value.AbstractObservableValue; import org.eclipse.core.databinding.observable.value.IObservableValue; import org.eclipse.emf.ecore.EObject; import org.eclipse.emf.ecore.EStructuralFeature; @@ -35,7 +34,13 @@ import org.eclipse.uml2.uml.UMLPackage; /** * The multiplicity observable values contains a list of 3 observable values : The first the multiplicity lower and upper value for the 'simple' mode and the 2 following are the lower and the upper value observable value. + * + * @deprecated since 4.3 + * use {@link org.eclipe.papyrus.uml.properties.databinding.ExtendedMultiplicityObservableValue} API, instead + * + * This class Will be removed in Papyrus 5.0, see bug 540829 */ +@Deprecated public class ExtendedMultiplicityObservableValue extends ReferenceCountedObservable.Value implements AggregatedObservable { /** @@ -61,7 +66,7 @@ public class ExtendedMultiplicityObservableValue extends ReferenceCountedObserva /** - * + * * Constructor. * * @param domain @@ -81,7 +86,7 @@ public class ExtendedMultiplicityObservableValue extends ReferenceCountedObserva */ public ExtendedMultiplicityObservableValue(final EObject eObject, final EditingDomain domain) { this.domain = domain; - this.observableValues = new ArrayList<IObservableValue>(NUMBER_OBSERVABLE_VALUES); + this.observableValues = new ArrayList<>(NUMBER_OBSERVABLE_VALUES); if (null != eObject) { observableValues.add(new MultiplicityObservableValue(eObject, domain)); @@ -98,7 +103,7 @@ public class ExtendedMultiplicityObservableValue extends ReferenceCountedObserva /** * {@inheritDoc} - * + * * @see org.eclipse.papyrus.infra.tools.databinding.AggregatedObservable#aggregate(org.eclipse.core.databinding.observable.IObservable) */ @SuppressWarnings("unchecked") @@ -108,9 +113,9 @@ public class ExtendedMultiplicityObservableValue extends ReferenceCountedObserva final Object value = ((IObservableValue) observable).getValue(); if (value instanceof List<?> && NUMBER_OBSERVABLE_VALUES == ((List<?>) value).size() && isAllIObservableValueType((List<?>) value)) { final ExtendedMultiplicityObservableValue result = new ExtendedMultiplicityObservableValue(domain); - + int count = 0; - while(count < NUMBER_OBSERVABLE_VALUES){ + while (count < NUMBER_OBSERVABLE_VALUES) { final IObservableValue existingMultiplicityValues = observableValues.get(count); final IObservableValue multiplicityValueToAggregate = ((List<IObservableValue>) value).get(count); if (existingMultiplicityValues instanceof AggregatedObservable) { @@ -119,7 +124,7 @@ public class ExtendedMultiplicityObservableValue extends ReferenceCountedObserva } count++; } - + return result; } } @@ -128,8 +133,9 @@ public class ExtendedMultiplicityObservableValue extends ReferenceCountedObserva /** * Get if all the elements of the list are observable values. - * - * @param values The values list. + * + * @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) { @@ -147,7 +153,7 @@ public class ExtendedMultiplicityObservableValue extends ReferenceCountedObserva /** * {@inheritDoc} - * + * * @see org.eclipse.core.databinding.observable.value.IObservableValue#getValueType() */ @Override @@ -157,22 +163,24 @@ public class ExtendedMultiplicityObservableValue extends ReferenceCountedObserva /** * {@inheritDoc} - * + * * @see org.eclipse.core.databinding.observable.value.AbstractObservableValue#doGetValue() */ @Override protected Object doGetValue() { return getObservableValues(); } - + /** * If the input is a list of three elements that are all observable-values, - * take them. Otherwise, throw. + * take them. Otherwise, throw. * - * @param value the value to set - * - * @throws IllegalArgumentException if {@code value} is not a list of three - * {@link IObservableValue}s + * @param value + * the value to set + * + * @throws IllegalArgumentException + * if {@code value} is not a list of three + * {@link IObservableValue}s */ @Override protected void doSetValue(Object value) { @@ -186,18 +194,18 @@ public class ExtendedMultiplicityObservableValue extends ReferenceCountedObserva if (!listValue.stream().allMatch(IObservableValue.class::isInstance)) { throw new IllegalArgumentException(String.format("value is not a list of %d IObservableValues", NUMBER_OBSERVABLE_VALUES)); //$NON-NLS-1$ } - + // Only do anything if the result would be different if (!listValue.equals(observableValues)) { @SuppressWarnings("unchecked") - List<? extends IObservableValue<?>> newObservables = (List<? extends IObservableValue<?>>)listValue; - + List<? extends IObservableValue<?>> newObservables = (List<? extends IObservableValue<?>>) listValue; + // Retain the new, release the old (some may be both) newObservables.forEach(ReferenceCountedObservable.Util::retain); observableValues.forEach(ReferenceCountedObservable.Util::autorelease); - + List<IObservableValue<?>> oldObservables = new ArrayList<>(observableValues); - + observableValues.clear(); observableValues.addAll(newObservables); fireValueChange(Diffs.createValueDiff(oldObservables, newObservables)); @@ -206,7 +214,7 @@ public class ExtendedMultiplicityObservableValue extends ReferenceCountedObserva /** * Get the observable values. - * + * * @return the observableValues. */ public List<IObservableValue> getObservableValues() { @@ -215,7 +223,7 @@ public class ExtendedMultiplicityObservableValue extends ReferenceCountedObserva /** * {@inheritDoc} - * + * * @see org.eclipse.core.databinding.observable.AbstractObservable#dispose() */ @Override @@ -230,6 +238,7 @@ public class ExtendedMultiplicityObservableValue extends ReferenceCountedObserva /** * This retains the support. */ + @Override public void retain() { refCount.retain(); } @@ -237,6 +246,7 @@ public class ExtendedMultiplicityObservableValue extends ReferenceCountedObserva /** * This releases the support. */ + @Override public void release() { refCount.release(); } @@ -244,13 +254,14 @@ public class ExtendedMultiplicityObservableValue extends ReferenceCountedObserva /** * This auto-relreases the support. */ + @Override public void autorelease() { refCount.autorelease(); } /** * {@inheritDoc} - * + * * @see org.eclipse.papyrus.infra.tools.databinding.AggregatedObservable#hasDifferentValues() */ @Override diff --git a/plugins/uml/tools/org.eclipse.papyrus.uml.tools/src/org/eclipse/papyrus/uml/tools/databinding/ExtensionEndMultiplicityObservableValue.java b/plugins/uml/tools/org.eclipse.papyrus.uml.tools/src/org/eclipse/papyrus/uml/tools/databinding/ExtensionEndMultiplicityObservableValue.java index 291ca4946fd..f3678b37b38 100644 --- a/plugins/uml/tools/org.eclipse.papyrus.uml.tools/src/org/eclipse/papyrus/uml/tools/databinding/ExtensionEndMultiplicityObservableValue.java +++ b/plugins/uml/tools/org.eclipse.papyrus.uml.tools/src/org/eclipse/papyrus/uml/tools/databinding/ExtensionEndMultiplicityObservableValue.java @@ -28,7 +28,12 @@ import org.eclipse.uml2.uml.ExtensionEnd; * * @author Camille Letavernier * + * @deprecated since 4.3 + * use {@link org.eclipe.papyrus.uml.properties.databinding.ExtensionEndMultiplicityObservableValue} API, instead + * + * This class Will be removed in Papyrus 5.0, see bug 540829 */ +@Deprecated public class ExtensionEndMultiplicityObservableValue extends MultiplicityObservableValue { public ExtensionEndMultiplicityObservableValue(ExtensionEnd source, EditingDomain domain) { diff --git a/plugins/uml/tools/org.eclipse.papyrus.uml.tools/src/org/eclipse/papyrus/uml/tools/databinding/ExtensionRequiredObservableValue.java b/plugins/uml/tools/org.eclipse.papyrus.uml.tools/src/org/eclipse/papyrus/uml/tools/databinding/ExtensionRequiredObservableValue.java index 5d12e8b13a3..3e2337a0f4f 100644 --- a/plugins/uml/tools/org.eclipse.papyrus.uml.tools/src/org/eclipse/papyrus/uml/tools/databinding/ExtensionRequiredObservableValue.java +++ b/plugins/uml/tools/org.eclipse.papyrus.uml.tools/src/org/eclipse/papyrus/uml/tools/databinding/ExtensionRequiredObservableValue.java @@ -32,7 +32,12 @@ import org.eclipse.uml2.uml.Extension; * * @author Camille Letavernier * + * @deprecated since 4.3 + * use {@link org.eclipe.papyrus.uml.properties.databinding.ExtensionRequiredObservableValue} instead + * + * This class Will be removed in Papyrus 5.0, see bug 540829 */ +@Deprecated public class ExtensionRequiredObservableValue extends AbstractObservableValue implements IChangeListener, IObserving { private Extension extension; @@ -50,6 +55,7 @@ public class ExtensionRequiredObservableValue extends AbstractObservableValue im currentValue = extension.isRequired(); } + @Override public Object getValueType() { return Boolean.class; } @@ -75,6 +81,7 @@ public class ExtensionRequiredObservableValue extends AbstractObservableValue im currentValue = required; } + @Override public Object getObserved() { return extension; } @@ -87,6 +94,7 @@ public class ExtensionRequiredObservableValue extends AbstractObservableValue im super.dispose(); } + @Override public void handleChange(ChangeEvent event) { final boolean oldValue = currentValue; final boolean newValue = doGetValue(); diff --git a/plugins/uml/tools/org.eclipse.papyrus.uml.tools/src/org/eclipse/papyrus/uml/tools/databinding/ImageExpressionObservableValue.java b/plugins/uml/tools/org.eclipse.papyrus.uml.tools/src/org/eclipse/papyrus/uml/tools/databinding/ImageExpressionObservableValue.java index 8f4ebc0ddcb..489e08057ec 100644 --- a/plugins/uml/tools/org.eclipse.papyrus.uml.tools/src/org/eclipse/papyrus/uml/tools/databinding/ImageExpressionObservableValue.java +++ b/plugins/uml/tools/org.eclipse.papyrus.uml.tools/src/org/eclipse/papyrus/uml/tools/databinding/ImageExpressionObservableValue.java @@ -27,7 +27,12 @@ import org.eclipse.uml2.uml.Image; * An IObservableValue for editing Images * * @author Camille Letavernier + * @deprecated since 4.3 + * use {@link org.eclipe.papyrus.uml.properties.databinding.ImageExpressionObservableValue} API, instead + * + * This class Will be removed in Papyrus 5.0, see bug 540829 */ +@Deprecated public class ImageExpressionObservableValue extends AbstractObservableValue implements IObserving { private Image image; @@ -48,6 +53,7 @@ public class ImageExpressionObservableValue extends AbstractObservableValue impl this.domain = domain; } + @Override public Object getValueType() { return String.class; } @@ -64,6 +70,7 @@ public class ImageExpressionObservableValue extends AbstractObservableValue impl Runnable runnable = new Runnable() { + @Override public void run() { ImageUtil.setExpression(image, expression); @@ -75,6 +82,7 @@ public class ImageExpressionObservableValue extends AbstractObservableValue impl } } + @Override public Object getObserved() { return image; } diff --git a/plugins/uml/tools/org.eclipse.papyrus.uml.tools/src/org/eclipse/papyrus/uml/tools/databinding/ImageKindObservableValue.java b/plugins/uml/tools/org.eclipse.papyrus.uml.tools/src/org/eclipse/papyrus/uml/tools/databinding/ImageKindObservableValue.java index e3cf7596680..2da63760d35 100644 --- a/plugins/uml/tools/org.eclipse.papyrus.uml.tools/src/org/eclipse/papyrus/uml/tools/databinding/ImageKindObservableValue.java +++ b/plugins/uml/tools/org.eclipse.papyrus.uml.tools/src/org/eclipse/papyrus/uml/tools/databinding/ImageKindObservableValue.java @@ -29,7 +29,13 @@ import org.eclipse.uml2.uml.Image; * * @author Camille Letavernier * + * @deprecated since 4.3 + * use {@link org.eclipe.papyrus.uml.properties.databinding.ImageKindObservableValue} API, instead + * + * This class Will be removed in Papyrus 5.0, see bug 540829 + * */ +@Deprecated public class ImageKindObservableValue extends AbstractObservableValue implements IObserving { /** @@ -68,6 +74,7 @@ public class ImageKindObservableValue extends AbstractObservableValue implements this.domain = domain; } + @Override public Object getValueType() { return String.class; } @@ -90,6 +97,7 @@ public class ImageKindObservableValue extends AbstractObservableValue implements Runnable runnable = new Runnable() { + @Override public void run() { ImageUtil.setKind(image, kind); } @@ -100,6 +108,7 @@ public class ImageKindObservableValue extends AbstractObservableValue implements } } + @Override public Object getObserved() { return image; } diff --git a/plugins/uml/tools/org.eclipse.papyrus.uml.tools/src/org/eclipse/papyrus/uml/tools/databinding/ImageNameObservableValue.java b/plugins/uml/tools/org.eclipse.papyrus.uml.tools/src/org/eclipse/papyrus/uml/tools/databinding/ImageNameObservableValue.java index 1642f3673ed..c9389644001 100644 --- a/plugins/uml/tools/org.eclipse.papyrus.uml.tools/src/org/eclipse/papyrus/uml/tools/databinding/ImageNameObservableValue.java +++ b/plugins/uml/tools/org.eclipse.papyrus.uml.tools/src/org/eclipse/papyrus/uml/tools/databinding/ImageNameObservableValue.java @@ -27,7 +27,13 @@ import org.eclipse.uml2.uml.Image; * An IObservableValue for editing Images * * @author Camille Letavernier + * + * @deprecated since 4.3 + * use {@link org.eclipe.papyrus.uml.properties.databinding.ImageNameObservableValue} API, instead + * + * This class Will be removed in Papyrus 5.0, see bug 540829 */ +@Deprecated public class ImageNameObservableValue extends AbstractObservableValue implements IObserving { private Image image; @@ -48,6 +54,7 @@ public class ImageNameObservableValue extends AbstractObservableValue implements this.domain = domain; } + @Override public Object getValueType() { return String.class; } @@ -64,6 +71,7 @@ public class ImageNameObservableValue extends AbstractObservableValue implements Runnable runnable = new Runnable() { + @Override public void run() { ImageUtil.setName(image, name); @@ -75,6 +83,7 @@ public class ImageNameObservableValue extends AbstractObservableValue implements } } + @Override public Object getObserved() { return image; } diff --git a/plugins/uml/tools/org.eclipse.papyrus.uml.tools/src/org/eclipse/papyrus/uml/tools/databinding/MultiplicityObservableValue.java b/plugins/uml/tools/org.eclipse.papyrus.uml.tools/src/org/eclipse/papyrus/uml/tools/databinding/MultiplicityObservableValue.java index d91fa4e6911..2ec1b3b06bd 100644 --- a/plugins/uml/tools/org.eclipse.papyrus.uml.tools/src/org/eclipse/papyrus/uml/tools/databinding/MultiplicityObservableValue.java +++ b/plugins/uml/tools/org.eclipse.papyrus.uml.tools/src/org/eclipse/papyrus/uml/tools/databinding/MultiplicityObservableValue.java @@ -48,7 +48,13 @@ import org.eclipse.uml2.uml.UMLPackage; * These commands will probably only work in a Papyrus context. * * @author Camille Letavernier + * + * @deprecated since 4.3 + * use {@link org.eclipe.papyrus.uml.properties.databinding.MultiplicityObservableValue} instead + * + * This class Will be removed in Papyrus 5.0, see bug 540829 */ +@Deprecated public class MultiplicityObservableValue extends ReferenceCountedObservable.Value implements IChangeListener, CommandBasedObservableValue, AggregatedObservable, IObserving { private IObservableValue lowerBound, upperBound, lowerValue, upperValue, lowerValueSpecification, upperValueSpecification; @@ -114,6 +120,7 @@ public class MultiplicityObservableValue extends ReferenceCountedObservable.Valu * * @param event */ + @Override public void handleChange(ChangeEvent event) { boolean fireChange = false; if (event.getSource() == lowerValue || event.getSource() == upperValue) { @@ -164,6 +171,7 @@ public class MultiplicityObservableValue extends ReferenceCountedObservable.Valu } } + @Override public Object getObserved() { return eObject; } @@ -190,6 +198,7 @@ public class MultiplicityObservableValue extends ReferenceCountedObservable.Valu super.dispose(); } + @Override public Object getValueType() { return String.class; } @@ -219,6 +228,7 @@ public class MultiplicityObservableValue extends ReferenceCountedObservable.Valu domain.getCommandStack().execute(command); } + @Override public Command getCommand(Object value) { String val = (String) value; @@ -239,6 +249,7 @@ public class MultiplicityObservableValue extends ReferenceCountedObservable.Valu return UnexecutableCommand.INSTANCE; } + @Override public AggregatedObservable aggregate(IObservable observable) { try { return new AggregatedPapyrusObservableValue(domain, this, observable); @@ -247,6 +258,7 @@ public class MultiplicityObservableValue extends ReferenceCountedObservable.Valu } } + @Override public boolean hasDifferentValues() { return false; } diff --git a/plugins/uml/tools/org.eclipse.papyrus.uml.tools/src/org/eclipse/papyrus/uml/tools/databinding/NavigationObservableValue.java b/plugins/uml/tools/org.eclipse.papyrus.uml.tools/src/org/eclipse/papyrus/uml/tools/databinding/NavigationObservableValue.java index 5fd2f6edc7a..c3f97646873 100644 --- a/plugins/uml/tools/org.eclipse.papyrus.uml.tools/src/org/eclipse/papyrus/uml/tools/databinding/NavigationObservableValue.java +++ b/plugins/uml/tools/org.eclipse.papyrus.uml.tools/src/org/eclipse/papyrus/uml/tools/databinding/NavigationObservableValue.java @@ -51,7 +51,13 @@ import org.eclipse.uml2.uml.UMLPackage; * The navigable property is a virtual property, represented as a Boolean. * * @author Camille Letavernier + * + * @deprecated since 4.3 + * use {@link org.eclipe.papyrus.uml.properties.databinding.NavigationObservableValue} API, instead + * + * This class Will be removed in Papyrus 5.0, see bug 540829 */ +@Deprecated public class NavigationObservableValue extends ReferenceCountedObservable.Value implements IChangeListener, CommandBasedObservableValue, AggregatedObservable, IObserving { private Property memberEnd; @@ -78,10 +84,12 @@ public class NavigationObservableValue extends ReferenceCountedObservable.Value ownerObservableList.addChangeListener(this); } + @Override public void handleChange(ChangeEvent event) { fireValueChange(Diffs.createValueDiff(currentValue, doGetValue())); } + @Override public Object getValueType() { return Boolean.class; } @@ -97,6 +105,7 @@ public class NavigationObservableValue extends ReferenceCountedObservable.Value domain.getCommandStack().execute(command); } + @Override public Object getObserved() { return memberEnd; } @@ -108,6 +117,7 @@ public class NavigationObservableValue extends ReferenceCountedObservable.Value ownerObservableList.dispose(); } + @Override public Command getCommand(Object value) { if (value instanceof Boolean) { boolean isNavigable = (Boolean) value; @@ -117,16 +127,16 @@ public class NavigationObservableValue extends ReferenceCountedObservable.Value Association association = memberEnd.getAssociation(); - List<Property> navigableEnds = new ArrayList<Property>(); + List<Property> navigableEnds = new ArrayList<>(); navigableEnds.addAll(association.getNavigableOwnedEnds()); - List<SetRequest> setRequests = new LinkedList<SetRequest>(); + List<SetRequest> setRequests = new LinkedList<>(); if (isNavigable) { navigableEnds.add(memberEnd); } else { if (memberEnd.getOwningAssociation() == null && memberEnd.getOwner() instanceof Classifier) { - List<Property> ownedEnds = new LinkedList<Property>(); + List<Property> ownedEnds = new LinkedList<>(); ownedEnds.addAll(association.getOwnedEnds()); ownedEnds.add(memberEnd); setRequests.add(new SetRequest(association, UMLPackage.eINSTANCE.getAssociation_OwnedEnd(), ownedEnds)); @@ -159,6 +169,7 @@ public class NavigationObservableValue extends ReferenceCountedObservable.Value return UnexecutableCommand.INSTANCE; } + @Override public AggregatedObservable aggregate(IObservable observable) { try { return new AggregatedPapyrusObservableValue(domain, this, observable); @@ -167,6 +178,7 @@ public class NavigationObservableValue extends ReferenceCountedObservable.Value } } + @Override public boolean hasDifferentValues() { return false; } diff --git a/plugins/uml/tools/org.eclipse.papyrus.uml.tools/src/org/eclipse/papyrus/uml/tools/databinding/OwnerObservableValue.java b/plugins/uml/tools/org.eclipse.papyrus.uml.tools/src/org/eclipse/papyrus/uml/tools/databinding/OwnerObservableValue.java index 70db19c0f96..47f0b806fa9 100644 --- a/plugins/uml/tools/org.eclipse.papyrus.uml.tools/src/org/eclipse/papyrus/uml/tools/databinding/OwnerObservableValue.java +++ b/plugins/uml/tools/org.eclipse.papyrus.uml.tools/src/org/eclipse/papyrus/uml/tools/databinding/OwnerObservableValue.java @@ -56,7 +56,14 @@ import org.eclipse.uml2.uml.UMLPackage; * This value doesn't make sense for n-ary associations, when n > 2. * * @author Camille Letavernier + * + * @deprecated since 3.2 + * use {@link org.eclipe.papyrus.uml.properties.databinding.OwnerObservableValue} API, instead + * + * This class Will be removed in Papyrus 5.0, see bug 540829 */ + +@Deprecated public class OwnerObservableValue extends ReferenceCountedObservable.Value implements IChangeListener, AggregatedObservable, CommandBasedObservableValue, IObserving { private Property memberEnd; @@ -147,7 +154,7 @@ public class OwnerObservableValue extends ReferenceCountedObservable.Value imple IElementEditService provider = ElementEditServiceUtils.getCommandProvider(association); if (provider != null) { EStructuralFeature feature = UMLPackage.eINSTANCE.getAssociation_OwnedEnd(); - List<Property> attributeList = new ArrayList<Property>(); + List<Property> attributeList = new ArrayList<>(); attributeList.addAll(association.getOwnedEnds()); attributeList.add(memberEnd); // association.eSet(feature, attributeList); diff --git a/plugins/uml/tools/org.eclipse.papyrus.uml.tools/src/org/eclipse/papyrus/uml/tools/databinding/PapyrusObservableList.java b/plugins/uml/tools/org.eclipse.papyrus.uml.tools/src/org/eclipse/papyrus/uml/tools/databinding/PapyrusObservableList.java index c693b51a7cd..c590f4731f9 100644 --- a/plugins/uml/tools/org.eclipse.papyrus.uml.tools/src/org/eclipse/papyrus/uml/tools/databinding/PapyrusObservableList.java +++ b/plugins/uml/tools/org.eclipse.papyrus.uml.tools/src/org/eclipse/papyrus/uml/tools/databinding/PapyrusObservableList.java @@ -11,7 +11,7 @@ * Contributors: * Camille Letavernier (CEA LIST) camille.letavernier@cea.fr - Initial API and implementation * Christian W. Damus - bug 485220 - * + * *****************************************************************************/ package org.eclipse.papyrus.uml.tools.databinding; @@ -41,7 +41,10 @@ import org.eclipse.papyrus.infra.ui.emf.databinding.EMFObservableList; * Papyrus commands * * @author Camille Letavernier - * @deprecated Use the {@link org.eclipse.papyrus.infra.gmfdiag.common.databinding.GMFObservableList} API, instead + * @deprecated since 1.2.0 + * Use the {@link org.eclipse.papyrus.infra.gmfdiag.common.databinding.GMFObservableList} API, instead + * + * This class Will be removed in Papyrus 5.0, see bug 540829 */ @Deprecated @SuppressWarnings("unchecked") @@ -251,7 +254,7 @@ public class PapyrusObservableList extends EMFObservableList { * @return */ protected Collection<? extends IEditCommandRequest> getRequests(List<Object> newValues, Collection<?> removedValues) { - LinkedList<IEditCommandRequest> requests = new LinkedList<IEditCommandRequest>(); + LinkedList<IEditCommandRequest> requests = new LinkedList<>(); if (feature instanceof EReference && ((EReference) feature).isContainment() && removedValues != null) { for (Object o : removedValues) { diff --git a/plugins/uml/tools/org.eclipse.papyrus.uml.tools/src/org/eclipse/papyrus/uml/tools/databinding/PapyrusObservableValue.java b/plugins/uml/tools/org.eclipse.papyrus.uml.tools/src/org/eclipse/papyrus/uml/tools/databinding/PapyrusObservableValue.java index 71d2df83e84..4cd3c50096d 100644 --- a/plugins/uml/tools/org.eclipse.papyrus.uml.tools/src/org/eclipse/papyrus/uml/tools/databinding/PapyrusObservableValue.java +++ b/plugins/uml/tools/org.eclipse.papyrus.uml.tools/src/org/eclipse/papyrus/uml/tools/databinding/PapyrusObservableValue.java @@ -45,7 +45,10 @@ import org.eclipse.papyrus.uml.tools.Activator; * Papyrus commands * * @author Camille Letavernier - * @deprecated Use the {@link org.eclipse.papyrus.infra.gmfdiag.common.databinding.GMFObservableValue} API, instead + * @deprecated since 1.2.0 + * Use the {@link org.eclipse.papyrus.infra.gmfdiag.common.databinding.GMFObservableValue} API, instead + * + * This class Will be removed in Papyrus 5.0, see bug 540829 */ @Deprecated public class PapyrusObservableValue extends EMFObservableValue implements AggregatedObservable, CommandBasedObservableValue, ReferenceCountedObservable { diff --git a/plugins/uml/tools/org.eclipse.papyrus.uml.tools/src/org/eclipse/papyrus/uml/tools/databinding/ProfileApplicationObservableList.java b/plugins/uml/tools/org.eclipse.papyrus.uml.tools/src/org/eclipse/papyrus/uml/tools/databinding/ProfileApplicationObservableList.java index e2507a63d7d..d61ccaf89eb 100644 --- a/plugins/uml/tools/org.eclipse.papyrus.uml.tools/src/org/eclipse/papyrus/uml/tools/databinding/ProfileApplicationObservableList.java +++ b/plugins/uml/tools/org.eclipse.papyrus.uml.tools/src/org/eclipse/papyrus/uml/tools/databinding/ProfileApplicationObservableList.java @@ -45,7 +45,13 @@ import org.eclipse.uml2.uml.ProfileApplication; * An IObservableList for Profile application * * @author Camille Letavernier + * + * @deprecated since 4.3 + * use {@link org.eclipe.papyrus.uml.properties.databinding.ProfileApplicationObservableList} API, instead + * + * This class Will be removed in Papyrus 5.0, see bug 540829 */ +@Deprecated @SuppressWarnings({ "unchecked", "rawtypes" }) public class ProfileApplicationObservableList extends WritableList implements ICommitListener, IObserving { @@ -71,7 +77,7 @@ public class ProfileApplicationObservableList extends WritableList implements IC this.umlSource = umlSource; this.domain = domain; - commands = new LinkedList<Command>(); + commands = new LinkedList<>(); listener = new AbstractStereotypeListener(umlSource) { @@ -135,6 +141,7 @@ public class ProfileApplicationObservableList extends WritableList implements IC }; } + @Override public Object getObserved() { return umlSource; } @@ -145,6 +152,7 @@ public class ProfileApplicationObservableList extends WritableList implements IC this.listener.dispose(); } + @Override public void commit(AbstractEditor editor) { if (commands.isEmpty()) { return; @@ -210,7 +218,7 @@ public class ProfileApplicationObservableList extends WritableList implements IC static Collection<Profile> getAppliedProfiles(Package package_) { final ProfileApplicationDelegateRegistry reg = ProfileApplicationDelegateRegistry.INSTANCE; - List<Profile> result = new ArrayList<Profile>(); + List<Profile> result = new ArrayList<>(); for (ProfileApplication next : reg.getDelegate(package_).getProfileApplications(package_)) { Profile profile = reg.getDelegate(next).getAppliedProfile(next); if (profile != null) { @@ -273,7 +281,7 @@ public class ProfileApplicationObservableList extends WritableList implements IC // We only apply the profiles that are not applied yet (To avoid removing them when undo is called) c.removeAll(wrappedList); - Collection<Profile> profiles = new LinkedList<Profile>(); + Collection<Profile> profiles = new LinkedList<>(); for (Object element : c) { if (element instanceof Profile) { profiles.add(EMFHelper.reloadIntoContext((Profile) element, umlSource)); @@ -305,7 +313,7 @@ public class ProfileApplicationObservableList extends WritableList implements IC */ @Override public boolean retainAll(Collection c) { - List<Object> objectsToRemove = new LinkedList<Object>(); + List<Object> objectsToRemove = new LinkedList<>(); for (Object object : c) { if (!contains(object)) { objectsToRemove.add(object); diff --git a/plugins/uml/tools/org.eclipse.papyrus.uml.tools/src/org/eclipse/papyrus/uml/tools/databinding/ProvidedInterfaceObservableList.java b/plugins/uml/tools/org.eclipse.papyrus.uml.tools/src/org/eclipse/papyrus/uml/tools/databinding/ProvidedInterfaceObservableList.java index 830a72a33f4..8ae3f33c716 100644 --- a/plugins/uml/tools/org.eclipse.papyrus.uml.tools/src/org/eclipse/papyrus/uml/tools/databinding/ProvidedInterfaceObservableList.java +++ b/plugins/uml/tools/org.eclipse.papyrus.uml.tools/src/org/eclipse/papyrus/uml/tools/databinding/ProvidedInterfaceObservableList.java @@ -51,7 +51,13 @@ import org.eclipse.uml2.uml.UMLPackage; * An IObservableList to edit the UML Derived feature {@link Port#getProvideds()}. * * @author Camille Letavernier + * + * @deprecated since 4.3 + * use {@link org.eclipe.papyrus.uml.properties.databinding.ProvidedInterfaceObservableList} API, instead + * + * This class Will be removed in Papyrus 5.0, see bug 540829 */ +@Deprecated public class ProvidedInterfaceObservableList extends PapyrusObservableList { diff --git a/plugins/uml/tools/org.eclipse.papyrus.uml.tools/src/org/eclipse/papyrus/uml/tools/databinding/RequiredInterfaceObservableList.java b/plugins/uml/tools/org.eclipse.papyrus.uml.tools/src/org/eclipse/papyrus/uml/tools/databinding/RequiredInterfaceObservableList.java index 8c7bf6db621..38f0c58efff 100644 --- a/plugins/uml/tools/org.eclipse.papyrus.uml.tools/src/org/eclipse/papyrus/uml/tools/databinding/RequiredInterfaceObservableList.java +++ b/plugins/uml/tools/org.eclipse.papyrus.uml.tools/src/org/eclipse/papyrus/uml/tools/databinding/RequiredInterfaceObservableList.java @@ -51,8 +51,12 @@ import org.eclipse.uml2.uml.Usage; * An IObservableList to edit the UML Derived feature {@link Port#getRequireds()} * * @author Camille Letavernier + * @deprecated since 4.3 + * use {@link org.eclipe.papyrus.uml.properties.databinding.RequiredInterfaceObservableList} API, instead * + * This class Will be removed in Papyrus 5.0, see bug 540829 */ +@Deprecated public class RequiredInterfaceObservableList extends PapyrusObservableList { /** The port. */ diff --git a/plugins/uml/tools/org.eclipse.papyrus.uml.tools/src/org/eclipse/papyrus/uml/tools/databinding/UnsettableStringValue.java b/plugins/uml/tools/org.eclipse.papyrus.uml.tools/src/org/eclipse/papyrus/uml/tools/databinding/UnsettableStringValue.java index b4d149f1d49..43cb6e4f9c9 100644 --- a/plugins/uml/tools/org.eclipse.papyrus.uml.tools/src/org/eclipse/papyrus/uml/tools/databinding/UnsettableStringValue.java +++ b/plugins/uml/tools/org.eclipse.papyrus.uml.tools/src/org/eclipse/papyrus/uml/tools/databinding/UnsettableStringValue.java @@ -29,7 +29,14 @@ import org.eclipse.papyrus.infra.emf.requests.UnsetRequest; * A specialized observable for string-valued attributes that are "unsettable" in the EMF sense, having a distinct unset state. * For string features that have a {@code null} default, instead of accepting the empty string, the feature is simply unset so * that it will be {@code null}. + * + * @deprecated since 4.3 + * use {@link org.eclipe.papyrus.uml.properties.databinding.UnsettableStringObservableValue} API,instead + * + * This class Will be removed in Papyrus 5.0, see bug 540829 + * */ +@Deprecated public class UnsettableStringValue extends PapyrusObservableValue { public UnsettableStringValue(EObject eObject, EStructuralFeature eStructuralFeature, EditingDomain domain) { diff --git a/plugins/uml/tools/org.eclipse.papyrus.uml.tools/src/org/eclipse/papyrus/uml/tools/helper/UMLDatabindingHelper.java b/plugins/uml/tools/org.eclipse.papyrus.uml.tools/src/org/eclipse/papyrus/uml/tools/helper/UMLDatabindingHelper.java index 548cd27adbe..7513551a8c0 100644..100755 --- a/plugins/uml/tools/org.eclipse.papyrus.uml.tools/src/org/eclipse/papyrus/uml/tools/helper/UMLDatabindingHelper.java +++ b/plugins/uml/tools/org.eclipse.papyrus.uml.tools/src/org/eclipse/papyrus/uml/tools/helper/UMLDatabindingHelper.java @@ -24,7 +24,13 @@ import org.eclipse.papyrus.uml.tools.databinding.PapyrusObservableValue; * A Helper class for UML Databinding * * @author Camille Letavernier + * + * @deprecated since 3.2 + * Use the {@link org.eclipse.papyrus.uml.properties.databinding.helpers.UMLDatabindingHelper} API, instead + * + * This class Will be removed in Papyrus 5.0, see bug 540829 */ +@Deprecated public class UMLDatabindingHelper { /** @@ -41,7 +47,7 @@ public class UMLDatabindingHelper { * The editing domain on which the commands will be executed. If null, direct * object modifications will be used. * @return - * The IObservableValue + * The IObservableValue */ public static IObservableValue getObservableValue(EObject source, EStructuralFeature feature, EditingDomain domain) { return domain == null ? EMFProperties.value(feature).observe(source) : new PapyrusObservableValue(source, feature, domain); diff --git a/plugins/uml/tools/org.eclipse.papyrus.uml.tools/src/org/eclipse/papyrus/uml/tools/providers/ProfileLabelProvider.java b/plugins/uml/tools/org.eclipse.papyrus.uml.tools/src/org/eclipse/papyrus/uml/tools/providers/ProfileLabelProvider.java index 89f4b0c1837..a4e5b6e4431 100644 --- a/plugins/uml/tools/org.eclipse.papyrus.uml.tools/src/org/eclipse/papyrus/uml/tools/providers/ProfileLabelProvider.java +++ b/plugins/uml/tools/org.eclipse.papyrus.uml.tools/src/org/eclipse/papyrus/uml/tools/providers/ProfileLabelProvider.java @@ -20,14 +20,19 @@ import org.eclipse.uml2.uml.Package; import org.eclipse.uml2.uml.Profile; //TODO : To be refactored. Merge this class with UMLLabelProvider +//should be removed in Papyrus 5.0 (see bug 540821) +/** + * @deprecated since 1.2.0 + * + */ @Deprecated public class ProfileLabelProvider extends EMFLabelProvider implements ILabelProvider { private Package umlPackage; - public static final String TAG_PROFILE_CHANGED = " (has changed, consider re-applying profile)"; + public static final String TAG_PROFILE_CHANGED = " (has changed, consider re-applying profile)"; //$NON-NLS-1$ - public static final String UNKNOWN_PROFILE = "<Unknown>"; + public static final String UNKNOWN_PROFILE = "<Unknown>"; //$NON-NLS-1$ public ProfileLabelProvider(Package umlPackage) { this.umlPackage = umlPackage; |