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/editor
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/editor')
-rw-r--r--plugins/editor/org.eclipse.papyrus.editor/META-INF/MANIFEST.MF3
-rw-r--r--plugins/editor/org.eclipse.papyrus.editor/src/org/eclipse/papyrus/editor/commands/RenameNestedEditorCommand.java268
2 files changed, 146 insertions, 125 deletions
diff --git a/plugins/editor/org.eclipse.papyrus.editor/META-INF/MANIFEST.MF b/plugins/editor/org.eclipse.papyrus.editor/META-INF/MANIFEST.MF
index 72779849904..74335c6544c 100644
--- a/plugins/editor/org.eclipse.papyrus.editor/META-INF/MANIFEST.MF
+++ b/plugins/editor/org.eclipse.papyrus.editor/META-INF/MANIFEST.MF
@@ -2,7 +2,8 @@ Manifest-Version: 1.0
Export-Package: org.eclipse.papyrus.editor
Require-Bundle: org.eclipse.gmf.runtime.diagram.ui;bundle-version="[1.8.0,2.0.0)",
org.eclipse.papyrus.infra.ui;bundle-version="[2.0.0,3.0.0)";visibility:=reexport,
- 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.internationalization.utils;bundle-version="[1.0.0,2.0.0)"
Bundle-Vendor: %providerName
Bundle-ActivationPolicy: lazy
Bundle-Version: 2.0.0.qualifier
diff --git a/plugins/editor/org.eclipse.papyrus.editor/src/org/eclipse/papyrus/editor/commands/RenameNestedEditorCommand.java b/plugins/editor/org.eclipse.papyrus.editor/src/org/eclipse/papyrus/editor/commands/RenameNestedEditorCommand.java
index 2f963b10320..ed198c75175 100644
--- a/plugins/editor/org.eclipse.papyrus.editor/src/org/eclipse/papyrus/editor/commands/RenameNestedEditorCommand.java
+++ b/plugins/editor/org.eclipse.papyrus.editor/src/org/eclipse/papyrus/editor/commands/RenameNestedEditorCommand.java
@@ -1,124 +1,144 @@
-/**
- *
- */
-package org.eclipse.papyrus.editor.commands;
-
-import org.eclipse.core.commands.AbstractHandler;
-import org.eclipse.core.commands.ExecutionEvent;
-import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.core.runtime.IAdaptable;
-import org.eclipse.emf.common.command.Command;
-import org.eclipse.emf.transaction.RecordingCommand;
-import org.eclipse.emf.transaction.TransactionalEditingDomain;
-import org.eclipse.gmf.runtime.notation.Diagram;
-import org.eclipse.jface.dialogs.InputDialog;
-import org.eclipse.jface.window.Window;
-import org.eclipse.papyrus.editor.Activator;
-import org.eclipse.papyrus.infra.core.sasheditor.internal.SashWindowsContainer;
-import org.eclipse.papyrus.infra.core.services.ServiceException;
-import org.eclipse.papyrus.infra.core.services.ServicesRegistry;
-import org.eclipse.papyrus.infra.core.utils.ServiceUtils;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.ui.IEditorPart;
-
-/**
- * A command to be used with the Eclipse Commands Framework.
- * This command is to be used with {@link SashWindowsContainer} implemented with the Di model.
- * This command allows to rename a nested editor.
- *
- * This command use a Transaction.
- * TODO Move to gmf adapter.
- *
- * @author cedric dumoulin
- *
- */
-public class RenameNestedEditorCommand extends AbstractHandler {
-
- /**
- * Check if the Command is enabled.
- */
- @Override
- public void setEnabled(Object evaluationContext) {
- // System.out.println("call to CloseDiagramCommand.setEnable(" + evaluationContext + ")");
- }
-
- /**
- * Execute the command. This method is called when the action is triggered.
- *
- */
- @Override
- public Object execute(ExecutionEvent event) throws ExecutionException {
-
- // try {
- // IEditorPart part = HandlerUtil.getActiveEditor(event);
- // IPageMngr pageMngr = (IPageMngr)part.getAdapter(IPageMngr.class);
- // ISashWindowsContainer container = (ISashWindowsContainer)part.getAdapter(ISashWindowsContainer.class);
- // IPage sashPage = container.getActiveSashWindowsPage();
- //
- // if(sashPage instanceof IEditorPage )
- // {
- // IEditorPage editorPage = (IEditorPage)sashPage;
- // execute(editorPage.getRawModel(), editorPage.getIEditorPart());
- // }
- // // Bug from sash Di to be corrected
- // if(pageIdentifier instanceof PageRef)
- // {
- // pageIdentifier = ((PageRef)pageIdentifier).getPageIdentifier();
- // }
- // execute(sashPage.getRawModel(), sashPage.);
- //
- // } catch (NullPointerException e) {
- // // PageMngr can't be found
- // return null;
- // }
-
-
-
- return null;
- }
-
- /**
- * Close selected page.
- *
- * @param pageMngr
- */
- public void execute(final Diagram diagram, final IEditorPart editorPart) {
- TransactionalEditingDomain editingDomain = null;
-
- if (editorPart instanceof IAdaptable) {
- ServicesRegistry registry = (ServicesRegistry) ((IAdaptable) editorPart).getAdapter(ServicesRegistry.class);
-
- if (registry == null) {
- editingDomain = (TransactionalEditingDomain) ((IAdaptable) editorPart).getAdapter(TransactionalEditingDomain.class);
- } else {
- try {
- editingDomain = ServiceUtils.getInstance().getTransactionalEditingDomain(registry);
- } catch (ServiceException ex) {
- Activator.log.error(ex);
- }
- }
- }
-
-
- if (editingDomain != null) {
- InputDialog dialog = new InputDialog(Display.getCurrent().getActiveShell(), "Rename an existing diagram", "New name:", diagram.getName(), null);
- if (dialog.open() == Window.OK) {
- final String name = dialog.getValue();
- if (name != null && name.length() > 0) {
-
- Command command = new RecordingCommand(editingDomain) {
-
-
- @Override
- protected void doExecute() {
- diagram.setName(name);
- }
- };
-
- editingDomain.getCommandStack().execute(command);
- }
- }
- }
- }
-
-}
+/*****************************************************************************
+ * Copyright (c) 2016 CEA LIST, 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:
+ * Nicolas FAUVERGUE (ALL4TEC) nicolas.fauvergue@all4tec.net - Bug 496905
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.editor.commands;
+
+import org.eclipse.core.commands.AbstractHandler;
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.emf.common.command.Command;
+import org.eclipse.emf.transaction.RecordingCommand;
+import org.eclipse.emf.transaction.TransactionalEditingDomain;
+import org.eclipse.gmf.runtime.notation.Diagram;
+import org.eclipse.jface.dialogs.InputDialog;
+import org.eclipse.jface.window.Window;
+import org.eclipse.papyrus.editor.Activator;
+import org.eclipse.papyrus.infra.core.sasheditor.internal.SashWindowsContainer;
+import org.eclipse.papyrus.infra.core.services.ServiceException;
+import org.eclipse.papyrus.infra.core.services.ServicesRegistry;
+import org.eclipse.papyrus.infra.core.utils.ServiceUtils;
+import org.eclipse.papyrus.infra.internationalization.utils.utils.LabelInternationalization;
+import org.eclipse.papyrus.infra.internationalization.utils.utils.LabelInternationalizationUtils;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.ui.IEditorPart;
+
+/**
+ * A command to be used with the Eclipse Commands Framework.
+ * This command is to be used with {@link SashWindowsContainer} implemented with the Di model.
+ * This command allows to rename a nested editor.
+ *
+ * This command use a Transaction.
+ * TODO Move to gmf adapter.
+ *
+ * @author cedric dumoulin
+ *
+ */
+public class RenameNestedEditorCommand extends AbstractHandler {
+
+ /**
+ * Check if the Command is enabled.
+ */
+ @Override
+ public void setEnabled(Object evaluationContext) {
+ // System.out.println("call to CloseDiagramCommand.setEnable(" + evaluationContext + ")");
+ }
+
+ /**
+ * Execute the command. This method is called when the action is triggered.
+ *
+ */
+ @Override
+ public Object execute(ExecutionEvent event) throws ExecutionException {
+
+ // try {
+ // IEditorPart part = HandlerUtil.getActiveEditor(event);
+ // IPageMngr pageMngr = (IPageMngr)part.getAdapter(IPageMngr.class);
+ // ISashWindowsContainer container = (ISashWindowsContainer)part.getAdapter(ISashWindowsContainer.class);
+ // IPage sashPage = container.getActiveSashWindowsPage();
+ //
+ // if(sashPage instanceof IEditorPage )
+ // {
+ // IEditorPage editorPage = (IEditorPage)sashPage;
+ // execute(editorPage.getRawModel(), editorPage.getIEditorPart());
+ // }
+ // // Bug from sash Di to be corrected
+ // if(pageIdentifier instanceof PageRef)
+ // {
+ // pageIdentifier = ((PageRef)pageIdentifier).getPageIdentifier();
+ // }
+ // execute(sashPage.getRawModel(), sashPage.);
+ //
+ // } catch (NullPointerException e) {
+ // // PageMngr can't be found
+ // return null;
+ // }
+
+
+
+ return null;
+ }
+
+ /**
+ * Close selected page.
+ *
+ * @param pageMngr
+ */
+ public void execute(final Diagram diagram, final IEditorPart editorPart) {
+ TransactionalEditingDomain editingDomain = null;
+
+ if (editorPart instanceof IAdaptable) {
+ ServicesRegistry registry = (ServicesRegistry) ((IAdaptable) editorPart).getAdapter(ServicesRegistry.class);
+
+ if (registry == null) {
+ editingDomain = (TransactionalEditingDomain) ((IAdaptable) editorPart).getAdapter(TransactionalEditingDomain.class);
+ } else {
+ try {
+ editingDomain = ServiceUtils.getInstance().getTransactionalEditingDomain(registry);
+ } catch (ServiceException ex) {
+ Activator.log.error(ex);
+ }
+ }
+ }
+
+ if (editingDomain != null) {
+ // If the diagram label is available, modify this one.
+ final String diagramLabel = LabelInternationalization.getInstance().getDiagramLabelWithoutName(diagram);
+ if(null != diagramLabel){
+ 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();
+ editingDomain.getCommandStack().execute(LabelInternationalization.getInstance().getSetDiagramLabelCommand(editingDomain, diagram, label, null));
+ }
+ }else{
+ InputDialog dialog = new InputDialog(Display.getCurrent().getActiveShell(), "Rename an existing diagram", "New name:", diagram.getName(), null); //$NON-NLS-1$ //$NON-NLS-2$
+ if (dialog.open() == Window.OK) {
+ final String name = dialog.getValue();
+ if (name != null && name.length() > 0) {
+
+ Command command = new RecordingCommand(editingDomain) {
+
+
+ @Override
+ protected void doExecute() {
+ diagram.setName(name);
+ }
+ };
+
+ editingDomain.getCommandStack().execute(command);
+ }
+ }
+ }
+ }
+ }
+
+}

Back to the top