Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian W. Damus2016-01-17 17:27:59 +0000
committerChristian W. Damus2016-01-22 15:57:11 +0000
commitb089eab1fca586752027404cc398a173237337f8 (patch)
tree3d5f106bd6ba19ab6364284dec8cd34341cfd758 /plugins/infra/emf
parente8587f9c60ed458d6daee5128186f5b1ee54ac00 (diff)
downloadorg.eclipse.papyrus-b089eab1fca586752027404cc398a173237337f8.tar.gz
org.eclipse.papyrus-b089eab1fca586752027404cc398a173237337f8.tar.xz
org.eclipse.papyrus-b089eab1fca586752027404cc398a173237337f8.zip
Bug 485220: [Architecture] Provide a more modular architecture
https://bugs.eclipse.org/bugs/show_bug.cgi?id=485220 Move UI-dependent APIs from the org.eclipse.papyrus.infra.tools bundle to org.eclipse.papyrus.infra.ui. Accordingly move tests into a new org.eclipse.papyrus.infra.ui.tests bundle. Two crucial UI dependencies are inverted by introduction of new OSGi services with core interfaces specified in the non-UI layer: * IExecutorService extends Java Platform's ExecutorService with APIs for synchronous execution (a la Display.syncExec). A new CoreExecutors class in the infra.tools bundle supplies the instance provided by the OSGi service implementation in the infra.ui bundle. This provides compatibility for clients of various UIUtil APIs that they can no longer access * IContextualServiceRegistryTracker abstracts the concept of the default ServicesRegistry found in the currently active editor, which the ServiceUtilsForHandlers class (and hence all of its clients) relies on. Again an OSGi service implementation in the infra.ui bundle supplies the implementation of this tracker, which is exposed in infra.core through the service-utils API Also move UI-dependent APIs from the org.eclipse.papyrus.infra.core bundle into org.eclipse.papyrus.infra.ui. This includes * moving the 'papyrusDiagram' and 'papyrusContentOutline' extension points into the org.eclipse.papyrus.infra.ui namespace * moving various UI-related services such as EditorLifeycleManager, SaveLayoutBeforeClose, and the IMultiDiagramEditor, itself, into the org.eclipse.papyrus.infra.ui bundle This necessitates not only widespread refactorings on the moved APIs, but also concomitant move of other APIs in other bundles because they cannot plausibly use these moved APIs from their new home in org.eclipse.papyrus.infra.ui and/or they cannot reasonably also be moved to the UI bundle and/or they must be used by bundles that now have no UI dependency: * the DI/sash-windows EMF model is moved out of infra.core.sasheditor.di bundle into a new model-only org.eclipse.papyrus.infra.sashwindows.di bundle (which symbolic name incidentally now better reflects the contained Java package names) * the IPageManager and ILocalPageService interfaces are moved out of infra.core.sasheditor.di bundle because they need to remain accessible by headless code such as the edit advices that ensure deletion of sash-model pages for notations that are deleted. These are now in a package named org.eclipse.papyrus.infra.code.sashwindows.di.service. Accordingly the class hierarchy implementing the IPageManager interface is changed: the obsolete PageMngrImpl is deleted, replaced by a BasicPageManagerImpl which now the PageManagerImpl extends. A service factory creates the basic page manager in a headless context, but is overridden by the UI-aware implementation when the UI bundles are installed * the MultiDiagramEditorGefDelegate (which has a GEF 3 dependency) is moved from the org.eclipse.papyrus.infra.core.sasheditor bundle to a new org.eclipse.papyrus.infra.gmfdiag.gef bundle. Its usage for an adapter of ActionRegistry type is extracted out of the CoreMultiDiagramEditor class into a new external adapter-factory in the infra.gmfdiag.gef bundle Tests all still pass (inasmuch as they do in the nightly master builds). Change-Id: I573dee5d9312d6e5746d74575350d0152b591ab3
Diffstat (limited to 'plugins/infra/emf')
-rw-r--r--plugins/infra/emf/org.eclipse.papyrus.infra.emf.diagram.common/META-INF/MANIFEST.MF4
-rw-r--r--plugins/infra/emf/org.eclipse.papyrus.infra.emf.diagram.common/src/org/eclipse/papyrus/infra/emf/diagram/common/handler/CreateDiagramHandler.java4
-rw-r--r--plugins/infra/emf/org.eclipse.papyrus.infra.emf.readonly/META-INF/MANIFEST.MF3
-rw-r--r--plugins/infra/emf/org.eclipse.papyrus.infra.emf.readonly/src/org/eclipse/papyrus/infra/emf/readonly/Activator.java19
-rw-r--r--plugins/infra/emf/org.eclipse.papyrus.infra.emf.readonly/src/org/eclipse/papyrus/infra/emf/readonly/ReadOnlyManager.java10
-rw-r--r--plugins/infra/emf/org.eclipse.papyrus.infra.emf.readonly/src/org/eclipse/papyrus/infra/emf/readonly/ReferencedModelReadOnlyHandler.java2
-rw-r--r--plugins/infra/emf/org.eclipse.papyrus.infra.emf/META-INF/MANIFEST.MF4
-rw-r--r--plugins/infra/emf/org.eclipse.papyrus.infra.emf/plugin.xml7
-rw-r--r--plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/advice/RemovePageHelper.java11
-rw-r--r--plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/providers/MoDiscoContentProvider.java2
-rw-r--r--plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/utils/EMFHelper.java14
-rw-r--r--plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/utils/EMFStringValueConverter.java375
-rw-r--r--plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/utils/ServiceUtilsForHandlers.java22
13 files changed, 56 insertions, 421 deletions
diff --git a/plugins/infra/emf/org.eclipse.papyrus.infra.emf.diagram.common/META-INF/MANIFEST.MF b/plugins/infra/emf/org.eclipse.papyrus.infra.emf.diagram.common/META-INF/MANIFEST.MF
index 1df66b9ee5a..e4acf402212 100644
--- a/plugins/infra/emf/org.eclipse.papyrus.infra.emf.diagram.common/META-INF/MANIFEST.MF
+++ b/plugins/infra/emf/org.eclipse.papyrus.infra.emf.diagram.common/META-INF/MANIFEST.MF
@@ -5,11 +5,13 @@ Require-Bundle: org.eclipse.papyrus.infra.core;bundle-version="1.2.0",
org.eclipse.gmf.runtime.notation;bundle-version="1.5.0",
org.eclipse.emf.transaction;bundle-version="1.4.0",
org.eclipse.papyrus.infra.core.sasheditor;bundle-version="1.2.0",
+ org.eclipse.papyrus.infra.core.sashwindows.di;bundle-version="1.2.0",
org.eclipse.core.commands;bundle-version="3.6.1",
org.eclipse.ui,
org.eclipse.papyrus.infra.gmfdiag.common;bundle-version="1.2.0",
org.eclipse.papyrus.infra.emf;bundle-version="1.2.0",
- org.eclipse.papyrus.infra.core.log;bundle-version="1.2.0"
+ org.eclipse.papyrus.infra.core.log;bundle-version="1.2.0",
+ org.eclipse.papyrus.infra.ui;bundle-version="1.2.0"
Bundle-Vendor: %providerName
Bundle-ActivationPolicy: lazy
Bundle-Version: 1.2.0.qualifier
diff --git a/plugins/infra/emf/org.eclipse.papyrus.infra.emf.diagram.common/src/org/eclipse/papyrus/infra/emf/diagram/common/handler/CreateDiagramHandler.java b/plugins/infra/emf/org.eclipse.papyrus.infra.emf.diagram.common/src/org/eclipse/papyrus/infra/emf/diagram/common/handler/CreateDiagramHandler.java
index 95553fb86f0..65cc2685b15 100644
--- a/plugins/infra/emf/org.eclipse.papyrus.infra.emf.diagram.common/src/org/eclipse/papyrus/infra/emf/diagram/common/handler/CreateDiagramHandler.java
+++ b/plugins/infra/emf/org.eclipse.papyrus.infra.emf.diagram.common/src/org/eclipse/papyrus/infra/emf/diagram/common/handler/CreateDiagramHandler.java
@@ -23,13 +23,13 @@ import org.eclipse.emf.transaction.TransactionalEditingDomain;
import org.eclipse.gmf.runtime.notation.Diagram;
import org.eclipse.gmf.runtime.notation.NotationFactory;
import org.eclipse.papyrus.infra.core.Activator;
-import org.eclipse.papyrus.infra.core.extension.diagrameditor.IPluggableEditorFactory;
-import org.eclipse.papyrus.infra.core.sasheditor.contentprovider.IPageManager;
+import org.eclipse.papyrus.infra.core.sashwindows.di.service.IPageManager;
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.emf.utils.ServiceUtilsForHandlers;
import org.eclipse.papyrus.infra.gmfdiag.common.model.NotationUtils;
+import org.eclipse.papyrus.infra.ui.extension.diagrameditor.IPluggableEditorFactory;
/**
* Base class for create diagram Handlers.
diff --git a/plugins/infra/emf/org.eclipse.papyrus.infra.emf.readonly/META-INF/MANIFEST.MF b/plugins/infra/emf/org.eclipse.papyrus.infra.emf.readonly/META-INF/MANIFEST.MF
index 54b2a39e6c8..5f652aca106 100644
--- a/plugins/infra/emf/org.eclipse.papyrus.infra.emf.readonly/META-INF/MANIFEST.MF
+++ b/plugins/infra/emf/org.eclipse.papyrus.infra.emf.readonly/META-INF/MANIFEST.MF
@@ -11,7 +11,8 @@ Require-Bundle: org.eclipse.papyrus.infra.onefile;bundle-version="1.2.0",
org.eclipse.papyrus.infra.core;bundle-version="1.2.0",
org.eclipse.papyrus.infra.emf;bundle-version="1.2.0",
com.google.guava;bundle-version="11.0.0",
- org.eclipse.papyrus.infra.tools;bundle-version="1.2.0"
+ org.eclipse.papyrus.infra.tools;bundle-version="1.2.0",
+ org.eclipse.papyrus.infra.ui;bundle-version="1.2.0"
Bundle-Vendor: %providerName
Bundle-ActivationPolicy: lazy
Bundle-Version: 1.2.0.qualifier
diff --git a/plugins/infra/emf/org.eclipse.papyrus.infra.emf.readonly/src/org/eclipse/papyrus/infra/emf/readonly/Activator.java b/plugins/infra/emf/org.eclipse.papyrus.infra.emf.readonly/src/org/eclipse/papyrus/infra/emf/readonly/Activator.java
index 34de737df89..eebb9793f98 100644
--- a/plugins/infra/emf/org.eclipse.papyrus.infra.emf.readonly/src/org/eclipse/papyrus/infra/emf/readonly/Activator.java
+++ b/plugins/infra/emf/org.eclipse.papyrus.infra.emf.readonly/src/org/eclipse/papyrus/infra/emf/readonly/Activator.java
@@ -1,6 +1,5 @@
/*****************************************************************************
- * Copyright (c) 2011, 2015 Atos Origin, Christian W. Damus, and others.
- *
+ * Copyright (c) 2011, 2016 Atos Origin, 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
@@ -10,6 +9,7 @@
* Contributors:
* Mathieu Velten (Atos Origin) mathieu.velten@atosorigin.com - Initial API and implementation
* Christian W. Damus - bug 463564
+ * Christian W. Damus - bug 485220
*
*****************************************************************************/
package org.eclipse.papyrus.infra.emf.readonly;
@@ -19,8 +19,7 @@ import java.util.concurrent.Executor;
import org.eclipse.core.runtime.Plugin;
import org.eclipse.papyrus.infra.core.log.LogHelper;
import org.eclipse.papyrus.infra.core.resource.AbstractReadOnlyHandler;
-import org.eclipse.papyrus.infra.tools.util.UIUtil;
-import org.eclipse.swt.widgets.Display;
+import org.eclipse.papyrus.infra.tools.util.CoreExecutors;
import org.osgi.framework.BundleContext;
/**
@@ -46,11 +45,6 @@ public class Activator extends Plugin {
public Activator() {
}
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)
- */
@Override
public void start(BundleContext context) throws Exception {
super.start(context);
@@ -58,11 +52,6 @@ public class Activator extends Plugin {
log = new LogHelper(this);
}
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)
- */
@Override
public void stop(BundleContext context) throws Exception {
plugin = null;
@@ -87,7 +76,7 @@ public class Activator extends Plugin {
public synchronized Executor getReadOnlyCacheExecutor() {
if (readOnlyCacheExecutor == null) {
// The default executor is one that runs tasks on the display's event queue
- readOnlyCacheExecutor = UIUtil.createUIExecutor(Display.getDefault());
+ readOnlyCacheExecutor = CoreExecutors.getUIExecutorService();
}
return readOnlyCacheExecutor;
}
diff --git a/plugins/infra/emf/org.eclipse.papyrus.infra.emf.readonly/src/org/eclipse/papyrus/infra/emf/readonly/ReadOnlyManager.java b/plugins/infra/emf/org.eclipse.papyrus.infra.emf.readonly/src/org/eclipse/papyrus/infra/emf/readonly/ReadOnlyManager.java
index 1a068ef24d5..1377317e949 100644
--- a/plugins/infra/emf/org.eclipse.papyrus.infra.emf.readonly/src/org/eclipse/papyrus/infra/emf/readonly/ReadOnlyManager.java
+++ b/plugins/infra/emf/org.eclipse.papyrus.infra.emf.readonly/src/org/eclipse/papyrus/infra/emf/readonly/ReadOnlyManager.java
@@ -42,11 +42,6 @@ import org.eclipse.emf.common.util.URI;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.edit.domain.EditingDomain;
import org.eclipse.emf.transaction.TransactionalEditingDomain;
-import org.eclipse.papyrus.infra.core.editor.IMultiDiagramEditor;
-import org.eclipse.papyrus.infra.core.editor.IReloadableEditor;
-import org.eclipse.papyrus.infra.core.editor.reload.EditorReloadEvent;
-import org.eclipse.papyrus.infra.core.editor.reload.IEditorReloadListener;
-import org.eclipse.papyrus.infra.core.editor.reload.IReloadContextProvider;
import org.eclipse.papyrus.infra.core.resource.AbstractReadOnlyHandler;
import org.eclipse.papyrus.infra.core.resource.IReadOnlyHandler;
import org.eclipse.papyrus.infra.core.resource.IReadOnlyHandler2;
@@ -56,6 +51,11 @@ import org.eclipse.papyrus.infra.core.resource.ReadOnlyEvent;
import org.eclipse.papyrus.infra.core.services.ServiceException;
import org.eclipse.papyrus.infra.core.utils.AdapterUtils;
import org.eclipse.papyrus.infra.emf.utils.ServiceUtilsForResourceSet;
+import org.eclipse.papyrus.infra.ui.editor.IMultiDiagramEditor;
+import org.eclipse.papyrus.infra.ui.editor.IReloadableEditor;
+import org.eclipse.papyrus.infra.ui.editor.reload.EditorReloadEvent;
+import org.eclipse.papyrus.infra.ui.editor.reload.IEditorReloadListener;
+import org.eclipse.papyrus.infra.ui.editor.reload.IReloadContextProvider;
import com.google.common.base.Optional;
import com.google.common.collect.ImmutableSet;
diff --git a/plugins/infra/emf/org.eclipse.papyrus.infra.emf.readonly/src/org/eclipse/papyrus/infra/emf/readonly/ReferencedModelReadOnlyHandler.java b/plugins/infra/emf/org.eclipse.papyrus.infra.emf.readonly/src/org/eclipse/papyrus/infra/emf/readonly/ReferencedModelReadOnlyHandler.java
index 1582a7a9a97..4f627676eff 100644
--- a/plugins/infra/emf/org.eclipse.papyrus.infra.emf.readonly/src/org/eclipse/papyrus/infra/emf/readonly/ReferencedModelReadOnlyHandler.java
+++ b/plugins/infra/emf/org.eclipse.papyrus.infra.emf.readonly/src/org/eclipse/papyrus/infra/emf/readonly/ReferencedModelReadOnlyHandler.java
@@ -23,12 +23,12 @@ import org.eclipse.emf.ecore.resource.ResourceSet;
import org.eclipse.emf.ecore.resource.URIConverter;
import org.eclipse.emf.edit.domain.EditingDomain;
import org.eclipse.jface.dialogs.MessageDialog;
-import org.eclipse.papyrus.infra.core.editor.reload.IReloadContextProvider;
import org.eclipse.papyrus.infra.core.resource.AbstractReadOnlyHandler;
import org.eclipse.papyrus.infra.core.resource.IReadOnlyHandler2;
import org.eclipse.papyrus.infra.core.resource.ModelSet;
import org.eclipse.papyrus.infra.core.resource.ReadOnlyAxis;
import org.eclipse.papyrus.infra.emf.readonly.internal.messages.Messages;
+import org.eclipse.papyrus.infra.ui.editor.reload.IReloadContextProvider;
import org.eclipse.swt.widgets.Display;
import com.google.common.base.Optional;
diff --git a/plugins/infra/emf/org.eclipse.papyrus.infra.emf/META-INF/MANIFEST.MF b/plugins/infra/emf/org.eclipse.papyrus.infra.emf/META-INF/MANIFEST.MF
index 6df6c79fa58..95ded3a267b 100644
--- a/plugins/infra/emf/org.eclipse.papyrus.infra.emf/META-INF/MANIFEST.MF
+++ b/plugins/infra/emf/org.eclipse.papyrus.infra.emf/META-INF/MANIFEST.MF
@@ -24,7 +24,9 @@ Require-Bundle: org.eclipse.papyrus.infra.core.log;bundle-version="1.2.0",
org.eclipse.gmf.runtime.emf.type.core;bundle-version="1.7.0",
com.google.guava;bundle-version="11.0.0",
org.eclipse.papyrus.emf.facet.custom.ui;bundle-version="1.2.0",
- org.eclipse.papyrus.emf.facet.custom.core;bundle-version="1.2.0"
+ org.eclipse.papyrus.emf.facet.custom.core;bundle-version="1.2.0",
+ org.eclipse.papyrus.infra.core.sasheditor;bundle-version="1.2.0",
+ org.eclipse.papyrus.infra.core.sashwindows.di;bundle-version="1.2.0"
Bundle-Vendor: Eclipse Modeling Project
Bundle-ActivationPolicy: lazy
Bundle-Version: 1.2.0.qualifier
diff --git a/plugins/infra/emf/org.eclipse.papyrus.infra.emf/plugin.xml b/plugins/infra/emf/org.eclipse.papyrus.infra.emf/plugin.xml
index d7c9c6fbd2a..bf405510fb0 100644
--- a/plugins/infra/emf/org.eclipse.papyrus.infra.emf/plugin.xml
+++ b/plugins/infra/emf/org.eclipse.papyrus.infra.emf/plugin.xml
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<?eclipse version="3.4"?>
<!--
- Copyright (c) 2012, 2014 CEA and others.
+ Copyright (c) 2012, 2016 CEA, 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
@@ -13,6 +13,7 @@
Christian W. Damus (CEA) - bug 323802
Christian W. Damus (CEA) - bug 408491
Christian W. Damus (CEA) - bug 431953 (pre-requisite refactoring of ModelSet service start-up)
+ Christian W. Damus - bug 485220
-->
<plugin>
@@ -65,9 +66,9 @@
<elementType
ref="org.eclipse.papyrus.infra.emf.page">
</elementType>
- <elementType
+ <advice
ref="org.eclipse.papyrus.infra.emf.deletePageAdvice">
- </elementType>
+ </advice>
</binding>
</extension>
<extension
diff --git a/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/advice/RemovePageHelper.java b/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/advice/RemovePageHelper.java
index dd3dc672392..e74a0fa568d 100644
--- a/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/advice/RemovePageHelper.java
+++ b/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/advice/RemovePageHelper.java
@@ -1,5 +1,5 @@
/*****************************************************************************
- * Copyright (c) 2013, 2014 CEA LIST and others.
+ * Copyright (c) 2013, 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
@@ -9,6 +9,7 @@
* Contributors:
* Camille Letavernier (CEA LIST) camille.letavernier@cea.fr - Initial API and implementation
* Christian W. Damus (CEA) - bug 433371
+ * Christian W. Damus - bug 485220
*
*****************************************************************************/
package org.eclipse.papyrus.infra.emf.advice;
@@ -22,8 +23,8 @@ import org.eclipse.emf.transaction.TransactionalEditingDomain;
import org.eclipse.gmf.runtime.common.core.command.CommandResult;
import org.eclipse.gmf.runtime.common.core.command.ICommand;
import org.eclipse.gmf.runtime.emf.commands.core.command.AbstractTransactionalCommand;
-import org.eclipse.papyrus.infra.core.sasheditor.contentprovider.IPageManager;
-import org.eclipse.papyrus.infra.core.sasheditor.di.contentprovider.utils.IPageUtils;
+import org.eclipse.papyrus.infra.core.sashwindows.di.service.IPageManager;
+import org.eclipse.papyrus.infra.core.sashwindows.di.util.DiUtils;
import org.eclipse.papyrus.infra.core.services.ServiceException;
import org.eclipse.papyrus.infra.emf.utils.ServiceUtilsForEObject;
@@ -37,9 +38,9 @@ public class RemovePageHelper {
public static ICommand getRemovePageCommand(final TransactionalEditingDomain editingDomain, final EObject elementToDestroy) {
try {
- final IPageManager pageManager = ServiceUtilsForEObject.getInstance().getIPageManager(elementToDestroy);
+ final IPageManager pageManager = ServiceUtilsForEObject.getInstance().getService(IPageManager.class, elementToDestroy);
if (pageManager.allPages().contains(elementToDestroy)) {
- final Command command = IPageUtils.getMemoizedCloseAllPagesCommand(editingDomain, pageManager, elementToDestroy);
+ final Command command = DiUtils.getMemoizedCloseAllPagesCommand(editingDomain, pageManager, elementToDestroy);
if (command != null) {
return new AbstractTransactionalCommand(editingDomain, "Delete page", null) { //$NON-NLS-1$
diff --git a/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/providers/MoDiscoContentProvider.java b/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/providers/MoDiscoContentProvider.java
index 8fd37159f40..035bce4ac83 100644
--- a/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/providers/MoDiscoContentProvider.java
+++ b/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/providers/MoDiscoContentProvider.java
@@ -20,7 +20,7 @@ import org.eclipse.papyrus.infra.core.resource.AbstractBaseModel;
import org.eclipse.papyrus.infra.core.resource.IModel;
import org.eclipse.papyrus.infra.core.resource.ModelSet;
import org.eclipse.papyrus.infra.core.resource.ModelUtils;
-import org.eclipse.papyrus.infra.core.sasheditor.contentprovider.IPageManager;
+import org.eclipse.papyrus.infra.core.sashwindows.di.service.IPageManager;
import org.eclipse.papyrus.infra.core.services.ServicesRegistry;
import org.eclipse.papyrus.infra.emf.Activator;
diff --git a/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/utils/EMFHelper.java b/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/utils/EMFHelper.java
index 3fedf630c3f..49ea6eeb2d9 100644
--- a/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/utils/EMFHelper.java
+++ b/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/utils/EMFHelper.java
@@ -1,5 +1,5 @@
/*****************************************************************************
- * Copyright (c) 2010, 2015 CEA LIST, Christian W. Damus, and others.
+ * Copyright (c) 2010, 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
@@ -10,12 +10,8 @@
* Camille Letavernier (CEA LIST) camille.letavernier@cea.fr - Initial API and implementation
* Christian W. Damus (CEA) - filter out EObjects that are Resources (CDO)
* Christian W. Damus (CEA) - Support read-only state at object level (CDO)
- * Christian W. Damus (CEA) - bug 323802
- * Christian W. Damus (CEA) - bug 429826
- * Christian W. Damus (CEA) - bug 408491
- * Christian W. Damus (CEA) - bug 432813
- * Christian W. Damus (CEA) - bug 422257
- * Christian W. Damus - bug 469188
+ * Christian W. Damus (CEA) - bugs 323802, 429826, 408491, 432813, 422257
+ * Christian W. Damus - bugs 469188, 485220
*
*****************************************************************************/
package org.eclipse.papyrus.infra.emf.utils;
@@ -58,7 +54,7 @@ import org.eclipse.papyrus.infra.core.resource.IReadOnlyHandler;
import org.eclipse.papyrus.infra.core.resource.IReadOnlyHandler2;
import org.eclipse.papyrus.infra.core.resource.ReadOnlyAxis;
import org.eclipse.papyrus.infra.core.services.ServiceException;
-import org.eclipse.papyrus.infra.core.utils.ServiceUtilsForActionHandlers;
+import org.eclipse.papyrus.infra.core.utils.ServiceUtils;
import org.eclipse.papyrus.infra.emf.Activator;
import org.eclipse.papyrus.infra.tools.util.PlatformHelper;
@@ -305,7 +301,7 @@ public class EMFHelper {
EditingDomain domain = AdapterFactoryEditingDomain.getEditingDomainFor(source);
if (domain == null) {
try {
- domain = ServiceUtilsForActionHandlers.getInstance().getTransactionalEditingDomain();
+ domain = ServiceUtils.getInstance().getTransactionalEditingDomain(null);
} catch (ServiceException e) {
// Ignore: We cannot find the domain
}
diff --git a/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/utils/EMFStringValueConverter.java b/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/utils/EMFStringValueConverter.java
deleted file mode 100644
index 584812db6dc..00000000000
--- a/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/utils/EMFStringValueConverter.java
+++ /dev/null
@@ -1,375 +0,0 @@
-/*****************************************************************************
- * Copyright (c) 2013 CEA LIST.
- *
- *
- * 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:
- * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation
- *
- *****************************************************************************/
-package org.eclipse.papyrus.infra.emf.utils;
-
-import java.util.ArrayList;
-import java.util.Collection;
-
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.emf.common.util.Enumerator;
-import org.eclipse.emf.ecore.EClass;
-import org.eclipse.emf.ecore.EClassifier;
-import org.eclipse.emf.ecore.EDataType;
-import org.eclipse.emf.ecore.EEnum;
-import org.eclipse.emf.ecore.EEnumLiteral;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.ecore.EStructuralFeature;
-import org.eclipse.osgi.util.NLS;
-import org.eclipse.papyrus.infra.emf.Activator;
-import org.eclipse.papyrus.infra.tools.converter.AbstractStringValueConverter;
-import org.eclipse.papyrus.infra.tools.converter.ConvertedValueContainer;
-import org.eclipse.papyrus.infra.tools.converter.MultiConvertedValueContainer;
-import org.eclipse.papyrus.infra.tools.converter.StringValueConverterStatus;
-import org.eclipse.papyrus.infra.tools.util.BooleanHelper;
-import org.eclipse.papyrus.infra.tools.util.TypesConstants;
-
-/**
- * Value solver for EMF
- *
- * WARNING : incomplete implementations
- *
- * @author vl222926
- *
- */
-
-public class EMFStringValueConverter extends AbstractStringValueConverter {
-
-
-
- /**
- * Context used for the resolution of the string
- */
- private EObject resolutionContext;
-
- /**
- * The separator used for multivalue
- */
- protected final String multiValueSeparator;
-
- /**
- *
- * Constructor.
- *
- * @param resolutionContext
- * the context used for the resolution of the string
- */
- public EMFStringValueConverter(final EObject resolutionContext, final String multiValueSeparator) {
- this.resolutionContext = resolutionContext;
- this.multiValueSeparator = multiValueSeparator;
- }
-
-
- /**
- *
- * @return
- * the context to use for the resolution
- */
- public EObject getResolutionContext() {
- return resolutionContext;
- }
-
- /**
- *
- * @see org.eclipse.ui.services.IDisposable#dispose()
- *
- */
- public void dispose() {
- this.resolutionContext = null;
- }
-
- /**
- *
- * @param resolutionContext
- * the table context
- * @param feature
- * the feature
- * @param valueAsString
- * the pasted string for this feature
- * @return
- * the value for the pasted string or <code>null</code> if not found
- */
- @Override
- protected ConvertedValueContainer<?> doDeduceValueFromString(final Object feature, final String valueAsString) {
- final EClassifier featureType = getFeatureType(feature);
- if (feature instanceof EStructuralFeature) {
- return deduceValueFromString(feature, featureType, valueAsString);
- }
- return null;
- }
-
- /**
- *
- * @param feature
- * @param featureType
- * @param valueAsString
- * @return
- */
- protected ConvertedValueContainer<?> deduceValueFromString(final Object feature, final EClassifier featureType, final String valueAsString) {
- ConvertedValueContainer<?> realValue = null;
- // if(feature instanceof EStructuralFeature) {
- final int upperbound = getFeatureUpperBound(feature);
- boolean isMany = (upperbound > 1 || upperbound == -1);
- if (featureType instanceof EDataType) {
- if (featureType instanceof EEnum) {
- realValue = deduceEEnumLiteralValue((EEnum) featureType, isMany, valueAsString);
- }
- final String typeName = featureType.getName();
- if (TypesConstants.STRING.equals(typeName) || EMFContants.ESTRING.equals(typeName)) {
- realValue = deduceStringValue(isMany, valueAsString);
- } else if (EMFContants.EBOOLEAN.equals(typeName) || TypesConstants.BOOLEAN.equals(typeName)) {
- realValue = deduceBooleanValue(isMany, valueAsString);
- } else if (EMFContants.EINT.equals(typeName) || TypesConstants.INTEGER.equals(typeName)) {
- realValue = deduceIntValue(isMany, valueAsString);
- } else if (EMFContants.EDOUBLE.equals(typeName)) {
- realValue = deduceDoubleValue(isMany, valueAsString);
- }
- } else if (featureType instanceof EClass) {
- realValue = deduceEObjectValue(getResolutionContext(), feature, (EClass) featureType, isMany, valueAsString);
- }
- return realValue;
- }
-
- protected int getFeatureUpperBound(final Object feature) {
- return ((EStructuralFeature) feature).getUpperBound();
- }
-
-
-
- /**
- *
- * @param resolutionContext
- * the context used for the resolution
- * @param feature
- * the feature
- * @param featureType
- * the type of the feature
- * @param isMany
- * <code>true</code> if the feature isMany
- * @param valueAsString
- * the string value to resolve
- * @return
- * a value container referencing the eobject represented by the string
- * @throws StringValueSolverException
- */
- protected ConvertedValueContainer<?> deduceEObjectValue(EObject resolutionContext, Object feature, EClass featureType, boolean isMany, String valueAsString) {
- if (valueAsString == null || valueAsString.equals("")) {
- return new ConvertedValueContainer<EObject>(null, Status.OK_STATUS);
- }
- final IStatus status = new Status(IStatus.ERROR, Activator.PLUGIN_ID, NLS.bind(THE_STRING_VALUE_X_CANT_BE_RESOLVED, valueAsString));
- return new ConvertedValueContainer<EObject>(null, status);
- }
-
- /**
- *
- * @param feature
- * an object representing a feature
- * @return
- * the type of the feature
- */
- protected EClassifier getFeatureType(final Object feature) {
- final EClassifier featureType;
- if (feature instanceof EStructuralFeature) {
- return ((EStructuralFeature) feature).getEType();
- } else {
- featureType = null;
- }
- return featureType;
- }
-
- /**
- *
- * @param eenum
- * the enumeration
- * @param isMany
- * <code>true</code> if the feature is many
- * @param valueAsString
- * the value to convert
- * @return
- * the converted value
- */
- protected ConvertedValueContainer<?> deduceEEnumLiteralValue(final EEnum eenum, final boolean isMany, final String valueAsString) {
- ConvertedValueContainer<?> returnedValue = null;
- IStatus iStatus = Status.OK_STATUS;
- final Collection<String> unresolvedValues = new ArrayList<String>();
- if (isMany) {
- final Collection<EEnumLiteral> values = new ArrayList<EEnumLiteral>();
- for (final String str : valueAsString.split(this.multiValueSeparator)) {
- final EEnumLiteral literal = eenum.getEEnumLiteral(str);
- if (literal != null) {
- values.add(literal);
- } else {
- unresolvedValues.add(str);
- }
- }
- if (!unresolvedValues.isEmpty()) {
- iStatus = new StringValueConverterStatus(IStatus.ERROR, Activator.PLUGIN_ID, NLS.bind(SOME_STRING_ARE_NOT_VALID_TO_CREATE_X, EMFContants.EENUM_LITERAL), unresolvedValues);
- }
- returnedValue = new MultiConvertedValueContainer<EEnumLiteral>(values, iStatus);
- } else {
- final EEnumLiteral literal = eenum.getEEnumLiteral(valueAsString);
- if (literal != null) {
- // returnedValue = new ConvertedValueContainer<EEnumLiteral>(literal, iStatus);
- // fix a bug on enumerator
- returnedValue = new ConvertedValueContainer<Enumerator>(literal.getInstance(), iStatus);
- } else {
- unresolvedValues.add(valueAsString);
- iStatus = new StringValueConverterStatus(IStatus.ERROR, Activator.PLUGIN_ID, NLS.bind(THE_STRING_X_IS_NOT_VALID_TO_CREATE_Y, valueAsString, EMFContants.EENUM_LITERAL), unresolvedValues);
- returnedValue = new ConvertedValueContainer<Boolean>(null, iStatus);
- }
- }
- return returnedValue;
- }
-
- /**
- *
- * @param isMany
- * <code>true</code> if the feature isMany
- * @param valueAsString
- * the value to parse
- * @return
- * the result of the parsing
- */
- protected ConvertedValueContainer<?> deduceBooleanValue(final boolean isMany, final String valueAsString) {
- ConvertedValueContainer<?> returnedValue = null;
- IStatus iStatus = Status.OK_STATUS;
- final Collection<String> unresolvedValues = new ArrayList<String>();
- if (isMany) {
- final Collection<Boolean> values = new ArrayList<Boolean>();
- for (final String str : valueAsString.split(this.multiValueSeparator)) {
- if (BooleanHelper.isBoolean(str)) {
- values.add(Boolean.valueOf(valueAsString));
- } else {
- unresolvedValues.add(str);
- }
- }
- if (!unresolvedValues.isEmpty()) {
- iStatus = new StringValueConverterStatus(IStatus.ERROR, Activator.PLUGIN_ID, NLS.bind(SOME_STRING_ARE_NOT_VALID_TO_CREATE_X, TypesConstants.BOOLEAN), unresolvedValues);
- }
- returnedValue = new MultiConvertedValueContainer<Boolean>(values, iStatus);
- } else {
- if (BooleanHelper.isBoolean(valueAsString)) {
- returnedValue = new ConvertedValueContainer<Boolean>(Boolean.valueOf(valueAsString), iStatus);
- } else {
- unresolvedValues.add(valueAsString);
- iStatus = new StringValueConverterStatus(IStatus.ERROR, Activator.PLUGIN_ID, NLS.bind(THE_STRING_X_IS_NOT_VALID_TO_CREATE_Y, valueAsString, TypesConstants.BOOLEAN), unresolvedValues);
- returnedValue = new ConvertedValueContainer<Boolean>(null, iStatus);
- }
- }
- return returnedValue;
- }
-
- /**
- *
- * @param isMany
- * <code>true</code> if the feature isMany
- * @param valueAsString
- * the value to parse
- * @return
- * the result of the parsing
- */
- protected ConvertedValueContainer<?> deduceDoubleValue(final boolean isMany, final String valueAsString) {
- ConvertedValueContainer<?> returnedValue = null;
- IStatus iStatus = Status.OK_STATUS;
- final Collection<String> unresolvedValues = new ArrayList<String>();
- if (isMany) {
- final Collection<Double> values = new ArrayList<Double>();
- for (final String str : valueAsString.split(this.multiValueSeparator)) {
- final Double value = Double.valueOf(str);
- if (value != null) {
- values.add(value);
- } else {
- unresolvedValues.add(str);
- }
- }
- if (!unresolvedValues.isEmpty()) {
- iStatus = new StringValueConverterStatus(IStatus.ERROR, Activator.PLUGIN_ID, NLS.bind(SOME_STRING_ARE_NOT_VALID_TO_CREATE_X, TypesConstants.DOUBLE), unresolvedValues);
- }
- returnedValue = new MultiConvertedValueContainer<Double>(values, iStatus);
- } else {
- try {
- returnedValue = new ConvertedValueContainer<Double>(Double.valueOf(valueAsString), iStatus);
- } catch (final NumberFormatException e) {
- unresolvedValues.add(valueAsString);
- iStatus = new StringValueConverterStatus(IStatus.ERROR, Activator.PLUGIN_ID, NLS.bind(THE_STRING_X_IS_NOT_VALID_TO_CREATE_Y, valueAsString, TypesConstants.DOUBLE), unresolvedValues);
- returnedValue = new ConvertedValueContainer<Boolean>(null, iStatus);
- }
- }
- return returnedValue;
- }
-
- /**
- *
- * @param isMany
- * <code>true</code> if the feature isMany
- * @param valueAsString
- * the value to parse
- * @return
- * the result of the parsing
- */
- protected ConvertedValueContainer<?> deduceIntValue(final boolean isMany, final String valueAsString) {
- ConvertedValueContainer<?> returnedValue = null;
- IStatus iStatus = Status.OK_STATUS;
- final Collection<String> unresolvedValues = new ArrayList<String>();
- if (isMany) {
- final Collection<Integer> values = new ArrayList<Integer>();
- for (final String str : valueAsString.split(this.multiValueSeparator)) {
- try {
- values.add(Integer.valueOf(str));
- } catch (final NumberFormatException e) {
- unresolvedValues.add(str);
- }
- }
- if (!unresolvedValues.isEmpty()) {
- iStatus = new StringValueConverterStatus(IStatus.ERROR, Activator.PLUGIN_ID, NLS.bind(SOME_STRING_ARE_NOT_VALID_TO_CREATE_X, TypesConstants.INTEGER), unresolvedValues);
- }
- returnedValue = new MultiConvertedValueContainer<Integer>(values, iStatus);
- } else {
- try {
- returnedValue = new ConvertedValueContainer<Integer>(Integer.valueOf(valueAsString), iStatus);
- } catch (final NumberFormatException e) {
- unresolvedValues.add(valueAsString);
- iStatus = new StringValueConverterStatus(IStatus.ERROR, Activator.PLUGIN_ID, NLS.bind(THE_STRING_X_IS_NOT_VALID_TO_CREATE_Y, valueAsString, TypesConstants.INTEGER), unresolvedValues);
- returnedValue = new ConvertedValueContainer<Boolean>(null, iStatus);
- }
- }
- return returnedValue;
- }
-
-
- /**
- *
- * @param isMany
- * <code>true</code> if the feature is many
- * @param valueAsString
- * the value as string
- * @return
- * the value container with the real value(s)
- */
- protected ConvertedValueContainer<?> deduceStringValue(final boolean isMany, final String valueAsString) {
- ConvertedValueContainer<?> returnedValue = null;
- final IStatus iStatus = Status.OK_STATUS;
- if (isMany) {
- final Collection<String> values = new ArrayList<String>();
- for (final String str : valueAsString.split(this.multiValueSeparator)) {
- values.add(str);
- }
- returnedValue = new MultiConvertedValueContainer<String>(values, iStatus);
- } else {
- returnedValue = new ConvertedValueContainer<String>(valueAsString, iStatus);
- }
- return returnedValue;
- }
-
-}
diff --git a/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/utils/ServiceUtilsForHandlers.java b/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/utils/ServiceUtilsForHandlers.java
index b3068b03106..6c853bfe9f2 100644
--- a/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/utils/ServiceUtilsForHandlers.java
+++ b/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/utils/ServiceUtilsForHandlers.java
@@ -1,5 +1,5 @@
/*****************************************************************************
- * Copyright (c) 2012 CEA LIST.
+ * Copyright (c) 2012, 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
@@ -8,16 +8,20 @@
*
* Contributors:
* Camille Letavernier (CEA LIST) camille.letavernier@cea.fr - Initial API and implementation
+ * Christian W. Damus - bug 485220
+ *
*****************************************************************************/
package org.eclipse.papyrus.infra.emf.utils;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.expressions.IEvaluationContext;
import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.papyrus.infra.core.sasheditor.editor.ISashWindowsContainer;
import org.eclipse.papyrus.infra.core.services.ServiceException;
import org.eclipse.papyrus.infra.core.services.ServiceNotFoundException;
import org.eclipse.papyrus.infra.core.services.ServicesRegistry;
import org.eclipse.papyrus.infra.core.utils.AbstractServiceUtils;
+import org.eclipse.ui.IEditorPart;
import org.eclipse.ui.ISources;
import org.eclipse.ui.IWorkbenchPart;
import org.eclipse.ui.IWorkbenchPartSite;
@@ -38,6 +42,18 @@ public class ServiceUtilsForHandlers extends AbstractServiceUtils<ExecutionEvent
// Singleton
}
+ /**
+ * Gets the {@link IEditorPart} of the currently nested active editor.
+ *
+ * @param from
+ * @return
+ * @throws ServiceException
+ * If an error occurs while getting the requested service.
+ */
+ public IEditorPart getNestedActiveIEditorPart(ExecutionEvent from) throws ServiceException {
+ return getService(ISashWindowsContainer.class, from).getActiveEditor();
+ }
+
@Override
public ServicesRegistry getServiceRegistry(ExecutionEvent from) throws ServiceException {
@@ -83,7 +99,7 @@ public class ServiceUtilsForHandlers extends AbstractServiceUtils<ExecutionEvent
// Try to adapt the active part to the ServicesRegistry
IWorkbenchPart part = (IWorkbenchPart) evaluationContext.getVariable(ISources.ACTIVE_PART_NAME);
- registry = (ServicesRegistry) (part).getAdapter(ServicesRegistry.class);
+ registry = (part).getAdapter(ServicesRegistry.class);
if (registry != null) {
return registry;
}
@@ -92,6 +108,8 @@ public class ServiceUtilsForHandlers extends AbstractServiceUtils<ExecutionEvent
throw new ServiceNotFoundException("The ServiceRegistry cannot be resolved"); //$NON-NLS-1$
}
+
+
public static ServiceUtilsForHandlers getInstance() {
return instance;
}

Back to the top