diff options
author | Vincent Lorenzo | 2018-11-05 14:53:19 +0000 |
---|---|---|
committer | Patrick Tessier | 2018-11-27 09:37:56 +0000 |
commit | 67608342c715324e60e646f6ed9b62c3f4ffd8d8 (patch) | |
tree | 8c1e932a4122fb243260f5402e06de1eaed0ed18 /plugins/uml | |
parent | df37716b50a1de5ce5123801ce6e584ad10a26f0 (diff) | |
download | org.eclipse.papyrus-67608342c715324e60e646f6ed9b62c3f4ffd8d8.tar.gz org.eclipse.papyrus-67608342c715324e60e646f6ed9b62c3f4ffd8d8.tar.xz org.eclipse.papyrus-67608342c715324e60e646f6ed9b62c3f4ffd8d8.zip |
Bug 540879: [Properties] Clean code of Observable and neighbours classes
- oep.infra.emf.appearance plugin now use java 1.8
- fix some pom.xml files
- add some non-nls marker
- remove some possible NPE
Change-Id: I68ad6b1384871438979c101dcc85b3f79994f9fd
Signed-off-by: Vincent Lorenzo <vincent.lorenzo@cea.fr>
Diffstat (limited to 'plugins/uml')
15 files changed, 76 insertions, 30 deletions
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 63df9e2893f..d007d75db67 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 @@ -120,7 +120,7 @@ public class AppliedCommentsObservableList extends PapyrusObservableList { if (value instanceof Comment) { - addAppliedCommentCommand = new CompoundCommand("Add applied comment"); + addAppliedCommentCommand = new CompoundCommand("Add applied comment"); //$NON-NLS-1$ // Add the comment to source#ownedComment SetRequest setRequest = new SetRequest((TransactionalEditingDomain) editingDomain, source, feature, value); @@ -179,7 +179,7 @@ public class AppliedCommentsObservableList extends PapyrusObservableList { public Command getRemoveAllCommand(Collection<?> values) { Iterator<?> itr = values.iterator(); Element value; - CompoundCommand removeAppliedCommentCommand = new CompoundCommand("Remove applied comment"); + CompoundCommand removeAppliedCommentCommand = new CompoundCommand("Remove applied comment"); //$NON-NLS-1$ while (itr.hasNext()) { value = (Element) itr.next(); Assert.isTrue(value instanceof Comment); diff --git a/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/databinding/ImportedPackageLocationObservableValue.java b/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/databinding/ImportedPackageLocationObservableValue.java index 4042517dccf..1cd5b629427 100644 --- a/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/databinding/ImportedPackageLocationObservableValue.java +++ b/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/databinding/ImportedPackageLocationObservableValue.java @@ -17,6 +17,7 @@ package org.eclipse.papyrus.uml.properties.databinding; import org.eclipse.core.databinding.observable.value.AbstractObservableValue; import org.eclipse.emf.common.util.URI; import org.eclipse.emf.ecore.util.EcoreUtil; +import org.eclipse.papyrus.uml.properties.messages.Messages; import org.eclipse.uml2.uml.Package; /** @@ -28,7 +29,7 @@ import org.eclipse.uml2.uml.Package; public class ImportedPackageLocationObservableValue extends AbstractObservableValue { /** The Constant UNKNOWN_LOCATION. */ - private static final String UNKNOWN_LOCATION = "Unknown"; + private static final String UNKNOWN_LOCATION = Messages.ImportedPackageLocationObservableValue_Unknown; /** The imported package. */ private Package importedPackage = null; 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 4e7cdfce469..ebb85ab741f 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 @@ -42,6 +42,6 @@ public class StringDataTypeObservableValue extends PapyrusObservableValue implem @Override public String toString() { - return getValue() == null ? "" : getValue().toString(); + return getValue() == null ? "" : getValue().toString(); //$NON-NLS-1$ } } diff --git a/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/messages/Messages.java b/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/messages/Messages.java index 78a0ce4e1cb..c90e2d1f5f8 100644 --- a/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/messages/Messages.java +++ b/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/messages/Messages.java @@ -41,6 +41,8 @@ public class Messages extends NLS { public static String ExpressionEditor_BodyLabel; + public static String ImportedPackageLocationObservableValue_Unknown; + public static String ProfileApplicationEditor_ApplyProfile; public static String ProfileApplicationEditor_ApplyProfilesDialogDescription; diff --git a/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/messages/messages.properties b/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/messages/messages.properties index af95abc6a7e..0d18af0101e 100644 --- a/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/messages/messages.properties +++ b/plugins/uml/properties/org.eclipse.papyrus.uml.properties/src/org/eclipse/papyrus/uml/properties/messages/messages.properties @@ -17,6 +17,7 @@ UMLNotationModelElement_DepthNone=None ExpressionLanguageFactory_EditLanguage=Edit language ExpressionLanguageFactory_LanguageDuplicateError=The same language cannot be used more than once ExpressionLanguageFactory_SetNewLanguage=Set the new language +ImportedPackageLocationObservableValue_Unknown=Unknown MultiplicityPreference_MultiplicityEditor=Multiplicity Editor MultiplicityPreference_SimpleModeDescription= is the edition of lower and upper values by one editor. MultiplicityPreference_AdvancedModeDescription= is the edition of lower and upper values by two editors. diff --git a/plugins/uml/tools/org.eclipse.papyrus.uml.tools/src/org/eclipse/papyrus/uml/tools/commands/UndefineProfileCommand.java b/plugins/uml/tools/org.eclipse.papyrus.uml.tools/src/org/eclipse/papyrus/uml/tools/commands/UndefineProfileCommand.java index c7b11b1bdde..6e168a7b7da 100644 --- a/plugins/uml/tools/org.eclipse.papyrus.uml.tools/src/org/eclipse/papyrus/uml/tools/commands/UndefineProfileCommand.java +++ b/plugins/uml/tools/org.eclipse.papyrus.uml.tools/src/org/eclipse/papyrus/uml/tools/commands/UndefineProfileCommand.java @@ -1,6 +1,6 @@ /***************************************************************************** * Copyright (c) 2015 CEA LIST and others. - * + * * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 * which accompanies this distribution, and is available at @@ -10,7 +10,7 @@ * * Contributors: * Gabriel Pascual (ALL4TEC) gabriel.pascual@all4tec.net - Initial API and implementation - * + * *****************************************************************************/ package org.eclipse.papyrus.uml.tools.commands; @@ -35,17 +35,15 @@ import org.eclipse.uml2.uml.util.UMLUtil; /** * Removed all Profile Definitions of all Profile model. - * + * * @author Gabriel Pascual + * @since 4.1 * */ public class UndefineProfileCommand extends RecordingCommand { - /** The Constant DECORATION_PROFILE_SERVICE_ERROR. */ - private static final String DECORATION_PROFILE_SERVICE_ERROR = "Impossible to display decoration warning for Profile"; //$NON-NLS-1$ - /** The Constant COMMAND_TITLE. */ - private static final String COMMAND_TITLE = "Undefine Profile"; + private static final String COMMAND_TITLE = "Undefine Profile"; //$NON-NLS-1$ /** The profile definition. */ private final PapyrusDefinitionAnnotation profileDefinition; @@ -70,7 +68,7 @@ public class UndefineProfileCommand extends RecordingCommand { super(editingDomain, COMMAND_TITLE, null); this.rootProfile = rootProfile; this.profileDefinition = annotation; - profilesStack = new LinkedList<Profile>(Collections.singleton(rootProfile)); + profilesStack = new LinkedList<>(Collections.singleton(rootProfile)); } /** 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 91c5670658d..5d12e8b13a3 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 @@ -68,7 +68,7 @@ public class ExtensionRequiredObservableValue extends AbstractObservableValue im Boolean required = (Boolean) value; if (extension.getOwnedEnds().isEmpty()) { - Activator.log.warn("Unable to change the extension \"isRequired\" property"); + Activator.log.warn("Unable to change the extension \"isRequired\" property"); //$NON-NLS-1$ } observable.setValue(required ? MultiplicityParser.ONE : MultiplicityParser.OPTIONAL); diff --git a/plugins/uml/tools/org.eclipse.papyrus.uml.tools/src/org/eclipse/papyrus/uml/tools/databinding/NamedElementValidator.java b/plugins/uml/tools/org.eclipse.papyrus.uml.tools/src/org/eclipse/papyrus/uml/tools/databinding/NamedElementValidator.java index 726050de40c..b131eb0cb82 100644 --- a/plugins/uml/tools/org.eclipse.papyrus.uml.tools/src/org/eclipse/papyrus/uml/tools/databinding/NamedElementValidator.java +++ b/plugins/uml/tools/org.eclipse.papyrus.uml.tools/src/org/eclipse/papyrus/uml/tools/databinding/NamedElementValidator.java @@ -69,7 +69,7 @@ public class NamedElementValidator extends AbstractUMLValidator { EList<NamedElement> listElement = ns.getMembers(); for (NamedElement namedElement : listElement) { if ((self != namedElement) && !self.isDistinguishableFrom(namedElement, ns)) { - return warning("Name is indistinguishable from another element in the Namespace"); + return warning("Name is indistinguishable from another element in the Namespace"); //$NON-NLS-1$ } } } finally { diff --git a/plugins/uml/tools/org.eclipse.papyrus.uml.tools/src/org/eclipse/papyrus/uml/tools/databinding/OwnedAttributeHelper.java b/plugins/uml/tools/org.eclipse.papyrus.uml.tools/src/org/eclipse/papyrus/uml/tools/databinding/OwnedAttributeHelper.java index cbe58f1ac64..71cd6866ae4 100644 --- a/plugins/uml/tools/org.eclipse.papyrus.uml.tools/src/org/eclipse/papyrus/uml/tools/databinding/OwnedAttributeHelper.java +++ b/plugins/uml/tools/org.eclipse.papyrus.uml.tools/src/org/eclipse/papyrus/uml/tools/databinding/OwnedAttributeHelper.java @@ -1,6 +1,6 @@ /***************************************************************************** * 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 @@ -10,7 +10,7 @@ * * Contributors: * CEA LIST - Initial API and implementation - * + * *****************************************************************************/ package org.eclipse.papyrus.uml.tools.databinding; @@ -35,9 +35,26 @@ import org.eclipse.uml2.uml.StructuredClassifier; import org.eclipse.uml2.uml.Type; import org.eclipse.uml2.uml.UMLPackage; +/** + * + * This class provides methods to set the owner for UML Association + * + */ public class OwnedAttributeHelper { - public static EStructuralFeature getFeatureForType(Type type) { + /** + * + * @param type + * a UML type + * @return + * the owned attribute feature for the given type, or <code>null</code> when not found + * @since 4.1 + */ + public static final EStructuralFeature getOwnedAttributeFeatureForType(final Type type) { + if (null == type) { + Activator.log.warn("The type is null!"); //$NON-NLS-1$ + } + if (type instanceof StructuredClassifier) { return UMLPackage.eINSTANCE.getStructuredClassifier_OwnedAttribute(); } @@ -54,15 +71,42 @@ public class OwnedAttributeHelper { return UMLPackage.eINSTANCE.getSignal_OwnedAttribute(); } + // Unknown type : we try to find the feature reflexively - Activator.log.warn("Unknown type : " + type.eClass().getName()); + final String eClassName = type.eClass().getName(); + Activator.log.warn(String.format("Unknown type : %s", eClassName)); //$NON-NLS-1$ EStructuralFeature feature = type.eClass().getEStructuralFeature("ownedAttribute"); //$NON-NLS-1$ if (feature == null) { - Activator.log.warn("Cannot find a valid feature for type " + type.eClass().getName()); + Activator.log.warn(String.format("Cannot find a valid feature for type %s.", eClassName)); //$NON-NLS-1$ } return feature; } - + + /** + * + * @param type + * a UML type + * @return + * the owned attribute feature for the given type, or <code>null</code> when not found + * + * @deprecated since 4.1 + * use org.eclipse.papyrus.uml.tools.databinding.OwnedAttributeHelper.getOwnedAttributeFeatureForType(Type) API instead + * This method will be removed in Papyrus 5.0, see bug 540875 + */ + @Deprecated + public static EStructuralFeature getFeatureForType(Type type) { + return getOwnedAttributeFeatureForType(type); + } + + /** + * + * @param association + * an association + * @param memberEnd + * the member end of the association + * @return + * the command to use to set the owner of the association + */ public static ICommand getSetTypeOwnerForAssociationAttributeCommand(Association association, Property memberEnd) { ICommand command = null; Type ownerType; @@ -74,10 +118,10 @@ public class OwnedAttributeHelper { ownerType = ownerList.get(0); } - EStructuralFeature ownedAttributeFeature = getFeatureForType(ownerType); + EStructuralFeature ownedAttributeFeature = getOwnedAttributeFeatureForType(ownerType); if (ownedAttributeFeature != null) { - List<Property> attributeList = new ArrayList<Property>(); + List<Property> attributeList = new ArrayList<>(); attributeList.addAll((EList<Property>) ownerType.eGet(ownedAttributeFeature)); attributeList.add(memberEnd); 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 95070ffe783..70db19c0f96 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 @@ -166,7 +166,7 @@ public class OwnerObservableValue extends ReferenceCountedObservable.Value imple this.currentValue = owner; return new GMFtoEMFCommandWrapper(command); } else { - Activator.log.warn("Cannot modify the memberEnd owner"); + Activator.log.warn("Cannot modify the memberEnd owner"); //$NON-NLS-1$ } } 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 25779e34b4b..c693b51a7cd 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 @@ -84,7 +84,7 @@ public class PapyrusObservableList extends EMFObservableList { return new GMFtoEMFCommandWrapper(provider.getEditCommand(requests.iterator().next())); } - CompositeCommand cc = new CompositeCommand("Edit list"); + CompositeCommand cc = new CompositeCommand("Edit list"); //$NON-NLS-1$ for (IEditCommandRequest request : requests) { ICommand cmd = provider.getEditCommand(request); 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 6f1df275730..71d2df83e84 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,7 @@ import org.eclipse.papyrus.uml.tools.Activator; * Papyrus commands * * @author Camille Letavernier - * @deprecated Use the {@link org.eclipse.papyrus.infra.gmfdiag.common.databinding.GMFObservableList} API, instead + * @deprecated Use the {@link org.eclipse.papyrus.infra.gmfdiag.common.databinding.GMFObservableValue} API, instead */ @Deprecated public class PapyrusObservableValue extends EMFObservableValue implements AggregatedObservable, CommandBasedObservableValue, ReferenceCountedObservable { @@ -108,10 +108,10 @@ public class PapyrusObservableValue extends EMFObservableValue implements Aggreg Object oldValue = getValue(); try { - IElementEditService provider = ElementEditServiceUtils.getCommandProvider((EObject)getObserved()); + IElementEditService provider = ElementEditServiceUtils.getCommandProvider((EObject) getObserved()); if (provider != null) { - CompositeCommand cc = new CompositeCommand("Edit value"); + CompositeCommand cc = new CompositeCommand("Edit value"); //$NON-NLS-1$ if (oldValue instanceof EObject && eStructuralFeature instanceof EReference && ((EReference) eStructuralFeature).isContainment()) { cc.add(provider.getEditCommand(new DestroyElementRequest((TransactionalEditingDomain) domain, (EObject) oldValue, false))); 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 cd383052c42..e2507a63d7d 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 @@ -278,7 +278,7 @@ public class ProfileApplicationObservableList extends WritableList implements IC if (element instanceof Profile) { profiles.add(EMFHelper.reloadIntoContext((Profile) element, umlSource)); } else { - throw new IllegalArgumentException("The new value should only contain profiles"); + throw new IllegalArgumentException("The new value should only contain profiles"); //$NON-NLS-1$ } } Command command = new ApplyProfileCommand(umlSource, profiles, (TransactionalEditingDomain) domain); 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 22921b0b8fa..0cfaa80f199 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 @@ -98,7 +98,7 @@ public class ProvidedInterfaceObservableList extends PapyrusObservableList { 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")); + 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 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 e0ec2bfbe1b..9585acbb9f1 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 @@ -94,7 +94,7 @@ public class RequiredInterfaceObservableList extends PapyrusObservableList { 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")); + 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 { |