From 169c86a4a168a14f1921d5737158c286b40adab3 Mon Sep 17 00:00:00 2001 From: Nicolas FAUVERGUE Date: Thu, 15 Dec 2016 13:36:45 +0100 Subject: Bug 509278: [Internationalization] Diagram and Table labels in Model Explorer must be managed by custom facet https://bugs.eclipse.org/bugs/show_bug.cgi?id=509278 - Manage the diagram and table labels with facet - Remove internationalization dependency from emf.facet.custom.ui Change-Id: I4df27993c0905d64ab19f630ebbc42213c58a614 Signed-off-by: Nicolas FAUVERGUE --- .../META-INF/MANIFEST.MF | 3 +- .../resources/PapyrusDiagram.custom | 19 +++++++++++ .../modelexplorer/queries/GetDiagramLabel.java | 39 ++++++++++++++++++++++ 3 files changed, 60 insertions(+), 1 deletion(-) create mode 100644 plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.modelexplorer/src/org/eclipse/papyrus/infra/gmfdiag/modelexplorer/queries/GetDiagramLabel.java (limited to 'plugins/infra/gmfdiag') diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.modelexplorer/META-INF/MANIFEST.MF b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.modelexplorer/META-INF/MANIFEST.MF index 6c76cfaf435..f1a1f366938 100644 --- a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.modelexplorer/META-INF/MANIFEST.MF +++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.modelexplorer/META-INF/MANIFEST.MF @@ -4,7 +4,8 @@ Require-Bundle: org.eclipse.papyrus.infra.gmfdiag.common;bundle-version="[3.0.0, org.eclipse.papyrus.infra.emf;bundle-version="[2.0.0,3.0.0)", org.eclipse.papyrus.infra.gmfdiag.common;bundle-version="[3.0.0,4.0.0)", org.eclipse.papyrus.views.modelexplorer;bundle-version="[3.0.0,4.0.0)", - org.eclipse.papyrus.infra.internationalization.utils;bundle-version="[1.0.0,2.0.0)" + org.eclipse.papyrus.infra.internationalization.utils;bundle-version="[1.0.0,2.0.0)", + org.eclipse.papyrus.infra.internationalization.edit;bundle-version="[1.0.0,2.0.0)" Bundle-Vendor: %providerName Bundle-ActivationPolicy: lazy Bundle-Version: 1.2.0.qualifier diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.modelexplorer/resources/PapyrusDiagram.custom b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.modelexplorer/resources/PapyrusDiagram.custom index c6446db5d4b..3926b555773 100644 --- a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.modelexplorer/resources/PapyrusDiagram.custom +++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.modelexplorer/resources/PapyrusDiagram.custom @@ -18,6 +18,25 @@ documentation="Representation of diagram in model explorer"> + + + + + + + + diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.modelexplorer/src/org/eclipse/papyrus/infra/gmfdiag/modelexplorer/queries/GetDiagramLabel.java b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.modelexplorer/src/org/eclipse/papyrus/infra/gmfdiag/modelexplorer/queries/GetDiagramLabel.java new file mode 100644 index 00000000000..79bbc1eb8b1 --- /dev/null +++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.modelexplorer/src/org/eclipse/papyrus/infra/gmfdiag/modelexplorer/queries/GetDiagramLabel.java @@ -0,0 +1,39 @@ +/** + * Copyright (c) 2016 CEA LIST, and others. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Nicolas FAUVERGUE (CEA LIST) nicolas.fauvergue@cea.fr - Initial API and implementation + * + */ +package org.eclipse.papyrus.infra.gmfdiag.modelexplorer.queries; + +import org.eclipse.gmf.runtime.notation.Diagram; +import org.eclipse.gmf.runtime.notation.NotationEditPlugin; +import org.eclipse.papyrus.emf.facet.efacet.core.IFacetManager; +import org.eclipse.papyrus.emf.facet.efacet.core.exception.DerivedTypedElementException; +import org.eclipse.papyrus.emf.facet.query.java.core.IJavaQuery2; +import org.eclipse.papyrus.emf.facet.query.java.core.IParameterValueList2; +import org.eclipse.papyrus.infra.internationalization.utils.utils.LabelInternationalization; +import org.eclipse.papyrus.infra.ui.editorsfactory.AbstractGetEditorIconQuery; + +/** + * Return the label of the corresponding diagram. + */ +public class GetDiagramLabel extends AbstractGetEditorIconQuery implements IJavaQuery2 { + + /** + * {@inheritDoc} + * + * @see org.eclipse.papyrus.emf.facet.query.java.core.IJavaQuery2#evaluate(org.eclipse.emf.ecore.EObject, org.eclipse.papyrus.emf.facet.query.java.core.IParameterValueList2, org.eclipse.papyrus.emf.facet.efacet.core.IFacetManager) + */ + public String evaluate(final Diagram source, final IParameterValueList2 parameterValues, final IFacetManager facetManager) throws DerivedTypedElementException { + final String label = LabelInternationalization.getInstance().getDiagramLabel(source); + return label == null || label.length() == 0 ? NotationEditPlugin.INSTANCE.getString("_UI_Diagram_type", true) : //$NON-NLS-1$ + NotationEditPlugin.INSTANCE.getString("_UI_Diagram_type", true) + " " + label; //$NON-NLS-1$ //$NON-NLS-2$ + } +} -- cgit v1.2.3