Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian W. Damus2016-02-11 21:38:52 +0000
committerChristian W. Damus2016-02-24 22:26:27 +0000
commit09fde7a4087685b065b7f1e40375686fb9f19f2a (patch)
tree36668c0515a08586179a74cefcf1dc6197311d70 /plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di
parent2f0dd86c51f8543f56a99cd4371965a01287fcaa (diff)
downloadorg.eclipse.papyrus-09fde7a4087685b065b7f1e40375686fb9f19f2a.tar.gz
org.eclipse.papyrus-09fde7a4087685b065b7f1e40375686fb9f19f2a.tar.xz
org.eclipse.papyrus-09fde7a4087685b065b7f1e40375686fb9f19f2a.zip
Bug 485220: [Architecture] Provide a more modular architecture
https://bugs.eclipse.org/bugs/show_bug.cgi?id=485220 Implement version management: PDE API Tooling and Oomph Version Management. Introduce two new plug-in projects to manage versioning using Oomph: * org.eclipse.papyrus.releng.main.release for the Main bundles and features * org.eclipse.papyrus.releng.dev.release for the Dev Tools Add new menu actions to the Dev Tools: * main menu bar: * synchronize POM and manifest versions * "Configure" context menu on bundle projects and MANIFEST.MF * optimize bundle dependencies and re-exports * update dependency version ranges to match current workspace and PDE target Remove obsolete menu actions from the Dev Tools: * main menu bar: * Set all Papyrus feature versions * Set all Papyrus plug-in versions * Set versions of all Papyrus dependencies in Papyrus plug-ins Fix versioning errors reported by PDE and Oomph. Ensure proper version ranges consistent with latest build target. Optimize the dependencies of all Papyrus Main bundles and Dev Tools. Remove version- and reexport-checking tests in the BundlesTests that are now not needed because, on the one hand, we now implement discrete bundle versioning (managed by PDE/Oomph) and on the other, we now use re-exports properly to ensure classpath consistency in clients of a bundle's API. Thorough overhaul of the "project editors" API, including: * rationalize the API interfaces * refactor the all-in-one PluginEditor class from the customization bundle to the project-editors bundle * update clients in the Customization and DSML Validation components * fix a bunch of operations that didn't work * add missing operations required by the new Dev Tools actions * complete some unimplemented APIs * add a comprehensive JUnit test suite covering all of the project-editors API Change-Id: I6a699d93909f61099226ceb994140f03ea99a70f
Diffstat (limited to 'plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di')
-rw-r--r--plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/.project80
-rw-r--r--plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/META-INF/MANIFEST.MF47
-rw-r--r--plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/custom-src/org/eclipse/papyrus/infra/core/sasheditor/di/contentprovider/DiSashModelManager.java668
-rw-r--r--plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/custom-src/org/eclipse/papyrus/infra/core/sasheditor/di/contentprovider/DiSashModelMngr.java504
-rw-r--r--plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/custom-src/org/eclipse/papyrus/infra/core/sasheditor/di/contentprovider/IPageModelFactory.java156
-rw-r--r--plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/custom-src/org/eclipse/papyrus/infra/core/sasheditor/di/contentprovider/internal/PageManagerImpl.java327
-rw-r--r--plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/custom-src/org/eclipse/papyrus/infra/core/sasheditor/di/contentprovider/utils/IPageUtils.java173
-rw-r--r--plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/pom.xml2
8 files changed, 993 insertions, 964 deletions
diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/.project b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/.project
index 46189987209..e0e931c07d1 100644
--- a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/.project
+++ b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/.project
@@ -1,28 +1,52 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<projectDescription>
- <name>org.eclipse.papyrus.infra.core.sasheditor.di</name>
- <comment></comment>
- <projects>
- </projects>
- <buildSpec>
- <buildCommand>
- <name>org.eclipse.jdt.core.javabuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- <buildCommand>
- <name>org.eclipse.pde.ManifestBuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- <buildCommand>
- <name>org.eclipse.pde.SchemaBuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- </buildSpec>
- <natures>
- <nature>org.eclipse.pde.PluginNature</nature>
- <nature>org.eclipse.jdt.core.javanature</nature>
- </natures>
-</projectDescription>
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.eclipse.papyrus.infra.core.sasheditor.di</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.ManifestBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.SchemaBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.api.tools.apiAnalysisBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.oomph.version.VersionBuilder</name>
+ <arguments>
+ <dictionary>
+ <key>check.maven.pom</key>
+ <value>true</value>
+ </dictionary>
+ <dictionary>
+ <key>ignore.lower.bound.dependency.ranges</key>
+ <value>true</value>
+ </dictionary>
+ <dictionary>
+ <key>release.path</key>
+ <value>/org.eclipse.papyrus.releng.main.release/release.xml</value>
+ </dictionary>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.pde.PluginNature</nature>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ <nature>org.eclipse.pde.api.tools.apiAnalysisNature</nature>
+ <nature>org.eclipse.oomph.version.VersionNature</nature>
+ </natures>
+</projectDescription>
diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/META-INF/MANIFEST.MF b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/META-INF/MANIFEST.MF
index 3d881990d21..f0fdd97593a 100644
--- a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/META-INF/MANIFEST.MF
+++ b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/META-INF/MANIFEST.MF
@@ -1,27 +1,20 @@
-Manifest-Version: 1.0
-Export-Package: org.eclipse.papyrus.infra.core.sasheditor.di.contentprovider,
- org.eclipse.papyrus.infra.core.sasheditor.di.contentprovider.commands,
- org.eclipse.papyrus.infra.core.sasheditor.di.contentprovider.internal,
- org.eclipse.papyrus.infra.core.sasheditor.di.contentprovider.utils
-Bundle-ActivationPolicy: lazy
-Bundle-ClassPath: .
-Bundle-Localization: plugin
-Bundle-Name: %pluginName
-Bundle-RequiredExecutionEnvironment: JavaSE-1.8
-Require-Bundle: org.eclipse.swt;bundle-version="3.5.0",
- org.eclipse.papyrus.infra.core.sasheditor;bundle-version="1.2.0";visibility:=reexport,
- org.eclipse.ui;bundle-version="3.6.0",
- org.eclipse.core.runtime;bundle-version="3.6.0",
- org.eclipse.emf.ecore;visibility:=reexport,
- org.eclipse.emf.ecore.xmi;bundle-version="2.5.0";visibility:=reexport,
- org.eclipse.uml2.types;visibility:=reexport,
- org.eclipse.uml2.common;visibility:=reexport,
- org.eclipse.emf.transaction;bundle-version="1.4.0",
- org.eclipse.papyrus.infra.core.log;bundle-version="1.2.0",
- org.eclipse.papyrus.infra.core.sashwindows.di;bundle-version="1.2.0"
-Bundle-Vendor: %providerName
-Bundle-Version: 1.2.0.qualifier
-Bundle-Activator: org.eclipse.papyrus.infra.core.sasheditor.di.contentprovider.Activator
-Bundle-ManifestVersion: 2
-Bundle-SymbolicName: org.eclipse.papyrus.infra.core.sasheditor.di;singleton:=true
-Eclipse-ExtensibleAPI: true
+Manifest-Version: 1.0
+Export-Package: org.eclipse.papyrus.infra.core.sasheditor.di.contentprovider,
+ org.eclipse.papyrus.infra.core.sasheditor.di.contentprovider.commands,
+ org.eclipse.papyrus.infra.core.sasheditor.di.contentprovider.internal;x-internal:=true,
+ org.eclipse.papyrus.infra.core.sasheditor.di.contentprovider.utils
+Bundle-ActivationPolicy: lazy
+Bundle-ClassPath: .
+Bundle-Localization: plugin
+Bundle-Name: %pluginName
+Bundle-RequiredExecutionEnvironment: JavaSE-1.8
+Require-Bundle: org.eclipse.papyrus.infra.core.sasheditor;bundle-version="[2.0.0,3.0.0)";visibility:=reexport,
+ org.eclipse.emf.transaction;bundle-version="[1.9.0,2.0.0)";visibility:=reexport,
+ org.eclipse.papyrus.infra.core.log;bundle-version="[1.2.0,2.0.0)";visibility:=reexport,
+ org.eclipse.papyrus.infra.core.sashwindows.di;bundle-version="[1.2.0,2.0.0)";visibility:=reexport
+Bundle-Vendor: %providerName
+Bundle-Version: 2.0.0.qualifier
+Bundle-Activator: org.eclipse.papyrus.infra.core.sasheditor.di.contentprovider.Activator
+Bundle-ManifestVersion: 2
+Bundle-SymbolicName: org.eclipse.papyrus.infra.core.sasheditor.di;singleton:=true
+Eclipse-ExtensibleAPI: true
diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/custom-src/org/eclipse/papyrus/infra/core/sasheditor/di/contentprovider/DiSashModelManager.java b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/custom-src/org/eclipse/papyrus/infra/core/sasheditor/di/contentprovider/DiSashModelManager.java
index 2d242f0b080..a06bc084fdf 100644
--- a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/custom-src/org/eclipse/papyrus/infra/core/sasheditor/di/contentprovider/DiSashModelManager.java
+++ b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/custom-src/org/eclipse/papyrus/infra/core/sasheditor/di/contentprovider/DiSashModelManager.java
@@ -1,333 +1,335 @@
-/*****************************************************************************
- * 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 - bugs 469188, 485220
- *
- *****************************************************************************/
-
-package org.eclipse.papyrus.infra.core.sasheditor.di.contentprovider;
-
-import java.util.Map;
-
-import org.eclipse.emf.ecore.resource.Resource;
-import org.eclipse.emf.transaction.RecordingCommand;
-import org.eclipse.emf.transaction.TransactionalEditingDomain;
-import org.eclipse.papyrus.infra.core.sasheditor.contentprovider.IContentChangedProvider;
-import org.eclipse.papyrus.infra.core.sasheditor.contentprovider.ISashWindowsContentProvider;
-import org.eclipse.papyrus.infra.core.sasheditor.di.contentprovider.internal.ContentChangedEventProvider;
-import org.eclipse.papyrus.infra.core.sasheditor.di.contentprovider.internal.CurrentFolderAndPageManager;
-import org.eclipse.papyrus.infra.core.sasheditor.di.contentprovider.internal.DiContentProvider;
-import org.eclipse.papyrus.infra.core.sasheditor.di.contentprovider.internal.ICurrentFolderAndPageMngr;
-import org.eclipse.papyrus.infra.core.sasheditor.di.contentprovider.internal.PageManagerImpl;
-import org.eclipse.papyrus.infra.core.sasheditor.di.contentprovider.internal.TransactionalDiContentProvider;
-import org.eclipse.papyrus.infra.core.sasheditor.di.contentprovider.internal.TransactionalPageManagerImpl;
-import org.eclipse.papyrus.infra.core.sasheditor.di.contentprovider.utils.TransactionHelper;
-import org.eclipse.papyrus.infra.core.sasheditor.editor.ISashWindowsContainer;
-import org.eclipse.papyrus.infra.core.sashwindows.di.SashWindowsMngr;
-import org.eclipse.papyrus.infra.core.sashwindows.di.service.IPageManager;
-import org.eclipse.papyrus.infra.core.sashwindows.di.util.DiUtils;
-
-
-/**
- * Class used as main entry point to access a sash model build on EMF / di
- * This class allows to get facade objects on the diSashModel.
- *
- * @author cedric dumoulin
- *
- */
-public class DiSashModelManager {
-
- /** The EMF model used to store the sash windows structure and pages */
- protected SashWindowsMngr sashWindowMngr;
-
- /**
- * Instance of the {@link PageManagerImpl}.
- */
- private final PageManagerImpl pageMngr;
-
- /**
- * Instance of the DiContentProvider used to manipulate SashModel.
- */
- private final DiContentProvider contentProvider;
-
- private final TransactionalDiContentProvider transDiContentProvider;
-
- private final IPageModelFactory pageModelFactory;
-
- /**
- * Object used externally listen to model changes.
- * The object is also used internally to control how events are fired (limit multiple events).
- */
- protected ContentChangedEventProvider contentChangedEventProvider;
-
- /** The factory used to create IPageModel */
- // private IPageModelFactory pageModelFactory;
-
-
- /**
- *
- * Constructor.
- *
- * @param pageModelFactory
- * @param diResource
- * @param currentFolderAndPageMngr
- */
- public DiSashModelManager(IPageModelFactory pageModelFactory, final Resource diResource, TransactionalEditingDomain editingDomain, ICurrentFolderAndPageMngr currentFolderAndPageMngr) {
- // this.pageModelFactory = pageModelFactory;
-
- // lookup the SashModel
- sashWindowMngr = lookupSashWindowMngr(diResource);
- // If no SashWindow structure is found, create a new one using a transaction.
- if (sashWindowMngr == null) {
- // Create a default model and attach it to resource.
- sashWindowMngr = createDefaultSashModel();
- // Create a command
- RecordingCommand cmd = new RecordingCommand(editingDomain) {
-
- @Override
- protected void doExecute() {
- diResource.getContents().add(sashWindowMngr);
- }
- };
- // Execute command
- editingDomain.getCommandStack().execute(cmd);
- }
-
- this.pageModelFactory = pageModelFactory;
-
- contentProvider = new DiContentProvider(sashWindowMngr.getSashModel(), pageModelFactory, contentChangedEventProvider);
- // Create the TransactionalDiContentProvider
- transDiContentProvider = new TransactionalDiContentProvider(getDiContentProvider(), editingDomain);
-
- // Create the TransactionalPageMngrImpl
- pageMngr = new TransactionalPageManagerImpl(sashWindowMngr, contentChangedEventProvider, currentFolderAndPageMngr);
- }
-
- /**
- *
- * Constructor.
- *
- * @param pageModelFactory
- * @param diResource
- * @param currentFolderAndPageMngr
- */
- public DiSashModelManager(IPageModelFactory pageModelFactory, final Resource diResource, TransactionalEditingDomain editingDomain) {
-
- // lookup the SashModel
- sashWindowMngr = lookupSashWindowMngr(diResource);
- // If no SashWindow structure is found, create a new one using a transaction.
- if (sashWindowMngr == null) {
- // Create a default model and attach it to resource.
- sashWindowMngr = createDefaultSashModel();
-
- try {
- TransactionHelper.run(editingDomain, new Runnable() {
-
- @Override
- public void run() {
- diResource.getContents().add(sashWindowMngr);
-
- };
- });
- } catch (Exception ex) {
- Activator.log.error(ex);
- }
- }
-
- this.pageModelFactory = pageModelFactory;
-
- contentProvider = new DiContentProvider(sashWindowMngr.getSashModel(), pageModelFactory, getContentChangedEventProvider());
- // Create the TransactionalDiContentProvider
- transDiContentProvider = new TransactionalDiContentProvider(getDiContentProvider(), editingDomain);
-
- // Create the TransactionalPageMngrImpl
- pageMngr = new TransactionalPageManagerImpl(sashWindowMngr, getContentChangedEventProvider());
-
- }
-
- /**
- *
- * @param currentFolderAndPageMngr
- */
- public void setCurrentFolderAndPageMngr(ICurrentFolderAndPageMngr currentFolderAndPageMngr) {
- pageMngr.setCurrentFolderAndPageMngr(currentFolderAndPageMngr);
- }
-
- /**
- * Set the CurrentFolderAndPageManager as an instance of {@link CurrentFolderAndPageManager}
- *
- * @param currentFolderAndPageMngr
- */
- public void setCurrentFolderAndPageMngr(ISashWindowsContainer sashWindowsContainer) {
- pageMngr.setCurrentFolderAndPageMngr(new CurrentFolderAndPageManager(sashWindowsContainer));
- }
-
- /**
- *
- * Constructor.
- * Only create a {@link IPageMngr} impl. Do not create the DiContentProvider as there is no factory provided.
- * Internal use.
- *
- * @param pageModelFactory
- * @param diResource
- */
- // private DiSashModelManager(final Resource diResource, TransactionalEditingDomain editingDomain, ICurrentFolderAndPageMngr currentFolderAndPageMngr) {
- // this(null, diResource, editingDomain, currentFolderAndPageMngr);
- //
- // }
-
-
- /**
- * Get the internal EMF implementation.
- * Intended to be used by tests.
- *
- * @return the sashWindowMngr
- */
- protected SashWindowsMngr getDiSashWindowsMngr() {
- return sashWindowMngr;
- }
-
-
- /**
- * Return the internal implementation of ContentProvider.
- * Create if if needed.
- * This method should not be subclassed
- *
- * @return the contentProvider
- */
- protected DiContentProvider getDiContentProvider() {
- return contentProvider;
- }
-
- /**
- * Return the internal implementation of ContentProvider.
- * Create if if needed.
- * This method should not be subclassed
- *
- * @return the contentProvider
- */
- protected TransactionalDiContentProvider getTransactionalDiContentProvider() {
- return transDiContentProvider;
- }
-
- /**
- * Return the internal implementation of PageMngr.
- * Create if if needed.
- * This method should not be subclassed
- *
- * @return the PageMngrImpl
- */
- protected final PageManagerImpl getPageManagerImpl() {
- return pageMngr;
- }
-
- /**
- * Return the internal implementation of ContentChangedEventProvider.
- * Create if if needed.
- * This method should not be subclassed
- *
- * @return the PageMngrImpl
- */
- protected final ContentChangedEventProvider getContentChangedEventProvider() {
- if (contentChangedEventProvider == null) {
- contentChangedEventProvider = new ContentChangedEventProvider(sashWindowMngr);
- }
-
- return contentChangedEventProvider;
- }
-
- /**
- * Get the IPageManager providing basic methods to manage Pages in the sash model.
- *
- * @return
- */
- public IPageManager getIPageManager() {
- return getPageManagerImpl();
- }
-
- /**
- * Get the ContentProvider used by the SashWindows system.
- * This class can also be used to accurately manage the sash model.
- *
- * @return
- */
- public ISashWindowsContentProvider getISashWindowsContentProvider() {
-
- return getTransactionalDiContentProvider();
-
- }
-
- /**
- * Get the ContentChangedProvider for the SashModel
- *
- * @return
- */
- public IContentChangedProvider getSashModelContentChangedProvider() {
- return getContentChangedEventProvider();
- }
-
- /**
- * Create a default model with one window and one folder.
- *
- * @param diResource
- * @return
- */
- protected SashWindowsMngr createDefaultSashModel() {
- SashWindowsMngr result = DiUtils.createDefaultSashWindowsMngr();
-
- if (result.getSashModel() != null) {
- // Default this to true for new models, which store the sash model
- // in the workspace private area by default
- result.getSashModel().setRestoreActivePage(true);
- }
-
- return result;
- }
-
- /**
- * Lookup for the SashModel object in the resource
- *
- * @param diResource
- * @return
- */
- protected SashWindowsMngr lookupSashWindowMngr(Resource diResource) {
-
- return DiUtils.lookupSashWindowsMngr(diResource);
- }
-
- /*
- * Create an instance of IPageMngr acting on the provided resource.
- * This instance is suitable to add, remove, close or open diagrams.
- *
- * @param diResource
- *
- * @return The non transactional version of the IPageMngr
- */
- // public static IPageMngr createIPageMngr(Resource diResource) {
- //
- // // Create an instance of the DiSashModelMngr with no factory.
- // // The factory is not needed since we don't get the ISashWindowsContentProvider.
- // return new DiSashModelManager(null, diResource).getIPageMngr();
- //
- // }
-
- /**
- * Finds a the EditorIDs that can open the given pageIdentifier
- *
- * @param pageIdentifier
- * @return A map of (ID -> Label) for the matching editors
- *
- * @see {@link IPageManager#DEFAULT_EDITOR}
- */
- public Map<String, String> getEditorIDsFor(Object pageIdentifier) {
- return pageModelFactory.getEditorIDsFor(pageIdentifier);
- }
-
-}
+/*****************************************************************************
+ * 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 - bugs 469188, 485220
+ *
+ *****************************************************************************/
+
+package org.eclipse.papyrus.infra.core.sasheditor.di.contentprovider;
+
+import java.util.Map;
+
+import org.eclipse.emf.ecore.resource.Resource;
+import org.eclipse.emf.transaction.RecordingCommand;
+import org.eclipse.emf.transaction.TransactionalEditingDomain;
+import org.eclipse.papyrus.infra.core.sasheditor.contentprovider.IContentChangedProvider;
+import org.eclipse.papyrus.infra.core.sasheditor.contentprovider.ISashWindowsContentProvider;
+import org.eclipse.papyrus.infra.core.sasheditor.di.contentprovider.internal.ContentChangedEventProvider;
+import org.eclipse.papyrus.infra.core.sasheditor.di.contentprovider.internal.CurrentFolderAndPageManager;
+import org.eclipse.papyrus.infra.core.sasheditor.di.contentprovider.internal.DiContentProvider;
+import org.eclipse.papyrus.infra.core.sasheditor.di.contentprovider.internal.ICurrentFolderAndPageMngr;
+import org.eclipse.papyrus.infra.core.sasheditor.di.contentprovider.internal.PageManagerImpl;
+import org.eclipse.papyrus.infra.core.sasheditor.di.contentprovider.internal.TransactionalDiContentProvider;
+import org.eclipse.papyrus.infra.core.sasheditor.di.contentprovider.internal.TransactionalPageManagerImpl;
+import org.eclipse.papyrus.infra.core.sasheditor.di.contentprovider.utils.TransactionHelper;
+import org.eclipse.papyrus.infra.core.sasheditor.editor.ISashWindowsContainer;
+import org.eclipse.papyrus.infra.core.sashwindows.di.SashWindowsMngr;
+import org.eclipse.papyrus.infra.core.sashwindows.di.service.IPageManager;
+import org.eclipse.papyrus.infra.core.sashwindows.di.util.DiUtils;
+
+
+/**
+ * Class used as main entry point to access a sash model build on EMF / di
+ * This class allows to get facade objects on the diSashModel.
+ *
+ * @author cedric dumoulin
+ *
+ */
+public class DiSashModelManager {
+
+ /** The EMF model used to store the sash windows structure and pages */
+ protected SashWindowsMngr sashWindowMngr;
+
+ /**
+ * Instance of the {@link PageManagerImpl}.
+ */
+ private final PageManagerImpl pageMngr;
+
+ /**
+ * Instance of the DiContentProvider used to manipulate SashModel.
+ */
+ private final DiContentProvider contentProvider;
+
+ private final TransactionalDiContentProvider transDiContentProvider;
+
+ private final IPageModelFactory pageModelFactory;
+
+ /**
+ * Object used externally listen to model changes.
+ * The object is also used internally to control how events are fired (limit multiple events).
+ */
+ protected ContentChangedEventProvider contentChangedEventProvider;
+
+ /** The factory used to create IPageModel */
+ // private IPageModelFactory pageModelFactory;
+
+
+ /**
+ *
+ * Constructor.
+ *
+ * @param pageModelFactory
+ * @param diResource
+ * @param currentFolderAndPageMngr
+ */
+ public DiSashModelManager(IPageModelFactory pageModelFactory, final Resource diResource, TransactionalEditingDomain editingDomain, ICurrentFolderAndPageMngr currentFolderAndPageMngr) {
+ // this.pageModelFactory = pageModelFactory;
+
+ // lookup the SashModel
+ sashWindowMngr = lookupSashWindowMngr(diResource);
+ // If no SashWindow structure is found, create a new one using a transaction.
+ if (sashWindowMngr == null) {
+ // Create a default model and attach it to resource.
+ sashWindowMngr = createDefaultSashModel();
+ // Create a command
+ RecordingCommand cmd = new RecordingCommand(editingDomain) {
+
+ @Override
+ protected void doExecute() {
+ diResource.getContents().add(sashWindowMngr);
+ }
+ };
+ // Execute command
+ editingDomain.getCommandStack().execute(cmd);
+ }
+
+ this.pageModelFactory = pageModelFactory;
+
+ contentProvider = new DiContentProvider(sashWindowMngr.getSashModel(), pageModelFactory, contentChangedEventProvider);
+ // Create the TransactionalDiContentProvider
+ transDiContentProvider = new TransactionalDiContentProvider(getDiContentProvider(), editingDomain);
+
+ // Create the TransactionalPageMngrImpl
+ pageMngr = new TransactionalPageManagerImpl(sashWindowMngr, contentChangedEventProvider, currentFolderAndPageMngr);
+ }
+
+ /**
+ *
+ * Constructor.
+ *
+ * @param pageModelFactory
+ * @param diResource
+ * @param currentFolderAndPageMngr
+ */
+ public DiSashModelManager(IPageModelFactory pageModelFactory, final Resource diResource, TransactionalEditingDomain editingDomain) {
+
+ // lookup the SashModel
+ sashWindowMngr = lookupSashWindowMngr(diResource);
+ // If no SashWindow structure is found, create a new one using a transaction.
+ if (sashWindowMngr == null) {
+ // Create a default model and attach it to resource.
+ sashWindowMngr = createDefaultSashModel();
+
+ try {
+ TransactionHelper.run(editingDomain, new Runnable() {
+
+ @Override
+ public void run() {
+ diResource.getContents().add(sashWindowMngr);
+
+ };
+ });
+ } catch (Exception ex) {
+ Activator.log.error(ex);
+ }
+ }
+
+ this.pageModelFactory = pageModelFactory;
+
+ contentProvider = new DiContentProvider(sashWindowMngr.getSashModel(), pageModelFactory, getContentChangedEventProvider());
+ // Create the TransactionalDiContentProvider
+ transDiContentProvider = new TransactionalDiContentProvider(getDiContentProvider(), editingDomain);
+
+ // Create the TransactionalPageMngrImpl
+ pageMngr = new TransactionalPageManagerImpl(sashWindowMngr, getContentChangedEventProvider());
+
+ }
+
+ /**
+ *
+ * @param currentFolderAndPageMngr
+ */
+ public void setCurrentFolderAndPageMngr(ICurrentFolderAndPageMngr currentFolderAndPageMngr) {
+ pageMngr.setCurrentFolderAndPageMngr(currentFolderAndPageMngr);
+ }
+
+ /**
+ * Set the CurrentFolderAndPageManager as an instance of {@link CurrentFolderAndPageManager}
+ *
+ * @param currentFolderAndPageMngr
+ */
+ public void setCurrentFolderAndPageMngr(ISashWindowsContainer sashWindowsContainer) {
+ pageMngr.setCurrentFolderAndPageMngr(new CurrentFolderAndPageManager(sashWindowsContainer));
+ }
+
+ /**
+ *
+ * Constructor.
+ * Only create a {@link IPageMngr} impl. Do not create the DiContentProvider as there is no factory provided.
+ * Internal use.
+ *
+ * @param pageModelFactory
+ * @param diResource
+ */
+ // private DiSashModelManager(final Resource diResource, TransactionalEditingDomain editingDomain, ICurrentFolderAndPageMngr currentFolderAndPageMngr) {
+ // this(null, diResource, editingDomain, currentFolderAndPageMngr);
+ //
+ // }
+
+
+ /**
+ * Get the internal EMF implementation.
+ * Intended to be used by tests.
+ *
+ * @return the sashWindowMngr
+ */
+ protected SashWindowsMngr getDiSashWindowsMngr() {
+ return sashWindowMngr;
+ }
+
+
+ /**
+ * Return the internal implementation of ContentProvider.
+ * Create if if needed.
+ * This method should not be subclassed
+ *
+ * @return the contentProvider
+ */
+ protected DiContentProvider getDiContentProvider() {
+ return contentProvider;
+ }
+
+ /**
+ * Return the internal implementation of ContentProvider.
+ * Create if if needed.
+ * This method should not be subclassed
+ *
+ * @return the contentProvider
+ */
+ protected TransactionalDiContentProvider getTransactionalDiContentProvider() {
+ return transDiContentProvider;
+ }
+
+ /**
+ * Return the internal implementation of PageMngr.
+ * Create if if needed.
+ * This method should not be subclassed
+ *
+ * @return the PageMngrImpl
+ */
+ protected final PageManagerImpl getPageManagerImpl() {
+ return pageMngr;
+ }
+
+ /**
+ * Return the internal implementation of ContentChangedEventProvider.
+ * Create if if needed.
+ * This method should not be subclassed
+ *
+ * @return the PageMngrImpl
+ */
+ protected final ContentChangedEventProvider getContentChangedEventProvider() {
+ if (contentChangedEventProvider == null) {
+ contentChangedEventProvider = new ContentChangedEventProvider(sashWindowMngr);
+ }
+
+ return contentChangedEventProvider;
+ }
+
+ /**
+ * Get the IPageManager providing basic methods to manage Pages in the sash model.
+ *
+ * @return
+ * @since 2.0
+ */
+ public IPageManager getIPageManager() {
+ return getPageManagerImpl();
+ }
+
+ /**
+ * Get the ContentProvider used by the SashWindows system.
+ * This class can also be used to accurately manage the sash model.
+ *
+ * @return
+ */
+ public ISashWindowsContentProvider getISashWindowsContentProvider() {
+
+ return getTransactionalDiContentProvider();
+
+ }
+
+ /**
+ * Get the ContentChangedProvider for the SashModel
+ *
+ * @return
+ */
+ public IContentChangedProvider getSashModelContentChangedProvider() {
+ return getContentChangedEventProvider();
+ }
+
+ /**
+ * Create a default model with one window and one folder.
+ *
+ * @param diResource
+ * @return
+ */
+ protected SashWindowsMngr createDefaultSashModel() {
+ SashWindowsMngr result = DiUtils.createDefaultSashWindowsMngr();
+
+ if (result.getSashModel() != null) {
+ // Default this to true for new models, which store the sash model
+ // in the workspace private area by default
+ result.getSashModel().setRestoreActivePage(true);
+ }
+
+ return result;
+ }
+
+ /**
+ * Lookup for the SashModel object in the resource
+ *
+ * @param diResource
+ * @return
+ */
+ protected SashWindowsMngr lookupSashWindowMngr(Resource diResource) {
+
+ return DiUtils.lookupSashWindowsMngr(diResource);
+ }
+
+ /*
+ * Create an instance of IPageMngr acting on the provided resource.
+ * This instance is suitable to add, remove, close or open diagrams.
+ *
+ * @param diResource
+ *
+ * @return The non transactional version of the IPageMngr
+ */
+ // public static IPageMngr createIPageMngr(Resource diResource) {
+ //
+ // // Create an instance of the DiSashModelMngr with no factory.
+ // // The factory is not needed since we don't get the ISashWindowsContentProvider.
+ // return new DiSashModelManager(null, diResource).getIPageMngr();
+ //
+ // }
+
+ /**
+ * Finds a the EditorIDs that can open the given pageIdentifier
+ *
+ * @param pageIdentifier
+ * @return A map of (ID -> Label) for the matching editors
+ *
+ * @see {@link IPageManager#DEFAULT_EDITOR}
+ * @since 2.0
+ */
+ public Map<String, String> getEditorIDsFor(Object pageIdentifier) {
+ return pageModelFactory.getEditorIDsFor(pageIdentifier);
+ }
+
+}
diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/custom-src/org/eclipse/papyrus/infra/core/sasheditor/di/contentprovider/DiSashModelMngr.java b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/custom-src/org/eclipse/papyrus/infra/core/sasheditor/di/contentprovider/DiSashModelMngr.java
index 75a65785394..ab174d6f9cc 100644
--- a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/custom-src/org/eclipse/papyrus/infra/core/sasheditor/di/contentprovider/DiSashModelMngr.java
+++ b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/custom-src/org/eclipse/papyrus/infra/core/sasheditor/di/contentprovider/DiSashModelMngr.java
@@ -1,251 +1,253 @@
-/*****************************************************************************
- * Copyright (c) 2009, 2015 CEA LIST & LIFL, 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 469188
- *
- *****************************************************************************/
-
-package org.eclipse.papyrus.infra.core.sasheditor.di.contentprovider;
-
-import org.eclipse.emf.ecore.resource.Resource;
-import org.eclipse.papyrus.infra.core.sasheditor.contentprovider.IContentChangedProvider;
-import org.eclipse.papyrus.infra.core.sasheditor.contentprovider.ISashWindowsContentProvider;
-import org.eclipse.papyrus.infra.core.sasheditor.di.contentprovider.internal.ContentChangedEventProvider;
-import org.eclipse.papyrus.infra.core.sasheditor.di.contentprovider.internal.DiContentProvider;
-import org.eclipse.papyrus.infra.core.sasheditor.di.contentprovider.internal.PageManagerImpl;
-import org.eclipse.papyrus.infra.core.sasheditor.di.contentprovider.internal.TransactionalPageManagerImpl;
-import org.eclipse.papyrus.infra.core.sashwindows.di.SashWindowsMngr;
-import org.eclipse.papyrus.infra.core.sashwindows.di.service.IPageManager;
-import org.eclipse.papyrus.infra.core.sashwindows.di.util.DiUtils;
-
-
-/**
- * Class used as main entry point to access a sash model build on EMF / di
- *
- * @author cedric dumoulin
- */
-public class DiSashModelMngr {
-
- /** The EMF model used to store the sash windows structure and pages */
- protected SashWindowsMngr sashWindowMngr;
-
- /**
- * Instance of the pageMngr.
- */
- private PageManagerImpl pageMngr = null;
-
- /**
- * Instance of the DiContentProvider used to manipulate SashModel.
- */
- private DiContentProvider contentProvider;
-
- /**
- * Object used externally listen to model changes.
- * The object is also used internally to control how events are fired (limit multiple events).
- */
- protected ContentChangedEventProvider contentChangedEventProvider;
-
- /** The factory used to create IPageModel */
- private IPageModelFactory pageModelFactory;
-
-
- /**
- * Constructor.
- * Create a DiSashModelMngr with the specified factory. A SashModel is created but not attached to a resource.
- * This constructor is for subclasses. The subclasses should initialize the sashWindowMngr
- *
- * @param pageModelFactory
- * @param createDefaultSashModel
- * If true, create the default SashModel by calling {@link #createDefaultSashModel()}
- */
- protected DiSashModelMngr(IPageModelFactory pageModelFactory, boolean createDefaultSashModel) {
- this.pageModelFactory = pageModelFactory;
- // Create a SashModel
- if (createDefaultSashModel) {
- sashWindowMngr = createDefaultSashModel();
- }
- }
-
- /**
- * Constructor.
- * Create a DiSashModelMngr with the specified factory. A SashModel is created but not attached to a resource.
- *
- * @param pageModelFactory
- */
- public DiSashModelMngr(IPageModelFactory pageModelFactory) {
- this.pageModelFactory = pageModelFactory;
- // Create a SashModel
- sashWindowMngr = createDefaultSashModel();
- }
-
- /**
- * Constructor.
- * Create a DiSashModelMngr with the specified factory. The SashModel is searched in the Resource. If not found,
- * create one in the resource.
- *
- * @param pageModelFactory
- * @param diResource
- */
- public DiSashModelMngr(IPageModelFactory pageModelFactory, Resource diResource) {
- this.pageModelFactory = pageModelFactory;
-
- // lookup the SashModel
- sashWindowMngr = lookupSashWindowMngr(diResource);
- if (sashWindowMngr == null) {
- // Create a default model and attach it to resource.
- sashWindowMngr = createDefaultSashModel();
- diResource.getContents().add(sashWindowMngr);
- }
- }
-
- /**
- * Constructor.
- * Create a DiSashModelMngr with the specified factory and sashModel.
- *
- * @param pageModelFactory
- * @param sashModel
- */
- public DiSashModelMngr(IPageModelFactory pageModelFactory, SashWindowsMngr sashModel) {
- this.pageModelFactory = pageModelFactory;
- this.sashWindowMngr = sashModel;
- }
-
- /**
- * Get the internal EMF implementation.
- * Intended to be used by tests.
- *
- * @return the sashWindowMngr
- */
- protected SashWindowsMngr getDiSashWindowsMngr() {
- return sashWindowMngr;
- }
-
-
- /**
- * Return the internal implementation of ContentProvider.
- * Create if if needed.
- * This method should not be subclassed
- *
- * @return the contentProvider
- */
- protected final DiContentProvider getDiContentProvider() {
- if (contentProvider == null) {
- contentProvider = new DiContentProvider(sashWindowMngr.getSashModel(), pageModelFactory, getContentChangedEventProvider());
- }
- return contentProvider;
- }
-
- /**
- * Return the internal implementation of PageMngr.
- * Create if if needed.
- * This method should not be subclassed
- *
- * @return the PageMngrImpl
- */
- protected final PageManagerImpl getPageMngrImpl() {
- if (pageMngr == null) {
- pageMngr = new TransactionalPageManagerImpl(sashWindowMngr, getContentChangedEventProvider());
- }
-
- return pageMngr;
- }
-
- /**
- * Return the internal implementation of ContentChangedEventProvider.
- * Create if if needed.
- * This method should not be subclassed
- *
- * @return the PageMngrImpl
- */
- protected final ContentChangedEventProvider getContentChangedEventProvider() {
- if (contentChangedEventProvider == null) {
- contentChangedEventProvider = new ContentChangedEventProvider(sashWindowMngr);
- }
-
- return contentChangedEventProvider;
- }
-
- /**
- * Get the IPageMngr providing basic methods to manage Pages in the sash model.
- *
- * @return
- */
- public IPageManager getIPageMngr() {
- return getPageMngrImpl();
- }
-
- /**
- * Get the ContentProvider used by the SashWindows system.
- * This class can also be used to accurately manage the sash model.
- *
- * @return
- */
- public ISashWindowsContentProvider getISashWindowsContentProvider() {
-
- return getDiContentProvider();
-
- }
-
- /**
- * Get the ContentChangedProvider for the SashModel
- *
- * @return
- */
- public IContentChangedProvider getSashModelContentChangedProvider() {
- return getContentChangedEventProvider();
- }
-
- /**
- * Create a default model with one window and one folder.
- *
- * @param diResource
- * @return
- */
- protected SashWindowsMngr createDefaultSashModel() {
- SashWindowsMngr result = DiUtils.createDefaultSashWindowsMngr();
-
- if (result.getSashModel() != null) {
- // Default this to true for new models, which store the sash model
- // in the workspace private area by default
- result.getSashModel().setRestoreActivePage(true);
- }
-
- return result;
- }
-
- /**
- * Lookup for the SashModel object in the resource
- *
- * @param diResource
- * @return
- */
- protected SashWindowsMngr lookupSashWindowMngr(Resource diResource) {
-
- return DiUtils.lookupSashWindowsMngr(diResource);
- }
-
- /**
- * Create an instance of IPageMngr acting on the provided resource.
- * This instance is suitable to add, remove, close or open diagrams.
- *
- * @param diResource
- * @return The non transactional version of the IPageMngr
- */
- public static IPageManager createIPageMngr(Resource diResource) {
-
- // Create an instance of the DiSashModelMngr with no factory.
- // The factory is not needed since we don't get the ISashWindowsContentProvider.
- return new DiSashModelMngr(null, diResource).getIPageMngr();
-
- }
-
-
-}
+/*****************************************************************************
+ * Copyright (c) 2009, 2015 CEA LIST & LIFL, 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 469188
+ *
+ *****************************************************************************/
+
+package org.eclipse.papyrus.infra.core.sasheditor.di.contentprovider;
+
+import org.eclipse.emf.ecore.resource.Resource;
+import org.eclipse.papyrus.infra.core.sasheditor.contentprovider.IContentChangedProvider;
+import org.eclipse.papyrus.infra.core.sasheditor.contentprovider.ISashWindowsContentProvider;
+import org.eclipse.papyrus.infra.core.sasheditor.di.contentprovider.internal.ContentChangedEventProvider;
+import org.eclipse.papyrus.infra.core.sasheditor.di.contentprovider.internal.DiContentProvider;
+import org.eclipse.papyrus.infra.core.sasheditor.di.contentprovider.internal.PageManagerImpl;
+import org.eclipse.papyrus.infra.core.sasheditor.di.contentprovider.internal.TransactionalPageManagerImpl;
+import org.eclipse.papyrus.infra.core.sashwindows.di.SashWindowsMngr;
+import org.eclipse.papyrus.infra.core.sashwindows.di.service.IPageManager;
+import org.eclipse.papyrus.infra.core.sashwindows.di.util.DiUtils;
+
+
+/**
+ * Class used as main entry point to access a sash model build on EMF / di
+ *
+ * @author cedric dumoulin
+ */
+public class DiSashModelMngr {
+
+ /** The EMF model used to store the sash windows structure and pages */
+ protected SashWindowsMngr sashWindowMngr;
+
+ /**
+ * Instance of the pageMngr.
+ */
+ private PageManagerImpl pageMngr = null;
+
+ /**
+ * Instance of the DiContentProvider used to manipulate SashModel.
+ */
+ private DiContentProvider contentProvider;
+
+ /**
+ * Object used externally listen to model changes.
+ * The object is also used internally to control how events are fired (limit multiple events).
+ */
+ protected ContentChangedEventProvider contentChangedEventProvider;
+
+ /** The factory used to create IPageModel */
+ private IPageModelFactory pageModelFactory;
+
+
+ /**
+ * Constructor.
+ * Create a DiSashModelMngr with the specified factory. A SashModel is created but not attached to a resource.
+ * This constructor is for subclasses. The subclasses should initialize the sashWindowMngr
+ *
+ * @param pageModelFactory
+ * @param createDefaultSashModel
+ * If true, create the default SashModel by calling {@link #createDefaultSashModel()}
+ */
+ protected DiSashModelMngr(IPageModelFactory pageModelFactory, boolean createDefaultSashModel) {
+ this.pageModelFactory = pageModelFactory;
+ // Create a SashModel
+ if (createDefaultSashModel) {
+ sashWindowMngr = createDefaultSashModel();
+ }
+ }
+
+ /**
+ * Constructor.
+ * Create a DiSashModelMngr with the specified factory. A SashModel is created but not attached to a resource.
+ *
+ * @param pageModelFactory
+ */
+ public DiSashModelMngr(IPageModelFactory pageModelFactory) {
+ this.pageModelFactory = pageModelFactory;
+ // Create a SashModel
+ sashWindowMngr = createDefaultSashModel();
+ }
+
+ /**
+ * Constructor.
+ * Create a DiSashModelMngr with the specified factory. The SashModel is searched in the Resource. If not found,
+ * create one in the resource.
+ *
+ * @param pageModelFactory
+ * @param diResource
+ */
+ public DiSashModelMngr(IPageModelFactory pageModelFactory, Resource diResource) {
+ this.pageModelFactory = pageModelFactory;
+
+ // lookup the SashModel
+ sashWindowMngr = lookupSashWindowMngr(diResource);
+ if (sashWindowMngr == null) {
+ // Create a default model and attach it to resource.
+ sashWindowMngr = createDefaultSashModel();
+ diResource.getContents().add(sashWindowMngr);
+ }
+ }
+
+ /**
+ * Constructor.
+ * Create a DiSashModelMngr with the specified factory and sashModel.
+ *
+ * @param pageModelFactory
+ * @param sashModel
+ */
+ public DiSashModelMngr(IPageModelFactory pageModelFactory, SashWindowsMngr sashModel) {
+ this.pageModelFactory = pageModelFactory;
+ this.sashWindowMngr = sashModel;
+ }
+
+ /**
+ * Get the internal EMF implementation.
+ * Intended to be used by tests.
+ *
+ * @return the sashWindowMngr
+ */
+ protected SashWindowsMngr getDiSashWindowsMngr() {
+ return sashWindowMngr;
+ }
+
+
+ /**
+ * Return the internal implementation of ContentProvider.
+ * Create if if needed.
+ * This method should not be subclassed
+ *
+ * @return the contentProvider
+ */
+ protected final DiContentProvider getDiContentProvider() {
+ if (contentProvider == null) {
+ contentProvider = new DiContentProvider(sashWindowMngr.getSashModel(), pageModelFactory, getContentChangedEventProvider());
+ }
+ return contentProvider;
+ }
+
+ /**
+ * Return the internal implementation of PageMngr.
+ * Create if if needed.
+ * This method should not be subclassed
+ *
+ * @return the PageMngrImpl
+ */
+ protected final PageManagerImpl getPageMngrImpl() {
+ if (pageMngr == null) {
+ pageMngr = new TransactionalPageManagerImpl(sashWindowMngr, getContentChangedEventProvider());
+ }
+
+ return pageMngr;
+ }
+
+ /**
+ * Return the internal implementation of ContentChangedEventProvider.
+ * Create if if needed.
+ * This method should not be subclassed
+ *
+ * @return the PageMngrImpl
+ */
+ protected final ContentChangedEventProvider getContentChangedEventProvider() {
+ if (contentChangedEventProvider == null) {
+ contentChangedEventProvider = new ContentChangedEventProvider(sashWindowMngr);
+ }
+
+ return contentChangedEventProvider;
+ }
+
+ /**
+ * Get the IPageMngr providing basic methods to manage Pages in the sash model.
+ *
+ * @return
+ * @since 2.0
+ */
+ public IPageManager getIPageMngr() {
+ return getPageMngrImpl();
+ }
+
+ /**
+ * Get the ContentProvider used by the SashWindows system.
+ * This class can also be used to accurately manage the sash model.
+ *
+ * @return
+ */
+ public ISashWindowsContentProvider getISashWindowsContentProvider() {
+
+ return getDiContentProvider();
+
+ }
+
+ /**
+ * Get the ContentChangedProvider for the SashModel
+ *
+ * @return
+ */
+ public IContentChangedProvider getSashModelContentChangedProvider() {
+ return getContentChangedEventProvider();
+ }
+
+ /**
+ * Create a default model with one window and one folder.
+ *
+ * @param diResource
+ * @return
+ */
+ protected SashWindowsMngr createDefaultSashModel() {
+ SashWindowsMngr result = DiUtils.createDefaultSashWindowsMngr();
+
+ if (result.getSashModel() != null) {
+ // Default this to true for new models, which store the sash model
+ // in the workspace private area by default
+ result.getSashModel().setRestoreActivePage(true);
+ }
+
+ return result;
+ }
+
+ /**
+ * Lookup for the SashModel object in the resource
+ *
+ * @param diResource
+ * @return
+ */
+ protected SashWindowsMngr lookupSashWindowMngr(Resource diResource) {
+
+ return DiUtils.lookupSashWindowsMngr(diResource);
+ }
+
+ /**
+ * Create an instance of IPageMngr acting on the provided resource.
+ * This instance is suitable to add, remove, close or open diagrams.
+ *
+ * @param diResource
+ * @return The non transactional version of the IPageMngr
+ * @since 2.0
+ */
+ public static IPageManager createIPageMngr(Resource diResource) {
+
+ // Create an instance of the DiSashModelMngr with no factory.
+ // The factory is not needed since we don't get the ISashWindowsContentProvider.
+ return new DiSashModelMngr(null, diResource).getIPageMngr();
+
+ }
+
+
+}
diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/custom-src/org/eclipse/papyrus/infra/core/sasheditor/di/contentprovider/IPageModelFactory.java b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/custom-src/org/eclipse/papyrus/infra/core/sasheditor/di/contentprovider/IPageModelFactory.java
index c9a5991f9e7..eed593316ca 100644
--- a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/custom-src/org/eclipse/papyrus/infra/core/sasheditor/di/contentprovider/IPageModelFactory.java
+++ b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/custom-src/org/eclipse/papyrus/infra/core/sasheditor/di/contentprovider/IPageModelFactory.java
@@ -1,76 +1,80 @@
-/*****************************************************************************
- * Copyright (c) 2009 - 2015 CEA LIST & LIFL
- *
- * 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
- * Camille Letavernier (CEA LIST) - camille.letavernier@cea.fr - Bug 476625
- *****************************************************************************/
-package org.eclipse.papyrus.infra.core.sasheditor.di.contentprovider;
-
-import java.util.Collections;
-import java.util.Map;
-
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.papyrus.infra.core.sasheditor.contentprovider.IPageModel;
-import org.eclipse.papyrus.infra.core.sashwindows.di.service.IPageManager;
-
-
-/**
- * Factory used to create IPageModel from an object identifying a page.
- * IPageModel are objects used by the Sash Windows to create a page.
- *
- * @author cedric dumoulin
- */
-public interface IPageModelFactory {
-
- /**
- * Generic EditorID that represents the default editor associated to any page identifier
- */
- String DEFAULT_EDITOR = IPageManager.class.getCanonicalName() + ".Default";
-
- /**
- * Create the IPageModel for the pageIdentifier. The pageIdentifier is the object passed to
- * the {@link IPageManager#addEditor(EObject)}.
- * This factory method is called by the Sash Windows whenever it needs to create a page. The identifier
- * is found in the sash model.
- *
- * @param pageIdentifier
- * The identifier identifying the page to create.
- * @return
- */
- public IPageModel createIPageModel(Object pageIdentifier);
-
- /**
- * @see org.eclipse.papyrus.infra.core.sasheditor.di.contentprovider.IPageModelFactory#createIPageModel(java.lang.Object)
- *
- * @param pageIdentifier
- * @return
- */
- default IPageModel createIPageModel(Object pageIdentifier, String favoriteEditorID) {
- return createIPageModel(pageIdentifier);
- }
-
- /**
- * Finds the EditorIDs that can open the given pageIdentifier. This list is a hint
- *
- * The exact behavior is implementation-specific; this method shouldn't be used
- * to determine whether a page identifier can actually be opened.
- *
- * Implementations may return a list containing the {@link IPageManager#DEFAULT_EDITOR} ID,
- * and the list might be incomplete (i.e. editors not listed might
- * still be able to open the given pageIdentifier)
- *
- * @param pageIdentifier
- * @return A map of (ID -> Label) of the editors that can open the given page
- *
- * @see {@link IPageManager#DEFAULT_EDITOR}
- */
- default Map<String, String> getEditorIDsFor(Object pageIdentifier) {
- return Collections.singletonMap(DEFAULT_EDITOR, "Default editor");
- }
-}
+/*****************************************************************************
+ * Copyright (c) 2009 - 2015 CEA LIST & LIFL
+ *
+ * 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
+ * Camille Letavernier (CEA LIST) - camille.letavernier@cea.fr - Bug 476625
+ *****************************************************************************/
+package org.eclipse.papyrus.infra.core.sasheditor.di.contentprovider;
+
+import java.util.Collections;
+import java.util.Map;
+
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.papyrus.infra.core.sasheditor.contentprovider.IPageModel;
+import org.eclipse.papyrus.infra.core.sashwindows.di.service.IPageManager;
+
+
+/**
+ * Factory used to create IPageModel from an object identifying a page.
+ * IPageModel are objects used by the Sash Windows to create a page.
+ *
+ * @author cedric dumoulin
+ */
+public interface IPageModelFactory {
+
+ /**
+ * Generic EditorID that represents the default editor associated to any page identifier
+ *
+ * @since 2.0
+ */
+ String DEFAULT_EDITOR = IPageManager.class.getCanonicalName() + ".Default";
+
+ /**
+ * Create the IPageModel for the pageIdentifier. The pageIdentifier is the object passed to
+ * the {@link IPageManager#addEditor(EObject)}.
+ * This factory method is called by the Sash Windows whenever it needs to create a page. The identifier
+ * is found in the sash model.
+ *
+ * @param pageIdentifier
+ * The identifier identifying the page to create.
+ * @return
+ */
+ public IPageModel createIPageModel(Object pageIdentifier);
+
+ /**
+ * @see org.eclipse.papyrus.infra.core.sasheditor.di.contentprovider.IPageModelFactory#createIPageModel(java.lang.Object)
+ *
+ * @param pageIdentifier
+ * @return
+ * @since 2.0
+ */
+ default IPageModel createIPageModel(Object pageIdentifier, String favoriteEditorID) {
+ return createIPageModel(pageIdentifier);
+ }
+
+ /**
+ * Finds the EditorIDs that can open the given pageIdentifier. This list is a hint
+ *
+ * The exact behavior is implementation-specific; this method shouldn't be used
+ * to determine whether a page identifier can actually be opened.
+ *
+ * Implementations may return a list containing the {@link IPageManager#DEFAULT_EDITOR} ID,
+ * and the list might be incomplete (i.e. editors not listed might
+ * still be able to open the given pageIdentifier)
+ *
+ * @param pageIdentifier
+ * @return A map of (ID -> Label) of the editors that can open the given page
+ *
+ * @see {@link IPageManager#DEFAULT_EDITOR}
+ * @since 2.0
+ */
+ default Map<String, String> getEditorIDsFor(Object pageIdentifier) {
+ return Collections.singletonMap(DEFAULT_EDITOR, "Default editor");
+ }
+}
diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/custom-src/org/eclipse/papyrus/infra/core/sasheditor/di/contentprovider/internal/PageManagerImpl.java b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/custom-src/org/eclipse/papyrus/infra/core/sasheditor/di/contentprovider/internal/PageManagerImpl.java
index 9430edf2787..df2826bf9d3 100644
--- a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/custom-src/org/eclipse/papyrus/infra/core/sasheditor/di/contentprovider/internal/PageManagerImpl.java
+++ b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/custom-src/org/eclipse/papyrus/infra/core/sasheditor/di/contentprovider/internal/PageManagerImpl.java
@@ -1,163 +1,166 @@
-/*****************************************************************************
- * Copyright (c) 2013, 2014 Cedric Dumoulin, CEA, 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 (CEA) - bug 433371
- * Céline Janssens (ALL4TEC) celine.janssens@all4tec.net - Bug 415638
- * Gabriel Pascual (ALL4TEC) gabriel.pascual@all4tec.net - Bug 440754
- *****************************************************************************/
-
-package org.eclipse.papyrus.infra.core.sasheditor.di.contentprovider.internal;
-
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.papyrus.infra.core.sasheditor.di.contentprovider.IOpenable;
-import org.eclipse.papyrus.infra.core.sashwindows.di.SashWindowsMngr;
-import org.eclipse.papyrus.infra.core.sashwindows.di.TabFolder;
-import org.eclipse.papyrus.infra.core.sashwindows.di.service.BasicPageManagerImpl;
-import org.eclipse.swt.widgets.Display;
-
-
-/**
- * This class provide high level method to manage the Sash pages through its DI
- * implementation.
- *
- * @author cedric dumoulin
- *
- */
-public class PageManagerImpl extends BasicPageManagerImpl {
-
- /**
- * An object used to get the current folder, or to ask to set the
- * active page.
- * This is usually backuped by the SashWindowContainer. <br>
- */
- private ICurrentFolderAndPageMngr folderAndPageMngr;
-
- private ContentChangedEventProvider contentChangedEventProvider;
-
- /**
- * Constructor.
- * Use a default {@link ICurrentFolderAndPageMngr} that alwayrs use the first
- * folder as the current folder. Futhermore, the default implementation doesn't
- * allow to set the active folder. <br>
- * Suitable for tests
- *
- * @param diSashModel
- * The model onto which operation of this class act.
- * @param contentChangedEventProvider
- * A class listening on changes on the internal model and delivering events to registered listeners. This implementation
- * need the class in order to deactivate event triggering during the operations.
- *
- */
- protected PageManagerImpl(SashWindowsMngr diSashModel, ContentChangedEventProvider contentChangedEventProvider) {
- super(diSashModel);
-
- this.contentChangedEventProvider = contentChangedEventProvider;
- this.folderAndPageMngr = new DefaultCurrentFolderAndPageMngr(diSashModel);
- }
-
- /**
- * Constructor.
- *
- * @param diSashModel
- * the di sash model
- * @param contentChangedEventProvider
- * the content changed event provider
- * @param folderAndPageMngr
- * the folder and page mngr
- */
- protected PageManagerImpl(SashWindowsMngr diSashModel, ContentChangedEventProvider contentChangedEventProvider, ICurrentFolderAndPageMngr folderAndPageMngr) {
- super(diSashModel);
-
- this.contentChangedEventProvider = contentChangedEventProvider;
- this.folderAndPageMngr = folderAndPageMngr;
- }
-
- @Override
- protected TabFolder getCurrentFolder() {
- return folderAndPageMngr.getCurrentFolder();
- }
-
- @Override
- protected boolean isLegacyMode() {
- // We are never in legacy mode even if there is a page list
- return false;
- }
-
- @Override
- protected boolean isPage(EObject content) {
- return Platform.getAdapterManager().getAdapter(content, IOpenable.class) != null;
- }
-
- @Override
- public void closePage(Object pageIdentifier) {
- // Suppress event notifications
- doExecute(() -> super.closePage(pageIdentifier));
- }
-
- @Override
- public void closeAllOpenedPages() {
- // Suppress event notifications
- doExecute(() -> super.closeAllOpenedPages());
- }
-
- @Override
- public void closeOtherPages(Object pageIdentifier) {
- // Suppress event notifications
- doExecute(() -> super.closeOtherPages(pageIdentifier));
- }
-
- @Override
- public void selectPage(final Object pageIdentifier) {
- Display.getDefault().syncExec(new Runnable() {
-
- @Override
- public void run() {
- folderAndPageMngr.setActivePage(pageIdentifier);
- }
- });
- }
-
- /**
- * Sets the current folder and page mngr.
- *
- * @param currentFolderAndPageMngr
- * the new current folder and page mngr
- */
- public void setCurrentFolderAndPageMngr(ICurrentFolderAndPageMngr currentFolderAndPageMngr) {
- this.folderAndPageMngr = currentFolderAndPageMngr;
-
- }
-
- @Override
- protected <T> T doExecute(SashModelOperation<T> sashModelOperation) {
- T result;
-
- final boolean deliver = contentChangedEventProvider.isDeliver();
-
- contentChangedEventProvider.setDeliver(false);
- try {
- result = super.doExecute(sashModelOperation);
- } finally {
- contentChangedEventProvider.setDeliver(deliver);
- }
-
- return result;
- }
-
- private void doExecute(Runnable sashModelOperation) {
- doExecute(ignored -> {
- sashModelOperation.run();
- return ignored;
- });
- }
-
+/*****************************************************************************
+ * Copyright (c) 2013, 2014 Cedric Dumoulin, CEA, 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 (CEA) - bug 433371
+ * Céline Janssens (ALL4TEC) celine.janssens@all4tec.net - Bug 415638
+ * Gabriel Pascual (ALL4TEC) gabriel.pascual@all4tec.net - Bug 440754
+ *****************************************************************************/
+
+package org.eclipse.papyrus.infra.core.sasheditor.di.contentprovider.internal;
+
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.papyrus.infra.core.sasheditor.di.contentprovider.IOpenable;
+import org.eclipse.papyrus.infra.core.sashwindows.di.SashWindowsMngr;
+import org.eclipse.papyrus.infra.core.sashwindows.di.TabFolder;
+import org.eclipse.papyrus.infra.core.sashwindows.di.service.BasicPageManagerImpl;
+import org.eclipse.swt.widgets.Display;
+
+
+/**
+ * This class provide high level method to manage the Sash pages through its DI
+ * implementation.
+ *
+ * @author cedric dumoulin
+ *
+ */
+public class PageManagerImpl extends BasicPageManagerImpl {
+
+ /**
+ * An object used to get the current folder, or to ask to set the
+ * active page.
+ * This is usually backuped by the SashWindowContainer. <br>
+ */
+ private ICurrentFolderAndPageMngr folderAndPageMngr;
+
+ private ContentChangedEventProvider contentChangedEventProvider;
+
+ /**
+ * Constructor.
+ * Use a default {@link ICurrentFolderAndPageMngr} that alwayrs use the first
+ * folder as the current folder. Futhermore, the default implementation doesn't
+ * allow to set the active folder. <br>
+ * Suitable for tests
+ *
+ * @param diSashModel
+ * The model onto which operation of this class act.
+ * @param contentChangedEventProvider
+ * A class listening on changes on the internal model and delivering events to registered listeners. This implementation
+ * need the class in order to deactivate event triggering during the operations.
+ *
+ */
+ protected PageManagerImpl(SashWindowsMngr diSashModel, ContentChangedEventProvider contentChangedEventProvider) {
+ super(diSashModel);
+
+ this.contentChangedEventProvider = contentChangedEventProvider;
+ this.folderAndPageMngr = new DefaultCurrentFolderAndPageMngr(diSashModel);
+ }
+
+ /**
+ * Constructor.
+ *
+ * @param diSashModel
+ * the di sash model
+ * @param contentChangedEventProvider
+ * the content changed event provider
+ * @param folderAndPageMngr
+ * the folder and page mngr
+ */
+ protected PageManagerImpl(SashWindowsMngr diSashModel, ContentChangedEventProvider contentChangedEventProvider, ICurrentFolderAndPageMngr folderAndPageMngr) {
+ super(diSashModel);
+
+ this.contentChangedEventProvider = contentChangedEventProvider;
+ this.folderAndPageMngr = folderAndPageMngr;
+ }
+
+ @Override
+ protected TabFolder getCurrentFolder() {
+ return folderAndPageMngr.getCurrentFolder();
+ }
+
+ @Override
+ protected boolean isLegacyMode() {
+ // We are never in legacy mode even if there is a page list
+ return false;
+ }
+
+ /**
+ * @since 2.0
+ */
+ @Override
+ protected boolean isPage(EObject content) {
+ return Platform.getAdapterManager().getAdapter(content, IOpenable.class) != null;
+ }
+
+ @Override
+ public void closePage(Object pageIdentifier) {
+ // Suppress event notifications
+ doExecute(() -> super.closePage(pageIdentifier));
+ }
+
+ @Override
+ public void closeAllOpenedPages() {
+ // Suppress event notifications
+ doExecute(() -> super.closeAllOpenedPages());
+ }
+
+ @Override
+ public void closeOtherPages(Object pageIdentifier) {
+ // Suppress event notifications
+ doExecute(() -> super.closeOtherPages(pageIdentifier));
+ }
+
+ @Override
+ public void selectPage(final Object pageIdentifier) {
+ Display.getDefault().syncExec(new Runnable() {
+
+ @Override
+ public void run() {
+ folderAndPageMngr.setActivePage(pageIdentifier);
+ }
+ });
+ }
+
+ /**
+ * Sets the current folder and page mngr.
+ *
+ * @param currentFolderAndPageMngr
+ * the new current folder and page mngr
+ */
+ public void setCurrentFolderAndPageMngr(ICurrentFolderAndPageMngr currentFolderAndPageMngr) {
+ this.folderAndPageMngr = currentFolderAndPageMngr;
+
+ }
+
+ @Override
+ protected <T> T doExecute(SashModelOperation<T> sashModelOperation) {
+ T result;
+
+ final boolean deliver = contentChangedEventProvider.isDeliver();
+
+ contentChangedEventProvider.setDeliver(false);
+ try {
+ result = super.doExecute(sashModelOperation);
+ } finally {
+ contentChangedEventProvider.setDeliver(deliver);
+ }
+
+ return result;
+ }
+
+ private void doExecute(Runnable sashModelOperation) {
+ doExecute(ignored -> {
+ sashModelOperation.run();
+ return ignored;
+ });
+ }
+
} \ No newline at end of file
diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/custom-src/org/eclipse/papyrus/infra/core/sasheditor/di/contentprovider/utils/IPageUtils.java b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/custom-src/org/eclipse/papyrus/infra/core/sasheditor/di/contentprovider/utils/IPageUtils.java
index a719de92179..d80bdfdf3a1 100644
--- a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/custom-src/org/eclipse/papyrus/infra/core/sasheditor/di/contentprovider/utils/IPageUtils.java
+++ b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/custom-src/org/eclipse/papyrus/infra/core/sasheditor/di/contentprovider/utils/IPageUtils.java
@@ -1,86 +1,87 @@
-/*****************************************************************************
- * Copyright (c) 2010, 2015 LIFL, 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:
- * Cedric Dumoulin (LIFL) cedric.dumoulin@lifl.fr - Initial API and implementation
- * Christian W. Damus (CEA) - bug 433371
- * Christian W. Damus - bug 469188
- *
- *****************************************************************************/
-
-package org.eclipse.papyrus.infra.core.sasheditor.di.contentprovider.utils;
-
-import org.eclipse.core.runtime.IAdaptable;
-import org.eclipse.papyrus.infra.core.sasheditor.editor.ICloseablePart;
-import org.eclipse.papyrus.infra.core.sasheditor.editor.IPage;
-import org.eclipse.papyrus.infra.core.sasheditor.editor.ISashWindowsContainer;
-import org.eclipse.papyrus.infra.core.sashwindows.di.PageRef;
-
-
-/**
- * Class providing a utility methods allowing to get the real Model from the {@link IPage#getRawModel()}.
- * The utility takes into account the bug 309943.
- *
- * @author cedric dumoulin
- *
- */
-public class IPageUtils {
-
- /**
- * Get the real model rather than the PageRef. This method is a trick to temporally solve the bug 309943.
- *
- * @param page
- * @return
- */
- public static Object getRawModel(IPage page) {
-
- if (page == null) {
- return null;
- }
-
- Object pageModel = page.getRawModel();
- // Get the real model because of bug
- if (pageModel instanceof PageRef) {
- return ((PageRef) pageModel).getPageIdentifier();
- }
- // do not use trick
- return pageModel;
- }
-
- /**
- * Lookup the IPage model corresponding to the identifier from the {@link ISashWindowsContainer}.
- * The identifier can be either a {@link PageRef} or a emf Diagram. <br>
- * This method can be used as a hack to bug 401107
- *
- * @param container
- * @param identifier
- * @return The corresponding IPage, or null if not found.
- */
- public static IPage lookupModelPage(ISashWindowsContainer container, Object identifier) {
-
- LookupIPageVisitor visitor = new LookupIPageVisitor(identifier);
- container.visit(visitor);
- return visitor.getResult();
- }
-
- /**
- * Queries whether the user should be permitted to close a {@code page}.
- *
- * @param page
- * a page
- * @return whether it can be closed
- */
- public static boolean canClose(IPage page) {
- ICloseablePart closeable = (page instanceof IAdaptable)
- ? ((IAdaptable) page).getAdapter(ICloseablePart.class)
- : null;
-
- return (closeable == null) || closeable.canClose();
- }
-}
+/*****************************************************************************
+ * Copyright (c) 2010, 2015 LIFL, 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:
+ * Cedric Dumoulin (LIFL) cedric.dumoulin@lifl.fr - Initial API and implementation
+ * Christian W. Damus (CEA) - bug 433371
+ * Christian W. Damus - bug 469188
+ *
+ *****************************************************************************/
+
+package org.eclipse.papyrus.infra.core.sasheditor.di.contentprovider.utils;
+
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.papyrus.infra.core.sasheditor.editor.ICloseablePart;
+import org.eclipse.papyrus.infra.core.sasheditor.editor.IPage;
+import org.eclipse.papyrus.infra.core.sasheditor.editor.ISashWindowsContainer;
+import org.eclipse.papyrus.infra.core.sashwindows.di.PageRef;
+
+
+/**
+ * Class providing a utility methods allowing to get the real Model from the {@link IPage#getRawModel()}.
+ * The utility takes into account the bug 309943.
+ *
+ * @author cedric dumoulin
+ *
+ */
+public class IPageUtils {
+
+ /**
+ * Get the real model rather than the PageRef. This method is a trick to temporally solve the bug 309943.
+ *
+ * @param page
+ * @return
+ */
+ public static Object getRawModel(IPage page) {
+
+ if (page == null) {
+ return null;
+ }
+
+ Object pageModel = page.getRawModel();
+ // Get the real model because of bug
+ if (pageModel instanceof PageRef) {
+ return ((PageRef) pageModel).getPageIdentifier();
+ }
+ // do not use trick
+ return pageModel;
+ }
+
+ /**
+ * Lookup the IPage model corresponding to the identifier from the {@link ISashWindowsContainer}.
+ * The identifier can be either a {@link PageRef} or a emf Diagram. <br>
+ * This method can be used as a hack to bug 401107
+ *
+ * @param container
+ * @param identifier
+ * @return The corresponding IPage, or null if not found.
+ */
+ public static IPage lookupModelPage(ISashWindowsContainer container, Object identifier) {
+
+ LookupIPageVisitor visitor = new LookupIPageVisitor(identifier);
+ container.visit(visitor);
+ return visitor.getResult();
+ }
+
+ /**
+ * Queries whether the user should be permitted to close a {@code page}.
+ *
+ * @param page
+ * a page
+ * @return whether it can be closed
+ * @since 2.0
+ */
+ public static boolean canClose(IPage page) {
+ ICloseablePart closeable = (page instanceof IAdaptable)
+ ? ((IAdaptable) page).getAdapter(ICloseablePart.class)
+ : null;
+
+ return (closeable == null) || closeable.canClose();
+ }
+}
diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/pom.xml b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/pom.xml
index 1daf5ae6e56..3f95ec850c6 100644
--- a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/pom.xml
+++ b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/pom.xml
@@ -7,6 +7,6 @@
<version>0.0.1-SNAPSHOT</version>
</parent>
<artifactId>org.eclipse.papyrus.infra.core.sasheditor.di</artifactId>
- <version>1.2.0-SNAPSHOT</version>
+ <version>2.0.0-SNAPSHOT</version>
<packaging>eclipse-plugin</packaging>
</project> \ No newline at end of file

Back to the top