diff options
author | Nicolas FAUVERGUE | 2016-12-14 14:46:21 +0000 |
---|---|---|
committer | Nicolas FAUVERGUE | 2016-12-14 14:46:21 +0000 |
commit | b758a18d7d4312b6a82d12e82d4ad07c360eb0f3 (patch) | |
tree | e4c463994381403d5590928feb94ebea3d8fa331 | |
parent | 196a8243261de00e321d5189c541550822e77e11 (diff) | |
download | org.eclipse.papyrus-b758a18d7d4312b6a82d12e82d4ad07c360eb0f3.tar.gz org.eclipse.papyrus-b758a18d7d4312b6a82d12e82d4ad07c360eb0f3.tar.xz org.eclipse.papyrus-b758a18d7d4312b6a82d12e82d4ad07c360eb0f3.zip |
Bug 509067 : [Internationalization] Manage the properties files with a
proper Resource fix hudson build
Change-Id: I1e1348fa7cb8cd12b3dd6c1c38398ee7d4b9d9d8
Signed-off-by: Nicolas FAUVERGUE <nicolas.fauvergue@cea.fr>
3 files changed, 52 insertions, 23 deletions
diff --git a/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization/META-INF/MANIFEST.MF b/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization/META-INF/MANIFEST.MF index 4f283852947..c45aaded456 100644 --- a/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization/META-INF/MANIFEST.MF +++ b/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization/META-INF/MANIFEST.MF @@ -26,7 +26,6 @@ Require-Bundle: org.eclipse.emf.ecore;bundle-version="[2.12.0,3.0.0)";visibility org.eclipse.jface;bundle-version="[3.12.0,4.0.0)", org.eclipse.papyrus.infra.emf.gmf;bundle-version="[1.2.0,2.0.0)", org.eclipse.help;bundle-version="[3.7.0,4.0.0)", - org.eclipse.papyrus.infra.doc;bundle-version="[1.2.0,2.0.0)", - org.eclipse.papyrus.infra.viewpoints.policy;bundle-version="[1.2.0,2.0.0)" + org.eclipse.papyrus.infra.doc;bundle-version="[1.2.0,2.0.0)" Bundle-ActivationPolicy: lazy Bundle-Activator: org.eclipse.papyrus.infra.internationalization.Activator diff --git a/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization/src/org/eclipse/papyrus/infra/internationalization/utils/QualifiedNameUtils.java b/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization/src/org/eclipse/papyrus/infra/internationalization/utils/QualifiedNameUtils.java index a97690b7b70..9c06ab56672 100644 --- a/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization/src/org/eclipse/papyrus/infra/internationalization/utils/QualifiedNameUtils.java +++ b/plugins/infra/internationalization/org.eclipse.papyrus.infra.internationalization/src/org/eclipse/papyrus/infra/internationalization/utils/QualifiedNameUtils.java @@ -13,7 +13,7 @@ package org.eclipse.papyrus.infra.internationalization.utils; -import java.util.List; +import java.util.Iterator; import org.eclipse.emf.ecore.EObject; import org.eclipse.emf.ecore.EStructuralFeature; @@ -22,7 +22,6 @@ import org.eclipse.emf.ecore.xmi.XMIResource; import org.eclipse.gmf.runtime.notation.Diagram; import org.eclipse.gmf.runtime.notation.Style; import org.eclipse.papyrus.infra.nattable.model.nattable.Table; -import org.eclipse.papyrus.infra.viewpoints.style.PapyrusViewStyle; /** * The utils methods corresponding to the qualified name calculation for the @@ -51,9 +50,9 @@ public class QualifiedNameUtils { // Loop until no more parent to calculate qualified name while (null != parent && !hasNotFoundName) { - if (parent.eResource().getURI().equals(eObject.eResource().getURI())){ + if (parent.eResource().getURI().equals(eObject.eResource().getURI())) { hasNotFoundName = true; - + // Get the name feature if existing final EStructuralFeature feature = parent.eClass().getEStructuralFeature("name"); //$NON-NLS-1$ if (null != feature) { @@ -79,7 +78,7 @@ public class QualifiedNameUtils { return result.toString(); } - + /** * Get the diagram owner. * @@ -88,30 +87,61 @@ public class QualifiedNameUtils { * @return The diagram owner */ public static EObject getOwner(final Diagram diagram) { - final PapyrusViewStyle pvs = getPapyrusViewStyle(diagram); + final Style pvs = getPapyrusViewStyle(diagram); if (null != pvs) { - final EObject value = pvs.getOwner(); - if (null != value) { - return value; + EStructuralFeature ownerFeature = getOwnerFeature(pvs); + if (null != ownerFeature) { + final Object value = pvs.eGet(ownerFeature); + if (null != value && value instanceof EObject) { + return (EObject) value; + } } } return diagram.getElement(); } - + /** - * Returns the PapyrusViewStyle owned by this diagram (if any) - * + * Get the owner feature of style by reflexive if exists. + * + * @param style + * The current style to check. + * @return The structural feature or <code>null</code> if doesn't exist + */ + private static EStructuralFeature getOwnerFeature(final Style style) { + EStructuralFeature feature = null; + + Iterator<EStructuralFeature> existingFeatures = style.eClass().getEAllStructuralFeatures().iterator(); + while (existingFeatures.hasNext() && null == feature) { + EStructuralFeature currentFeature = existingFeatures.next(); + if (currentFeature.getName().equals("owner")) { //$NON-NLS-1$ + feature = currentFeature; + } + } + + return feature; + } + + /** + * Get the papyrus view style of diagram by reflexive if exists. + * * @param diagram - * @return + * The diagram. + * @return The papyrus view style or <code>null</code> if doesn't exist. */ - @SuppressWarnings("unchecked") - public static final PapyrusViewStyle getPapyrusViewStyle(final Diagram diagram) { - for (final Style ownedStyle : (List<Style>) diagram.getStyles()) { // Access all styles directly to avoid CSS computation, and use instanceof (Rather than reflexive EMF) - if (ownedStyle instanceof PapyrusViewStyle) { - return (PapyrusViewStyle) ownedStyle; + private static final Style getPapyrusViewStyle(final Diagram diagram) { + Style papyrusViewStyle = null; + + final Iterator<?> ownedStyles = diagram.getStyles().iterator(); + while (ownedStyles.hasNext() && null == papyrusViewStyle) { + final Object ownedStyle = ownedStyles.next(); + if (ownedStyle instanceof Style) { + if (((Style) ownedStyle).eClass().getName().equals("PapyrusViewStyle")) { //$NON-NLS-1$ + papyrusViewStyle = (Style) ownedStyle; + } } } - return null; + + return papyrusViewStyle; } /** diff --git a/plugins/uml/modelexplorer/org.eclipse.papyrus.uml.modelexplorer/src/org/eclipse/papyrus/uml/modelexplorer/directeditor/NamedElementDirectEditorConfiguration.java b/plugins/uml/modelexplorer/org.eclipse.papyrus.uml.modelexplorer/src/org/eclipse/papyrus/uml/modelexplorer/directeditor/NamedElementDirectEditorConfiguration.java index e04ae4829f8..1c6db7e0ed6 100644 --- a/plugins/uml/modelexplorer/org.eclipse.papyrus.uml.modelexplorer/src/org/eclipse/papyrus/uml/modelexplorer/directeditor/NamedElementDirectEditorConfiguration.java +++ b/plugins/uml/modelexplorer/org.eclipse.papyrus.uml.modelexplorer/src/org/eclipse/papyrus/uml/modelexplorer/directeditor/NamedElementDirectEditorConfiguration.java @@ -31,7 +31,7 @@ public class NamedElementDirectEditorConfiguration extends AbstractBasicDirectEd public String getTextToEdit(final Object objectToEdit) { String result = null; if (objectToEdit instanceof NamedElement) { - final String namedElementLabel = UMLLabelInternationalization.getInstance().getLabel((NamedElement) objectToEdit); + final String namedElementLabel = UMLLabelInternationalization.getInstance().getLabelWithoutUML((NamedElement) objectToEdit); if (null != namedElementLabel && LabelInternationalizationPreferencesUtils.getInternationalizationPreference(((NamedElement) objectToEdit))) { result = namedElementLabel; } else { @@ -52,7 +52,7 @@ public class NamedElementDirectEditorConfiguration extends AbstractBasicDirectEd public boolean isLabelSet(final Object objectToEdit) { boolean result = false; if (objectToEdit instanceof NamedElement) { - final String namedElementLabel = UMLLabelInternationalization.getInstance().getLabel((NamedElement) objectToEdit); + final String namedElementLabel = UMLLabelInternationalization.getInstance().getLabelWithoutUML((NamedElement) objectToEdit); result = null != namedElementLabel && LabelInternationalizationPreferencesUtils.getInternationalizationPreference(((NamedElement) objectToEdit)); } return result; |