Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKhemir Ibtihel2020-10-29 14:31:39 +0000
committervincent lorenzo2020-11-04 16:50:31 +0000
commit3f954c7ab6c0e7e3fb63f7491a5d5976cb5842e4 (patch)
tree1c1b32abcfab7162075b67f516d43b7ad586fb32 /plugins
parent5391965a4b046944afdcd1deb92ca8047a22efc1 (diff)
downloadorg.eclipse.papyrus-3f954c7ab6c0e7e3fb63f7491a5d5976cb5842e4.tar.gz
org.eclipse.papyrus-3f954c7ab6c0e7e3fb63f7491a5d5976cb5842e4.tar.xz
org.eclipse.papyrus-3f954c7ab6c0e7e3fb63f7491a5d5976cb5842e4.zip
Bug 311044: Operation with undefined name causes null pointer exception
Change-Id: Ic6d11fa9fe75aa1bb0fcbd905452f39d8fd9148f Signed-off-by: Khemir Ibtihel <ibtihel.khemir@cea.fr>
Diffstat (limited to 'plugins')
-rw-r--r--plugins/uml/internationalization/org.eclipse.papyrus.uml.internationalization.utils/src/org/eclipse/papyrus/uml/internationalization/utils/utils/UMLLabelInternationalization.java58
1 files changed, 35 insertions, 23 deletions
diff --git a/plugins/uml/internationalization/org.eclipse.papyrus.uml.internationalization.utils/src/org/eclipse/papyrus/uml/internationalization/utils/utils/UMLLabelInternationalization.java b/plugins/uml/internationalization/org.eclipse.papyrus.uml.internationalization.utils/src/org/eclipse/papyrus/uml/internationalization/utils/utils/UMLLabelInternationalization.java
index abe8987ba9d..6871453aa38 100644
--- a/plugins/uml/internationalization/org.eclipse.papyrus.uml.internationalization.utils/src/org/eclipse/papyrus/uml/internationalization/utils/utils/UMLLabelInternationalization.java
+++ b/plugins/uml/internationalization/org.eclipse.papyrus.uml.internationalization.utils/src/org/eclipse/papyrus/uml/internationalization/utils/utils/UMLLabelInternationalization.java
@@ -1,6 +1,6 @@
/*****************************************************************************
- * Copyright (c) 2016 CEA LIST and others.
- *
+ * Copyright (c) 2016, 2020 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:
* Nicolas FAUVERGUE (ALL4TEC) nicolas.fauvergue@all4tec.net - Initial API and implementation
- *
+ * Ibtihel KHEMIR (CEA-LIST) ibtihel.khemir@cea.fr - Bug 311044
*****************************************************************************/
package org.eclipse.papyrus.uml.internationalization.utils.utils;
@@ -49,7 +49,7 @@ public class UMLLabelInternationalization {
/**
* Get the singleton instance (create it if not existing).
- *
+ *
* @return The singleton instance.
*/
public static UMLLabelInternationalization getInstance() {
@@ -61,7 +61,7 @@ public class UMLLabelInternationalization {
/**
* This allows to get the label of the named element.
- *
+ *
* @param namedElement
* The named element.
* @return The label of the named element or the name if the label is null.
@@ -72,7 +72,7 @@ public class UMLLabelInternationalization {
/**
* This allows to get the label of the named element.
- *
+ *
* @param namedElement
* The named element.
* @param localize
@@ -81,23 +81,34 @@ public class UMLLabelInternationalization {
*/
public String getLabel(final NamedElement namedElement, final boolean localize) {
String result = null;
+
if (null != namedElement.eResource()) {
URI resourceURI = namedElement.eResource().getURI();
final ResourceSet resourceSet = namedElement.eResource().getResourceSet();
- if(resourceSet instanceof ModelSet) {
- resourceURI = ((ModelSet)resourceSet).getURIWithoutExtension().appendFileExtension(DiModel.DI_FILE_EXTENSION);
+ if (resourceSet instanceof ModelSet) {
+ resourceURI = ((ModelSet) resourceSet).getURIWithoutExtension().appendFileExtension(DiModel.DI_FILE_EXTENSION);
}
- if(InternationalizationPreferencesUtils.getInternationalizationPreference(resourceURI)) {
+ if (InternationalizationPreferencesUtils.getInternationalizationPreference(resourceURI)) {
result = getLabelWithoutUML(namedElement, localize);
+
}
}
- return null != result ? result : namedElement.getName();
+ String name = null;
+
+ if (namedElement.getName() == null) {
+ name = ""; //$NON-NLS-1$
+ } else {
+ name = namedElement.getName();
+ }
+
+ return null != result ? result : name;
+
}
/**
* This allows to get the label of the named element without the getName
* when the label is null.
- *
+ *
* @param namedElement
* The named element.
* @return The label of the named element.
@@ -109,7 +120,7 @@ public class UMLLabelInternationalization {
/**
* This allows to get the label of the named element without the getName
* when the label is null.
- *
+ *
* @param namedElement
* The named element.
* @param localize
@@ -122,7 +133,7 @@ public class UMLLabelInternationalization {
/**
* This allows to set the named element label.
- *
+ *
* @param namedElement
* The named element.
* @param value
@@ -137,7 +148,7 @@ public class UMLLabelInternationalization {
/**
* This allows to get the set named element label command.
- *
+ *
* @param domain
* The editing domain to use.
* @param namedElement
@@ -156,7 +167,7 @@ public class UMLLabelInternationalization {
/**
* This allows to get the keyword of the stereotype.
- *
+ *
* @param stereotype
* The stereotype.
* @return The keyword of the stereotype or the name if the keyword is null.
@@ -167,7 +178,7 @@ public class UMLLabelInternationalization {
/**
* This allows to get the keyword of the stereotype.
- *
+ *
* @param stereotype
* The stereotype.
* @param localize
@@ -176,11 +187,12 @@ public class UMLLabelInternationalization {
*/
public String getKeyword(final Stereotype stereotype, final boolean localize) {
String result = null;
+
if (null != stereotype.eResource()) {
URI resourceURI = stereotype.eResource().getURI();
final ResourceSet resourceSet = stereotype.eResource().getResourceSet();
- if(resourceSet instanceof ModelSet) {
- resourceURI = ((ModelSet)resourceSet).getURIWithoutExtension().appendFileExtension(DiModel.DI_FILE_EXTENSION);
+ if (resourceSet instanceof ModelSet) {
+ resourceURI = ((ModelSet) resourceSet).getURIWithoutExtension().appendFileExtension(DiModel.DI_FILE_EXTENSION);
}
if (InternationalizationPreferencesUtils.getInternationalizationPreference(resourceURI)) {
result = LabelInternationalizationUtils.getLabelWithoutSubstract(stereotype, localize);
@@ -192,7 +204,7 @@ public class UMLLabelInternationalization {
/**
* This allows to get the keyword of the stereotype without the getName when
* the keyword is null.
- *
+ *
* @param stereotype
* The stereotype.
* @return The keyword of the stereotype.
@@ -204,7 +216,7 @@ public class UMLLabelInternationalization {
/**
* This allows to get the keyword of the stereotype without the getName when
* the keyword is null.
- *
+ *
* @param stereotype
* The stereotype.
* @param localize
@@ -217,7 +229,7 @@ public class UMLLabelInternationalization {
/**
* This allows to set the stereotype keyword.
- *
+ *
* @param stereotype
* The stereotype.
* @param value
@@ -232,7 +244,7 @@ public class UMLLabelInternationalization {
/**
* This allows to get the set stereotype keyword command.
- *
+ *
* @param domain
* The editing domain to use.
* @param stereotype
@@ -252,7 +264,7 @@ public class UMLLabelInternationalization {
/**
* This allows to get the qualified label (this means the qualified name
* with labels).
- *
+ *
* @param namedElement
* The named element to get its qualified label.
* @return The qualified label or <code>null</code>.

Back to the top