Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCamille Letavernier2014-03-07 12:20:12 +0000
committerCamille Letavernier2014-03-07 12:20:12 +0000
commit97634ae58842a093a94b52adc043101b2b3eaa52 (patch)
tree69088003635d679212eaff2e50f5d3d3aa384a82 /plugins/infra
parenta10d9125b1b754f2849bded045b84bec5ac63dab (diff)
downloadorg.eclipse.papyrus-97634ae58842a093a94b52adc043101b2b3eaa52.tar.gz
org.eclipse.papyrus-97634ae58842a093a94b52adc043101b2b3eaa52.tar.xz
org.eclipse.papyrus-97634ae58842a093a94b52adc043101b2b3eaa52.zip
429239: [Resource Management] Refactoring of the 3-files model and
PageManager https://bugs.eclipse.org/bugs/show_bug.cgi?id=429239 - Fix tests to match the refactoring
Diffstat (limited to 'plugins/infra')
-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.java30
-rw-r--r--plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/custom-src/org/eclipse/papyrus/infra/core/sasheditor/di/contentprovider/internal/PageMngrImpl.java69
2 files changed, 64 insertions, 35 deletions
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 a821864dd89..b43a0878b3c 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
@@ -14,7 +14,14 @@
package org.eclipse.papyrus.infra.core.sasheditor.di.contentprovider.internal;
+import java.util.LinkedList;
+import java.util.List;
+
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.papyrus.infra.core.sasheditor.contentprovider.IPageManager;
+import org.eclipse.papyrus.infra.core.sasheditor.di.contentprovider.IOpenable;
import org.eclipse.papyrus.infra.core.sashwindows.di.SashWindowsMngr;
import org.eclipse.swt.widgets.Display;
@@ -65,6 +72,29 @@ public class PageManagerImpl extends PageMngrImpl implements IPageManager {
}
@Override
+ public void addPage(Object pageIdentifier) {
+ //Nothing
+ }
+
+ @Override
+ public List<Object> allPages() {
+ //FIXME: Temporary, naive code. Need to implement a mechanism to contribute page providers
+ List<Object> result = new LinkedList<Object>();
+ for(Resource resource : diSashModel.eResource().getResourceSet().getResources()) {
+ if(resource != null && resource.isLoaded()) {
+ if("notation".equals(resource.getURI().fileExtension())) {
+ for(EObject content : resource.getContents()) {
+ if(Platform.getAdapterManager().getAdapter(content, IOpenable.class) != null) {
+ result.add(content);
+ }
+ }
+ }
+ }
+ }
+ return result;
+ }
+
+ @Override
public void selectPage(final Object pageIdentifier) {
Display.getDefault().syncExec(new Runnable() {
diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/custom-src/org/eclipse/papyrus/infra/core/sasheditor/di/contentprovider/internal/PageMngrImpl.java b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/custom-src/org/eclipse/papyrus/infra/core/sasheditor/di/contentprovider/internal/PageMngrImpl.java
index c4a59dd63fd..561bea818c0 100644
--- a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/custom-src/org/eclipse/papyrus/infra/core/sasheditor/di/contentprovider/internal/PageMngrImpl.java
+++ b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/custom-src/org/eclipse/papyrus/infra/core/sasheditor/di/contentprovider/internal/PageMngrImpl.java
@@ -14,14 +14,11 @@
package org.eclipse.papyrus.infra.core.sasheditor.di.contentprovider.internal;
-import java.util.LinkedList;
+import java.util.ArrayList;
import java.util.List;
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.papyrus.infra.core.sasheditor.contentprovider.IPageMngr;
-import org.eclipse.papyrus.infra.core.sasheditor.di.contentprovider.IOpenable;
+import org.eclipse.papyrus.infra.core.sashwindows.di.PageRef;
import org.eclipse.papyrus.infra.core.sashwindows.di.SashWindowsMngr;
import org.eclipse.papyrus.infra.core.sashwindows.di.TabFolder;
@@ -30,7 +27,7 @@ import org.eclipse.papyrus.infra.core.sashwindows.di.TabFolder;
* Implementation of the page manager.
* The page manager provides basic methods to access the DiSashModel and its PageList.
* This is the users interface to add, open, close and remove pages.
- *
+ *
* @author cedric dumoulin
*/
public class PageMngrImpl implements IPageMngr {
@@ -62,20 +59,24 @@ public class PageMngrImpl implements IPageMngr {
/**
* Add a page to the PageList. Do not open the corresponding editor.
* The page will be visible in the list.
- *
+ *
* @see org.eclipse.papyrus.infra.core.sasheditor.contentprovider.IPageMngr#addEditor(org.eclipse.emf.ecore.EObject)
- *
+ *
* @param pageIdentifier
*/
@Override
@Deprecated
public void addPage(Object pageIdentifier) {
- //Nothing to do. The list of pages is now computed dynamically
+
+ // We do not need to disable event delivering,
+ // as addition to pageList doesn't fire events.
+
+ diSashModel.getPageList().addPage(pageIdentifier);
}
/**
* Get the folder model {@link TabFolder} of the current folder.
- *
+ *
* @return
*/
private TabFolder getCurrentFolder() {
@@ -84,32 +85,25 @@ public class PageMngrImpl implements IPageMngr {
/**
* @see org.eclipse.papyrus.infra.core.sasheditor.contentprovider.IPageMngr#allPages()
- *
+ *
* @return
*/
@Override
public List<Object> allPages() {
- //FIXME: Temporary, naive code. Need to implement a mechanism to contribute page providers
- List<Object> result = new LinkedList<Object>();
- for(Resource resource : diSashModel.eResource().getResourceSet().getResources()) {
- if(resource != null && resource.isLoaded()) {
- if("notation".equals(resource.getURI().fileExtension())) {
- for(EObject content : resource.getContents()) {
- if(Platform.getAdapterManager().getAdapter(content, IOpenable.class) != null) {
- result.add(content);
- }
- }
- }
- }
+ // TODO : use and return a shadow list ?
+ List<Object> list = new ArrayList<Object>();
+ for(PageRef pageRef : diSashModel.getPageList().getAvailablePage()) {
+
+ list.add(pageRef.getPageIdentifier());
}
- return result;
+ return list;
}
/**
* Remove the page from the SashModel
- *
+ *
* @see org.eclipse.papyrus.infra.core.sasheditor.contentprovider.IPageMngr#closePage(org.eclipse.emf.ecore.EObject)
- *
+ *
* @param pageIdentifier
*/
@Override
@@ -122,9 +116,9 @@ public class PageMngrImpl implements IPageMngr {
/**
* Remove all pages from the SashModel. Left only the top level folder
- *
+ *
* @see org.eclipse.papyrus.infra.core.sasheditor.contentprovider.IPageMngr#closePage(org.eclipse.emf.ecore.EObject)
- *
+ *
* @param pageIdentifier
*/
@Override
@@ -138,9 +132,9 @@ public class PageMngrImpl implements IPageMngr {
/**
* Remove all pages from the SashModel. Left only the top level folder
- *
+ *
* @see org.eclipse.papyrus.infra.core.sasheditor.contentprovider.IPageMngr#closePage(org.eclipse.emf.ecore.EObject)
- *
+ *
* @param pageIdentifier
*/
@Override
@@ -152,7 +146,7 @@ public class PageMngrImpl implements IPageMngr {
/**
* @see org.eclipse.papyrus.infra.core.sasheditor.contentprovider.IPageMngr#openPage(org.eclipse.emf.ecore.EObject)
- *
+ *
* @param pageIdentifier
*/
@Override
@@ -166,21 +160,26 @@ public class PageMngrImpl implements IPageMngr {
/**
* @see org.eclipse.papyrus.infra.core.sasheditor.contentprovider.IPageMngr#removePage(org.eclipse.emf.ecore.EObject)
- *
+ *
* @param pageIdentifier
*/
@Override
@Deprecated
public void removePage(Object pageIdentifier) {
- closePage(pageIdentifier);
+ // remove from pageList and from SashModel
+ diSashModel.getPageList().removePage(pageIdentifier);
+
+ contentChangedEventProvider.setDeliver(false);
+ diSashModel.getSashModel().removePageAndEmptyFolder(pageIdentifier);
+ contentChangedEventProvider.setDeliver(true);
}
/**
- *
+ *
* @see org.eclipse.papyrus.infra.core.sasheditor.contentprovider.IPageMngr#isOpen(java.lang.Object)
* @param pageIdentifier
* @return
- *
+ *
*/
@Override
public boolean isOpen(Object pageIdentifier) {

Back to the top