Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNicolas FAUVERGUE2016-11-24 11:20:54 +0000
committerGerrit Code Review @ Eclipse.org2016-11-29 10:57:50 +0000
commitb3141df23ca644573f8b2813ad8859722d418bd9 (patch)
tree6db261c6f918988a7117bfe93731af4ca17f0723 /plugins/infra/gmfdiag
parent6d4f41d7e479bfa607ffde18b16fe8ebdae561c2 (diff)
downloadorg.eclipse.papyrus-b3141df23ca644573f8b2813ad8859722d418bd9.tar.gz
org.eclipse.papyrus-b3141df23ca644573f8b2813ad8859722d418bd9.tar.xz
org.eclipse.papyrus-b3141df23ca644573f8b2813ad8859722d418bd9.zip
Bug 496905: [Diagram][ModelExplorer][Table][Dialog] Papyrus must integrate
the internationalization feature provided by UML. https://bugs.eclipse.org/bugs/show_bug.cgi?id=496905 Commit of infra for internationalization. Change-Id: I1b1859bf111e1ef7a7522212fbe639cf2bd13890 Signed-off-by: Nicolas FAUVERGUE <nicolas.fauvergue@all4tec.net>
Diffstat (limited to 'plugins/infra/gmfdiag')
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.commands/META-INF/MANIFEST.MF3
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.commands/src/org/eclipse/papyrus/commands/RenameDiagramHandler.java450
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/META-INF/MANIFEST.MF3
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.hyperlink/META-INF/MANIFEST.MF3
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.hyperlink/src/org/eclipse/papyrus/infra/gmfdiag/hyperlink/ui/AdvancedHLManager.java5
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.modelexplorer/META-INF/MANIFEST.MF3
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.modelexplorer/src/org/eclipse/papyrus/infra/gmfdiag/modelexplorer/handlers/RenameDiagramHandler.java56
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.properties/META-INF/MANIFEST.MF4
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.properties/model/notation/ui/SingleDiagram.xwt1
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.properties/src/org/eclipse/papyrus/infra/gmfdiag/properties/databinding/DiagramLabelObservableValue.java219
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.properties/src/org/eclipse/papyrus/infra/gmfdiag/properties/modelelement/GMFModelElement.java21
11 files changed, 528 insertions, 240 deletions
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.commands/META-INF/MANIFEST.MF b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.commands/META-INF/MANIFEST.MF
index a3d544e8994..247d2fbd75d 100644
--- a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.commands/META-INF/MANIFEST.MF
+++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.commands/META-INF/MANIFEST.MF
@@ -5,7 +5,8 @@ Require-Bundle: org.eclipse.emf.transaction.ui;bundle-version="[1.4.0,2.0.0)",
org.eclipse.papyrus.infra.viewpoints.policy;bundle-version="[1.2.0,2.0.0)";visibility:=reexport,
org.eclipse.gmf.runtime.diagram.ui.resources.editor;bundle-version="[1.7.0,2.0.0)",
org.eclipse.papyrus.infra.ui;bundle-version="[2.0.0,3.0.0)";visibility:=reexport,
- org.eclipse.papyrus.infra.emf.gmf;bundle-version="[1.2.0,2.0.0)";visibility:=reexport
+ org.eclipse.papyrus.infra.emf.gmf;bundle-version="[1.2.0,2.0.0)";visibility:=reexport,
+ org.eclipse.papyrus.infra.internationalization.utils;bundle-version="[1.0.0,2.0.0)"
Export-Package: org.eclipse.papyrus.commands,
org.eclipse.papyrus.commands.util,
org.eclipse.papyrus.commands.wrappers
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.commands/src/org/eclipse/papyrus/commands/RenameDiagramHandler.java b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.commands/src/org/eclipse/papyrus/commands/RenameDiagramHandler.java
index 2ed0050da80..775298271b8 100644
--- a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.commands/src/org/eclipse/papyrus/commands/RenameDiagramHandler.java
+++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.commands/src/org/eclipse/papyrus/commands/RenameDiagramHandler.java
@@ -1,218 +1,232 @@
-/*****************************************************************************
- * Copyright (c) 2013, 2016 Cedric Dumoulin, Christian W. Damus, 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:
- * Cedric Dumoulin Cedric.dumoulin@lifl.fr - Initial API and implementation
- * Christian W. Damus - bug 485220
- *
- *****************************************************************************/
-package org.eclipse.papyrus.commands;
-
-import org.eclipse.core.commands.AbstractHandler;
-import org.eclipse.core.commands.ExecutionEvent;
-import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.core.expressions.IEvaluationContext;
-import org.eclipse.emf.common.command.Command;
-import org.eclipse.emf.transaction.RecordingCommand;
-import org.eclipse.emf.transaction.TransactionalEditingDomain;
-import org.eclipse.gmf.runtime.diagram.ui.resources.editor.parts.DiagramDocumentEditor;
-import org.eclipse.gmf.runtime.notation.Diagram;
-import org.eclipse.jface.dialogs.InputDialog;
-import org.eclipse.jface.window.Window;
-import org.eclipse.papyrus.commands.messages.Messages;
-import org.eclipse.papyrus.infra.core.sasheditor.editor.ISashWindowsContainer;
-import org.eclipse.papyrus.infra.core.services.ServiceException;
-import org.eclipse.papyrus.infra.ui.util.ServiceUtilsForIEvaluationContext;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.ui.IEditorPart;
-
-/**
- * This handler allows to rename a gmf diagram.
- * The handler is activated when the current selection denote a gmf diagram.
- *
- * <br>
- * There is another RenameHandler in Papyrus (for modelexplorer):
- * /org.eclipse.papyrus.infra.gmfdiag.modelexplorer/src/org/eclipse/papyrus/infra/gmfdiag/modelexplorer/handlers/RenameDiagramHandler.java
- *
- * @author cedric dumoulin
- *
- */
-public class RenameDiagramHandler extends AbstractHandler {
-
- /**
- * @see org.eclipse.core.commands.IHandler#execute(org.eclipse.core.commands.ExecutionEvent)
- * @param event
- * @return
- * @throws ExecutionException
- *
- */
- public Object execute(ExecutionEvent event) throws ExecutionException {
- executeTransaction(event);
-
- return null;
- }
-
- /**
- * Execute as transaction
- *
- * @param event
- */
- private void executeTransaction(ExecutionEvent event) {
-
- // Get requested objects
- final Diagram notationDiagramHelper;
- TransactionalEditingDomain editingDomain;
- try {
- IEvaluationContext context = getIEvaluationContext(event);
- notationDiagramHelper = lookupNotationDiagramChecked(context);
- editingDomain = lookupTransactionalEditingDomain(context);
- } catch (NotFoundException e) {
- // silently fails
- return;
- } catch (ServiceException e) {
- // silently fails
- return;
- }
-
- // Open the dialog to ask the new name
- String currentName = notationDiagramHelper.getName();
- String newName = null;
- InputDialog dialog = new InputDialog(Display.getCurrent().getActiveShell(), Messages.RenameDiagramHandler_RenameAnExistingDiagram, Messages.RenameDiagramHandler_NewName, currentName, null);
- if (dialog.open() == Window.OK) {
- newName = dialog.getValue();
- if (newName == null || newName.length() <= 0) {
- return;
- }
- } else {
- // cancelled
- return;
- }
-
- final String name = newName;
- Command cmd = new RecordingCommand(editingDomain, getCommandName()) {
-
- @Override
- protected void doExecute() {
- // Rename the diagram !
- notationDiagramHelper.setName(name);
- }
-
-
- };
-
- editingDomain.getCommandStack().execute(cmd);
-
- }
-
- /**
- * Get the name used in the {@link RecordingCommand}. This name will be visible in
- * undo/redo.
- *
- * @return The command name to show.
- */
- public String getCommandName() {
- return Messages.RenameDiagramHandler_RenameDiagram;
- }
-
- protected IEvaluationContext getIEvaluationContext(ExecutionEvent event) throws NotFoundException {
- try {
- return (IEvaluationContext) event.getApplicationContext();
- } catch (ClassCastException e) {
- throw new NotFoundException("IEvaluationContext can't be found."); //$NON-NLS-1$
- }
-
- }
-
- // /**
- // *
- // * @return
- // * @throws NotFoundException
- // */
- // protected LayerStackMngr lookupLayerStackMngrChecked() throws NotFoundException {
- //
- // return lookupLayersViewChecked().getLayerStackMngrChecked();
- //
- // }
-
- /**
- * Get the notation diagram helper.
- * This method can be used from {@link #execute(ExecutionEvent)} or {@link #setEnabled(Object)}.
- *
- * @return The
- * @throws NotFoundException
- * @throws ServiceException
- */
- protected Diagram lookupNotationDiagramChecked(IEvaluationContext context) throws NotFoundException, ServiceException {
-
-
- // Get page from the event !
- IEditorPart editor = ServiceUtilsForIEvaluationContext.getInstance().getService(ISashWindowsContainer.class, context).getActiveEditor();
-
- if (!(editor instanceof DiagramDocumentEditor)) {
- throw new NotFoundException("Selected editor do not contains Diagram"); //$NON-NLS-1$
- }
- DiagramDocumentEditor diagramEditor = (DiagramDocumentEditor) editor;
-
- Diagram diagram = diagramEditor.getDiagram();
- if (diagram == null) {
- throw new NotFoundException("Selected editor do not contains Diagram"); //$NON-NLS-1$
- }
-
- // Return a new instance of the Helper
- return diagram;
- }
-
- /**
- * Try to lookup the TransactionalEditingDomain.
- *
- * @return
- * @throws ServiceException
- * If the Editing domain can't be found.
- */
- protected TransactionalEditingDomain lookupTransactionalEditingDomain(IEvaluationContext context) throws ServiceException {
-
- // Get page from the event !
- // IWorkbenchPage page = HandlerUtil.getActiveWorkbenchWindow(event).getActivePage();
-
- return ServiceUtilsForIEvaluationContext.getInstance().getTransactionalEditingDomain(context);
- }
-
- /**
- * Called by framework. Need to set the enabled flag.
- *
- * @see org.eclipse.core.commands.AbstractHandler#setEnabled(java.lang.Object)
- *
- * @param evaluationContext
- */
- @Override
- public void setEnabled(Object evaluationContext) {
-
- if (!(evaluationContext instanceof IEvaluationContext)) {
- setBaseEnabled(false);
- return;
- }
-
- IEvaluationContext context = (IEvaluationContext) evaluationContext;
-
- try {
- // Try to get the diagram
- lookupNotationDiagramChecked(context);
-
- // ok, we got it.
- setBaseEnabled(true);
-
- } catch (ServiceException e) {
- // Can't find ServiceRegistry: disable
- setBaseEnabled(false);
- } catch (NotFoundException e) {
- // Can't find ServiceRegistry: disable
- setBaseEnabled(false);
- }
-
- }
-}
+/*****************************************************************************
+ * Copyright (c) 2013, 2016 Cedric Dumoulin, Christian W. Damus, 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:
+ * Cedric Dumoulin Cedric.dumoulin@lifl.fr - Initial API and implementation
+ * Christian W. Damus - bug 485220
+ * Nicolas FAUVERGUE (ALL4TEC) nicolas.fauvergue@all4tec.net - Bug 496905
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.commands;
+
+import org.eclipse.core.commands.AbstractHandler;
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.core.expressions.IEvaluationContext;
+import org.eclipse.emf.common.command.Command;
+import org.eclipse.emf.transaction.RecordingCommand;
+import org.eclipse.emf.transaction.TransactionalEditingDomain;
+import org.eclipse.gmf.runtime.diagram.ui.resources.editor.parts.DiagramDocumentEditor;
+import org.eclipse.gmf.runtime.notation.Diagram;
+import org.eclipse.jface.dialogs.InputDialog;
+import org.eclipse.jface.window.Window;
+import org.eclipse.papyrus.commands.messages.Messages;
+import org.eclipse.papyrus.infra.core.sasheditor.editor.ISashWindowsContainer;
+import org.eclipse.papyrus.infra.core.services.ServiceException;
+import org.eclipse.papyrus.infra.internationalization.utils.utils.LabelInternationalization;
+import org.eclipse.papyrus.infra.internationalization.utils.utils.LabelInternationalizationPreferencesUtils;
+import org.eclipse.papyrus.infra.ui.util.ServiceUtilsForIEvaluationContext;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.ui.IEditorPart;
+
+/**
+ * This handler allows to rename a gmf diagram.
+ * The handler is activated when the current selection denote a gmf diagram.
+ *
+ * <br>
+ * There is another RenameHandler in Papyrus (for modelexplorer):
+ * /org.eclipse.papyrus.infra.gmfdiag.modelexplorer/src/org/eclipse/papyrus/infra/gmfdiag/modelexplorer/handlers/RenameDiagramHandler.java
+ *
+ * @author cedric dumoulin
+ *
+ */
+public class RenameDiagramHandler extends AbstractHandler {
+
+ /**
+ * @see org.eclipse.core.commands.IHandler#execute(org.eclipse.core.commands.ExecutionEvent)
+ * @param event
+ * @return
+ * @throws ExecutionException
+ *
+ */
+ public Object execute(ExecutionEvent event) throws ExecutionException {
+ executeTransaction(event);
+
+ return null;
+ }
+
+ /**
+ * Execute as transaction
+ *
+ * @param event
+ */
+ private void executeTransaction(ExecutionEvent event) {
+
+ // Get requested objects
+ final Diagram notationDiagramHelper;
+ TransactionalEditingDomain editingDomain;
+ try {
+ IEvaluationContext context = getIEvaluationContext(event);
+ notationDiagramHelper = lookupNotationDiagramChecked(context);
+ editingDomain = lookupTransactionalEditingDomain(context);
+ } catch (NotFoundException e) {
+ // silently fails
+ return;
+ } catch (ServiceException e) {
+ // silently fails
+ return;
+ }
+
+ // If the diagram label is available, modify this one.
+ Command cmd = null;
+ final String diagramLabel = LabelInternationalization.getInstance().getDiagramLabelWithoutName(notationDiagramHelper);
+ if(null != diagramLabel && LabelInternationalizationPreferencesUtils.getInternationalizationPreference(notationDiagramHelper)){
+ InputDialog dialog = new InputDialog(Display.getCurrent().getActiveShell(), "Rename diagram label", "New label:", diagramLabel, null); //$NON-NLS-1$ //$NON-NLS-2$
+ if (Window.OK == dialog.open()) {
+ final String label = dialog.getValue();
+ cmd = LabelInternationalization.getInstance().getSetDiagramLabelCommand(editingDomain, notationDiagramHelper, label, null);
+ }
+ }else{
+ // Open the dialog to ask the new name
+ String currentName = notationDiagramHelper.getName();
+ String newName = null;
+ InputDialog dialog = new InputDialog(Display.getCurrent().getActiveShell(), Messages.RenameDiagramHandler_RenameAnExistingDiagram, Messages.RenameDiagramHandler_NewName, currentName, null);
+ if (dialog.open() == Window.OK) {
+ newName = dialog.getValue();
+ if (newName == null || newName.length() <= 0) {
+ return;
+ }
+ } else {
+ // cancelled
+ return;
+ }
+
+ final String name = newName;
+ cmd = new RecordingCommand(editingDomain, getCommandName()) {
+
+ @Override
+ protected void doExecute() {
+ // Rename the diagram !
+ notationDiagramHelper.setName(name);
+ }
+
+
+ };
+ }
+
+ editingDomain.getCommandStack().execute(cmd);
+
+ }
+
+ /**
+ * Get the name used in the {@link RecordingCommand}. This name will be visible in
+ * undo/redo.
+ *
+ * @return The command name to show.
+ */
+ public String getCommandName() {
+ return Messages.RenameDiagramHandler_RenameDiagram;
+ }
+
+ protected IEvaluationContext getIEvaluationContext(ExecutionEvent event) throws NotFoundException {
+ try {
+ return (IEvaluationContext) event.getApplicationContext();
+ } catch (ClassCastException e) {
+ throw new NotFoundException("IEvaluationContext can't be found."); //$NON-NLS-1$
+ }
+
+ }
+
+ // /**
+ // *
+ // * @return
+ // * @throws NotFoundException
+ // */
+ // protected LayerStackMngr lookupLayerStackMngrChecked() throws NotFoundException {
+ //
+ // return lookupLayersViewChecked().getLayerStackMngrChecked();
+ //
+ // }
+
+ /**
+ * Get the notation diagram helper.
+ * This method can be used from {@link #execute(ExecutionEvent)} or {@link #setEnabled(Object)}.
+ *
+ * @return The
+ * @throws NotFoundException
+ * @throws ServiceException
+ */
+ protected Diagram lookupNotationDiagramChecked(IEvaluationContext context) throws NotFoundException, ServiceException {
+
+
+ // Get page from the event !
+ IEditorPart editor = ServiceUtilsForIEvaluationContext.getInstance().getService(ISashWindowsContainer.class, context).getActiveEditor();
+
+ if (!(editor instanceof DiagramDocumentEditor)) {
+ throw new NotFoundException("Selected editor do not contains Diagram"); //$NON-NLS-1$
+ }
+ DiagramDocumentEditor diagramEditor = (DiagramDocumentEditor) editor;
+
+ Diagram diagram = diagramEditor.getDiagram();
+ if (diagram == null) {
+ throw new NotFoundException("Selected editor do not contains Diagram"); //$NON-NLS-1$
+ }
+
+ // Return a new instance of the Helper
+ return diagram;
+ }
+
+ /**
+ * Try to lookup the TransactionalEditingDomain.
+ *
+ * @return
+ * @throws ServiceException
+ * If the Editing domain can't be found.
+ */
+ protected TransactionalEditingDomain lookupTransactionalEditingDomain(IEvaluationContext context) throws ServiceException {
+
+ // Get page from the event !
+ // IWorkbenchPage page = HandlerUtil.getActiveWorkbenchWindow(event).getActivePage();
+
+ return ServiceUtilsForIEvaluationContext.getInstance().getTransactionalEditingDomain(context);
+ }
+
+ /**
+ * Called by framework. Need to set the enabled flag.
+ *
+ * @see org.eclipse.core.commands.AbstractHandler#setEnabled(java.lang.Object)
+ *
+ * @param evaluationContext
+ */
+ @Override
+ public void setEnabled(Object evaluationContext) {
+
+ if (!(evaluationContext instanceof IEvaluationContext)) {
+ setBaseEnabled(false);
+ return;
+ }
+
+ IEvaluationContext context = (IEvaluationContext) evaluationContext;
+
+ try {
+ // Try to get the diagram
+ lookupNotationDiagramChecked(context);
+
+ // ok, we got it.
+ setBaseEnabled(true);
+
+ } catch (ServiceException e) {
+ // Can't find ServiceRegistry: disable
+ setBaseEnabled(false);
+ } catch (NotFoundException e) {
+ // Can't find ServiceRegistry: disable
+ setBaseEnabled(false);
+ }
+
+ }
+}
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/META-INF/MANIFEST.MF b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/META-INF/MANIFEST.MF
index ddf6a8377e7..501ee1c8008 100644
--- a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/META-INF/MANIFEST.MF
+++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/META-INF/MANIFEST.MF
@@ -68,7 +68,8 @@ Require-Bundle: org.eclipse.emf.ecore.edit;bundle-version="[2.9.0,3.0.0)",
org.eclipse.papyrus.infra.services.edit.ui;bundle-version="[3.0.0,4.0.0)";visibility:=reexport,
org.eclipse.papyrus.infra.emf.gmf,
org.eclipse.papyrus.infra.ui;bundle-version="[2.0.0,3.0.0)",
- org.eclipse.papyrus.infra.core;bundle-version="[2.2.0,3.0.0)"
+ org.eclipse.papyrus.infra.core;bundle-version="[2.2.0,3.0.0)",
+ org.eclipse.papyrus.infra.internationalization.utils;bundle-version="[1.0.0,2.0.0)"
Bundle-Vendor: %providerName
Bundle-ActivationPolicy: lazy
Bundle-ClassPath: .
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.hyperlink/META-INF/MANIFEST.MF b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.hyperlink/META-INF/MANIFEST.MF
index 1d5325c5559..35c570d064d 100644
--- a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.hyperlink/META-INF/MANIFEST.MF
+++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.hyperlink/META-INF/MANIFEST.MF
@@ -3,7 +3,8 @@ Require-Bundle: org.eclipse.papyrus.infra.hyperlink;bundle-version="[3.0.0,4.0.0
org.eclipse.papyrus.infra.gmfdiag.common;bundle-version="[3.0.0,4.0.0)";visibility:=reexport,
org.eclipse.papyrus.infra.gmfdiag.navigation;bundle-version="[2.0.0,3.0.0)";visibility:=reexport,
org.eclipse.papyrus.infra.gmfdiag.preferences;bundle-version="[3.0.0,4.0.0)",
- org.eclipse.papyrus.infra.gmfdiag.dnd;bundle-version="[1.2.0,2.0.0)"
+ org.eclipse.papyrus.infra.gmfdiag.dnd;bundle-version="[1.2.0,2.0.0)",
+ org.eclipse.papyrus.infra.internationalization.utils;bundle-version="[1.0.0,2.0.0)"
Export-Package: org.eclipse.papyrus.infra.gmfdiag.hyperlink,
org.eclipse.papyrus.infra.gmfdiag.hyperlink.editpolicies,
org.eclipse.papyrus.infra.gmfdiag.hyperlink.helper,
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.hyperlink/src/org/eclipse/papyrus/infra/gmfdiag/hyperlink/ui/AdvancedHLManager.java b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.hyperlink/src/org/eclipse/papyrus/infra/gmfdiag/hyperlink/ui/AdvancedHLManager.java
index aa68cc88e94..c93e62acfcd 100644
--- a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.hyperlink/src/org/eclipse/papyrus/infra/gmfdiag/hyperlink/ui/AdvancedHLManager.java
+++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.hyperlink/src/org/eclipse/papyrus/infra/gmfdiag/hyperlink/ui/AdvancedHLManager.java
@@ -12,6 +12,8 @@
* Arthur Daussy (Atos) arthur.daussy@atos.net - Bug 363827 - [Improvement] Diagram creation, remember the latest tab chosen
* Vincent Lorenzo (CEA-LIST) Vincent.lorenzo@cea.fr (refactoring of the hyperlink)
* Christian W. Damus - bug 488965
+ * Nicolas FAUVERGUE (ALL4TEC) nicolas.fauvergue@all4tec.net - Bug 496905
+ *
*****************************************************************************/
package org.eclipse.papyrus.infra.gmfdiag.hyperlink.ui;
@@ -30,6 +32,7 @@ import org.eclipse.papyrus.infra.gmfdiag.hyperlink.object.HyperLinkEditor;
import org.eclipse.papyrus.infra.hyperlink.helper.HyperLinkHelperFactory;
import org.eclipse.papyrus.infra.hyperlink.ui.AbstractHyperLinkTab;
import org.eclipse.papyrus.infra.hyperlink.ui.HyperLinkManagerShell;
+import org.eclipse.papyrus.infra.internationalization.utils.utils.LabelInternationalization;
import org.eclipse.papyrus.infra.ui.editorsfactory.IPageIconsRegistry;
import org.eclipse.swt.widgets.Shell;
@@ -81,7 +84,7 @@ public class AdvancedHLManager extends HyperLinkManagerShell {
HyperLinkEditor hyperLinkEditor = new HyperLinkEditor();
hyperLinkEditor.setObject(diagrams.get(i));
hyperLinkEditor.setIsDefault(true);
- hyperLinkEditor.setTooltipText(diagrams.get(i).getName());
+ hyperLinkEditor.setTooltipText(LabelInternationalization.getInstance().getDiagramLabel(diagrams.get(i)));
hyperLinkDiagrams.add(hyperLinkEditor);
}
return hyperLinkDiagrams;
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 60578c27e04..6c76cfaf435 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
@@ -3,7 +3,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.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.views.modelexplorer;bundle-version="[3.0.0,4.0.0)",
+ org.eclipse.papyrus.infra.internationalization.utils;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/src/org/eclipse/papyrus/infra/gmfdiag/modelexplorer/handlers/RenameDiagramHandler.java b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.modelexplorer/src/org/eclipse/papyrus/infra/gmfdiag/modelexplorer/handlers/RenameDiagramHandler.java
index c8b292288bb..a318f4d1a89 100644
--- a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.modelexplorer/src/org/eclipse/papyrus/infra/gmfdiag/modelexplorer/handlers/RenameDiagramHandler.java
+++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.modelexplorer/src/org/eclipse/papyrus/infra/gmfdiag/modelexplorer/handlers/RenameDiagramHandler.java
@@ -10,6 +10,7 @@
* Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation
* Christian W. Damus - bug 485220
* Fanch BONNABESSE (ALL4TEC) fanch.bonnabesse@all4tec.net - Bug 497289
+ * Nicolas FAUVERGUE (ALL4TEC) nicolas.fauvergue@all4tec.net - Bug 496905
*
*****************************************************************************/
package org.eclipse.papyrus.infra.gmfdiag.modelexplorer.handlers;
@@ -31,6 +32,8 @@ import org.eclipse.jface.dialogs.InputDialog;
import org.eclipse.jface.window.Window;
import org.eclipse.papyrus.infra.emf.utils.EMFHelper;
import org.eclipse.papyrus.infra.gmfdiag.modelexplorer.messages.Messages;
+import org.eclipse.papyrus.infra.internationalization.utils.utils.LabelInternationalization;
+import org.eclipse.papyrus.infra.internationalization.utils.utils.LabelInternationalizationPreferencesUtils;
import org.eclipse.papyrus.views.modelexplorer.DirectEditorEditingSupport;
import org.eclipse.papyrus.infra.emf.gmf.command.GMFtoEMFCommandWrapper;
import org.eclipse.swt.widgets.Display;
@@ -51,18 +54,27 @@ public class RenameDiagramHandler extends AbstractDiagramCommandHandler {
if (editingDomain != null && diagrams.size() == 1) {
final Diagram diag = diagrams.get(0);
- final String currentName = diag.getName();
- if (currentName != null) {
-
- AbstractTransactionalCommand cmd = new AbstractTransactionalCommand(editingDomain, "RenameDiagramCommand", null) { //$NON-NLS-1$
-
+
+ final String diagramLabel = LabelInternationalization.getInstance().getDiagramLabelWithoutName(diag);
+ if(null != diagramLabel && LabelInternationalizationPreferencesUtils.getInternationalizationPreference(diag)){
+ AbstractTransactionalCommand cmd = new AbstractTransactionalCommand(editingDomain, "ChangeDiagramLabelCommand", null) { //$NON-NLS-1$
+
+ /**
+ *
+ * @see org.eclipse.gmf.runtime.emf.commands.core.command.AbstractTransactionalCommand#doExecuteWithResult(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
+ *
+ * @param monitor
+ * @param info
+ * @return
+ * @throws ExecutionException
+ */
@Override
- protected CommandResult doExecuteWithResult(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
- InputDialog dialog = new InputDialog(Display.getCurrent().getActiveShell(), Messages.RenameDiagramHandler_RenameAnExistingDiagram, Messages.RenameDiagramHandler_NewName, currentName, null);
- if (dialog.open() == Window.OK) {
- final String name = dialog.getValue();
- if (name != null && name.length() > 0) {
- diag.setName(name);
+ protected CommandResult doExecuteWithResult(final IProgressMonitor monitor, final IAdaptable info) throws ExecutionException {
+ InputDialog dialog = new InputDialog(Display.getCurrent().getActiveShell(), "Rename diagram label...", "New label:", diagramLabel, null); //$NON-NLS-1$ //$NON-NLS-2$
+ if (Window.OK == dialog.open()) {
+ final String label = dialog.getValue();
+ if (label != null && label.length() > 0) {
+ LabelInternationalization.getInstance().setDiagramLabel(diag, label, null);
}
return CommandResult.newOKCommandResult();
} else {
@@ -71,6 +83,28 @@ public class RenameDiagramHandler extends AbstractDiagramCommandHandler {
}
};
return new GMFtoEMFCommandWrapper(cmd);
+ }else{
+ final String currentName = diag.getName();
+ if (currentName != null) {
+
+ AbstractTransactionalCommand cmd = new AbstractTransactionalCommand(editingDomain, "RenameDiagramCommand", null) { //$NON-NLS-1$
+
+ @Override
+ protected CommandResult doExecuteWithResult(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
+ InputDialog dialog = new InputDialog(Display.getCurrent().getActiveShell(), Messages.RenameDiagramHandler_RenameAnExistingDiagram, Messages.RenameDiagramHandler_NewName, currentName, null);
+ if (dialog.open() == Window.OK) {
+ final String name = dialog.getValue();
+ if (name != null && name.length() > 0) {
+ diag.setName(name);
+ }
+ return CommandResult.newOKCommandResult();
+ } else {
+ return CommandResult.newCancelledCommandResult();
+ }
+ }
+ };
+ return new GMFtoEMFCommandWrapper(cmd);
+ }
}
}
return UnexecutableCommand.INSTANCE;
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.properties/META-INF/MANIFEST.MF b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.properties/META-INF/MANIFEST.MF
index 219350da220..76b8f339ba2 100644
--- a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.properties/META-INF/MANIFEST.MF
+++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.properties/META-INF/MANIFEST.MF
@@ -4,7 +4,9 @@ Export-Package: org.eclipse.papyrus.infra.gmfdiag.properties.extension,
Require-Bundle: org.eclipse.papyrus.infra.properties.ui;bundle-version="[2.0.0,3.0.0)";visibility:=reexport,
org.eclipse.core.databinding.beans;bundle-version="[1.3.0,2.0.0)",
org.eclipse.papyrus.infra.gmfdiag.preferences;bundle-version="[3.0.0,4.0.0)",
- org.eclipse.papyrus.infra.gmfdiag.canonical;bundle-version="[2.0.0,3.0.0)"
+ org.eclipse.papyrus.infra.gmfdiag.canonical;bundle-version="[2.0.0,3.0.0)",
+ org.eclipse.papyrus.infra.internationalization.utils;bundle-version="[1.0.0,2.0.0)",
+ org.eclipse.papyrus.infra.internationalization;bundle-version="[1.0.0,2.0.0)"
Bundle-Vendor: %Bundle-Vendor
Bundle-ActivationPolicy: lazy;exclude:="org.eclipse.papyrus.infra.gmfdiag.properties.constraint"
Bundle-Version: 3.0.0.qualifier
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.properties/model/notation/ui/SingleDiagram.xwt b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.properties/model/notation/ui/SingleDiagram.xwt
index 840b846b6db..db294948335 100644
--- a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.properties/model/notation/ui/SingleDiagram.xwt
+++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.properties/model/notation/ui/SingleDiagram.xwt
@@ -11,6 +11,7 @@
<ppel:PropertiesLayout numColumns="1"></ppel:PropertiesLayout>
</Composite.layout>
<ppe:StringEditor input="{Binding}" property="notation:Diagram:name"></ppe:StringEditor>
+ <ppe:StringEditor input="{Binding}" property="notation:Diagram:label"></ppe:StringEditor>
<ppe:ReferenceLabel input="{Binding}" property="notation:View:prototype" readOnly="true" customLabel="View Type"></ppe:ReferenceLabel>
<ppe:ReferenceDialog input="{Binding}" property="notation:View:owner" customLabel="Owner"></ppe:ReferenceDialog>
<ppe:ReferenceDialog input="{Binding}" property="notation:View:element" customLabel="Root element"></ppe:ReferenceDialog>
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.properties/src/org/eclipse/papyrus/infra/gmfdiag/properties/databinding/DiagramLabelObservableValue.java b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.properties/src/org/eclipse/papyrus/infra/gmfdiag/properties/databinding/DiagramLabelObservableValue.java
new file mode 100644
index 00000000000..3b1ddfc7109
--- /dev/null
+++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.properties/src/org/eclipse/papyrus/infra/gmfdiag/properties/databinding/DiagramLabelObservableValue.java
@@ -0,0 +1,219 @@
+/*****************************************************************************
+ * 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 (ALL4TEC) nicolas.fauvergue@all4tec.net - Initial API and implementation
+ *
+ *****************************************************************************/
+
+package org.eclipse.papyrus.infra.gmfdiag.properties.databinding;
+
+import org.eclipse.core.databinding.observable.Diffs;
+import org.eclipse.core.databinding.observable.IObserving;
+import org.eclipse.core.databinding.observable.Realm;
+import org.eclipse.core.databinding.observable.value.AbstractObservableValue;
+import org.eclipse.core.databinding.observable.value.ValueDiff;
+import org.eclipse.emf.common.command.Command;
+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.edit.domain.EditingDomain;
+import org.eclipse.gmf.runtime.notation.Diagram;
+import org.eclipse.papyrus.infra.gmfdiag.properties.Activator;
+import org.eclipse.papyrus.infra.internationalization.InternationalizationEntry;
+import org.eclipse.papyrus.infra.internationalization.InternationalizationPackage;
+import org.eclipse.papyrus.infra.internationalization.utils.utils.LabelInternationalization;
+import org.eclipse.papyrus.infra.internationalization.utils.utils.LabelInternationalizationUtils;
+import org.eclipse.papyrus.infra.tools.databinding.ReferenceCountedObservable;
+
+/**
+ * The observable value for the label of the {@link Diagram}.
+ */
+@SuppressWarnings("rawtypes")
+public class DiagramLabelObservableValue extends AbstractObservableValue implements IObserving, ReferenceCountedObservable {
+
+ /**
+ * The support reference counting on behalf of an {@code observable}.
+ */
+ private final ReferenceCountedObservable.Support refCount = new ReferenceCountedObservable.Support(this);
+
+ /**
+ * The diagram instance.
+ */
+ protected Diagram diagram;
+
+ /**
+ * The editing domain on which the commands will be executed.
+ */
+ protected EditingDomain domain;
+
+ /**
+ * The listener for the entry modification.
+ */
+ protected Adapter listener;
+
+ /**
+ * The internationalization entry corresponding to the diagram.
+ */
+ protected InternationalizationEntry entry;
+
+ /**
+ * Constructor.
+ *
+ * @param diagram
+ * The diagram.
+ * @param domain
+ * The editing domain.
+ */
+ public DiagramLabelObservableValue(final Diagram diagram, final EditingDomain domain) {
+ this(Realm.getDefault(), diagram, domain);
+ }
+
+ /**
+ * Constructor.
+ *
+ * @param realm
+ * The current Realm.
+ * @param diagram
+ * The diagram.
+ * @param domain
+ * The editing domain.
+ */
+ public DiagramLabelObservableValue(final Realm realm, final Diagram diagram, final EditingDomain domain) {
+ super(realm);
+ this.diagram = diagram;
+ this.domain = domain;
+ this.entry = LabelInternationalizationUtils.getInternationalizationEntry(diagram, diagram);
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.core.databinding.observable.AbstractObservable#dispose()
+ */
+ @Override
+ public synchronized void dispose() {
+ if (null != listener) {
+ entry.eAdapters().remove(listener);
+ listener = null;
+ }
+
+ entry = null;
+ diagram = null;
+ super.dispose();
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.core.databinding.observable.IObserving#getObserved()
+ */
+ public Object getObserved() {
+ return diagram;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.core.databinding.observable.ChangeManager#firstListenerAdded()
+ */
+ @Override
+ protected void firstListenerAdded() {
+ if (null != entry) {
+ if (null == listener) {
+ listener = new AdapterImpl() {
+ @Override
+ public void notifyChanged(Notification notification) {
+ if (InternationalizationPackage.eINSTANCE.getInternationalizationEntry_Value() == notification.getFeature() && !notification.isTouch()) {
+ final ValueDiff diff = Diffs.createValueDiff(notification.getOldValue(), notification.getNewValue());
+ getRealm().exec(new Runnable() {
+ @SuppressWarnings("unchecked")
+ public void run() {
+ fireValueChange(diff);
+ }
+ });
+ }
+ }
+ };
+ }
+ entry.eAdapters().add(listener);
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.core.databinding.observable.value.AbstractObservableValue#doGetValue()
+ */
+ @Override
+ protected Object doGetValue() {
+ return LabelInternationalization.getInstance().getDiagramLabelWithoutName(diagram);
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.core.databinding.observable.value.AbstractObservableValue#doSetValue(java.lang.Object)
+ */
+ @Override
+ protected void doSetValue(final Object value) {
+ try {
+
+ // Remove the listener on entry
+ if (null != entry && null != listener) {
+ entry.eAdapters().remove(listener);
+ }
+
+ final Command emfCommand = LabelInternationalization.getInstance().getSetDiagramLabelCommand(domain, diagram, (String) value, null);
+ domain.getCommandStack().execute(emfCommand);
+
+ // Get the entry after the modification and try to apply listener if possible
+ this.entry = LabelInternationalizationUtils.getInternationalizationEntry(diagram, diagram);
+ firstListenerAdded();
+ } catch (Exception ex) {
+ Activator.log.error(ex);
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.core.databinding.observable.value.IObservableValue#getValueType()
+ */
+ public Object getValueType() {
+ return null;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.papyrus.infra.tools.databinding.ReferenceCountedObservable#retain()
+ */
+ public void retain() {
+ refCount.retain();
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.papyrus.infra.tools.databinding.ReferenceCountedObservable#release()
+ */
+ public void release() {
+ refCount.release();
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.papyrus.infra.tools.databinding.ReferenceCountedObservable#autorelease()
+ */
+ public void autorelease() {
+ refCount.autorelease();
+ }
+
+}
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.properties/src/org/eclipse/papyrus/infra/gmfdiag/properties/modelelement/GMFModelElement.java b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.properties/src/org/eclipse/papyrus/infra/gmfdiag/properties/modelelement/GMFModelElement.java
index 27f0fb0c118..4d4cefbddf0 100644
--- a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.properties/src/org/eclipse/papyrus/infra/gmfdiag/properties/modelelement/GMFModelElement.java
+++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.properties/src/org/eclipse/papyrus/infra/gmfdiag/properties/modelelement/GMFModelElement.java
@@ -10,6 +10,7 @@
* Camille Letavernier (CEA LIST) camille.letavernier@cea.fr - Initial API and implementation
* Gabriel Pascual (ALL4TEC) gabriel.pascual@all4tec.net - Bug 454891
* Christian W. Damus - bug 485220
+ * Nicolas FAUVERGUE (ALL4TEC) nicolas.fauvergue@all4tec.net - Bug 496905
*
*****************************************************************************/
package org.eclipse.papyrus.infra.gmfdiag.properties.modelelement;
@@ -34,9 +35,11 @@ import org.eclipse.papyrus.infra.gmfdiag.common.databinding.GMFObservableList;
import org.eclipse.papyrus.infra.gmfdiag.common.databinding.GMFObservableValue;
import org.eclipse.papyrus.infra.gmfdiag.common.utils.DiagramUtils;
import org.eclipse.papyrus.infra.gmfdiag.properties.Activator;
+import org.eclipse.papyrus.infra.gmfdiag.properties.databinding.DiagramLabelObservableValue;
import org.eclipse.papyrus.infra.gmfdiag.properties.databinding.GradientObservableValue;
import org.eclipse.papyrus.infra.gmfdiag.properties.provider.ModelContentProvider;
import org.eclipse.papyrus.infra.gmfdiag.properties.util.LegacyOwnerObservable;
+import org.eclipse.papyrus.infra.internationalization.utils.utils.InternationalizationConstants;
import org.eclipse.papyrus.infra.properties.ui.modelelement.EMFModelElement;
import org.eclipse.papyrus.infra.services.labelprovider.service.LabelProviderService;
import org.eclipse.papyrus.infra.viewpoints.policy.PolicyChecker;
@@ -81,15 +84,23 @@ public class GMFModelElement extends EMFModelElement {
@Override
protected boolean isFeatureEditable(String propertyPath) {
- if (propertyPath.endsWith("owner")) {
- return true;
+ boolean result = true;
+ if(InternationalizationConstants.LABEL_PROPERTY_PATH.equals(propertyPath)){ //$NON-NLS-1$
+ result = true;
+ }else if (propertyPath.endsWith("owner")) { //$NON-NLS-1$
+ result = true;
+ }else{
+ result = super.isFeatureEditable(propertyPath);
}
- return super.isFeatureEditable(propertyPath);
+ return result;
}
@Override
protected IObservable doGetObservable(String propertyPath) {
- if (propertyPath.endsWith("owner")) {
+ if(InternationalizationConstants.LABEL_PROPERTY_PATH.equals(propertyPath)){ //$NON-NLS-1$
+ Diagram diagram = (Diagram) source;
+ return new DiagramLabelObservableValue(diagram, getDomain());
+ }else if (propertyPath.endsWith("owner")) {
Diagram diagram = (Diagram) source;
Style style = diagram.getStyle(StylePackage.Literals.PAPYRUS_VIEW_STYLE);
if (style != null) {
@@ -198,7 +209,7 @@ public class GMFModelElement extends EMFModelElement {
}
return super.getContentProvider(propertyPath);
}
-
+
/**
* Gets the root EObject from the given one
*

Back to the top