Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--plugins/infra/emf/org.eclipse.papyrus.infra.emf/META-INF/MANIFEST.MF2
-rw-r--r--plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/utils/EMFHelper.java78
-rw-r--r--plugins/infra/emf/org.eclipse.papyrus.infra.ui.emf/src/org/eclipse/papyrus/infra/ui/emf/databinding/EMFObservableValue.java5
-rw-r--r--plugins/infra/emf/org.eclipse.papyrus.infra.ui.emf/src/org/eclipse/papyrus/infra/ui/emf/providers/EMFContentProvider.java9
-rw-r--r--plugins/infra/emf/org.eclipse.papyrus.infra.ui.emf/src/org/eclipse/papyrus/infra/ui/emf/providers/EMFEnumeratorContentProvider.java7
-rw-r--r--plugins/infra/ui/org.eclipse.papyrus.infra.widgets/META-INF/MANIFEST.MF2
-rw-r--r--plugins/infra/ui/org.eclipse.papyrus.infra.widgets/src/org/eclipse/papyrus/infra/widgets/editors/DoubleEditor.java5
-rw-r--r--plugins/infra/ui/org.eclipse.papyrus.infra.widgets/src/org/eclipse/papyrus/infra/widgets/editors/IntegerEditor.java7
-rw-r--r--plugins/infra/ui/org.eclipse.papyrus.infra.widgets/src/org/eclipse/papyrus/infra/widgets/validator/IntegerValidator.java29
-rw-r--r--plugins/infra/ui/org.eclipse.papyrus.infra.widgets/src/org/eclipse/papyrus/infra/widgets/validator/RealValidator.java26
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/META-INF/MANIFEST.MF4
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/custom-src/org/eclipse/papyrus/uml/diagram/profile/custom/commands/DefineProfileCommand.java14
-rw-r--r--plugins/uml/tools/org.eclipse.papyrus.uml.tools/src/org/eclipse/papyrus/uml/tools/providers/UMLContentProvider.java11
13 files changed, 150 insertions, 49 deletions
diff --git a/plugins/infra/emf/org.eclipse.papyrus.infra.emf/META-INF/MANIFEST.MF b/plugins/infra/emf/org.eclipse.papyrus.infra.emf/META-INF/MANIFEST.MF
index f5234b3ea0b..b9e4f3066e5 100644
--- a/plugins/infra/emf/org.eclipse.papyrus.infra.emf/META-INF/MANIFEST.MF
+++ b/plugins/infra/emf/org.eclipse.papyrus.infra.emf/META-INF/MANIFEST.MF
@@ -17,7 +17,7 @@ Require-Bundle: org.eclipse.papyrus.infra.core;bundle-version="[3.0.0,4.0.0)";vi
org.eclipse.papyrus.emf.facet.custom.core;bundle-version="[3.0.0,4.0.0)";visibility:=reexport
Bundle-Vendor: Eclipse Modeling Project
Bundle-ActivationPolicy: lazy
-Bundle-Version: 3.0.0.qualifier
+Bundle-Version: 3.1.0.qualifier
Bundle-Name: EMF Tools
Bundle-Activator: org.eclipse.papyrus.infra.emf.Activator
Bundle-ManifestVersion: 2
diff --git a/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/utils/EMFHelper.java b/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/utils/EMFHelper.java
index c8d2a4da852..24421ba99af 100644
--- a/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/utils/EMFHelper.java
+++ b/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/utils/EMFHelper.java
@@ -1,5 +1,5 @@
/*****************************************************************************
- * Copyright (c) 2010, 2016 CEA LIST, Christian W. Damus, and others.
+ * Copyright (c) 2010, 2019 CEA LIST, Christian W. Damus, EclipseSource and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -14,6 +14,7 @@
* Christian W. Damus (CEA) - Support read-only state at object level (CDO)
* Christian W. Damus (CEA) - bugs 323802, 429826, 408491, 432813, 422257
* Christian W. Damus - bugs 469188, 485220
+ * EclipseSource - Bug 544476
*
*****************************************************************************/
package org.eclipse.papyrus.infra.emf.utils;
@@ -48,6 +49,7 @@ import org.eclipse.emf.ecore.resource.ResourceSet;
import org.eclipse.emf.ecore.resource.URIConverter;
import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
import org.eclipse.emf.ecore.util.EcoreUtil;
+import org.eclipse.emf.ecore.util.ExtendedMetaData;
import org.eclipse.emf.ecore.xmi.XMIResource;
import org.eclipse.emf.edit.domain.AdapterFactoryEditingDomain;
import org.eclipse.emf.edit.domain.EditingDomain;
@@ -438,12 +440,12 @@ public class EMFHelper {
/**
* Gets the object of a given {@code type} containing an {@code object}, or the
* {@code object} itself if it is of that {@code type}.
- *
+ *
* @param object
* the object for which to search for a container
* @param type
* the type of container to find
- *
+ *
* @return the container of the requested {@code type}, or {@code null} if none
* @since 2.0
*/
@@ -464,12 +466,12 @@ public class EMFHelper {
/**
* Gets the object of a given {@code type} containing an {@code object}, or the
* {@code object} itself if it is of that {@code type}.
- *
+ *
* @param object
* the object for which to search for a container
* @param type
* the type of container to find
- *
+ *
* @return the container of the requested {@code type}, or {@code null} if none
* @since 2.0
*/
@@ -496,14 +498,14 @@ public class EMFHelper {
* The list of EClasses implementing or extending the given EClass
*/
public static List<EClass> getSubclassesOf(final EClass type, final boolean concreteClassesOnly) {
- Set<EClass> result = new LinkedHashSet<EClass>();
+ Set<EClass> result = new LinkedHashSet<>();
if (!concreteClassesOnly || (!type.isAbstract() && !type.isInterface())) {
result.add(type);
}
EPackage ePackage = getRootPackage(type.getEPackage());
getSubclassesOf(type, ePackage, result, concreteClassesOnly);
- return new LinkedList<EClass>(result);
+ return new LinkedList<>(result);
}
/**
@@ -519,7 +521,7 @@ public class EMFHelper {
* The list of EClasses implementing or extending the given EClass
*/
public static List<EClass> getSubclassesOf(final EClass type, final boolean concreteClassesOnly, Collection<EPackage> packagesToBrowse) {
- Set<EClass> result = new LinkedHashSet<EClass>();
+ Set<EClass> result = new LinkedHashSet<>();
if (!concreteClassesOnly || (!type.isAbstract() && !type.isInterface())) {
result.add(type);
}
@@ -528,7 +530,7 @@ public class EMFHelper {
getSubclassesOf(type, ePackage, result, concreteClassesOnly);
}
- return new LinkedList<EClass>(result);
+ return new LinkedList<>(result);
}
/**
@@ -547,12 +549,12 @@ public class EMFHelper {
// If the current package is a dynamic package, it may not be registered (?). Add it directly
EPackage currentPackage = getRootPackage(type.getEPackage());
- Set<EPackage> allPackages = new LinkedHashSet<EPackage>();
+ Set<EPackage> allPackages = new LinkedHashSet<>();
allPackages.add(currentPackage);
if (browseAllRegisteredPackages) {
// FIXME // WARNING: This loop will load all EPackages. The first call is expensive.
- Set<String> allUris = new HashSet<String>(EPackage.Registry.INSTANCE.keySet());
+ Set<String> allUris = new HashSet<>(EPackage.Registry.INSTANCE.keySet());
for (String nsURI : allUris) {
allPackages.add(EPackage.Registry.INSTANCE.getEPackage(nsURI));
@@ -802,6 +804,7 @@ public class EMFHelper {
}
// EEnums are always required, as an EEnum always has a default value
+ // Note: For optional enums, the type will be a EDataType with instanceClass=Enumerator
if (eType instanceof EEnum) {
return true;
}
@@ -817,12 +820,45 @@ public class EMFHelper {
return true;
}
- // If there is a default value, there is always a value
+ // If there is a default value, there is always a value; except for Enums which might be nullable
if (feature.getDefaultValueLiteral() != null) {
+ boolean isNullableEnum = feature.getEType() instanceof EDataType && getEnumType(feature.getEType()) != null;
+ if (!isNullableEnum) {
+ return true;
+ }
+ }
+
+ return false; // The property is not required
+ }
+
+ /**
+ * @since 3.1
+ */
+ public static boolean isEnumType(EClassifier eType) {
+ if (eType instanceof EEnum) {
return true;
}
- return false; // The property if not required
+ if (eType instanceof EDataType) {
+ return getEnumType(eType) != null;
+ }
+
+ return false;
+ }
+
+ /**
+ * @since 3.1
+ */
+ public static EEnum getEnumType(EClassifier eType) {
+ if (eType instanceof EEnum) { // Standard Enums
+ return (EEnum) eType;
+ } else if (eType instanceof EDataType) { // Optional Enums
+ EDataType implType = (EDataType) eType;
+ EDataType baseType = ExtendedMetaData.INSTANCE.getBaseType(implType);
+ return baseType instanceof EEnum ? (EEnum) baseType : null;
+ }
+
+ return null;
}
/**
@@ -834,7 +870,7 @@ public class EMFHelper {
*/
public static <T> Set<T> allInstances(final Resource resource, Class<T> type) {
TreeIterator<EObject> iterator = resource.getAllContents();
- Set<T> result = new LinkedHashSet<T>();
+ Set<T> result = new LinkedHashSet<>();
while (iterator.hasNext()) {
EObject element = iterator.next();
@@ -853,7 +889,7 @@ public class EMFHelper {
* @return
*/
public static Set<EPackage> getAllEPackages(final Resource resource) {
- Set<EPackage> result = new LinkedHashSet<EPackage>();
+ Set<EPackage> result = new LinkedHashSet<>();
for (EObject rootElement : resource.getContents()) {
if (rootElement instanceof EPackage) {
@@ -873,7 +909,7 @@ public class EMFHelper {
* @return
*/
public static Set<EPackage> getAllNestedPackages(EPackage basePackage) {
- Set<EPackage> result = new LinkedHashSet<EPackage>();
+ Set<EPackage> result = new LinkedHashSet<>();
for (EPackage nestedPackage : basePackage.getESubpackages()) {
result.add(nestedPackage);
@@ -892,9 +928,9 @@ public class EMFHelper {
* the list of the metamodels known by the resource
*/
public static Set<EPackage> getMetamodels(final Resource resource) {
- Set<EPackage> metamodels = new HashSet<EPackage>();
+ Set<EPackage> metamodels = new HashSet<>();
if (resource != null) {
- final List<EObject> contents = new ArrayList<EObject>(resource.getContents());
+ final List<EObject> contents = new ArrayList<>(resource.getContents());
for (final EObject current : contents) {
metamodels.add(current.eClass().getEPackage());
}
@@ -952,7 +988,7 @@ public class EMFHelper {
EPackage mmPackage = usedObject.eClass().getEPackage();
// Retrieve the list of elements referencing the usedObject.
- Set<EObject> crossReferences = new HashSet<EObject>();
+ Set<EObject> crossReferences = new HashSet<>();
for (Setting setting : getUsages(usedObject)) {
EObject eObj = setting.getEObject();
if (eObj.eClass().getEPackage().equals(mmPackage)) {
@@ -981,7 +1017,7 @@ public class EMFHelper {
* @param subType
* another eClassifier
* @return
- * <code>true</code> if the 2nd {@link EClassifier} is a subtype of the first one
+ * <code>true</code> if the 2nd {@link EClassifier} is a subtype of the first one
*/
public static boolean isSuperType(final EClassifier superType, final EClassifier subType) {
if (superType == subType) {
@@ -1016,7 +1052,7 @@ public class EMFHelper {
public static List<EObject> getContainmentPath(EObject element) {
List<EObject> result;
if (element.eContainer() == null) {
- result = new LinkedList<EObject>();
+ result = new LinkedList<>();
result.add(element);
return result;
} else {
diff --git a/plugins/infra/emf/org.eclipse.papyrus.infra.ui.emf/src/org/eclipse/papyrus/infra/ui/emf/databinding/EMFObservableValue.java b/plugins/infra/emf/org.eclipse.papyrus.infra.ui.emf/src/org/eclipse/papyrus/infra/ui/emf/databinding/EMFObservableValue.java
index e8ff3181e17..a56abbfc503 100644
--- a/plugins/infra/emf/org.eclipse.papyrus.infra.ui.emf/src/org/eclipse/papyrus/infra/ui/emf/databinding/EMFObservableValue.java
+++ b/plugins/infra/emf/org.eclipse.papyrus.infra.ui.emf/src/org/eclipse/papyrus/infra/ui/emf/databinding/EMFObservableValue.java
@@ -70,6 +70,11 @@ public class EMFObservableValue extends EObjectObservableValue {
}
@Override
+ protected Object doGetValue() {
+ return eStructuralFeature.isUnsettable() && !eObject.eIsSet(eStructuralFeature) && eStructuralFeature.getDefaultValueLiteral() == null ? null : super.doGetValue();
+ }
+
+ @Override
protected void doSetValue(Object value) {
EObject eObject = EMFHelper.getEObject(value);
if (eObject != null) {
diff --git a/plugins/infra/emf/org.eclipse.papyrus.infra.ui.emf/src/org/eclipse/papyrus/infra/ui/emf/providers/EMFContentProvider.java b/plugins/infra/emf/org.eclipse.papyrus.infra.ui.emf/src/org/eclipse/papyrus/infra/ui/emf/providers/EMFContentProvider.java
index 3fd2276d5dd..6305666356b 100644
--- a/plugins/infra/emf/org.eclipse.papyrus.infra.ui.emf/src/org/eclipse/papyrus/infra/ui/emf/providers/EMFContentProvider.java
+++ b/plugins/infra/emf/org.eclipse.papyrus.infra.ui.emf/src/org/eclipse/papyrus/infra/ui/emf/providers/EMFContentProvider.java
@@ -1,5 +1,5 @@
/*****************************************************************************
- * Copyright (c) 2011 CEA LIST.
+ * Copyright (c) 2011, 2019 CEA LIST, EclipseSource and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -10,17 +10,18 @@
*
* Contributors:
* Camille Letavernier (CEA LIST) camille.letavernier@cea.fr - Initial API and implementation
+ * EclipseSource - Bug 544476
*****************************************************************************/
package org.eclipse.papyrus.infra.ui.emf.providers;
import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.EClassifier;
-import org.eclipse.emf.ecore.EEnum;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.EStructuralFeature;
import org.eclipse.emf.ecore.resource.ResourceSet;
import org.eclipse.jface.viewers.IStructuredContentProvider;
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.ui.emf.providers.strategy.ContainmentBrowseStrategy;
import org.eclipse.papyrus.infra.ui.emf.providers.strategy.SemanticEMFContentProvider;
@@ -60,11 +61,11 @@ public class EMFContentProvider extends EncapsulatedContentProvider {
* @param feature
* The object's feature being edited
* @return
- * A content provider returning all the values valid for the given feature
+ * A content provider returning all the values valid for the given feature
*/
protected IStructuredContentProvider getSemanticProvider(EObject editedEObject, EStructuralFeature feature) {
EClassifier type = feature.getEType();
- if (type instanceof EEnum) {
+ if (EMFHelper.isEnumType(type)) {
return new EMFEnumeratorContentProvider(feature);
} else if (type instanceof EClass) {
return new SemanticEMFContentProvider(editedEObject, feature);
diff --git a/plugins/infra/emf/org.eclipse.papyrus.infra.ui.emf/src/org/eclipse/papyrus/infra/ui/emf/providers/EMFEnumeratorContentProvider.java b/plugins/infra/emf/org.eclipse.papyrus.infra.ui.emf/src/org/eclipse/papyrus/infra/ui/emf/providers/EMFEnumeratorContentProvider.java
index 4d21219d5b5..9b3dc8b6e9e 100644
--- a/plugins/infra/emf/org.eclipse.papyrus.infra.ui.emf/src/org/eclipse/papyrus/infra/ui/emf/providers/EMFEnumeratorContentProvider.java
+++ b/plugins/infra/emf/org.eclipse.papyrus.infra.ui.emf/src/org/eclipse/papyrus/infra/ui/emf/providers/EMFEnumeratorContentProvider.java
@@ -1,5 +1,5 @@
/*****************************************************************************
- * Copyright (c) 2010 CEA LIST.
+ * Copyright (c) 2010, 2019 CEA LIST, EclipseSource and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -10,6 +10,7 @@
*
* Contributors:
* Camille Letavernier (CEA LIST) camille.letavernier@cea.fr - Initial API and implementation
+ * EclipseSource - Bug 544476
*****************************************************************************/
package org.eclipse.papyrus.infra.ui.emf.providers;
@@ -18,6 +19,7 @@ import org.eclipse.emf.ecore.EClassifier;
import org.eclipse.emf.ecore.EEnum;
import org.eclipse.emf.ecore.EEnumLiteral;
import org.eclipse.emf.ecore.EStructuralFeature;
+import org.eclipse.papyrus.infra.emf.utils.EMFHelper;
import org.eclipse.papyrus.infra.widgets.providers.AbstractStaticContentProvider;
/**
@@ -41,9 +43,10 @@ public class EMFEnumeratorContentProvider extends AbstractStaticContentProvider
this.feature = feature;
}
+ @Override
public Object[] getElements() {
EClassifier type = feature.getEType();
- EEnum enumerated = (EEnum) type;
+ EEnum enumerated = EMFHelper.getEnumType(type);
EEnumLiteral[] literals = enumerated.getELiterals().toArray(new EEnumLiteral[0]);
Enumerator[] values = new Enumerator[literals.length];
diff --git a/plugins/infra/ui/org.eclipse.papyrus.infra.widgets/META-INF/MANIFEST.MF b/plugins/infra/ui/org.eclipse.papyrus.infra.widgets/META-INF/MANIFEST.MF
index cb4a465a4ff..01b1ba5283b 100644
--- a/plugins/infra/ui/org.eclipse.papyrus.infra.widgets/META-INF/MANIFEST.MF
+++ b/plugins/infra/ui/org.eclipse.papyrus.infra.widgets/META-INF/MANIFEST.MF
@@ -31,7 +31,7 @@ Export-Package: org.eclipse.papyrus.infra.widgets,
org.eclipse.papyrus.infra.widgets.wizard.pages
Bundle-Vendor: %providerName
Bundle-ActivationPolicy: lazy
-Bundle-Version: 3.4.0.qualifier
+Bundle-Version: 3.5.0.qualifier
Bundle-Name: %pluginName
Bundle-Localization: plugin
Bundle-ManifestVersion: 2
diff --git a/plugins/infra/ui/org.eclipse.papyrus.infra.widgets/src/org/eclipse/papyrus/infra/widgets/editors/DoubleEditor.java b/plugins/infra/ui/org.eclipse.papyrus.infra.widgets/src/org/eclipse/papyrus/infra/widgets/editors/DoubleEditor.java
index 81bfb314bdb..111159b9f5a 100644
--- a/plugins/infra/ui/org.eclipse.papyrus.infra.widgets/src/org/eclipse/papyrus/infra/widgets/editors/DoubleEditor.java
+++ b/plugins/infra/ui/org.eclipse.papyrus.infra.widgets/src/org/eclipse/papyrus/infra/widgets/editors/DoubleEditor.java
@@ -42,7 +42,7 @@ public class DoubleEditor extends StringEditor {
public DoubleEditor(Composite parent, int style) {
super(parent, style);
- targetValidator = new RealValidator();
+ targetValidator = new RealValidator(true);
targetToModelConverter = new IConverter() {
@Override
@@ -60,6 +60,9 @@ public class DoubleEditor extends StringEditor {
if (fromObject instanceof String) {
String newString = ((String) fromObject)
.replaceAll(" ", ""); //$NON-NLS-1$ //$NON-NLS-2$
+ if (newString.isEmpty()) {
+ return null;
+ }
try {
return Double.parseDouble(newString);
} catch (NumberFormatException ex) {
diff --git a/plugins/infra/ui/org.eclipse.papyrus.infra.widgets/src/org/eclipse/papyrus/infra/widgets/editors/IntegerEditor.java b/plugins/infra/ui/org.eclipse.papyrus.infra.widgets/src/org/eclipse/papyrus/infra/widgets/editors/IntegerEditor.java
index 37cfa907e48..65d9f08da0a 100644
--- a/plugins/infra/ui/org.eclipse.papyrus.infra.widgets/src/org/eclipse/papyrus/infra/widgets/editors/IntegerEditor.java
+++ b/plugins/infra/ui/org.eclipse.papyrus.infra.widgets/src/org/eclipse/papyrus/infra/widgets/editors/IntegerEditor.java
@@ -59,7 +59,7 @@ public class IntegerEditor extends StringEditor {
public IntegerEditor(Composite parent, int style, String label) {
super(parent, style, label);
- targetValidator = new IntegerValidator();
+ targetValidator = new IntegerValidator(true);
targetToModelConverter = new IConverter() {
@@ -78,7 +78,7 @@ public class IntegerEditor extends StringEditor {
if (fromObject instanceof String) {
String newString = ((String) fromObject).replaceAll(" ", ""); //$NON-NLS-1$ //$NON-NLS-2$
try {
- Integer i = (Integer) StringToNumberConverter.toInteger(false).convert(newString);
+ Integer i = StringToNumberConverter.toInteger(false).convert(newString);
return i;
} catch (Exception ex) {
@@ -107,8 +107,9 @@ public class IntegerEditor extends StringEditor {
if (fromObject instanceof Integer) {
return Integer.toString((Integer) fromObject);
+ } else if (fromObject != null) {
+ errorBinding = true;
}
- errorBinding = true;
return ""; //$NON-NLS-1$
}
diff --git a/plugins/infra/ui/org.eclipse.papyrus.infra.widgets/src/org/eclipse/papyrus/infra/widgets/validator/IntegerValidator.java b/plugins/infra/ui/org.eclipse.papyrus.infra.widgets/src/org/eclipse/papyrus/infra/widgets/validator/IntegerValidator.java
index 1df71272adc..ac690a982a0 100644
--- a/plugins/infra/ui/org.eclipse.papyrus.infra.widgets/src/org/eclipse/papyrus/infra/widgets/validator/IntegerValidator.java
+++ b/plugins/infra/ui/org.eclipse.papyrus.infra.widgets/src/org/eclipse/papyrus/infra/widgets/validator/IntegerValidator.java
@@ -1,5 +1,5 @@
/*****************************************************************************
- * Copyright (c) 2013 CEA LIST.
+ * Copyright (c) 2013, 2019 CEA LIST, EclipseSource.
*
*
* All rights reserved. This program and the accompanying materials
@@ -12,6 +12,7 @@
* Contributors:
* Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation
* Camille Letavernier (CEA LIST) camille.letavernier@cea.fr - Modification to match IValidator
+ * EclipseSource - Bug 544476
*
*****************************************************************************/
package org.eclipse.papyrus.infra.widgets.validator;
@@ -28,6 +29,22 @@ import org.eclipse.papyrus.infra.widgets.messages.Messages;
*/
public class IntegerValidator extends AbstractValidator {
+ private final boolean allowNull;
+
+ public IntegerValidator() {
+ this(false);
+ }
+
+ /**
+ * Create a new {@link IntegerValidator}. If <code>allowNull</code>
+ * is true, null and empty strings will be considered valid values (These
+ * null/empty values can be used e.g. to reset or unset an integer value)
+ *
+ * @since 3.5
+ */
+ public IntegerValidator(boolean allowNull) {
+ this.allowNull = allowNull;
+ }
/**
*
@@ -41,9 +58,17 @@ public class IntegerValidator extends AbstractValidator {
return Status.OK_STATUS;
}
+ if (allowNull && newValue == null) {
+ return Status.OK_STATUS;
+ }
+
if (newValue instanceof String) {
+ String strValue = (String) newValue;
+ if (allowNull && strValue.isEmpty()) {
+ return Status.OK_STATUS;
+ }
try {
- Integer.parseInt((String) newValue);
+ Integer.parseInt(strValue);
return Status.OK_STATUS;
} catch (NumberFormatException ex) {
return error(Messages.IntegerInputValidator_NotAnIntegerMessage);
diff --git a/plugins/infra/ui/org.eclipse.papyrus.infra.widgets/src/org/eclipse/papyrus/infra/widgets/validator/RealValidator.java b/plugins/infra/ui/org.eclipse.papyrus.infra.widgets/src/org/eclipse/papyrus/infra/widgets/validator/RealValidator.java
index c67a8979ee7..3ff10f0d880 100644
--- a/plugins/infra/ui/org.eclipse.papyrus.infra.widgets/src/org/eclipse/papyrus/infra/widgets/validator/RealValidator.java
+++ b/plugins/infra/ui/org.eclipse.papyrus.infra.widgets/src/org/eclipse/papyrus/infra/widgets/validator/RealValidator.java
@@ -25,6 +25,22 @@ import org.eclipse.papyrus.infra.widgets.messages.Messages;
*/
public class RealValidator extends AbstractValidator {
+ private final boolean allowNull;
+
+ public RealValidator() {
+ this(false);
+ }
+
+ /**
+ * Create a new {@link RealValidator}. If <code>allowNull</code>
+ * is true, null and empty strings will be considered valid values (These
+ * null/empty values can be used e.g. to reset or unset a real value)
+ *
+ * @since 3.5
+ */
+ public RealValidator(boolean allowNull) {
+ this.allowNull = allowNull;
+ }
/**
*
@@ -38,9 +54,17 @@ public class RealValidator extends AbstractValidator {
return Status.OK_STATUS;
}
+ if (newValue == null && allowNull) {
+ return Status.OK_STATUS;
+ }
+
if (newValue instanceof String) {
+ String strValue = (String) newValue;
+ if (allowNull && strValue.isEmpty()) {
+ return Status.OK_STATUS;
+ }
try {
- Double.parseDouble((String) newValue);
+ Double.parseDouble(strValue);
return Status.OK_STATUS;
} catch (NumberFormatException ex) {
return error(Messages.RealInputValidator_NotaRealMessage);
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/META-INF/MANIFEST.MF b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/META-INF/MANIFEST.MF
index 1c3b7b49ae4..c10dae7dc71 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/META-INF/MANIFEST.MF
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/META-INF/MANIFEST.MF
@@ -66,8 +66,8 @@ Require-Bundle: org.eclipse.papyrus.uml.profile;bundle-version="[3.0.0,4.0.0)",
org.eclipse.gmf.runtime.diagram.ui.resources.editor,
org.eclipse.draw2d;visibility:=reexport,
org.eclipse.gmf.runtime.draw2d.ui;visibility:=reexport,
- org.eclipse.uml2.uml;bundle-version="[5.3.0,6.0.0)";visibility:=reexport,
- org.eclipse.uml2.uml.edit;bundle-version="[5.3.0,6.0.0)";visibility:=reexport,
+ org.eclipse.uml2.uml;bundle-version="[5.6.0,6.0.0)";visibility:=reexport,
+ org.eclipse.uml2.uml.edit;bundle-version="[5.5.0,6.0.0)";visibility:=reexport,
org.eclipse.emf.ecore;visibility:=reexport,
org.eclipse.emf.ecore.edit;visibility:=reexport,
org.eclipse.emf.validation;visibility:=reexport,
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/custom-src/org/eclipse/papyrus/uml/diagram/profile/custom/commands/DefineProfileCommand.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/custom-src/org/eclipse/papyrus/uml/diagram/profile/custom/commands/DefineProfileCommand.java
index e635477e288..16638dc1761 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/custom-src/org/eclipse/papyrus/uml/diagram/profile/custom/commands/DefineProfileCommand.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/custom-src/org/eclipse/papyrus/uml/diagram/profile/custom/commands/DefineProfileCommand.java
@@ -103,7 +103,7 @@ public class DefineProfileCommand extends AbstractTransactionalCommand {
* the package to define (if it is a profile)
*/
public static List<EPackage> defineProfiles(Package thePackage, boolean saveConstraintInDef) {
- Map<String, String> options = new HashMap<String, String>();
+ Map<String, String> options = new HashMap<>();
options.put(UML2EcoreConverter.OPTION__ECORE_TAGGED_VALUES, UMLUtil.OPTION__PROCESS);
options.put(UML2EcoreConverter.OPTION__DERIVED_FEATURES, UMLUtil.OPTION__REPORT);
@@ -124,16 +124,18 @@ public class DefineProfileCommand extends AbstractTransactionalCommand {
options.put(UML2EcoreConverter.OPTION__VALIDATION_DELEGATES, handleConstraints);
options.put(UML2EcoreConverter.OPTION__INVOCATION_DELEGATES, handleConstraints);
options.put(UML2EcoreConverter.OPTION__OPERATION_BODIES, handleConstraints);
-
- // Assure that "right" (consistent with xtext editor) OCL delegate is used , see bug 512428
+
+ // Assure that "right" (consistent with xtext editor) OCL delegate is used , see bug 512428
options.put(UML2EcoreConverter.OPTION__OCL_DELEGATE_URI, "http://www.eclipse.org/emf/2002/Ecore/OCL/Pivot"); //$NON-NLS-1$
options.put(UML2EcoreConverter.OPTION__COMMENTS, UMLUtil.OPTION__IGNORE);
options.put(Profile2EPackageConverter.OPTION__FOREIGN_DEFINITIONS, UMLUtil.OPTION__PROCESS);
options.put(UML2EcoreConverter.OPTION__UNTYPED_PROPERTIES, UMLUtil.OPTION__PROCESS); // Closer to the UML semantics of untyped properties
+ options.put(UML2EcoreConverter.OPTION__UNSETTABLE_PRIMITIVE_ATTRIBUTES, UMLUtil.OPTION__PROCESS); // Allow null value for EAttributes, if multiplicity is optional
+ options.put(UML2EcoreConverter.OPTION__NULLABLE_ENUM_ATTRIBUTES, UMLUtil.OPTION__PROCESS); // Allow null value for Enums (Special case of EAttribute), if multiplicity is optional
- List<Profile> toDefine = new ArrayList<Profile>();
+ List<Profile> toDefine = new ArrayList<>();
for (TreeIterator<EObject> all = UML2Util.getAllContents(thePackage, true, false); all.hasNext();) {
EObject next = all.next();
if (next instanceof Profile) {
@@ -149,7 +151,7 @@ public class DefineProfileCommand extends AbstractTransactionalCommand {
ProfileUtil.sortProfiles(toDefine);
}
- List<EPackage> result = new ArrayList<EPackage>(toDefine.size());
+ List<EPackage> result = new ArrayList<>(toDefine.size());
for (Profile next : toDefine) {
result.add(next.define(options, null, null));
}
@@ -253,7 +255,7 @@ public class DefineProfileCommand extends AbstractTransactionalCommand {
IFile f = WorkspaceSynchronizer.getFile(rootProfile.eResource());
return f != null ? Collections.<IFile> singletonList(f) : Collections.<IFile> emptyList();
}
-
+
/**
* Clean undefine tag.
*/
diff --git a/plugins/uml/tools/org.eclipse.papyrus.uml.tools/src/org/eclipse/papyrus/uml/tools/providers/UMLContentProvider.java b/plugins/uml/tools/org.eclipse.papyrus.uml.tools/src/org/eclipse/papyrus/uml/tools/providers/UMLContentProvider.java
index 1fb554baf9c..cd8ef601a45 100644
--- a/plugins/uml/tools/org.eclipse.papyrus.uml.tools/src/org/eclipse/papyrus/uml/tools/providers/UMLContentProvider.java
+++ b/plugins/uml/tools/org.eclipse.papyrus.uml.tools/src/org/eclipse/papyrus/uml/tools/providers/UMLContentProvider.java
@@ -1,5 +1,5 @@
/*****************************************************************************
- * Copyright (c) 2011 CEA LIST.
+ * Copyright (c) 2011, 2019 CEA LIST, EclipseSource and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -12,6 +12,7 @@
* Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation
* Camille Letavernier (CEA LIST) camille.letavernier@cea.fr
* Gabriel Pascual (ALL4TEC) gabriel.pascual@all4tec.net - Initial API and implementation
+ * EclipseSource - Bug 544476
*
*****************************************************************************/
package org.eclipse.papyrus.uml.tools.providers;
@@ -19,7 +20,6 @@ package org.eclipse.papyrus.uml.tools.providers;
import java.util.Collections;
import org.eclipse.emf.ecore.EClass;
-import org.eclipse.emf.ecore.EEnum;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.EStructuralFeature;
import org.eclipse.emf.ecore.resource.Resource;
@@ -30,6 +30,7 @@ import org.eclipse.papyrus.emf.facet.custom.metamodel.v0_2_0.internal.treeproxy.
import org.eclipse.papyrus.infra.core.services.ServiceException;
import org.eclipse.papyrus.infra.core.services.ServicesRegistry;
import org.eclipse.papyrus.infra.core.utils.ServiceUtils;
+import org.eclipse.papyrus.infra.emf.utils.EMFHelper;
import org.eclipse.papyrus.infra.emf.utils.ServiceUtilsForResource;
import org.eclipse.papyrus.infra.tools.util.PlatformHelper;
import org.eclipse.papyrus.infra.ui.emf.providers.EMFEnumeratorContentProvider;
@@ -64,7 +65,7 @@ public class UMLContentProvider extends EncapsulatedContentProvider {
@Override
public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
// Bug 522650: only update if there is an actual change, to avoid overriding the existing delegate
- if (newInput == oldInput) {
+ if (newInput == oldInput) {
super.inputChanged(viewer, oldInput, newInput);
return;
}
@@ -103,7 +104,7 @@ public class UMLContentProvider extends EncapsulatedContentProvider {
/**
* {@inheritDoc}
- *
+ *
* @see org.eclipse.papyrus.infra.widgets.providers.EncapsulatedContentProvider#hasChildren(java.lang.Object)
*/
@Override
@@ -232,7 +233,7 @@ public class UMLContentProvider extends EncapsulatedContentProvider {
return new InteractionOperatorContentProvider(source, feature);
}
- if (feature.getEType() instanceof EEnum) {
+ if (EMFHelper.isEnumType(feature.getEType())) {
return new EMFEnumeratorContentProvider(feature);
}

Back to the top