Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNicolas FAUVERGUE2016-12-15 10:03:37 +0000
committerNicolas FAUVERGUE2016-12-15 10:03:37 +0000
commit58ca472001b7bfdce9a05c6f73c09377de53152a (patch)
tree416e7f1f23799717b058b1f5fdb7752928ba3773 /plugins/infra
parentfa17679ff018be5f9f1edb6094a823a40b20be95 (diff)
downloadorg.eclipse.papyrus-58ca472001b7bfdce9a05c6f73c09377de53152a.tar.gz
org.eclipse.papyrus-58ca472001b7bfdce9a05c6f73c09377de53152a.tar.xz
org.eclipse.papyrus-58ca472001b7bfdce9a05c6f73c09377de53152a.zip
Bug 509067: [Internationalization] Manage the properties files with a
proper Resource https://bugs.eclipse.org/bugs/show_bug.cgi?id=509067 - Add not-null condition for owner of table/diagram Change-Id: I3876aea0f35fc4353e4124768e511380cb333462 Signed-off-by: Nicolas FAUVERGUE <nicolas.fauvergue@cea.fr>
Diffstat (limited to 'plugins/infra')
-rw-r--r--plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization.common/src/org/eclipse/papyrus/infra/internationalization/common/utils/InternationalizationPreferencesUtils.java8
-rw-r--r--plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization.utils/src/org/eclipse/papyrus/infra/internationalization/utils/utils/LabelInternationalization.java13
-rw-r--r--plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization.utils/src/org/eclipse/papyrus/infra/internationalization/utils/utils/LabelInternationalizationUtils.java3
-rw-r--r--plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization/src/org/eclipse/papyrus/infra/internationalization/modelresource/InternationalizationModelResource.java6
-rw-r--r--plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization/src/org/eclipse/papyrus/infra/internationalization/utils/EntryPartLabelSynchronizer.java9
-rw-r--r--plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization/src/org/eclipse/papyrus/infra/internationalization/utils/PreferencePartLabelSynchronizer.java8
6 files changed, 38 insertions, 9 deletions
diff --git a/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization.common/src/org/eclipse/papyrus/infra/internationalization/common/utils/InternationalizationPreferencesUtils.java b/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization.common/src/org/eclipse/papyrus/infra/internationalization/common/utils/InternationalizationPreferencesUtils.java
index 58cb94f1f35..2e4c8e0b756 100644
--- a/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization.common/src/org/eclipse/papyrus/infra/internationalization/common/utils/InternationalizationPreferencesUtils.java
+++ b/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization.common/src/org/eclipse/papyrus/infra/internationalization/common/utils/InternationalizationPreferencesUtils.java
@@ -146,7 +146,7 @@ public class InternationalizationPreferencesUtils {
*/
public static boolean getInternationalizationPreference(final EObject eObject) {
boolean result = false;
- if(null != eObject.eResource()){
+ if(null != eObject && null != eObject.eResource()){
result = getInternationalizationPreference(getRootContainer(eObject).eResource());
}
return result;
@@ -214,7 +214,11 @@ public class InternationalizationPreferencesUtils {
* @return The locale preference.
*/
public static Locale getLocalePreference(final EObject eObject) {
- return getLocalePreference(getRootContainer(eObject).eResource().getURI());
+ Locale result = null;
+ if(null != eObject){
+ result = getLocalePreference(getRootContainer(eObject).eResource().getURI());
+ }
+ return result;
}
/**
diff --git a/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization.utils/src/org/eclipse/papyrus/infra/internationalization/utils/utils/LabelInternationalization.java b/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization.utils/src/org/eclipse/papyrus/infra/internationalization/utils/utils/LabelInternationalization.java
index f1a6370d237..b0a112607ed 100644
--- a/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization.utils/src/org/eclipse/papyrus/infra/internationalization/utils/utils/LabelInternationalization.java
+++ b/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization.utils/src/org/eclipse/papyrus/infra/internationalization/utils/utils/LabelInternationalization.java
@@ -16,6 +16,7 @@ package org.eclipse.papyrus.infra.internationalization.utils.utils;
import java.util.Locale;
import org.eclipse.emf.common.command.Command;
+import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.edit.domain.EditingDomain;
import org.eclipse.gmf.runtime.notation.Diagram;
import org.eclipse.papyrus.infra.internationalization.common.utils.InternationalizationPreferencesUtils;
@@ -247,7 +248,11 @@ public class LabelInternationalization {
* The new preference value.
*/
public void setInternationalizationPreference(final Table table, final boolean value) {
- InternationalizationPreferencesUtils.setInternationalizationPreference(table.getOwner(), value);
+ EObject tableOwner = table.getOwner();
+ if(null == tableOwner){
+ tableOwner = table.getContext();
+ }
+ InternationalizationPreferencesUtils.setInternationalizationPreference(tableOwner, value);
}
/**
@@ -261,7 +266,11 @@ public class LabelInternationalization {
* <code>false</code> otherwise.
*/
public boolean getInternationalizationPreference(final Table table) {
- return InternationalizationPreferencesUtils.getInternationalizationPreference(table.getOwner());
+ EObject tableOwner = table.getOwner();
+ if(null == tableOwner){
+ tableOwner = table.getContext();
+ }
+ return InternationalizationPreferencesUtils.getInternationalizationPreference(tableOwner);
}
/**
diff --git a/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization.utils/src/org/eclipse/papyrus/infra/internationalization/utils/utils/LabelInternationalizationUtils.java b/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization.utils/src/org/eclipse/papyrus/infra/internationalization/utils/utils/LabelInternationalizationUtils.java
index fc1c888e554..2f2c5d992c4 100644
--- a/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization.utils/src/org/eclipse/papyrus/infra/internationalization/utils/utils/LabelInternationalizationUtils.java
+++ b/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization.utils/src/org/eclipse/papyrus/infra/internationalization/utils/utils/LabelInternationalizationUtils.java
@@ -281,6 +281,9 @@ public class LabelInternationalizationUtils {
EObject parentEObject = eObject;
if (eObject instanceof Table) {
parentEObject = ((Table) eObject).getOwner();
+ if(null == parentEObject){
+ parentEObject = ((Table) eObject).getContext();
+ }
} else if (eObject instanceof Diagram) {
parentEObject = QualifiedNameUtils.getOwner((Diagram) eObject);
}
diff --git a/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization/src/org/eclipse/papyrus/infra/internationalization/modelresource/InternationalizationModelResource.java b/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization/src/org/eclipse/papyrus/infra/internationalization/modelresource/InternationalizationModelResource.java
index 5a27f0324aa..173656f40b4 100644
--- a/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization/src/org/eclipse/papyrus/infra/internationalization/modelresource/InternationalizationModelResource.java
+++ b/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization/src/org/eclipse/papyrus/infra/internationalization/modelresource/InternationalizationModelResource.java
@@ -1148,7 +1148,11 @@ public class InternationalizationModelResource extends AbstractModelWithSharedRe
protected static EObject getParentEObject(final EObject eObject) {
EObject parentEObject = eObject;
if (eObject instanceof Table) {
- parentEObject = ((Table) eObject).getOwner();
+ if(null != ((Table) eObject).getOwner()){
+ parentEObject = ((Table) eObject).getOwner();
+ }else{
+ parentEObject = ((Table) eObject).getContext();
+ }
} else if (eObject instanceof Diagram) {
parentEObject = QualifiedNameUtils.getOwner((Diagram) eObject);
}
diff --git a/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization/src/org/eclipse/papyrus/infra/internationalization/utils/EntryPartLabelSynchronizer.java b/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization/src/org/eclipse/papyrus/infra/internationalization/utils/EntryPartLabelSynchronizer.java
index b52db2ff0c4..d69a90f29dc 100644
--- a/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization/src/org/eclipse/papyrus/infra/internationalization/utils/EntryPartLabelSynchronizer.java
+++ b/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization/src/org/eclipse/papyrus/infra/internationalization/utils/EntryPartLabelSynchronizer.java
@@ -16,6 +16,7 @@ package org.eclipse.papyrus.infra.internationalization.utils;
import org.eclipse.emf.common.notify.Adapter;
import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.notify.impl.AdapterImpl;
+import org.eclipse.emf.ecore.EObject;
import org.eclipse.gmf.runtime.notation.Diagram;
import org.eclipse.papyrus.infra.internationalization.InternationalizationEntry;
import org.eclipse.papyrus.infra.internationalization.InternationalizationPackage;
@@ -142,8 +143,12 @@ public class EntryPartLabelSynchronizer {
*/
protected String getTableLabel(final Table table) {
String result = null;
- if (InternationalizationPreferencesUtils.getInternationalizationPreference(table.getOwner())) {
- result = modelResource.getValueForEntryKey(table.eResource().getURI(), table);
+ EObject tableOwner = table.getOwner();
+ if(null == tableOwner){
+ tableOwner = table.getContext();
+ }
+ if (InternationalizationPreferencesUtils.getInternationalizationPreference(tableOwner)) {
+ result = modelResource.getValueForEntryKey(tableOwner.eResource().getURI(), table);
}
return null != result ? result : table.getName();
}
diff --git a/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization/src/org/eclipse/papyrus/infra/internationalization/utils/PreferencePartLabelSynchronizer.java b/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization/src/org/eclipse/papyrus/infra/internationalization/utils/PreferencePartLabelSynchronizer.java
index cebe9663f89..38c05a1b52f 100644
--- a/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization/src/org/eclipse/papyrus/infra/internationalization/utils/PreferencePartLabelSynchronizer.java
+++ b/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization/src/org/eclipse/papyrus/infra/internationalization/utils/PreferencePartLabelSynchronizer.java
@@ -146,8 +146,12 @@ public class PreferencePartLabelSynchronizer {
*/
protected String getTableLabel(final Table table) {
String result = null;
- if (InternationalizationPreferencesUtils.getInternationalizationPreference(table.getOwner())) {
- result = modelResource.getValueForEntryKey(table.eResource().getURI(), table);
+ EObject tableOwner = table.getOwner();
+ if(null == tableOwner){
+ tableOwner = table.getContext();
+ }
+ if (InternationalizationPreferencesUtils.getInternationalizationPreference(tableOwner)) {
+ result = modelResource.getValueForEntryKey(tableOwner.eResource().getURI(), table);
}
return null != result ? result : table.getName();
}

Back to the top