Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorcletavernie2012-11-23 10:52:23 +0000
committercletavernie2012-11-23 10:52:23 +0000
commit6424abf6e7e922c90a56eec84fd3f9b2de9dfae5 (patch)
tree8d3239a03710422cba8493b4dbe9ee2bb9aeda71 /plugins/editor
parentc7ed19562dfcf443385c0213765c98ffc841409f (diff)
downloadorg.eclipse.papyrus-6424abf6e7e922c90a56eec84fd3f9b2de9dfae5.tar.gz
org.eclipse.papyrus-6424abf6e7e922c90a56eec84fd3f9b2de9dfae5.tar.xz
org.eclipse.papyrus-6424abf6e7e922c90a56eec84fd3f9b2de9dfae5.zip
391945: [Refactoring] Part 2: Refactoring on Kepler (0.10)
https://bugs.eclipse.org/bugs/show_bug.cgi?id=391945
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/Activator.java6
-rw-r--r--plugins/editor/org.eclipse.papyrus.editor/src/org/eclipse/papyrus/editor/commands/RenameNestedEditorCommand.java74
3 files changed, 53 insertions, 30 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 face8883771..5a723911692 100644
--- a/plugins/editor/org.eclipse.papyrus.editor/META-INF/MANIFEST.MF
+++ b/plugins/editor/org.eclipse.papyrus.editor/META-INF/MANIFEST.MF
@@ -4,7 +4,8 @@ Require-Bundle: org.eclipse.papyrus.infra.core;bundle-version="0.10.0",
org.eclipse.gmf.runtime.notation;bundle-version="1.5.0",
org.eclipse.gmf.runtime.diagram.ui;bundle-version="1.5.0",
org.eclipse.papyrus.infra.core.sasheditor;bundle-version="0.10.0",
- org.eclipse.ui.ide;bundle-version="3.8.0"
+ org.eclipse.ui.ide;bundle-version="3.8.0",
+ org.eclipse.papyrus.infra.core.log;bundle-version="0.10.0"
Export-Package: org.eclipse.papyrus.editor
Bundle-Vendor: %providerName
Bundle-ActivationPolicy: lazy
diff --git a/plugins/editor/org.eclipse.papyrus.editor/src/org/eclipse/papyrus/editor/Activator.java b/plugins/editor/org.eclipse.papyrus.editor/src/org/eclipse/papyrus/editor/Activator.java
index 5e2d2ec474e..8aae9b1f975 100644
--- a/plugins/editor/org.eclipse.papyrus.editor/src/org/eclipse/papyrus/editor/Activator.java
+++ b/plugins/editor/org.eclipse.papyrus.editor/src/org/eclipse/papyrus/editor/Activator.java
@@ -1,5 +1,6 @@
package org.eclipse.papyrus.editor;
+import org.eclipse.papyrus.infra.core.log.LogHelper;
import org.eclipse.ui.plugin.AbstractUIPlugin;
import org.osgi.framework.BundleContext;
@@ -14,6 +15,8 @@ public class Activator extends AbstractUIPlugin {
// The shared instance
private static Activator plugin;
+ public static LogHelper log;
+
/**
* The constructor
*/
@@ -25,9 +28,11 @@ public class Activator extends AbstractUIPlugin {
*
* @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)
*/
+ @Override
public void start(BundleContext context) throws Exception {
super.start(context);
plugin = this;
+ log = new LogHelper(this);
}
/*
@@ -35,6 +40,7 @@ public class Activator extends AbstractUIPlugin {
*
* @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)
*/
+ @Override
public void stop(BundleContext context) throws Exception {
plugin = null;
super.stop(context);
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 5061c4fb806..455a7d7ef04 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
@@ -6,13 +6,17 @@ 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.infra.core.utils.EditorUtils;
+import org.eclipse.papyrus.editor.Activator;
+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;
@@ -43,28 +47,28 @@ public class RenameNestedEditorCommand extends AbstractHandler {
*/
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;
-// }
+ // 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;
+ // }
@@ -77,10 +81,23 @@ public class RenameNestedEditorCommand extends AbstractHandler {
* @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);
+ }
+ }
+ }
+
-
-
- TransactionalEditingDomain editingDomain = EditorUtils.getTransactionalEditingDomain();
if(editingDomain != null) {
InputDialog dialog = new InputDialog(Display.getCurrent().getActiveShell(), "Rename an existing diagram", "New name:", diagram.getName(), null);
if(dialog.open() == Window.OK) {
@@ -89,7 +106,7 @@ public class RenameNestedEditorCommand extends AbstractHandler {
Command command = new RecordingCommand(editingDomain) {
-
+
@Override
protected void doExecute() {
diagram.setName(name);
@@ -102,5 +119,4 @@ public class RenameNestedEditorCommand extends AbstractHandler {
}
}
- }
-
+}

Back to the top