Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorcletavernie2013-02-18 15:50:30 +0000
committercletavernie2013-02-18 15:50:30 +0000
commitf6beec7ac32f7979034f4a7ed96562d6ebb6cb5a (patch)
tree80076e899d16f9df808edcc9c251db6f379317c8 /plugins/infra
parent6773747c768861b2c89f2a232f6f600c482fcc66 (diff)
downloadorg.eclipse.papyrus-f6beec7ac32f7979034f4a7ed96562d6ebb6cb5a.tar.gz
org.eclipse.papyrus-f6beec7ac32f7979034f4a7ed96562d6ebb6cb5a.tar.xz
org.eclipse.papyrus-f6beec7ac32f7979034f4a7ed96562d6ebb6cb5a.zip
398712: [Core] Multiple issues with the PageManager
https://bugs.eclipse.org/bugs/show_bug.cgi?id=398712 360243: [ModelExplorer] Undo/Redo on delete for Diagrams and Tables https://bugs.eclipse.org/bugs/show_bug.cgi?id=360243
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/DiSashModelManager.java121
-rw-r--r--plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/custom-src/org/eclipse/papyrus/infra/core/sasheditor/di/contentprovider/commands/CloseAllDiagramsCommand.java86
-rw-r--r--plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/custom-src/org/eclipse/papyrus/infra/core/sasheditor/di/contentprovider/commands/CloseDiagramCommand.java49
-rw-r--r--plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/custom-src/org/eclipse/papyrus/infra/core/sasheditor/di/contentprovider/commands/CloseOtherDiagramsCommand.java39
-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.java57
-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.java17
-rw-r--r--plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/custom-src/org/eclipse/papyrus/infra/core/sasheditor/di/contentprovider/internal/TransactionalDiContentProvider.java40
-rw-r--r--plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/custom-src/org/eclipse/papyrus/infra/core/sasheditor/di/contentprovider/internal/TransactionalPageMngrImpl.java1
-rw-r--r--plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/contentprovider/IPageManager.java125
-rw-r--r--plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/contentprovider/IPageMngr.java5
-rw-r--r--plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/editor/AbstractMultiPageSashEditor.java14
-rw-r--r--plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/internal/EditorPart.java6
-rw-r--r--plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/internal/TabFolderPart.java179
-rw-r--r--plugins/infra/core/org.eclipse.papyrus.infra.core/build.properties2
-rw-r--r--plugins/infra/core/org.eclipse.papyrus.infra.core/plugin.xml32
-rw-r--r--plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/editor/CoreMultiDiagramEditor.java86
-rw-r--r--plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/modelsetquery/impl/ModelSetQueryInitializer.java8
-rw-r--r--plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/services/ServicesRegistry.java9
-rw-r--r--plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/utils/AbstractServiceUtils.java16
-rw-r--r--plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/utils/EditorUtils.java4
-rw-r--r--plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/utils/ServiceUtilsForActionHandlers.java15
-rw-r--r--plugins/infra/emf/org.eclipse.papyrus.infra.emf/plugin.xml2
-rw-r--r--plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/providers/MoDiscoContentProvider.java7
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.commands/src/org/eclipse/papyrus/commands/OpenDiagramCommand.java63
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/AbstractPapyrusGmfCreateDiagramCommandHandler.java55
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/helper/DiagramHelper.java7
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.hyperlink/src/org/eclipse/papyrus/infra/gmfdiag/hyperlink/dnd/HyperlinkDropStrategy.java4
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.hyperlink/src/org/eclipse/papyrus/infra/gmfdiag/hyperlink/editpolicies/HyperLinkPopupBarEditPolicy.java21
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.hyperlink/src/org/eclipse/papyrus/infra/gmfdiag/hyperlink/editpolicies/NavigationEditPolicy.java131
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.modelexplorer/src/org/eclipse/papyrus/infra/gmfdiag/modelexplorer/handlers/DeleteDiagramHandler.java15
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.modelexplorer/src/org/eclipse/papyrus/infra/gmfdiag/modelexplorer/handlers/DuplicateDiagramHandler.java4
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.navigation/src/org/eclipse/papyrus/infra/gmfdiag/navigation/NavigationHelper.java2
-rw-r--r--plugins/infra/org.eclipse.papyrus.infra.hyperlink/src/org/eclipse/papyrus/infra/hyperlink/helper/AbstractHyperLinkHelper.java11
-rw-r--r--plugins/infra/org.eclipse.papyrus.infra.hyperlink/src/org/eclipse/papyrus/infra/hyperlink/helper/EditorHyperLinkHelper.java12
-rw-r--r--plugins/infra/org.eclipse.papyrus.infra.hyperlink/src/org/eclipse/papyrus/infra/hyperlink/object/HyperLinkDocument.java7
-rw-r--r--plugins/infra/org.eclipse.papyrus.infra.hyperlink/src/org/eclipse/papyrus/infra/hyperlink/object/HyperLinkEditor.java33
-rw-r--r--plugins/infra/org.eclipse.papyrus.infra.hyperlink/src/org/eclipse/papyrus/infra/hyperlink/object/HyperLinkObject.java53
-rw-r--r--plugins/infra/org.eclipse.papyrus.infra.hyperlink/src/org/eclipse/papyrus/infra/hyperlink/object/HyperLinkWeb.java30
-rw-r--r--plugins/infra/org.eclipse.papyrus.infra.hyperlink/src/org/eclipse/papyrus/infra/hyperlink/ui/EditorLookForEditorShell.java66
-rw-r--r--plugins/infra/org.eclipse.papyrus.infra.hyperlink/src/org/eclipse/papyrus/infra/hyperlink/util/EditorListContentProvider.java4
-rw-r--r--plugins/infra/services/org.eclipse.papyrus.infra.services.resourceloading/src/org/eclipse/papyrus/infra/services/resourceloading/strategies/AskUserStrategy.java17
-rw-r--r--plugins/infra/services/org.eclipse.papyrus.infra.services.resourceloading/src/org/eclipse/papyrus/infra/services/resourceloading/util/LoadingUtils.java10
-rw-r--r--plugins/infra/table/org.eclipse.papyrus.infra.table.common/src/org/eclipse/papyrus/infra/table/common/handlers/AbstractCreateNattableEditorCommand.java4
-rw-r--r--plugins/infra/table/org.eclipse.papyrus.infra.table.modelexplorer/src/org/eclipse/papyrus/infra/table/modelexplorer/handlers/DeleteTableHandler.java7
-rw-r--r--plugins/infra/table/org.eclipse.papyrus.infra.table.modelexplorer/src/org/eclipse/papyrus/infra/table/modelexplorer/handlers/DuplicateTableHandler.java6
45 files changed, 1001 insertions, 481 deletions
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 7e4e8a55032..cf9a51fe027 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
@@ -18,11 +18,11 @@ 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.IPageManager;
import org.eclipse.papyrus.infra.core.sasheditor.contentprovider.IPageMngr;
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.DefaultCurrentFolderAndPageMngr;
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;
@@ -37,9 +37,9 @@ import org.eclipse.papyrus.infra.core.sashwindows.di.util.DiUtils;
* This class allows to get facade objects on the diSashModel.
*
* @author cedric dumoulin
- *
+ *
*/
-public class DiSashModelManager {
+public class DiSashModelManager {
/** The EMF model used to store the sash windows structure and pages */
protected SashWindowsMngr sashWindowMngr;
@@ -53,8 +53,9 @@ public class DiSashModelManager {
* Instance of the DiContentProvider used to manipulate SashModel.
*/
private DiContentProvider contentProvider;
+
private TransactionalDiContentProvider transDiContentProvider;
-
+
/**
* Object used externally listen to model changes.
* The object is also used internally to control how events are fired (limit multiple events).
@@ -62,7 +63,7 @@ public class DiSashModelManager {
protected ContentChangedEventProvider contentChangedEventProvider;
/** The factory used to create IPageModel */
-// private IPageModelFactory pageModelFactory;
+ // private IPageModelFactory pageModelFactory;
/**
@@ -71,33 +72,33 @@ public class DiSashModelManager {
*
* @param pageModelFactory
* @param diResource
- * @param currentFolderAndPageMngr
+ * @param currentFolderAndPageMngr
*/
public DiSashModelManager(IPageModelFactory pageModelFactory, final Resource diResource, TransactionalEditingDomain editingDomain, ICurrentFolderAndPageMngr currentFolderAndPageMngr) {
-// this.pageModelFactory = pageModelFactory;
-
+ // 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);
+ // 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);
}
-
+
contentProvider = new DiContentProvider(sashWindowMngr.getSashModel(), pageModelFactory, contentChangedEventProvider);
// Create the TransactionalDiContentProvider
transDiContentProvider = new TransactionalDiContentProvider(getDiContentProvider(), editingDomain);
-
+
// Create the TransactionalPageMngrImpl
pageMngr = new PageManagerImpl(sashWindowMngr, contentChangedEventProvider, currentFolderAndPageMngr);
}
@@ -108,7 +109,7 @@ public class DiSashModelManager {
*
* @param pageModelFactory
* @param diResource
- * @param currentFolderAndPageMngr
+ * @param currentFolderAndPageMngr
*/
public DiSashModelManager(IPageModelFactory pageModelFactory, final Resource diResource, TransactionalEditingDomain editingDomain) {
@@ -116,31 +117,31 @@ public class DiSashModelManager {
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);
-
+ // 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);
+
}
-
- contentProvider = new DiContentProvider(sashWindowMngr.getSashModel(), pageModelFactory, contentChangedEventProvider);
+
+ contentProvider = new DiContentProvider(sashWindowMngr.getSashModel(), pageModelFactory, getContentChangedEventProvider());
// Create the TransactionalDiContentProvider
transDiContentProvider = new TransactionalDiContentProvider(getDiContentProvider(), editingDomain);
-
+
// Create the TransactionalPageMngrImpl
- pageMngr = new PageManagerImpl(sashWindowMngr, contentChangedEventProvider);
-
+ pageMngr = new PageManagerImpl(sashWindowMngr, getContentChangedEventProvider());
+
}
-
+
/**
*
* @param currentFolderAndPageMngr
@@ -148,9 +149,10 @@ public class DiSashModelManager {
public void setCurrentFolderAndPageMngr(ICurrentFolderAndPageMngr currentFolderAndPageMngr) {
pageMngr.setCurrentFolderAndPageMngr(currentFolderAndPageMngr);
}
-
+
/**
* Set the CurrentFolderAndPageManager as an instance of {@link CurrentFolderAndPageManager}
+ *
* @param currentFolderAndPageMngr
*/
public void setCurrentFolderAndPageMngr(ISashWindowsContainer sashWindowsContainer) {
@@ -166,10 +168,10 @@ public class DiSashModelManager {
* @param pageModelFactory
* @param diResource
*/
-// private DiSashModelManager(final Resource diResource, TransactionalEditingDomain editingDomain, ICurrentFolderAndPageMngr currentFolderAndPageMngr) {
-// this(null, diResource, editingDomain, currentFolderAndPageMngr);
-//
-// }
+ // private DiSashModelManager(final Resource diResource, TransactionalEditingDomain editingDomain, ICurrentFolderAndPageMngr currentFolderAndPageMngr) {
+ // this(null, diResource, editingDomain, currentFolderAndPageMngr);
+ //
+ // }
/**
@@ -237,6 +239,15 @@ public class DiSashModelManager {
* @return
*/
public IPageMngr getIPageMngr() {
+ return getIPageManager();
+ }
+
+ /**
+ * Get the IPageManager providing basic methods to manage Pages in the sash model.
+ *
+ * @return
+ */
+ public IPageManager getIPageManager() {
return getPageManagerImpl();
}
@@ -289,12 +300,12 @@ public class DiSashModelManager {
* @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();
-//
-// }
+ // 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();
+ //
+ // }
}
diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/custom-src/org/eclipse/papyrus/infra/core/sasheditor/di/contentprovider/commands/CloseAllDiagramsCommand.java b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/custom-src/org/eclipse/papyrus/infra/core/sasheditor/di/contentprovider/commands/CloseAllDiagramsCommand.java
index 91084254406..8a70361e794 100644
--- a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/custom-src/org/eclipse/papyrus/infra/core/sasheditor/di/contentprovider/commands/CloseAllDiagramsCommand.java
+++ b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/custom-src/org/eclipse/papyrus/infra/core/sasheditor/di/contentprovider/commands/CloseAllDiagramsCommand.java
@@ -1,12 +1,11 @@
-/**
- *
- */
package org.eclipse.papyrus.infra.core.sasheditor.di.contentprovider.commands;
import org.eclipse.core.commands.AbstractHandler;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.papyrus.infra.core.sasheditor.contentprovider.IPageMngr;
+import org.eclipse.emf.transaction.RecordingCommand;
+import org.eclipse.emf.transaction.TransactionalEditingDomain;
+import org.eclipse.papyrus.infra.core.sasheditor.contentprovider.IPageManager;
import org.eclipse.ui.IEditorPart;
import org.eclipse.ui.handlers.HandlerUtil;
@@ -16,7 +15,7 @@ import org.eclipse.ui.handlers.HandlerUtil;
* on di.
*
* @author cedric dumoulin
- *
+ *
*/
public class CloseAllDiagramsCommand extends AbstractHandler {
@@ -25,49 +24,90 @@ public class CloseAllDiagramsCommand extends AbstractHandler {
*/
@Override
public void setEnabled(Object evaluationContext) {
-// System.out.println("call to CloseAllDiagramsCommand.setEnable(" + evaluationContext + ")");
+ // System.out.println("call to CloseAllDiagramsCommand.setEnable(" + evaluationContext + ")");
}
-
+
/**
* Execute the command. This method is called when the action is triggered.
*
*/
public Object execute(ExecutionEvent event) throws ExecutionException {
-
- IPageMngr pageMngr;
+
+ IPageManager pageMngr;
+ TransactionalEditingDomain editingDomain;
try {
- pageMngr = getPageMngr(event);
+ pageMngr = getPageManager(event);
+ editingDomain = getTransactionalEditingDomain(event);
} catch (NullPointerException e) {
- // PageMngr can't be found
+ // PageMngr or Editing Domain can't be found
return null;
}
- execute(pageMngr);
-
+ execute(pageMngr, editingDomain);
+
return null;
}
-
+
/**
* Get the PageMngr used to interact with the content provider.
+ *
* @param event
* @return
- * @throws NullPointerException if the PageMngr can't be found.
+ * @throws NullPointerException
+ * if the PageMngr can't be found.
*/
- private IPageMngr getPageMngr(ExecutionEvent event) {
-
+ private IPageManager getPageManager(ExecutionEvent event) {
+
IEditorPart part = HandlerUtil.getActiveEditor(event);
- IPageMngr pageMngr = (IPageMngr)part.getAdapter(IPageMngr.class);
-
+ IPageManager pageMngr = (IPageManager)part.getAdapter(IPageManager.class);
+
return pageMngr;
-
+
+ }
+
+ /**
+ * Get the TransactionalEditingDomain used to execute commands.
+ *
+ * @param event
+ * @return
+ * @throws NullPointerException
+ * if the TransactionalEditingDomain can't be found.
+ */
+ private TransactionalEditingDomain getTransactionalEditingDomain(ExecutionEvent event) {
+ IEditorPart activePart = HandlerUtil.getActiveEditor(event);
+ TransactionalEditingDomain editingDomain = (TransactionalEditingDomain)activePart.getAdapter(TransactionalEditingDomain.class);
+ return editingDomain;
}
/**
* Close all the diagrams.
+ *
* @param pageMngr
*/
- public void execute(IPageMngr pageMngr) {
-
- pageMngr.closeAllOpenedPages();
+ public void execute(final IPageManager pageMngr, TransactionalEditingDomain editingDomain) throws ExecutionException {
+ if(editingDomain == null) {
+ throw new ExecutionException("Editing domain not found");
+ }
+
+ boolean atLeastOneOpenPage = false;
+ for(Object pageIdentifier : pageMngr.allPages()) {
+ if(pageMngr.isOpen(pageIdentifier)) {
+ atLeastOneOpenPage = true;
+ break;
+ }
+ }
+
+ if(!atLeastOneOpenPage) {
+ return;
+ }
+
+ editingDomain.getCommandStack().execute(new RecordingCommand(editingDomain, "Close all pages") {
+
+ @Override
+ protected void doExecute() {
+
+ pageMngr.closeAllOpenedPages();
+ }
+ });
}
}
diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/custom-src/org/eclipse/papyrus/infra/core/sasheditor/di/contentprovider/commands/CloseDiagramCommand.java b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/custom-src/org/eclipse/papyrus/infra/core/sasheditor/di/contentprovider/commands/CloseDiagramCommand.java
index eca61bdd9b7..bf21cc25878 100644
--- a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/custom-src/org/eclipse/papyrus/infra/core/sasheditor/di/contentprovider/commands/CloseDiagramCommand.java
+++ b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/custom-src/org/eclipse/papyrus/infra/core/sasheditor/di/contentprovider/commands/CloseDiagramCommand.java
@@ -1,12 +1,11 @@
-/**
- *
- */
package org.eclipse.papyrus.infra.core.sasheditor.di.contentprovider.commands;
import org.eclipse.core.commands.AbstractHandler;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.papyrus.infra.core.sasheditor.contentprovider.IPageMngr;
+import org.eclipse.emf.transaction.RecordingCommand;
+import org.eclipse.emf.transaction.TransactionalEditingDomain;
+import org.eclipse.papyrus.infra.core.sasheditor.contentprovider.IPageManager;
import org.eclipse.papyrus.infra.core.sasheditor.editor.ISashWindowsContainer;
import org.eclipse.papyrus.infra.core.sashwindows.di.PageRef;
import org.eclipse.ui.IEditorPart;
@@ -18,7 +17,7 @@ import org.eclipse.ui.handlers.HandlerUtil;
* This command allows to close the currently openened diagram.
*
* @author cedric dumoulin
- *
+ *
*/
public class CloseDiagramCommand extends AbstractHandler {
@@ -29,45 +28,51 @@ public class CloseDiagramCommand extends AbstractHandler {
public void setEnabled(Object evaluationContext) {
// System.out.println("call to CloseDiagramCommand.setEnable(" + evaluationContext + ")");
}
-
+
/**
* Execute the command. This method is called when the action is triggered.
*
*/
public Object execute(ExecutionEvent event) throws ExecutionException {
-
+
try {
IEditorPart part = HandlerUtil.getActiveEditor(event);
- IPageMngr pageMngr = (IPageMngr)part.getAdapter(IPageMngr.class);
+ IPageManager pageMngr = (IPageManager)part.getAdapter(IPageManager.class);
+ TransactionalEditingDomain editingDomain = (TransactionalEditingDomain)part.getAdapter(TransactionalEditingDomain.class);
ISashWindowsContainer container = (ISashWindowsContainer)part.getAdapter(ISashWindowsContainer.class);
Object pageIdentifier = container.getActiveSashWindowsPage().getRawModel();
- // Bug from sash Di to be corrected
- if(pageIdentifier instanceof PageRef)
- {
+ //FIXME Bug from sash Di to be corrected
+ if(pageIdentifier instanceof PageRef) {
pageIdentifier = ((PageRef)pageIdentifier).getPageIdentifier();
}
-
- execute(pageMngr, pageIdentifier);
+
+ execute(pageMngr, editingDomain, pageIdentifier);
} catch (NullPointerException e) {
// PageMngr can't be found
return null;
}
-
-
-
+
+
+
return null;
}
-
+
/**
* Close selected page.
+ *
* @param pageMngr
*/
- public void execute(IPageMngr pageMngr, Object pageIdentifier) {
-
- if(pageMngr.isOpen(pageIdentifier)) {
- pageMngr.closePage(pageIdentifier);
- }
+ public void execute(final IPageManager pageMngr, TransactionalEditingDomain editingDomain, final Object pageIdentifier) {
+ if(pageMngr.isOpen(pageIdentifier)) {
+ editingDomain.getCommandStack().execute(new RecordingCommand(editingDomain, "Close page") {
+
+ @Override
+ protected void doExecute() {
+ pageMngr.closePage(pageIdentifier);
+ }
+ });
+ }
}
}
diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/custom-src/org/eclipse/papyrus/infra/core/sasheditor/di/contentprovider/commands/CloseOtherDiagramsCommand.java b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/custom-src/org/eclipse/papyrus/infra/core/sasheditor/di/contentprovider/commands/CloseOtherDiagramsCommand.java
index 609befa9b3f..d7e2990b76e 100644
--- a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/custom-src/org/eclipse/papyrus/infra/core/sasheditor/di/contentprovider/commands/CloseOtherDiagramsCommand.java
+++ b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/custom-src/org/eclipse/papyrus/infra/core/sasheditor/di/contentprovider/commands/CloseOtherDiagramsCommand.java
@@ -1,12 +1,11 @@
-/**
- *
- */
package org.eclipse.papyrus.infra.core.sasheditor.di.contentprovider.commands;
import org.eclipse.core.commands.AbstractHandler;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.papyrus.infra.core.sasheditor.contentprovider.IPageMngr;
+import org.eclipse.emf.transaction.RecordingCommand;
+import org.eclipse.emf.transaction.TransactionalEditingDomain;
+import org.eclipse.papyrus.infra.core.sasheditor.contentprovider.IPageManager;
import org.eclipse.papyrus.infra.core.sasheditor.editor.ISashWindowsContainer;
import org.eclipse.papyrus.infra.core.sashwindows.di.PageRef;
import org.eclipse.ui.IEditorPart;
@@ -38,15 +37,15 @@ public class CloseOtherDiagramsCommand extends AbstractHandler {
try {
IEditorPart part = HandlerUtil.getActiveEditor(event);
- IPageMngr pageMngr = (IPageMngr)part.getAdapter(IPageMngr.class);
+ IPageManager pageMngr = (IPageManager)part.getAdapter(IPageManager.class);
+ TransactionalEditingDomain editingDomain = (TransactionalEditingDomain)part.getAdapter(TransactionalEditingDomain.class);
ISashWindowsContainer container = (ISashWindowsContainer)part.getAdapter(ISashWindowsContainer.class);
Object pageIdentifier = container.getActiveSashWindowsPage().getRawModel();
- // Bug from sash Di to be corrected
- if(pageIdentifier instanceof PageRef)
- {
+ //FIXME Bug from sash Di to be corrected
+ if(pageIdentifier instanceof PageRef) {
pageIdentifier = ((PageRef)pageIdentifier).getPageIdentifier();
}
- execute(pageMngr, pageIdentifier);
+ execute(pageMngr, editingDomain, pageIdentifier);
} catch (NullPointerException e) {
// PageMngr can't be found
@@ -63,9 +62,27 @@ public class CloseOtherDiagramsCommand extends AbstractHandler {
*
* @param pageMngr
*/
- public void execute(IPageMngr pageMngr, Object pageIdentifier) {
+ public void execute(final IPageManager pageMngr, TransactionalEditingDomain editingDomain, final Object pageIdentifier) {
+ boolean atLeastOneDifferentPageOpen = false;
+ for(Object page : pageMngr.allPages()) {
+ if(page != pageIdentifier && pageMngr.isOpen(page)) {
+ atLeastOneDifferentPageOpen = true;
+ break;
+ }
+ }
+
+ if(!atLeastOneDifferentPageOpen) {
+ return; //Nothing to do
+ }
+
+ editingDomain.getCommandStack().execute(new RecordingCommand(editingDomain, "Close other pages") {
+
+ @Override
+ protected void doExecute() {
+ pageMngr.closeOtherPages(pageIdentifier);
+ }
+ });
- pageMngr.closeOtherPages(pageIdentifier);
}
}
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 a2c933b79f1..3a56c58656c 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,32 +14,31 @@
package org.eclipse.papyrus.infra.core.sasheditor.di.contentprovider.internal;
-import org.eclipse.papyrus.infra.core.sasheditor.contentprovider.IPageMngr;
+import org.eclipse.papyrus.infra.core.sasheditor.contentprovider.IPageManager;
import org.eclipse.papyrus.infra.core.sashwindows.di.SashWindowsMngr;
/**
- * This class provide high level method to manage the Sash pages through its DI
+ * This class provide high level method to manage the Sash pages through its DI
* implementation.
-
+ *
* @author cedric dumoulin
- *
+ *
*/
-public class PageManagerImpl extends PageMngrImpl implements IPageMngr {
+public class PageManagerImpl extends PageMngrImpl implements IPageManager {
-
-
/**
* 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>
+ * 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.
+ *
+ * @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.
*
*/
public PageManagerImpl(SashWindowsMngr diSashModel, ContentChangedEventProvider contentChangedEventProvider) {
@@ -48,7 +47,7 @@ public class PageManagerImpl extends PageMngrImpl implements IPageMngr {
/**
* Constructor.
- *
+ *
* @param diSashModel
* @param contentChangedEventProvider
* @param folderAndPageMngr
@@ -57,36 +56,18 @@ public class PageManagerImpl extends PageMngrImpl implements IPageMngr {
super(diSashModel, contentChangedEventProvider, folderAndPageMngr);
}
-
- /**
- * Remove all pages used to render the specified pageIndentifier.
- * If the pageIdentifier hasmore than one page rendering it, each of these
- * pages are closed.
- *
- *
- * @param pageIdentifier
- */
public void closeAllOpenedPages(Object pageIdentifier) {
-
- // TODO
- throw new UnsupportedOperationException("Not yet implemented.");
-
+ while(isOpen(pageIdentifier)) {
+ closePage(pageIdentifier);
+ }
}
-
- /**
- * Select the first page used to render the specified pageIdentifier.
- * Do nothing if this page identifier is not rendered.
- *
- * @param pageIdentifier
- */
- public void selectPage( Object pageIdentifier) {
-
+ public void selectPage(Object pageIdentifier) {
folderAndPageMngr.setActivePage(pageIdentifier);
}
public void setCurrentFolderAndPageMngr(ICurrentFolderAndPageMngr currentFolderAndPageMngr) {
this.folderAndPageMngr = currentFolderAndPageMngr;
-
+
}
}
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 444c7d2e0e0..073f2371ec9 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
@@ -35,12 +35,11 @@ public class PageMngrImpl implements IPageMngr {
/** Internal EMF model */
private SashWindowsMngr diSashModel;
-
+
/**
- * An object used to get the current folder, or to ask to set the
+ * An object used to get the current folder, or to ask to set the
* active page.
- * This is usually backuped by the SashWindowContainer.
- * <br>
+ * This is usually backuped by the SashWindowContainer. <br>
*/
protected ICurrentFolderAndPageMngr folderAndPageMngr;
@@ -70,7 +69,7 @@ public class PageMngrImpl implements IPageMngr {
// We do not need to disable event delivering,
// as addition to pageList doesn't fire events.
-
+
diSashModel.getPageList().addPage(pageIdentifier);
}
@@ -108,7 +107,7 @@ public class PageMngrImpl implements IPageMngr {
* @param pageIdentifier
*/
public void closePage(Object pageIdentifier) {
-
+
contentChangedEventProvider.setDeliver(false);
diSashModel.getSashModel().removePageAndEmptyFolder(pageIdentifier);
contentChangedEventProvider.setDeliver(true);
@@ -122,7 +121,7 @@ public class PageMngrImpl implements IPageMngr {
* @param pageIdentifier
*/
public void closeAllOpenedPages() {
-
+
contentChangedEventProvider.setDeliver(false);
diSashModel.getSashModel().removeAllPages();
contentChangedEventProvider.setDeliver(true);
@@ -150,7 +149,7 @@ public class PageMngrImpl implements IPageMngr {
public void openPage(Object pageIdentifier) {
// Add the page to the SashModel and to the PageList
- // We do not need to disable event delivering as the operation already fired
+ // We do not need to disable event delivering as the operation already fired
// one single event.
Iterator<PageRef> iterator = diSashModel.getPageList().getAvailablePage().iterator();
@@ -175,7 +174,7 @@ public class PageMngrImpl implements IPageMngr {
public void removePage(Object pageIdentifier) {
// remove from pageList and from SashModel
diSashModel.getPageList().removePage(pageIdentifier);
-
+
contentChangedEventProvider.setDeliver(false);
diSashModel.getSashModel().removePageAndEmptyFolder(pageIdentifier);
contentChangedEventProvider.setDeliver(true);
diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/custom-src/org/eclipse/papyrus/infra/core/sasheditor/di/contentprovider/internal/TransactionalDiContentProvider.java b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/custom-src/org/eclipse/papyrus/infra/core/sasheditor/di/contentprovider/internal/TransactionalDiContentProvider.java
index bc870900bd7..61582477a31 100644
--- a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/custom-src/org/eclipse/papyrus/infra/core/sasheditor/di/contentprovider/internal/TransactionalDiContentProvider.java
+++ b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/custom-src/org/eclipse/papyrus/infra/core/sasheditor/di/contentprovider/internal/TransactionalDiContentProvider.java
@@ -55,7 +55,7 @@ public class TransactionalDiContentProvider implements ISashWindowsContentProvid
public void addPage(final Object page) {
TransactionalEditingDomain editingDomain = getTransactionalEditingDomain();
- RecordingCommand command = new RecordingCommand(editingDomain) {
+ RecordingCommand command = new RecordingCommand(editingDomain, "Open page") {
@Override
protected void doExecute() {
@@ -76,7 +76,7 @@ public class TransactionalDiContentProvider implements ISashWindowsContentProvid
public void addPage(final Object page, final int index) {
TransactionalEditingDomain editingDomain = getTransactionalEditingDomain();
- RecordingCommand command = new RecordingCommand(editingDomain) {
+ RecordingCommand command = new RecordingCommand(editingDomain, "Open page") {
@Override
protected void doExecute() {
@@ -110,7 +110,7 @@ public class TransactionalDiContentProvider implements ISashWindowsContentProvid
public void createFolder(final ITabFolderModel tabFolder, final int tabIndex, final ITabFolderModel targetFolder, final int side) {
TransactionalEditingDomain editingDomain = getTransactionalEditingDomain();
- RecordingCommand command = new RecordingCommand(editingDomain) {
+ RecordingCommand command = new RecordingCommand(editingDomain, "Create folder") {
@Override
protected void doExecute() {
@@ -130,18 +130,18 @@ public class TransactionalDiContentProvider implements ISashWindowsContentProvid
* @param rawModel
*/
public void setCurrentFolder(final Object rawModel) {
- TransactionalEditingDomain editingDomain = getTransactionalEditingDomain();
-
-// RecordingCommand command = new RecordingCommand(editingDomain) {
-//
-// @Override
-// protected void doExecute() {
-// diContentProvider.setCurrentFolder(rawModel);
-//
-// }
-// };
-
-// editingDomain.getCommandStack().execute(command);
+ // TransactionalEditingDomain editingDomain = getTransactionalEditingDomain();
+
+ // RecordingCommand command = new RecordingCommand(editingDomain) {
+ //
+ // @Override
+ // protected void doExecute() {
+ // diContentProvider.setCurrentFolder(rawModel);
+ //
+ // }
+ // };
+
+ // editingDomain.getCommandStack().execute(command);
diContentProvider.setCurrentFolder(rawModel);
}
@@ -165,7 +165,7 @@ public class TransactionalDiContentProvider implements ISashWindowsContentProvid
public void movePage(final ITabFolderModel folderModel, final int oldIndex, final int newIndex) {
TransactionalEditingDomain editingDomain = getTransactionalEditingDomain();
- RecordingCommand command = new RecordingCommand(editingDomain) {
+ RecordingCommand command = new RecordingCommand(editingDomain, "Move page") {
@Override
protected void doExecute() {
@@ -189,7 +189,7 @@ public class TransactionalDiContentProvider implements ISashWindowsContentProvid
public void movePage(final ITabFolderModel srcFolderModel, final int sourceIndex, final ITabFolderModel targetFolderModel, final int targetIndex) {
TransactionalEditingDomain editingDomain = getTransactionalEditingDomain();
- RecordingCommand command = new RecordingCommand(editingDomain) {
+ RecordingCommand command = new RecordingCommand(editingDomain, "Move page") {
@Override
protected void doExecute() {
@@ -209,7 +209,7 @@ public class TransactionalDiContentProvider implements ISashWindowsContentProvid
public void removePage(final int index) {
TransactionalEditingDomain editingDomain = getTransactionalEditingDomain();
- RecordingCommand command = new RecordingCommand(editingDomain) {
+ RecordingCommand command = new RecordingCommand(editingDomain, "Close page") {
@Override
protected void doExecute() {
@@ -229,7 +229,7 @@ public class TransactionalDiContentProvider implements ISashWindowsContentProvid
public void removePage(final Object page) {
TransactionalEditingDomain editingDomain = getTransactionalEditingDomain();
- RecordingCommand command = new RecordingCommand(editingDomain) {
+ RecordingCommand command = new RecordingCommand(editingDomain, "Close page") {
@Override
protected void doExecute() {
@@ -251,7 +251,7 @@ public class TransactionalDiContentProvider implements ISashWindowsContentProvid
public void removePage(final ITabFolderModel parentFolder, final int tabIndex) {
TransactionalEditingDomain editingDomain = getTransactionalEditingDomain();
- RecordingCommand command = new RecordingCommand(editingDomain) {
+ RecordingCommand command = new RecordingCommand(editingDomain, "Close page") {
@Override
protected void doExecute() {
diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/custom-src/org/eclipse/papyrus/infra/core/sasheditor/di/contentprovider/internal/TransactionalPageMngrImpl.java b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/custom-src/org/eclipse/papyrus/infra/core/sasheditor/di/contentprovider/internal/TransactionalPageMngrImpl.java
index 5aa3e27d732..97686a980f4 100644
--- a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/custom-src/org/eclipse/papyrus/infra/core/sasheditor/di/contentprovider/internal/TransactionalPageMngrImpl.java
+++ b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/custom-src/org/eclipse/papyrus/infra/core/sasheditor/di/contentprovider/internal/TransactionalPageMngrImpl.java
@@ -28,6 +28,7 @@ import org.eclipse.papyrus.infra.core.sasheditor.contentprovider.IPageMngr;
*
* @author cedric dumoulin
*/
+@Deprecated
public class TransactionalPageMngrImpl implements IPageMngr {
/**
diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/contentprovider/IPageManager.java b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/contentprovider/IPageManager.java
new file mode 100644
index 00000000000..114407663d1
--- /dev/null
+++ b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/contentprovider/IPageManager.java
@@ -0,0 +1,125 @@
+/*****************************************************************************
+ * 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:
+ * Cedric Dumoulin (LIFL) cedric.dumoulin@lifl.fr - Initial API
+ * Camille Letavernier (CEA LIST) camille.letavernier@cea.fr
+ *****************************************************************************/
+package org.eclipse.papyrus.infra.core.sasheditor.contentprovider;
+
+import java.util.List;
+
+
+/**
+ * Interface providing method to manage pages in the Sash Windows system.
+ * This interface can be provided by ContentProvider whishing to provide a standard
+ * way to manage pages. This interface is not mandatory for the Sasheditor.
+ * This interface provide basic access to the Sash Windows system.
+ * It is intended to be used from the application in order to interact with the ContentProvider. Then,
+ * the {@link SashWindowsContainer} will refresh its views.
+ *
+ *
+ * @author dumoulin
+ */
+public interface IPageManager extends IPageMngr {
+
+ /**
+ * Add a Page identifier to the list of pages, do not open it.
+ *
+ * @param page
+ * The object identifying the page to add. This object will be passed to the {@link IPageModelFactory#createIPageModel(EObject)}. This
+ * identifier is stored in the sash model.
+ * It should be a reference on a EMF object identifying the page.
+ */
+ public void addPage(Object pageIdentifier);
+
+ /**
+ * Remove the page from the SashWindows system and from the list of page.
+ * The page will not be available anymore.
+ *
+ * @param pageIdentifier
+ * The object identifying the page
+ */
+ public void removePage(Object pageIdentifier);
+
+ /**
+ * Close the page corresponding to the identifier.
+ * The identifier is removed from the Sash Windows, but not from the list of pages.
+ *
+ * If the page is open more than once on the current Sash windows, only
+ * one instance will be closed.
+ *
+ * @param pageIdentifier
+ * The object identifying the page
+ *
+ *
+ * @see {@link #closeAllOpenedPages(Object)}
+ */
+ public void closePage(Object pageIdentifier);
+
+
+ /**
+ * Close all opened pages.
+ *
+ */
+ public void closeAllOpenedPages();
+
+ /**
+ * Close all opened pages except the one provided as parameter.
+ *
+ * @param pageIdentifier
+ */
+ public void closeOtherPages(Object pageIdentifier);
+
+ /**
+ * Open a Page corresponding to the identifier. If the page is not in the list of pages, add it.
+ * The identifier is first added to the current folder model. Then the Sash Windows should react and
+ * ask the {@link IPageModelFactory} to create the IPageModel. This later is then used to create the
+ * SWT page.
+ * If
+ *
+ * @param page
+ * The object identifying the page to add. This object will be passed to the {@link IPageModelFactory#createIPageModel(EObject)}. This
+ * identifier is stored in the sash model.
+ * It should be a reference on a EMF object identifying the page.
+ */
+ public void openPage(Object pageIdentifier);
+
+ /**
+ * Return all available page identifiers (open and closed pages).
+ *
+ * @return List of registered page identifiers.
+ */
+ public List<Object> allPages();
+
+ /**
+ * Return true if a page is open for the specified pageIdentifier.
+ *
+ * @param diagram
+ * @return
+ */
+ public boolean isOpen(Object pageIdentifier);
+
+ /**
+ * Remove all pages used to render the specified pageIndentifier.
+ * If the pageIdentifier has more than one page rendering it, each of these
+ * pages are closed.
+ *
+ * @param pageIdentifier
+ */
+ public void closeAllOpenedPages(Object pageIdentifier);
+
+ /**
+ * Select the first page used to render the specified pageIdentifier.
+ * Do nothing if this page identifier is not rendered.
+ *
+ * @param pageIdentifier
+ */
+ public void selectPage(Object pageIdentifier);
+
+}
diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/contentprovider/IPageMngr.java b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/contentprovider/IPageMngr.java
index 2cd2a1aaa2b..9c3d9fdfb5f 100644
--- a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/contentprovider/IPageMngr.java
+++ b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/contentprovider/IPageMngr.java
@@ -19,7 +19,7 @@ import java.util.List;
/**
* Interface providing method to manage pages in the Sash Windows system.
- * This interface can be provided by ContentProvider whishing to provide a standard
+ * This interface can be provided by ContentProvider whishing to provide a standard
* way to manage pages. This interface is not mandatory for the Sasheditor.
* This interface provide basic access to the Sash Windows system.
* It is intended to be used from the application in order to interact with the ContentProvider. Then,
@@ -27,7 +27,10 @@ import java.util.List;
*
*
* @author dumoulin
+ *
+ * @deprecated Use IPageManager instead
*/
+@Deprecated
public interface IPageMngr {
/**
diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/editor/AbstractMultiPageSashEditor.java b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/editor/AbstractMultiPageSashEditor.java
index 2681595980d..7110278062f 100644
--- a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/editor/AbstractMultiPageSashEditor.java
+++ b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/editor/AbstractMultiPageSashEditor.java
@@ -22,6 +22,7 @@ import org.eclipse.papyrus.infra.core.sasheditor.internal.IMultiEditorManager;
import org.eclipse.papyrus.infra.core.sasheditor.internal.SashWindowsContainer;
import org.eclipse.papyrus.infra.core.sasheditor.internal.eclipsecopy.MultiPageSelectionProvider;
import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Display;
import org.eclipse.ui.IEditorInput;
import org.eclipse.ui.IEditorPart;
import org.eclipse.ui.IEditorSite;
@@ -167,9 +168,8 @@ public abstract class AbstractMultiPageSashEditor extends EditorPart implements
deactivate();
//The selection provider keeps a reference to "this". It is not disposed.
getSite().setSelectionProvider(null);
- if(sashContainer!=null) {
+ if(sashContainer != null) {
sashContainer.dispose();
- sashContainer = null;
}
pageProvider = null;
@@ -180,10 +180,18 @@ public abstract class AbstractMultiPageSashEditor extends EditorPart implements
* Refresh the sash windows system
*/
protected void refreshTabs() {
+ Display.getDefault().syncExec(new Runnable() {
+
+ public void run() {
+ doRefreshTabs();
+ }
+ });
+ }
+
+ private void doRefreshTabs() {
if(sashContainer != null) {
sashContainer.refreshTabs();
}
-
}
/**
diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/internal/EditorPart.java b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/internal/EditorPart.java
index a3301360b15..0eea8c99ec2 100644
--- a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/internal/EditorPart.java
+++ b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/internal/EditorPart.java
@@ -623,7 +623,7 @@ public class EditorPart extends PagePart implements IEditorPage {
editorControl.setParent(newParent.getControl());
// Change state
- if(garbageState == GarbageState.UNVISITED || garbageState == GarbageState.ORPHANED) {
+ if(garbageState == GarbageState.UNVISITED || garbageState == GarbageState.ORPHANED || garbageState == GarbageState.CREATED) {
garbageState = GarbageState.REPARENTED;
} else {
// Bad state, this is an internal error
@@ -640,7 +640,9 @@ public class EditorPart extends PagePart implements IEditorPage {
*/
@Override
public void setFocus() {
- editorPart.setFocus();
+ if(editorPart != null) {
+ editorPart.setFocus();
+ }
}
diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/internal/TabFolderPart.java b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/internal/TabFolderPart.java
index aa4b701abd1..4578cd8d370 100644
--- a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/internal/TabFolderPart.java
+++ b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor/src/org/eclipse/papyrus/infra/core/sasheditor/internal/TabFolderPart.java
@@ -97,7 +97,7 @@ public class TabFolderPart extends AbstractTabFolderPart {
*/
public IDropTarget drag(Control currentControl, Object draggedObject, Point position, Rectangle dragRectangle) {
// System.out.println(TabFolderPart.this.getClass().getSimpleName() + ".drag()");
-// System.out.println(this + ".drag()");
+ // System.out.println(this + ".drag()");
return null;
}
};
@@ -108,14 +108,14 @@ public class TabFolderPart extends AbstractTabFolderPart {
private PTabFolder.IPTabFolderListener cTabFolderEventListener = new PTabFolder.IPTabFolderListener() {
public void contextMenuDetectEvent(CTabItem tab, Event event) {
-// System.out.println("contextMenuDetect()");
+ // System.out.println("contextMenuDetect()");
}
/**
* The close cross has been pressed. Remove the corresponding tab. {@inheritDoc}
*/
public void itemClosedEvent(CTabFolderEvent event, int pageIndex) {
-// System.out.println("itemClosedEvent()");
+ // System.out.println("itemClosedEvent()");
// TODO: call appropriate method (to be determine)
// model.removeTab(pageIndex);
// getSashWindowContainer().getContentProvider().removeTab(model, pageIndex);
@@ -123,7 +123,7 @@ public class TabFolderPart extends AbstractTabFolderPart {
}
public void menuDetectEvent(CTabItem tab, MenuDetectEvent event) {
-// System.out.println("menuDetectEvent()");
+ // System.out.println("menuDetectEvent()");
}
/**
@@ -184,6 +184,7 @@ public class TabFolderPart extends AbstractTabFolderPart {
*
* @param partMap
*/
+ @Override
public void fillPartMap(PartLists partMap) {
partMap.addPart(this);
garbageState = GarbageState.UNVISITED;
@@ -242,16 +243,17 @@ public class TabFolderPart extends AbstractTabFolderPart {
*/
private void initMenuManager() {
MenuManager menuManager = getSashWindowContainer().getFolderTabMenuManager();
- if(menuManager != null)
- {
+ if(menuManager != null) {
setFolderTabMenuManager(menuManager);
}
-
+
}
/**
* Set a {@link MenuManager} used to manage a contextual menu that is shown on the tabs area of this folder.
- * @param menuManager The {@link MenuManager} used to create the menu on the tab area.
+ *
+ * @param menuManager
+ * The {@link MenuManager} used to create the menu on the tab area.
*/
public void setFolderTabMenuManager(MenuManager menuManager) {
Composite folderControl = getControl();
@@ -261,10 +263,9 @@ public class TabFolderPart extends AbstractTabFolderPart {
/**
- * Called by any widget that has detected that the page has changed.
- * <br>
+ * Called by any widget that has detected that the page has changed. <br>
* As the selected page has been changed by a user ui interaction, we now need
- * to synchronize the ActivePage.
+ * to synchronize the ActivePage.
* Inform the {@link SashWindowsContainer} to set the active page accordingly to
* the new selection.
*
@@ -275,8 +276,9 @@ public class TabFolderPart extends AbstractTabFolderPart {
// System.out.println(this.getClass().getSimpleName() + ".pageChange("+ newPageIndex +")");
// Do nothing if out of range.
- if(newPageIndex < 0 || newPageIndex > currentTabItems.size() - 1)
+ if(newPageIndex < 0 || newPageIndex > currentTabItems.size() - 1) {
return;
+ }
getSashWindowContainer().setActivePage(currentTabItems.get(newPageIndex).childPart);
}
@@ -285,17 +287,18 @@ public class TabFolderPart extends AbstractTabFolderPart {
* An event signaling that the selected page is changed has been caught. Propagate the event to
* the container.
* Removed since 0.10
+ *
* @param newPageIndex
*/
-// protected void pageChangedEvent(int newPageIndex) {
-//
-// // System.out.println(this.getClass().getSimpleName() + ".pageChange("+ newPageIndex +")");
-// // Do nothing if out of range.
-// if(newPageIndex < 0 || newPageIndex > currentTabItems.size() - 1)
-// return;
-//
-// getSashWindowContainer().pageChangedEvent(currentTabItems.get(newPageIndex).childPart);
-// }
+ // protected void pageChangedEvent(int newPageIndex) {
+ //
+ // // System.out.println(this.getClass().getSimpleName() + ".pageChange("+ newPageIndex +")");
+ // // Do nothing if out of range.
+ // if(newPageIndex < 0 || newPageIndex > currentTabItems.size() - 1)
+ // return;
+ //
+ // getSashWindowContainer().pageChangedEvent(currentTabItems.get(newPageIndex).childPart);
+ // }
/**
* Select the specified page.
@@ -305,8 +308,9 @@ public class TabFolderPart extends AbstractTabFolderPart {
*/
protected void setSelection(int pageIndex) {
// Assert.isTrue(pageIndex >= 0 && pageIndex < getPageCount());
- if(!isValidPageIndex(pageIndex))
+ if(!isValidPageIndex(pageIndex)) {
return;
+ }
getTabFolder().setSelection(pageIndex);
}
@@ -316,7 +320,7 @@ public class TabFolderPart extends AbstractTabFolderPart {
* This does not set the ActivePage.
*
* @param page
- * the page that should be selected
+ * the page that should be selected
* @since 3.3
*/
public final void setSelection(PagePart requestedPage) {
@@ -337,14 +341,15 @@ public class TabFolderPart extends AbstractTabFolderPart {
*
* @see org.eclipse.papyrus.infra.core.sasheditor.eclipsecopy.MultiPageEditorTile#dispose()
*/
+ @Override
public void dispose() {
// detach menu as it is shared between folders.
getControl().setMenu(null);
deactivate();
-
-
-// getControl().dispose();
+
+
+ // getControl().dispose();
pTabFolder.dispose();
}
@@ -355,21 +360,21 @@ public class TabFolderPart extends AbstractTabFolderPart {
*/
@Override
public void disposeThisAndChildren() {
-
+
// Dispose children if any
- for( TabItemPart child : currentTabItems) {
+ for(TabItemPart child : currentTabItems) {
if(child != null) {
child.disposeThisAndChildren();
}
}
-
+
// clean up properties to help GC
partModel = null;
rawModel = null;
currentTabItems.clear();
currentTabItems = null;
dragOverListener = null;
-
+
}
/**
@@ -391,6 +396,7 @@ public class TabFolderPart extends AbstractTabFolderPart {
/**
* Return the swt Control associated to this part.
*/
+ @Override
public Composite getControl() {
return getTabFolder();
}
@@ -440,13 +446,15 @@ public class TabFolderPart extends AbstractTabFolderPart {
@Override
public AbstractPart findPartAt(Point toFind, Class<?> expectedTileType) {
- if(expectedTileType == this.getClass())
+ if(expectedTileType == this.getClass()) {
return this;
+ }
// ask current active tab
TabItemPart activeTabPart = getActiveTab();
- if(activeTabPart == null)
+ if(activeTabPart == null) {
return null;
+ }
return getActiveTab().findPartAt(toFind, expectedTileType);
}
@@ -476,9 +484,10 @@ public class TabFolderPart extends AbstractTabFolderPart {
}
/**
- * Get the visible PagePart (from the Container point of view).
+ * Get the visible PagePart (from the Container point of view).
* The visible PagePart is the one that has its diagram area visible.
* From the folder point of view, this is the active PagePart.
+ *
* @return
*/
public PagePart getVisiblePagePart() {
@@ -488,19 +497,21 @@ public class TabFolderPart extends AbstractTabFolderPart {
}
return null;
}
-
+
/**
* Find the part associated to the provided control.
*
*/
@Override
public AbstractPanelPart findPart(Object control) {
- if(getControl() == control)
+ if(getControl() == control) {
return this;
+ }
// Check if it is one of the Item
- if(control instanceof CTabItem && ((CTabItem)control).getParent() == getControl())
+ if(control instanceof CTabItem && ((CTabItem)control).getParent() == getControl()) {
return this;
+ }
// Ask childs TODO
return null;
@@ -517,6 +528,7 @@ public class TabFolderPart extends AbstractTabFolderPart {
* @param position
* @return
*/
+ @Override
public IDropTarget getDropTarget(Object draggedObject, TabFolderPart sourcePart, Point position) {
// see org.eclipse.ui.internal.presentations.util.ReplaceDragHandler
// Determine which tab we're currently dragging over
@@ -685,6 +697,7 @@ public class TabFolderPart extends AbstractTabFolderPart {
* @see
* @return the parent
*/
+ @Override
public void orphan() {
// orphan only if we are in UNCHANGED state
if(garbageState == GarbageState.UNVISITED) {
@@ -700,6 +713,7 @@ public class TabFolderPart extends AbstractTabFolderPart {
*
* @return
*/
+ @Override
public GarbageState getGarbageState() {
return garbageState;
}
@@ -709,6 +723,7 @@ public class TabFolderPart extends AbstractTabFolderPart {
*
* @see org.eclipse.papyrus.infra.core.sasheditor.sash.ITilePart#reparent(org.eclipse.papyrus.infra.core.sasheditor.sash.ITilePart)
*/
+ @Override
public void reparent(IPanelParent newParent, Composite swtParent) {
parent = newParent;
// Create control if needed
@@ -732,6 +747,7 @@ public class TabFolderPart extends AbstractTabFolderPart {
* The raw model to check
* @return
*/
+ @Override
public boolean isPartFor(Object realModel) {
return getRawModel() == realModel;
}
@@ -748,16 +764,18 @@ public class TabFolderPart extends AbstractTabFolderPart {
/**
* Refresh the tab of this page (I.e the name and icon in the tab).
*
- * @param page The page to be refreshed
+ * @param page
+ * The page to be refreshed
*/
- public void refreshPageTab( PagePart page) {
+ public void refreshPageTab(PagePart page) {
TabItemPart itemPart = currentTabItems.getByPagePart(page);
- if(itemPart==null)
+ if(itemPart == null) {
return;
-
+ }
+
itemPart.refreshTabDecorations();
}
-
+
/**
* Synchronize the TabFolder with the models.
* The Tabs order is fixed and can't be moved. So, we move the associated ITilepart if needed.
@@ -767,6 +785,7 @@ public class TabFolderPart extends AbstractTabFolderPart {
*
* @param partLists
*/
+ @Override
public void synchronize2(PartLists partLists) {
// get list of model to be displayed. This is a list of Object.
@@ -821,8 +840,9 @@ public class TabFolderPart extends AbstractTabFolderPart {
// end
}
// Set the active page as the last part if needed
- if(activePageIndex >= currentTabItems.size())
+ if(activePageIndex >= currentTabItems.size()) {
activePageIndex = currentTabItems.size() - 1;
+ }
}
@@ -888,15 +908,15 @@ public class TabFolderPart extends AbstractTabFolderPart {
// No part found, create one
modelPart = createChildPart(newModel);
if(modelPart != null) {
- existingParts.addCreatedPage(modelPart);
- // Attach it to the tabItem
- newTab = new TabItemPart(this, modelPart, index);
- }
+ existingParts.addCreatedPage(modelPart);
+ // Attach it to the tabItem
+ newTab = new TabItemPart(this, modelPart, index);
+ }
}
// Add to the list of items.
if(newTab != null) {
- currentTabItems.add(index, newTab);
+ currentTabItems.add(index, newTab);
}
}
@@ -938,6 +958,9 @@ public class TabFolderPart extends AbstractTabFolderPart {
} else {
// No part found, create one
modelPart = createChildPart(newModel);
+ if(modelPart == null) {
+ System.out.println("break");
+ }
existingParts.addCreatedPage(modelPart);
// Attach it to the tabItem
tabItem.resetChild(modelPart);
@@ -959,19 +982,19 @@ public class TabFolderPart extends AbstractTabFolderPart {
IPageModel partModel = getPartModel().createChildSashModel(newModel);
if(partModel != null) {
- // Delegate part creation to the container. This allow the container to provide appropriate
- // objects not available from the part.
- PagePart newPart = getSashWindowContainer().createPagePart(this, partModel, newModel);
- // Create control.
- // Fire events before and after
- getSashWindowContainer().getLifeCycleEventProvider().firePageAboutToBeOpenedEvent(newPart);
- newPart.createPartControl(getControl());
- getSashWindowContainer().getLifeCycleEventProvider().firePageOpenedEvent(newPart);
-
- return newPart;
- }
- // Use exception ?
- return null;
+ // Delegate part creation to the container. This allow the container to provide appropriate
+ // objects not available from the part.
+ PagePart newPart = getSashWindowContainer().createPagePart(this, partModel, newModel);
+ // Create control.
+ // Fire events before and after
+ getSashWindowContainer().getLifeCycleEventProvider().firePageAboutToBeOpenedEvent(newPart);
+ newPart.createPartControl(getControl());
+ getSashWindowContainer().getLifeCycleEventProvider().firePageOpenedEvent(newPart);
+
+ return newPart;
+ }
+ // Use exception ?
+ return null;
}
/**
@@ -1047,8 +1070,7 @@ public class TabFolderPart extends AbstractTabFolderPart {
// + ", " + this);
CTabFolder ctrl = getTabFolder();
- System.out.printf("tabfolder[%2d]: disposed=%-5b, visible=%-5b, garbState=%-10s, %s\n"
- , currentTabItems.size(), ctrl.isDisposed(), (ctrl.isDisposed() ? false : getTabFolder().isVisible()), garbageState, this);
+ System.out.printf("tabfolder[%2d]: disposed=%-5b, visible=%-5b, garbState=%-10s, %s\n", currentTabItems.size(), ctrl.isDisposed(), (ctrl.isDisposed() ? false : getTabFolder().isVisible()), garbageState, this);
}
/**
@@ -1058,6 +1080,7 @@ public class TabFolderPart extends AbstractTabFolderPart {
* @param visitor
* @return
*/
+ @Override
public boolean visit(IPartVisitor visitor) {
return visitor.accept(this);
}
@@ -1070,8 +1093,9 @@ public class TabFolderPart extends AbstractTabFolderPart {
public boolean visitChildren(IPartVisitor visitor) {
for(TabItemPart child : currentTabItems) {
- if(!child.visit(visitor))
+ if(!child.visit(visitor)) {
return false;
+ }
}
// All children have accepter the visit, continue visiting.
return true;
@@ -1106,13 +1130,17 @@ public class TabFolderPart extends AbstractTabFolderPart {
*/
public int indexOfModel(Object o) {
if(o == null) {
- for(int i = 0; i < size(); i++)
- if(get(i) == null)
+ for(int i = 0; i < size(); i++) {
+ if(get(i) == null) {
return i;
+ }
+ }
} else {
- for(int i = 0; i < size(); i++)
- if(o.equals(get(i).getChildPart().getRawModel()))
+ for(int i = 0; i < size(); i++) {
+ if(o.equals(get(i).getChildPart().getRawModel())) {
return i;
+ }
+ }
}
return -1;
}
@@ -1180,22 +1208,21 @@ public class TabFolderPart extends AbstractTabFolderPart {
Point pt = new Point(e.x, e.y);
CTabItem item = folder.getItem(pt);
int index = pTabFolder.getItemIndex(pt);
- if(index == -1)
- {
+ if(index == -1) {
toolTipManager.closeToolTip();
return;
}
PagePart part = currentTabItems.get(index).getChildPart();
-// System.out.println("MouseHover(" + e.widget
-// + ", part=" + part.getPageTitle()
-// + ", item=" + item
-// + ") - " + count++);
+ // System.out.println("MouseHover(" + e.widget
+ // + ", part=" + part.getPageTitle()
+ // + ", item=" + item
+ // + ") - " + count++);
// TODO move it away
//toolTipManager.showToolTip(item.getBounds(), part.getControl(), pt);
toolTipManager.showToolTip(part, item.getBounds(), pt);
}
-
+
};
@@ -1210,7 +1237,7 @@ public class TabFolderPart extends AbstractTabFolderPart {
public void handleEvent(Event event) {
switch(event.type) {
case SWT.MouseUp:
-// System.out.println("MouseUp()" + count++);
+ // System.out.println("MouseUp()" + count++);
toolTipManager.disableToolTip();
break;
}
@@ -1239,7 +1266,7 @@ public class TabFolderPart extends AbstractTabFolderPart {
control.removeListener(SWT.MouseUp, mouseClickedListener);
toolTipManager.dispose();
}
-
+
}
diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core/build.properties b/plugins/infra/core/org.eclipse.papyrus.infra.core/build.properties
index 7661d57ceb4..c7d739adfb7 100644
--- a/plugins/infra/core/org.eclipse.papyrus.infra.core/build.properties
+++ b/plugins/infra/core/org.eclipse.papyrus.infra.core/build.properties
@@ -2,6 +2,6 @@
#Mon Sep 12 09:29:37 CEST 2011
bin.includes=META-INF/,.,plugin.xml,schema/,plugin.properties,.options,icons/,about.ini,about.properties,about.html
output..=bin/
-src.includes=about.html,icons/,schema/,about.ini,about.properties
+src.includes = about.html
source..=src/
diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core/plugin.xml b/plugins/infra/core/org.eclipse.papyrus.infra.core/plugin.xml
index b825da03616..9644bea4c01 100644
--- a/plugins/infra/core/org.eclipse.papyrus.infra.core/plugin.xml
+++ b/plugins/infra/core/org.eclipse.papyrus.infra.core/plugin.xml
@@ -175,7 +175,7 @@
<serviceFactory
classname="org.eclipse.papyrus.infra.core.editor.ModelSetServiceFactory"
description="The service loading Models"
- id="org.eclipse.papyrus.resource.ModelSet"
+ id="org.eclipse.papyrus.infra.core.resource.ModelSet"
priority="1"
startKind="startup">
</serviceFactory>
@@ -186,7 +186,7 @@
priority="1"
startKind="startup">
<dependsOn
- serviceKeyRef="org.eclipse.papyrus.resource.ModelSet">
+ serviceKeyRef="org.eclipse.papyrus.infra.core.resource.ModelSet">
</dependsOn>
</serviceFactory>
<serviceFactory
@@ -196,7 +196,17 @@
priority="1"
startKind="startup">
<dependsOn
- serviceKeyRef="org.eclipse.papyrus.resource.ModelSet">
+ serviceKeyRef="org.eclipse.papyrus.infra.core.resource.ModelSet">
+ </dependsOn>
+ </serviceFactory>
+ <serviceFactory
+ classname="org.eclipse.papyrus.infra.core.resource.EditingDomainServiceFactory"
+ description="Editing Domain"
+ id="org.eclipse.emf.edit.domain.EditingDomain"
+ priority="1"
+ startKind="startup">
+ <dependsOn
+ serviceKeyRef="org.eclipse.papyrus.infra.core.resource.ModelSet">
</dependsOn>
</serviceFactory>
<serviceFactory
@@ -215,7 +225,7 @@
serviceKeyRef="org.eclipse.emf.transaction.TransactionalEditingDomain">
</dependsOn>
<dependsOn
- serviceKeyRef="org.eclipse.papyrus.resource.ModelSet">
+ serviceKeyRef="org.eclipse.papyrus.infra.core.resource.ModelSet">
</dependsOn>
</serviceFactory>
<serviceFactory
@@ -228,7 +238,7 @@
serviceKeyRef="org.eclipse.emf.transaction.TransactionalEditingDomain">
</dependsOn>
<dependsOn
- serviceKeyRef="org.eclipse.papyrus.resource.ModelSet">
+ serviceKeyRef="org.eclipse.papyrus.infra.core.resource.ModelSet">
</dependsOn>
</serviceFactory>
<serviceFactory
@@ -261,7 +271,7 @@
serviceKeyRef="org.eclipse.emf.transaction.TransactionalEditingDomain">
</dependsOn>
<dependsOn
- serviceKeyRef="org.eclipse.papyrus.resource.ModelSet">
+ serviceKeyRef="org.eclipse.papyrus.infra.core.resource.ModelSet">
</dependsOn>
</service>
<serviceFactory
@@ -274,6 +284,16 @@
serviceKeyRef=" org.eclipse.papyrus.infra.core.lifecycleevents.ISaveAndDirtyService">
</dependsOn>
</serviceFactory>
+ <serviceFactory
+ classname="org.eclipse.papyrus.infra.core.editor.PageMngrServiceFactory"
+ description="IPageManager allows to add and remove pages to the editor."
+ id="org.eclipse.papyrus.infra.core.sasheditor.contentprovider.IPageManager"
+ priority="1"
+ startKind="startup">
+ <dependsOn
+ serviceKeyRef="org.eclipse.papyrus.infra.core.sasheditor.di.contentprovider.DiSashModelManager">
+ </dependsOn>
+ </serviceFactory>
</extension>
<extension
point="org.eclipse.ui.exportWizards">
diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/editor/CoreMultiDiagramEditor.java b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/editor/CoreMultiDiagramEditor.java
index a2eeb0edbd7..7ab1f520db5 100644
--- a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/editor/CoreMultiDiagramEditor.java
+++ b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/editor/CoreMultiDiagramEditor.java
@@ -17,12 +17,14 @@ package org.eclipse.papyrus.infra.core.editor;
import static org.eclipse.papyrus.infra.core.Activator.log;
import java.util.ArrayList;
+import java.util.EventObject;
import java.util.List;
import org.eclipse.core.commands.operations.IUndoContext;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IMarker;
import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.emf.common.command.CommandStackListener;
import org.eclipse.emf.common.notify.AdapterFactory;
import org.eclipse.emf.common.util.URI;
import org.eclipse.emf.ecore.EObject;
@@ -31,6 +33,7 @@ import org.eclipse.emf.edit.domain.IEditingDomainProvider;
import org.eclipse.emf.edit.provider.ComposedAdapterFactory;
import org.eclipse.emf.edit.provider.IItemLabelProvider;
import org.eclipse.emf.edit.ui.provider.AdapterFactoryLabelProvider;
+import org.eclipse.emf.transaction.TransactionalCommandStack;
import org.eclipse.emf.transaction.TransactionalEditingDomain;
import org.eclipse.gef.ui.actions.ActionRegistry;
import org.eclipse.jface.action.MenuManager;
@@ -47,10 +50,10 @@ import org.eclipse.papyrus.infra.core.multidiagram.actionbarcontributor.CoreComp
import org.eclipse.papyrus.infra.core.resource.ModelMultiException;
import org.eclipse.papyrus.infra.core.resource.ModelSet;
import org.eclipse.papyrus.infra.core.sasheditor.contentprovider.IContentChangedListener;
+import org.eclipse.papyrus.infra.core.sasheditor.contentprovider.IPageManager;
import org.eclipse.papyrus.infra.core.sasheditor.contentprovider.IPageMngr;
import org.eclipse.papyrus.infra.core.sasheditor.contentprovider.ISashWindowsContentProvider;
import org.eclipse.papyrus.infra.core.sasheditor.di.contentprovider.DiSashModelManager;
-import org.eclipse.papyrus.infra.core.sasheditor.di.contentprovider.DiSashModelMngr;
import org.eclipse.papyrus.infra.core.sasheditor.editor.AbstractMultiPageSashEditor;
import org.eclipse.papyrus.infra.core.sasheditor.editor.ISashWindowsContainer;
import org.eclipse.papyrus.infra.core.sasheditor.editor.gef.MultiDiagramEditorGefDelegate;
@@ -162,8 +165,9 @@ public class CoreMultiDiagramEditor extends AbstractMultiPageSashEditor implemen
// the exec queue.
// When the method is executed asynchronously, the object is already finalized, and so
// editor is null.
- if(editor==null)
+ if(editor == null) {
return;
+ }
editor.firePropertyChange(IEditorPart.PROP_DIRTY);
}
});
@@ -215,30 +219,35 @@ public class CoreMultiDiagramEditor extends AbstractMultiPageSashEditor implemen
*/
private EditingDomainProvider domainProvider = new EditingDomainProvider(this);
- private static class ContentChangedListener implements IContentChangedListener {
-
- private CoreMultiDiagramEditor editor;
+ private boolean needsRefresh;
- public ContentChangedListener(CoreMultiDiagramEditor editor) {
- this.editor = editor;
- }
+ private class ContentChangedListener implements IContentChangedListener {
/**
* Called when the content is changed. RefreshTabs.
*/
public void contentChanged(ContentEvent event) {
- editor.refreshTabs();
+ needsRefresh = true;
}
+ }
- public void dispose() {
- this.editor = null;
+ private class RefreshTabsCommandStackListener implements CommandStackListener {
+
+ public void commandStackChanged(EventObject event) {
+ if(needsRefresh) {
+ needsRefresh = false;
+ refreshTabs();
+ }
}
+
}
/**
* A listener on model change events.
*/
- private ContentChangedListener contentChangedListener = new ContentChangedListener(this);
+ private ContentChangedListener contentChangedListener = new ContentChangedListener();
+
+ private RefreshTabsCommandStackListener refreshTabsCommandStackListener = new RefreshTabsCommandStackListener();
/**
* Undo context used to have the same undo context in all Papyrus related
@@ -317,17 +326,17 @@ public class CoreMultiDiagramEditor extends AbstractMultiPageSashEditor implemen
* @param pageFactory
* @param diResource
* Resource used to load/save the SashModel.
- *
- *
+ *
+ *
*/
-// protected ISashWindowsContentProvider createPageProvider(IPageModelFactory pageFactory, Resource diResource, TransactionalEditingDomain editingDomain) {
-//
-// sashModelMngr = new TransactionalDiSashModelMngr(pageFactory, diResource, editingDomain);
-//
-// ISashWindowsContentProvider pageProvider = sashModelMngr.getISashWindowsContentProvider();
-//
-// return pageProvider;
-// }
+ // protected ISashWindowsContentProvider createPageProvider(IPageModelFactory pageFactory, Resource diResource, TransactionalEditingDomain editingDomain) {
+ //
+ // sashModelMngr = new TransactionalDiSashModelMngr(pageFactory, diResource, editingDomain);
+ //
+ // ISashWindowsContentProvider pageProvider = sashModelMngr.getISashWindowsContentProvider();
+ //
+ // return pageProvider;
+ // }
/**
* Get The {@link IPageMngr} used to add, open, remove or close a diagram in
@@ -336,9 +345,9 @@ public class CoreMultiDiagramEditor extends AbstractMultiPageSashEditor implemen
*
* @return
*/
- protected IPageMngr getIPageMngr() throws IllegalStateException {
+ protected IPageManager getIPageManager() throws IllegalStateException {
try {
- return sashModelMngr.getIPageMngr();
+ return sashModelMngr.getIPageManager();
} catch (Exception e) {
throw new IllegalStateException("Method should be called after CoreMultiDiagramEditor#init(IEditorSite, IEditorInput) is called");
}
@@ -393,8 +402,8 @@ public class CoreMultiDiagramEditor extends AbstractMultiPageSashEditor implemen
return getServicesRegistry();
}
- if(IPageMngr.class == adapter) {
- return getIPageMngr();
+ if(IPageMngr.class == adapter || IPageManager.class == adapter) {
+ return getIPageManager();
}
if(IPropertySheetPage.class == adapter) {
@@ -608,13 +617,14 @@ public class CoreMultiDiagramEditor extends AbstractMultiPageSashEditor implemen
// Listen on contentProvider changes
sashModelMngr.getSashModelContentChangedProvider().addListener(contentChangedListener);
+ ((TransactionalCommandStack)transactionalEditingDomain.getCommandStack()).addCommandStackListener(refreshTabsCommandStackListener);
// Listen on input changed from the ISaveAndDirtyService
saveAndDirtyService.addInputChangedListener(editorInputChangedListener);
if(input instanceof IPapyrusPageInput) {
IPapyrusPageInput papyrusPageInput = (IPapyrusPageInput)input;
- IPageMngr pageMngr = getIPageMngr();
+ IPageManager pageMngr = getIPageManager();
if(papyrusPageInput.closeOtherPages()) {
pageMngr.closeAllOpenedPages();
@@ -628,10 +638,10 @@ public class CoreMultiDiagramEditor extends AbstractMultiPageSashEditor implemen
}
if(pageMngr.isOpen(pageIdentifier)) {
- pageMngr.closePage(pageIdentifier);
+ pageMngr.selectPage(pageIdentifier);
+ } else {
+ pageMngr.openPage(pageIdentifier);
}
-
- pageMngr.openPage(pageIdentifier);
}
}
}
@@ -656,13 +666,13 @@ public class CoreMultiDiagramEditor extends AbstractMultiPageSashEditor implemen
getServicesRegistry().startServicesByClassKeys(ISashWindowsContainer.class);
// Let the IPageMngr use the ISashWindowsContainer to discover current folder
// This should be done after SashWindowContainer initialization.
-// DiSashModelManager sashModelManager = getServicesRegistry().getService(DiSashModelManager.class);
+ // DiSashModelManager sashModelManager = getServicesRegistry().getService(DiSashModelManager.class);
sashModelMngr.setCurrentFolderAndPageMngr(getISashWindowsContainer());
-
+
} catch (ServiceException e) {
log.error(e);
}
-
+
}
/**
@@ -707,6 +717,7 @@ public class CoreMultiDiagramEditor extends AbstractMultiPageSashEditor implemen
public void dispose() {
if(sashModelMngr != null) {
sashModelMngr.getSashModelContentChangedProvider().removeListener(contentChangedListener);
+ transactionalEditingDomain.getCommandStack().removeCommandStackListener(refreshTabsCommandStackListener);
}
// Avoid memory leak
@@ -732,10 +743,13 @@ public class CoreMultiDiagramEditor extends AbstractMultiPageSashEditor implemen
}
if(contentChangedListener != null) {
- this.contentChangedListener.dispose();
this.contentChangedListener = null;
}
+ if(refreshTabsCommandStackListener != null) {
+ refreshTabsCommandStackListener = null;
+ }
+
if(editorInputChangedListener != null) {
this.editorInputChangedListener.dispose();
this.editorInputChangedListener = null;
@@ -937,6 +951,10 @@ public class CoreMultiDiagramEditor extends AbstractMultiPageSashEditor implemen
@Override
public IEditorPart getActiveEditor() {
+ if(needsRefresh) {
+ needsRefresh = false;
+ refreshTabs();
+ }
return super.getActiveEditor();
}
}
diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/modelsetquery/impl/ModelSetQueryInitializer.java b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/modelsetquery/impl/ModelSetQueryInitializer.java
index f1a77c24c4b..17dc7b993cd 100644
--- a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/modelsetquery/impl/ModelSetQueryInitializer.java
+++ b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/modelsetquery/impl/ModelSetQueryInitializer.java
@@ -32,7 +32,7 @@ public class ModelSetQueryInitializer implements IModelSetSnippet {
private IModelSetQueryAdapter modelQueryAdapter;
/**
- * @see org.eclipse.papyrus.resource.IModelSetSnippet#start(org.eclipse.papyrus.resource.ModelSet)
+ * @see org.eclipse.papyrus.resource.IModelSetSnippet#start(org.eclipse.papyrus.infra.core.resource.ModelSet)
*
* @param modelsManager
*/
@@ -47,8 +47,8 @@ public class ModelSetQueryInitializer implements IModelSetSnippet {
}
if(!found) {
modelQueryAdapter = createDefaultIModelSetQueryAdapter();
- if (modelQueryAdapter instanceof Adapter) {
- eAdapters.add((Adapter) modelQueryAdapter);
+ if(modelQueryAdapter instanceof Adapter) {
+ eAdapters.add((Adapter)modelQueryAdapter);
}
}
@@ -60,7 +60,7 @@ public class ModelSetQueryInitializer implements IModelSetSnippet {
}
/**
- * @see org.eclipse.papyrus.resource.IModelSetSnippet#dispose(org.eclipse.papyrus.resource.ModelSet)
+ * @see org.eclipse.papyrus.resource.IModelSetSnippet#dispose(org.eclipse.papyrus.infra.core.resource.ModelSet)
*
* @param modelsManager
*/
diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/services/ServicesRegistry.java b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/services/ServicesRegistry.java
index 478d7338535..3999fb29b89 100644
--- a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/services/ServicesRegistry.java
+++ b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/services/ServicesRegistry.java
@@ -851,11 +851,8 @@ public class ServicesRegistry {
// Clean up properties to help GC
addedServices.clear();
- addedServices = null;
anonymousServices.clear();
- anonymousServices = null;
namedServices.clear();
- namedServices = null;
// Report errors if any
if(errors.getExceptions().size() > 0) {
@@ -988,9 +985,9 @@ public class ServicesRegistry {
for(ServiceStartupEntry serviceEntry : services) {
try {
serviceEntry.disposeService();
- } catch (ServiceException e) {
- log.log(Level.SEVERE, "Can't dispose service '" + serviceEntry.getDescriptor().getKey() + "'", e);
- errors.addException(serviceEntry.getDescriptor(), e);
+ } catch (Exception ex) {
+ log.log(Level.SEVERE, "Can't dispose service'" + serviceEntry.getDescriptor().getKey() + "'", ex);
+ errors.addException(serviceEntry.getDescriptor(), ex);
}
}
}
diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/utils/AbstractServiceUtils.java b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/utils/AbstractServiceUtils.java
index b9253696df2..ad9fb429ee3 100644
--- a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/utils/AbstractServiceUtils.java
+++ b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/utils/AbstractServiceUtils.java
@@ -17,6 +17,7 @@ package org.eclipse.papyrus.infra.core.utils;
import org.eclipse.emf.transaction.TransactionalEditingDomain;
import org.eclipse.papyrus.infra.core.lifecycleevents.ILifeCycleEventsProvider;
import org.eclipse.papyrus.infra.core.resource.ModelSet;
+import org.eclipse.papyrus.infra.core.sasheditor.contentprovider.IPageManager;
import org.eclipse.papyrus.infra.core.sasheditor.contentprovider.IPageMngr;
import org.eclipse.papyrus.infra.core.sasheditor.editor.ISashWindowsContainer;
import org.eclipse.papyrus.infra.core.services.ServiceException;
@@ -66,12 +67,27 @@ public abstract class AbstractServiceUtils<T> {
* @return
* @throws ServiceException
* If an error occurs while getting the requested service.
+ *
+ * @deprecated Use {@link #getIPageManager(Object)} instead
*/
+ @Deprecated
public IPageMngr getIPageMngr(T from) throws ServiceException {
return getServiceRegistry(from).getService(IPageMngr.class);
}
/**
+ * Gets the {@link IPageManager} registered in the {@link ServicesRegistry}.
+ *
+ * @param from
+ * @return
+ * @throws ServiceException
+ * If an error occurs while getting the requested service.
+ */
+ public IPageManager getIPageManager(T from) throws ServiceException {
+ return getServiceRegistry(from).getService(IPageManager.class);
+ }
+
+ /**
* Gets the {@link IPageMngr} registered in the {@link ServicesRegistry}.
*
* @param from
diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/utils/EditorUtils.java b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/utils/EditorUtils.java
index f3ea7a7bcfd..b39091c5798 100644
--- a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/utils/EditorUtils.java
+++ b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/utils/EditorUtils.java
@@ -130,7 +130,11 @@ public class EditorUtils {
* @param editingDomain
*
* @return The transactional implementation of IPageMngr
+ *
+ * @deprecated The TransactionalIPageMngr is deprecated. You should use IPageManager instead.
+ * Transactions should be started by the IPageManager user when necessary.
*/
+ @Deprecated
public static IPageMngr getTransactionalIPageMngr(Resource diResource, TransactionalEditingDomain editingDomain) {
return TransactionalDiSashModelMngr.createIPageMngr(diResource, editingDomain);
}
diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/utils/ServiceUtilsForActionHandlers.java b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/utils/ServiceUtilsForActionHandlers.java
index be502649376..c5c582f3aaf 100644
--- a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/utils/ServiceUtilsForActionHandlers.java
+++ b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/utils/ServiceUtilsForActionHandlers.java
@@ -17,6 +17,7 @@ package org.eclipse.papyrus.infra.core.utils;
import org.eclipse.emf.transaction.TransactionalEditingDomain;
import org.eclipse.papyrus.infra.core.lifecycleevents.ILifeCycleEventsProvider;
import org.eclipse.papyrus.infra.core.resource.ModelSet;
+import org.eclipse.papyrus.infra.core.sasheditor.contentprovider.IPageManager;
import org.eclipse.papyrus.infra.core.sasheditor.contentprovider.IPageMngr;
import org.eclipse.papyrus.infra.core.sasheditor.editor.ISashWindowsContainer;
import org.eclipse.papyrus.infra.core.services.ServiceException;
@@ -99,12 +100,26 @@ public class ServiceUtilsForActionHandlers {
* @return
* @throws ServiceException
* If an error occurs while getting the requested service.
+ *
+ * @deprecated Use {@link #getIPageManager} instead
*/
+ @Deprecated
public IPageMngr getIPageMngr() throws ServiceException {
return getServiceRegistry().getService(IPageMngr.class);
}
/**
+ * Gets the {@link IPageManager} registered in the {@link ServicesRegistry}.
+ *
+ * @return
+ * @throws ServiceException
+ * If an error occurs while getting the requested service.
+ */
+ public IPageManager getIPageManager() throws ServiceException {
+ return getServiceRegistry().getService(IPageManager.class);
+ }
+
+ /**
* Gets the {@link IPageMngr} registered in the {@link ServicesRegistry}.
*
* @return
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 337ffc14cee..365d36a80f2 100644
--- a/plugins/infra/emf/org.eclipse.papyrus.infra.emf/plugin.xml
+++ b/plugins/infra/emf/org.eclipse.papyrus.infra.emf/plugin.xml
@@ -10,7 +10,7 @@
priority="1"
startKind="startup">
<dependsOn
- serviceKeyRef="org.eclipse.papyrus.resource.ModelSet">
+ serviceKeyRef="org.eclipse.papyrus.infra.core.resource.ModelSet">
</dependsOn>
</service>
</extension>
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 723454b1b4a..de352fc6f25 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,8 +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.IPageMngr;
-import org.eclipse.papyrus.infra.core.sasheditor.di.contentprovider.DiSashModelMngr;
+import org.eclipse.papyrus.infra.core.sasheditor.contentprovider.IPageManager;
import org.eclipse.papyrus.infra.core.services.ServicesRegistry;
import org.eclipse.papyrus.infra.emf.Activator;
@@ -37,7 +36,7 @@ public class MoDiscoContentProvider extends CustomizableModelContentProvider {
protected ModelSet modelSet;
/** The list of open pages (diagrams) */
- protected IPageMngr pageMngr;
+ protected IPageManager pageMngr;
/**
* Creates a new MoDiscoContentProvider.
@@ -80,7 +79,7 @@ public class MoDiscoContentProvider extends CustomizableModelContentProvider {
ServicesRegistry servicesRegistry = (ServicesRegistry)inputElement;
modelSet = ModelUtils.getModelSetChecked(servicesRegistry);
- pageMngr = servicesRegistry.getService(DiSashModelMngr.class).getIPageMngr();
+ pageMngr = servicesRegistry.getService(IPageManager.class);
return getRootElements(modelSet);
} catch (Exception e) {
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.commands/src/org/eclipse/papyrus/commands/OpenDiagramCommand.java b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.commands/src/org/eclipse/papyrus/commands/OpenDiagramCommand.java
index 7e6e50ebf81..fd9cdc16722 100644
--- a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.commands/src/org/eclipse/papyrus/commands/OpenDiagramCommand.java
+++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.commands/src/org/eclipse/papyrus/commands/OpenDiagramCommand.java
@@ -17,25 +17,25 @@ import org.eclipse.core.commands.ExecutionException;
import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.transaction.TransactionalEditingDomain;
+import org.eclipse.gmf.runtime.common.core.command.AbstractCommand;
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.resource.ModelSet;
-import org.eclipse.papyrus.infra.core.resource.sasheditor.DiModelUtils;
-import org.eclipse.papyrus.infra.core.sasheditor.contentprovider.IPageMngr;
-import org.eclipse.papyrus.infra.core.utils.EditorUtils;
+import org.eclipse.papyrus.infra.core.sasheditor.contentprovider.IPageManager;
+import org.eclipse.papyrus.infra.core.services.ServiceException;
+import org.eclipse.papyrus.infra.emf.utils.ServiceUtilsForEObject;
/**
* The Class OpenDiagramCommand.
*/
-public class OpenDiagramCommand extends AbstractTransactionalCommand {
+public class OpenDiagramCommand extends AbstractCommand {
/** The diagram to open. */
private EObject diagramToOpen = null;
private ICommand previousCreateDiagramCommand = null;
+ private boolean didOpen;
+
/**
* Instantiates a new open diagram command.
*
@@ -44,13 +44,13 @@ public class OpenDiagramCommand extends AbstractTransactionalCommand {
* @param diagram
* the diagram
*/
- public OpenDiagramCommand(TransactionalEditingDomain editingDomain, EObject diagram) {
- super(editingDomain, "Open diagram", null);
+ public OpenDiagramCommand(EObject diagram) {
+ super("Open diagram", null);
diagramToOpen = diagram;
}
- public OpenDiagramCommand(TransactionalEditingDomain editingDomain, ICommand previousCreateDiagramCommand) {
- super(editingDomain, "Open diagram", null);
+ public OpenDiagramCommand(ICommand previousCreateDiagramCommand) {
+ super("Open diagram", null);
this.previousCreateDiagramCommand = previousCreateDiagramCommand;
}
@@ -67,10 +67,8 @@ public class OpenDiagramCommand extends AbstractTransactionalCommand {
}
}
-
-
if(diagramToOpen != null) {
- IPageMngr pageMngr;
+ IPageManager pageManager;
// bug 358799
// The command is also called during the initialiation phase. In this case, the
@@ -83,18 +81,15 @@ public class OpenDiagramCommand extends AbstractTransactionalCommand {
* pageMngr =serviceRegistry.getService(IPageMngr.class);
* } else
*/
- if(getEditingDomain().getResourceSet() instanceof ModelSet) {
- ModelSet modelSet = (ModelSet)getEditingDomain().getResourceSet();
- pageMngr = EditorUtils.getIPageMngr(DiModelUtils.getDiResource(modelSet));
- } else {
- throw new IllegalStateException("Enable to get the page manager");////$NON-NLS-1$
- }
+ pageManager = ServiceUtilsForEObject.getInstance().getIPageManager(diagramToOpen);
-
- if(pageMngr.isOpen(diagramToOpen)) {
- pageMngr.closePage(diagramToOpen);
+ if(pageManager.isOpen(diagramToOpen)) {
+ pageManager.selectPage(diagramToOpen);
+ didOpen = false;
+ } else {
+ pageManager.openPage(diagramToOpen);
+ didOpen = true;
}
- pageMngr.openPage(diagramToOpen);
}
return CommandResult.newOKCommandResult();
@@ -102,4 +97,24 @@ public class OpenDiagramCommand extends AbstractTransactionalCommand {
throw new ExecutionException("Can't open diagram", e);
}
}
+
+ @Override
+ protected CommandResult doRedoWithResult(IProgressMonitor progressMonitor, IAdaptable info) throws ExecutionException {
+ return doExecuteWithResult(progressMonitor, info);
+ }
+
+ @Override
+ protected CommandResult doUndoWithResult(IProgressMonitor progressMonitor, IAdaptable info) throws ExecutionException {
+ try {
+ IPageManager pageManager = ServiceUtilsForEObject.getInstance().getIPageManager(diagramToOpen);
+
+ if(didOpen) {
+ pageManager.closePage(diagramToOpen);
+ }
+
+ return CommandResult.newOKCommandResult();
+ } catch (ServiceException ex) {
+ return CommandResult.newErrorCommandResult(ex);
+ }
+ }
}
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/AbstractPapyrusGmfCreateDiagramCommandHandler.java b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/AbstractPapyrusGmfCreateDiagramCommandHandler.java
index 6e556b0b22b..a7f8937277d 100644
--- a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/AbstractPapyrusGmfCreateDiagramCommandHandler.java
+++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/AbstractPapyrusGmfCreateDiagramCommandHandler.java
@@ -35,26 +35,24 @@ import org.eclipse.gmf.runtime.common.core.command.ICommand;
import org.eclipse.gmf.runtime.diagram.core.preferences.PreferencesHint;
import org.eclipse.gmf.runtime.diagram.core.services.ViewService;
import org.eclipse.gmf.runtime.emf.commands.core.command.AbstractTransactionalCommand;
-import org.eclipse.gmf.runtime.emf.type.core.requests.DestroyElementRequest;
import org.eclipse.gmf.runtime.notation.Diagram;
import org.eclipse.jface.dialogs.InputDialog;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.window.Window;
-import org.eclipse.papyrus.commands.DestroyElementPapyrusCommand;
import org.eclipse.papyrus.commands.ICreationCommand;
import org.eclipse.papyrus.commands.OpenDiagramCommand;
import org.eclipse.papyrus.commands.wrappers.GMFtoEMFCommandWrapper;
import org.eclipse.papyrus.infra.core.editor.IMultiDiagramEditor;
import org.eclipse.papyrus.infra.core.resource.ModelSet;
import org.eclipse.papyrus.infra.core.resource.sasheditor.DiModelUtils;
-import org.eclipse.papyrus.infra.core.sasheditor.contentprovider.IPageMngr;
+import org.eclipse.papyrus.infra.core.sasheditor.contentprovider.IPageManager;
import org.eclipse.papyrus.infra.core.sasheditor.contentprovider.ISashWindowsContentProvider;
import org.eclipse.papyrus.infra.core.services.ServiceException;
import org.eclipse.papyrus.infra.core.services.ServicesRegistry;
-import org.eclipse.papyrus.infra.core.utils.EditorUtils;
import org.eclipse.papyrus.infra.emf.utils.EMFHelper;
import org.eclipse.papyrus.infra.emf.utils.ServiceUtilsForHandlers;
+import org.eclipse.papyrus.infra.emf.utils.ServiceUtilsForResource;
import org.eclipse.papyrus.infra.gmfdiag.common.model.NotationUtils;
import org.eclipse.papyrus.uml.tools.model.UmlUtils;
import org.eclipse.swt.widgets.Display;
@@ -128,7 +126,7 @@ public abstract class AbstractPapyrusGmfCreateDiagramCommandHandler extends Abst
CompositeCommand cmd = new CompositeCommand("Create diagram");
ICommand createCmd = getCreateDiagramCommand(modelSet, container, name);
cmd.add(createCmd);
- cmd.add(new OpenDiagramCommand(dom, createCmd));
+ cmd.add(new OpenDiagramCommand(createCmd));
dom.getCommandStack().execute(new GMFtoEMFCommandWrapper(cmd));
}
@@ -303,7 +301,9 @@ public abstract class AbstractPapyrusGmfCreateDiagramCommandHandler extends Abst
return new AbstractTransactionalCommand(modelSet.getTransactionalEditingDomain(), Messages.AbstractPapyrusGmfCreateDiagramCommandHandler_CreateDiagramCommandLabel, modifiedFiles) {
- protected Diagram diagram = null;
+ protected Diagram diagram;
+
+ protected EObject modelElement;
@Override
protected CommandResult doExecuteWithResult(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
@@ -326,9 +326,14 @@ public abstract class AbstractPapyrusGmfCreateDiagramCommandHandler extends Abst
diagram = createDiagram(notationResource, model, name);
if(diagram != null) {
- IPageMngr pageMngr = EditorUtils.getIPageMngr(diResource);
- pageMngr.addPage(diagram);
- return CommandResult.newOKCommandResult(diagram);
+ try {
+ IPageManager pageManager = ServiceUtilsForResource.getInstance().getIPageManager(diResource);
+ pageManager.addPage(diagram);
+ return CommandResult.newOKCommandResult(diagram);
+ } catch (ServiceException ex) {
+ Activator.log.error(ex);
+ return CommandResult.newErrorCommandResult(ex);
+ }
}
return CommandResult.newErrorCommandResult("Error during diagram creation");
}
@@ -338,13 +343,37 @@ public abstract class AbstractPapyrusGmfCreateDiagramCommandHandler extends Abst
// the undo corresponds to a destroy diagram command
// during diagram creation no adapters are set to the diagram so the setElement is not registered
// to remove the cross reference using the element reference it is better to use the destroy element command
- DestroyElementPapyrusCommand depc = (diagram != null) ? new DestroyElementPapyrusCommand(new DestroyElementRequest(diagram, false)) : null;
+ // DestroyElementPapyrusCommand depc = (diagram != null) ? new DestroyElementPapyrusCommand(new DestroyElementRequest(diagram, false)) : null;
IStatus status = super.doUndo(monitor, info);
- if(depc != null) {
- depc.execute(null, null);
- }
+
+ modelElement = diagram.getElement();
+ diagram.setElement(null);
+ // if(depc != null) {
+ // depc.execute(monitor, info);
+ // }
+ return status;
+ }
+
+ @Override
+ protected IStatus doRedo(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
+ diagram.setElement(modelElement);
+ IStatus status = super.doRedo(monitor, info);
return status;
}
+
+ @Override
+ public boolean canUndo() {
+ boolean result = super.canUndo();
+ System.out.println("CanUndo = " + result);
+ return result;
+ }
+
+ @Override
+ public boolean canRedo() {
+ boolean result = super.canRedo();
+ System.out.println("CanRedo = " + result);
+ return result;
+ }
};
}
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/helper/DiagramHelper.java b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/helper/DiagramHelper.java
index b5208b6cf2c..b9d3b583c08 100644
--- a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/helper/DiagramHelper.java
+++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/helper/DiagramHelper.java
@@ -11,6 +11,7 @@
*****************************************************************************/
package org.eclipse.papyrus.infra.gmfdiag.common.helper;
+import java.util.LinkedList;
import java.util.List;
import org.eclipse.gef.EditPart;
@@ -35,10 +36,12 @@ public class DiagramHelper {
public static void refresh(DiagramEditPart diagramEditPart, boolean recursive) {
diagramEditPart.refresh();
if(recursive) {
- for(EditPart childEditPart : (List<EditPart>)diagramEditPart.getChildren()) {
+ List<EditPart> childrenToRefresh = new LinkedList<EditPart>(diagramEditPart.getChildren());
+ for(EditPart childEditPart : childrenToRefresh) {
refresh(childEditPart, true);
}
- for(EditPart childEditPart : (List<EditPart>)diagramEditPart.getConnections()) {
+ List<EditPart> connectionsToRefresh = new LinkedList<EditPart>(diagramEditPart.getConnections());
+ for(EditPart childEditPart : connectionsToRefresh) {
refresh(childEditPart, true);
}
}
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.hyperlink/src/org/eclipse/papyrus/infra/gmfdiag/hyperlink/dnd/HyperlinkDropStrategy.java b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.hyperlink/src/org/eclipse/papyrus/infra/gmfdiag/hyperlink/dnd/HyperlinkDropStrategy.java
index 75107e4f872..20640afb1fa 100644
--- a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.hyperlink/src/org/eclipse/papyrus/infra/gmfdiag/hyperlink/dnd/HyperlinkDropStrategy.java
+++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.hyperlink/src/org/eclipse/papyrus/infra/gmfdiag/hyperlink/dnd/HyperlinkDropStrategy.java
@@ -22,7 +22,7 @@ import org.eclipse.gmf.runtime.notation.Diagram;
import org.eclipse.gmf.runtime.notation.View;
import org.eclipse.jface.viewers.ILabelProvider;
import org.eclipse.papyrus.commands.Activator;
-import org.eclipse.papyrus.infra.core.sasheditor.contentprovider.IPageMngr;
+import org.eclipse.papyrus.infra.core.sasheditor.contentprovider.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;
@@ -85,7 +85,7 @@ public class HyperlinkDropStrategy extends TransactionalDropStrategy {
final ServicesRegistry registry;
try {
registry = ServiceUtilsForEObject.getInstance().getServiceRegistry(mainView);
- IPageMngr pageManager = ServiceUtils.getInstance().getIPageMngr(registry);
+ IPageManager pageManager = ServiceUtils.getInstance().getIPageManager(registry);
for(Object droppedObject : dropRequest.getObjects()) {
if(!(droppedObject instanceof EObject && pageManager.allPages().contains(droppedObject))) {
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.hyperlink/src/org/eclipse/papyrus/infra/gmfdiag/hyperlink/editpolicies/HyperLinkPopupBarEditPolicy.java b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.hyperlink/src/org/eclipse/papyrus/infra/gmfdiag/hyperlink/editpolicies/HyperLinkPopupBarEditPolicy.java
index 408038c5275..5f46e3c5738 100644
--- a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.hyperlink/src/org/eclipse/papyrus/infra/gmfdiag/hyperlink/editpolicies/HyperLinkPopupBarEditPolicy.java
+++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.hyperlink/src/org/eclipse/papyrus/infra/gmfdiag/hyperlink/editpolicies/HyperLinkPopupBarEditPolicy.java
@@ -31,6 +31,8 @@ import org.eclipse.draw2d.geometry.Point;
import org.eclipse.draw2d.geometry.Rectangle;
import org.eclipse.emf.ecore.EModelElement;
import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.transaction.RecordingCommand;
+import org.eclipse.emf.transaction.TransactionalEditingDomain;
import org.eclipse.gef.DragTracker;
import org.eclipse.gef.EditPartViewer;
import org.eclipse.gef.Handle;
@@ -294,8 +296,23 @@ public class HyperLinkPopupBarEditPolicy extends DiagramAssistantEditPolicy {
} else if(me.getSource() instanceof PopupBarLabelHandle) {
if((((PopupBarLabelHandle)me.getSource()).getReferencedObject()) instanceof HyperLinkObject) {
- HyperLinkObject hyperLinkObject = (HyperLinkObject)(((PopupBarLabelHandle)me.getSource()).getReferencedObject());
- hyperLinkObject.executeSelectPressed();
+ final HyperLinkObject hyperLinkObject = (HyperLinkObject)(((PopupBarLabelHandle)me.getSource()).getReferencedObject());
+ if(hyperLinkObject.needsOpenCommand()) {
+ try {
+ TransactionalEditingDomain editingDomain = ServiceUtilsForEditPart.getInstance().getTransactionalEditingDomain(getHost());
+ editingDomain.getCommandStack().execute(new RecordingCommand(editingDomain, "Open hyperlink") {
+
+ @Override
+ protected void doExecute() {
+ hyperLinkObject.openLink();
+ }
+ });
+ } catch (ServiceException ex) {
+
+ }
+ } else {
+ hyperLinkObject.openLink();
+ }
}
}
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.hyperlink/src/org/eclipse/papyrus/infra/gmfdiag/hyperlink/editpolicies/NavigationEditPolicy.java b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.hyperlink/src/org/eclipse/papyrus/infra/gmfdiag/hyperlink/editpolicies/NavigationEditPolicy.java
index a1fc04804bd..417a603d57e 100644
--- a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.hyperlink/src/org/eclipse/papyrus/infra/gmfdiag/hyperlink/editpolicies/NavigationEditPolicy.java
+++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.hyperlink/src/org/eclipse/papyrus/infra/gmfdiag/hyperlink/editpolicies/NavigationEditPolicy.java
@@ -19,14 +19,23 @@ import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.emf.ecore.EModelElement;
import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.transaction.TransactionalEditingDomain;
import org.eclipse.gef.Request;
import org.eclipse.gef.commands.Command;
import org.eclipse.gef.commands.UnexecutableCommand;
+import org.eclipse.gmf.runtime.common.core.command.CommandResult;
+import org.eclipse.gmf.runtime.common.core.command.CompositeCommand;
+import org.eclipse.gmf.runtime.common.core.command.ICommand;
import org.eclipse.gmf.runtime.diagram.ui.editparts.CompartmentEditPart;
import org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart;
import org.eclipse.gmf.runtime.diagram.ui.editpolicies.OpenEditPolicy;
+import org.eclipse.gmf.runtime.emf.commands.core.command.AbstractTransactionalCommand;
import org.eclipse.gmf.runtime.notation.Diagram;
import org.eclipse.papyrus.commands.CreationCommandDescriptor;
import org.eclipse.papyrus.infra.core.editorsfactory.IPageIconsRegistry;
@@ -168,7 +177,8 @@ public class NavigationEditPolicy extends OpenEditPolicy {
}
}
}
- if(defaultHyperLinkObject.size() == 0) {
+
+ if(defaultHyperLinkObject.isEmpty()) {
Command command = new Command() {
@Override
@@ -183,39 +193,136 @@ public class NavigationEditPolicy extends OpenEditPolicy {
};
return command;
}
+
if(defaultHyperLinkObject.size() == 1) {
// open the diagram
- Command command = new Command() {
+ final HyperLinkObject hyperlinkObject = defaultHyperLinkObject.get(0);
+ Command command = new Command("Navigate hyperlink") {
+
+ private ICommand openLinkCommand;
@Override
public void execute() {
- super.execute();
- defaultHyperLinkObject.get(0).executeSelectPressed();
+
+ if(hyperlinkObject.needsOpenCommand()) {
+ try {
+ TransactionalEditingDomain editingDomain = ServiceUtilsForEditPart.getInstance().getTransactionalEditingDomain(getHost());
+ openLinkCommand = new AbstractTransactionalCommand(editingDomain, "Navigate hyperlink", null) {
+
+ @Override
+ protected CommandResult doExecuteWithResult(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
+ hyperlinkObject.openLink();
+ return CommandResult.newOKCommandResult();
+ }
+ };
+
+ openLinkCommand.execute(new NullProgressMonitor(), null);
+ } catch (ServiceException ex) {
+ Activator.log.error(ex);
+ } catch (ExecutionException ex) {
+ Activator.log.error(ex);
+ }
+ } else {
+ hyperlinkObject.openLink();
+ }
+ }
+
+ @Override
+ public void undo() {
+ if(openLinkCommand != null && openLinkCommand.canUndo()) {
+ try {
+ openLinkCommand.undo(new NullProgressMonitor(), null);
+ } catch (ExecutionException ex) {
+ Activator.log.error(ex);
+ }
+ }
+ }
+
+ @Override
+ public void redo() {
+ if(openLinkCommand != null && openLinkCommand.canRedo()) {
+ try {
+ openLinkCommand.redo(new NullProgressMonitor(), null);
+ } catch (ExecutionException ex) {
+ Activator.log.error(ex);
+ }
+ }
}
};
return command;
-
}
+
if(defaultHyperLinkObject.size() > 1) {
// open a dialog to choose a diagram
EditorNavigationDialog diagramNavigationDialog = new EditorNavigationDialog(getHost().getViewer().getControl().getShell(), defaultHyperLinkObject, semanticElement);
diagramNavigationDialog.open();
final List<HyperLinkObject> hList = diagramNavigationDialog.getSelectedHyperlinks();
- Command command = new Command() {
+
+ Command command = new Command("Navigate hyperlinks") {
+
+ private CompositeCommand openLinksCommand;
@Override
public void execute() {
- super.execute();
-
Iterator<HyperLinkObject> iter = hList.iterator();
- while(iter.hasNext()) {
- HyperLinkObject hyperlinkObject = iter.next();
- hyperlinkObject.executeSelectPressed();
+ openLinksCommand = new CompositeCommand("Navigate hyperlinks");
+
+ try {
+ TransactionalEditingDomain editingDomain = ServiceUtilsForEditPart.getInstance().getTransactionalEditingDomain(getHost());
+ while(iter.hasNext()) {
+ final HyperLinkObject hyperlinkObject = iter.next();
+ if(hyperlinkObject.needsOpenCommand()) {
+ ICommand navigateCommand = new AbstractTransactionalCommand(editingDomain, "Navigate hyperlink", null) {
+
+ @Override
+ protected CommandResult doExecuteWithResult(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
+ hyperlinkObject.openLink();
+ return CommandResult.newOKCommandResult();
+ }
+
+ };
+ openLinksCommand.add(navigateCommand);
+ } else {
+ hyperlinkObject.openLink();
+ }
+ }
+
+ if(openLinksCommand.isEmpty()) {
+ return;
+ }
+
+ openLinksCommand.execute(new NullProgressMonitor(), null);
+ } catch (ServiceException ex) {
+ Activator.log.error(ex);
+ } catch (ExecutionException ex) {
+ Activator.log.error(ex);
+ }
+ }
+
+ @Override
+ public void undo() {
+ if(openLinksCommand != null && openLinksCommand.canUndo()) {
+ try {
+ openLinksCommand.undo(new NullProgressMonitor(), null);
+ } catch (ExecutionException ex) {
+ Activator.log.error(ex);
+ }
+ }
+ }
+
+ @Override
+ public void redo() {
+ if(openLinksCommand != null && openLinksCommand.canRedo()) {
+ try {
+ openLinksCommand.redo(new NullProgressMonitor(), null);
+ } catch (ExecutionException ex) {
+ Activator.log.error(ex);
+ }
}
}
};
- return command;
+ return command;
}
} catch (Exception e) {
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.modelexplorer/src/org/eclipse/papyrus/infra/gmfdiag/modelexplorer/handlers/DeleteDiagramHandler.java b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.modelexplorer/src/org/eclipse/papyrus/infra/gmfdiag/modelexplorer/handlers/DeleteDiagramHandler.java
index 75ead471eea..b8dad02a413 100644
--- a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.modelexplorer/src/org/eclipse/papyrus/infra/gmfdiag/modelexplorer/handlers/DeleteDiagramHandler.java
+++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.modelexplorer/src/org/eclipse/papyrus/infra/gmfdiag/modelexplorer/handlers/DeleteDiagramHandler.java
@@ -24,7 +24,7 @@ import org.eclipse.gmf.runtime.emf.type.core.requests.DestroyElementRequest;
import org.eclipse.gmf.runtime.notation.Diagram;
import org.eclipse.papyrus.commands.DestroyElementPapyrusCommand;
import org.eclipse.papyrus.commands.wrappers.GMFtoEMFCommandWrapper;
-import org.eclipse.papyrus.infra.core.sasheditor.contentprovider.IPageMngr;
+import org.eclipse.papyrus.infra.core.sasheditor.contentprovider.IPageManager;
/**
* Handler for the delete Diagram action
@@ -44,23 +44,22 @@ public class DeleteDiagramHandler extends AbstractDiagramCommandHandler {
@Override
protected Command getCommand() {
TransactionalEditingDomain editingDomain = getEditingDomain();
- final IPageMngr pageMngr = getPageManager();
+ final IPageManager pageManager = getPageManager();
List<Diagram> diagrams = getSelectedDiagrams();
- if(editingDomain != null && pageMngr != null && !diagrams.isEmpty()) {
+ if(editingDomain != null && pageManager != null && !diagrams.isEmpty()) {
CompoundCommand command = new CompoundCommand();
for(final Diagram diagram : diagrams) {
- Command sashRemoveComd = new RecordingCommand(editingDomain) {
+
+ Command sashRemoveComd = new RecordingCommand(editingDomain, "Remove page") {
@Override
protected void doExecute() {
- if(pageMngr.isOpen(diagram)) {
- pageMngr.closePage(diagram);
- }
- pageMngr.removePage(diagram);
+ pageManager.removePage(diagram);
}
+
};
// the destroy element command is a good way to destroy the cross reference
command.append(sashRemoveComd);
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.modelexplorer/src/org/eclipse/papyrus/infra/gmfdiag/modelexplorer/handlers/DuplicateDiagramHandler.java b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.modelexplorer/src/org/eclipse/papyrus/infra/gmfdiag/modelexplorer/handlers/DuplicateDiagramHandler.java
index f5bd1e57390..add91ac3f2c 100644
--- a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.modelexplorer/src/org/eclipse/papyrus/infra/gmfdiag/modelexplorer/handlers/DuplicateDiagramHandler.java
+++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.modelexplorer/src/org/eclipse/papyrus/infra/gmfdiag/modelexplorer/handlers/DuplicateDiagramHandler.java
@@ -24,7 +24,7 @@ import org.eclipse.emf.transaction.RecordingCommand;
import org.eclipse.emf.transaction.TransactionalEditingDomain;
import org.eclipse.gmf.runtime.notation.Diagram;
import org.eclipse.osgi.util.NLS;
-import org.eclipse.papyrus.infra.core.sasheditor.contentprovider.IPageMngr;
+import org.eclipse.papyrus.infra.core.sasheditor.contentprovider.IPageManager;
import org.eclipse.papyrus.infra.gmfdiag.modelexplorer.messages.Messages;
/**
@@ -44,7 +44,7 @@ public class DuplicateDiagramHandler extends AbstractDiagramCommandHandler {
@Override
protected Command getCommand() {
TransactionalEditingDomain editingDomain = getEditingDomain();
- final IPageMngr pageManager = getPageManager();
+ final IPageManager pageManager = getPageManager();
List<Diagram> diagrams = getSelectedDiagrams();
if(editingDomain != null && pageManager != null && !diagrams.isEmpty()) {
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.navigation/src/org/eclipse/papyrus/infra/gmfdiag/navigation/NavigationHelper.java b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.navigation/src/org/eclipse/papyrus/infra/gmfdiag/navigation/NavigationHelper.java
index 7e2f6212a93..dec4cbb177c 100644
--- a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.navigation/src/org/eclipse/papyrus/infra/gmfdiag/navigation/NavigationHelper.java
+++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.navigation/src/org/eclipse/papyrus/infra/gmfdiag/navigation/NavigationHelper.java
@@ -147,7 +147,7 @@ public class NavigationHelper {
ICommand createDiagCommand = creationCommandInterface.getCreateDiagramCommand(modelSet, navElement.getElement(), diagramName);
compositeCommand.add(createDiagCommand);
- compositeCommand.add(new OpenDiagramCommand(modelSet.getTransactionalEditingDomain(), createDiagCommand));
+ compositeCommand.add(new OpenDiagramCommand(createDiagCommand));
return compositeCommand;
}
diff --git a/plugins/infra/org.eclipse.papyrus.infra.hyperlink/src/org/eclipse/papyrus/infra/hyperlink/helper/AbstractHyperLinkHelper.java b/plugins/infra/org.eclipse.papyrus.infra.hyperlink/src/org/eclipse/papyrus/infra/hyperlink/helper/AbstractHyperLinkHelper.java
index cd2ea3bb151..5c97ad09217 100644
--- a/plugins/infra/org.eclipse.papyrus.infra.hyperlink/src/org/eclipse/papyrus/infra/hyperlink/helper/AbstractHyperLinkHelper.java
+++ b/plugins/infra/org.eclipse.papyrus.infra.hyperlink/src/org/eclipse/papyrus/infra/hyperlink/helper/AbstractHyperLinkHelper.java
@@ -89,17 +89,6 @@ public abstract class AbstractHyperLinkHelper {
}
/**
- * this method is called when the element is selected an clicked in order to
- * open a diagram in the case of hyperlink diagram
- *
- * @param HyperLinkObject
- * the hyperlink object that is selected
- */
- public void executeSelectPressed(HyperLinkObject HyperLinkObject) {
- HyperLinkObject.executeSelectPressed();
- }
-
- /**
* from a list of hyperlinks, it return a list of hyperlink with the same
* kind. for example return a list of diagramhyperlink
*
diff --git a/plugins/infra/org.eclipse.papyrus.infra.hyperlink/src/org/eclipse/papyrus/infra/hyperlink/helper/EditorHyperLinkHelper.java b/plugins/infra/org.eclipse.papyrus.infra.hyperlink/src/org/eclipse/papyrus/infra/hyperlink/helper/EditorHyperLinkHelper.java
index 6c3ca283831..9e61d74e98a 100644
--- a/plugins/infra/org.eclipse.papyrus.infra.hyperlink/src/org/eclipse/papyrus/infra/hyperlink/helper/EditorHyperLinkHelper.java
+++ b/plugins/infra/org.eclipse.papyrus.infra.hyperlink/src/org/eclipse/papyrus/infra/hyperlink/helper/EditorHyperLinkHelper.java
@@ -144,11 +144,13 @@ public class EditorHyperLinkHelper extends AbstractHyperLinkHelper {
public HyperLinkEditor getHyperLinkObjectFor(final EAnnotation eAnnotation) {
for(String source : HyperLinkConstants.validHyperLinkPageSources) {
if(source.equals(eAnnotation.getSource())) {
- HyperLinkEditor editor = new HyperLinkEditor();
- editor.setObject(eAnnotation.getReferences().get(0));
- editor.setIsDefault(Boolean.parseBoolean(eAnnotation.getDetails().get(HyperLinkConstants.HYPERLINK_IS_DEFAULT_NAVIGATION)));
- editor.setTooltipText(eAnnotation.getDetails().get(HyperLinkConstants.HYPERLINK_TOOLTYPE_TEXT));
- return editor;
+ if(!eAnnotation.getReferences().isEmpty()) {
+ HyperLinkEditor editor = new HyperLinkEditor();
+ editor.setObject(eAnnotation.getReferences().get(0));
+ editor.setIsDefault(Boolean.parseBoolean(eAnnotation.getDetails().get(HyperLinkConstants.HYPERLINK_IS_DEFAULT_NAVIGATION)));
+ editor.setTooltipText(eAnnotation.getDetails().get(HyperLinkConstants.HYPERLINK_TOOLTYPE_TEXT));
+ return editor;
+ }
}
}
diff --git a/plugins/infra/org.eclipse.papyrus.infra.hyperlink/src/org/eclipse/papyrus/infra/hyperlink/object/HyperLinkDocument.java b/plugins/infra/org.eclipse.papyrus.infra.hyperlink/src/org/eclipse/papyrus/infra/hyperlink/object/HyperLinkDocument.java
index e7a833f56d3..ba1bfcd570b 100644
--- a/plugins/infra/org.eclipse.papyrus.infra.hyperlink/src/org/eclipse/papyrus/infra/hyperlink/object/HyperLinkDocument.java
+++ b/plugins/infra/org.eclipse.papyrus.infra.hyperlink/src/org/eclipse/papyrus/infra/hyperlink/object/HyperLinkDocument.java
@@ -52,7 +52,7 @@ public class HyperLinkDocument extends HyperLinkObject {
}
@Override
- public void executeSelectPressed() {
+ public void openLink() {
try {
// this is a file try to open it
String fileName = getHyperlinkDocument();
@@ -80,4 +80,9 @@ public class HyperLinkDocument extends HyperLinkObject {
list.add(index, editor.getHyperlinkDocument());
}
+
+ @Override
+ public boolean needsOpenCommand() {
+ return false;
+ }
}
diff --git a/plugins/infra/org.eclipse.papyrus.infra.hyperlink/src/org/eclipse/papyrus/infra/hyperlink/object/HyperLinkEditor.java b/plugins/infra/org.eclipse.papyrus.infra.hyperlink/src/org/eclipse/papyrus/infra/hyperlink/object/HyperLinkEditor.java
index c6e306f06ca..cb88606aa09 100644
--- a/plugins/infra/org.eclipse.papyrus.infra.hyperlink/src/org/eclipse/papyrus/infra/hyperlink/object/HyperLinkEditor.java
+++ b/plugins/infra/org.eclipse.papyrus.infra.hyperlink/src/org/eclipse/papyrus/infra/hyperlink/object/HyperLinkEditor.java
@@ -17,8 +17,9 @@ import java.util.List;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.papyrus.infra.core.editorsfactory.IPageIconsRegistry;
-import org.eclipse.papyrus.infra.core.sasheditor.contentprovider.IPageMngr;
+import org.eclipse.papyrus.infra.core.sasheditor.contentprovider.IPageManager;
import org.eclipse.papyrus.infra.core.services.ServiceException;
+import org.eclipse.papyrus.infra.core.services.ServicesRegistry;
import org.eclipse.papyrus.infra.emf.utils.EMFHelper;
import org.eclipse.papyrus.infra.emf.utils.ServiceUtilsForEObject;
import org.eclipse.papyrus.infra.hyperlink.Activator;
@@ -33,12 +34,18 @@ public class HyperLinkEditor extends HyperLinkObject {
*
*/
@Override
- public void executeSelectPressed() {
+ public void openLink() {
EObject context = EMFHelper.getEObject(getObject());
if(context != null) {
try {
- IPageMngr pageMngr = ServiceUtilsForEObject.getInstance().getIPageMngr(context);
- pageMngr.openPage(getObject());
+ final IPageManager pageManager = ServiceUtilsForEObject.getInstance().getIPageManager(context);
+ Object objectToOpen = getObject();
+ if(pageManager.isOpen(objectToOpen)) {
+ pageManager.selectPage(objectToOpen);
+ } else {
+ pageManager.openPage(objectToOpen);
+ }
+
} catch (Exception ex) {
Activator.log.error(ex);
}
@@ -71,4 +78,22 @@ public class HyperLinkEditor extends HyperLinkObject {
list.add(index, editor.getHyperLinkEditor());
}
}
+
+ /**
+ * {@inheritDoc}
+ *
+ * This HyperLink needs an executable EMF command when the page is not yet opened
+ * Otherwise, openLink() can be called directly
+ */
+ @Override
+ public boolean needsOpenCommand() {
+ EObject context = EMFHelper.getEObject(getObject());
+ try {
+ ServicesRegistry registry = ServiceUtilsForEObject.getInstance().getServiceRegistry(context);
+ final IPageManager pageManager = registry.getService(IPageManager.class);
+ return !pageManager.isOpen(context);
+ } catch (ServiceException ex) {
+ return false;
+ }
+ }
}
diff --git a/plugins/infra/org.eclipse.papyrus.infra.hyperlink/src/org/eclipse/papyrus/infra/hyperlink/object/HyperLinkObject.java b/plugins/infra/org.eclipse.papyrus.infra.hyperlink/src/org/eclipse/papyrus/infra/hyperlink/object/HyperLinkObject.java
index 0daad237ce2..49bf2681ff2 100644
--- a/plugins/infra/org.eclipse.papyrus.infra.hyperlink/src/org/eclipse/papyrus/infra/hyperlink/object/HyperLinkObject.java
+++ b/plugins/infra/org.eclipse.papyrus.infra.hyperlink/src/org/eclipse/papyrus/infra/hyperlink/object/HyperLinkObject.java
@@ -20,7 +20,7 @@ import org.eclipse.emf.ecore.EObject;
/**
* This is the Object use to manipulate into hyperlinks
- *
+ *
*/
public abstract class HyperLinkObject {
@@ -29,13 +29,13 @@ public abstract class HyperLinkObject {
*/
protected String tooltipText;
- /** the object that is the target of the hyperlink**/
+ /** the object that is the target of the hyperlink **/
protected Object object;
/**
* boolean to known if this hyperlink is a default hyperlink
*/
- protected boolean isDefault=false;
+ protected boolean isDefault = false;
/**
* @return the associated tooltip
@@ -46,13 +46,14 @@ public abstract class HyperLinkObject {
/**
* set a string that is the associated tool tup
+ *
* @param tooltipText
*/
public void setTooltipText(String tooltipText) {
this.tooltipText = tooltipText;
}
- /**
+ /**
*
* @return the object that is the target of the hyperlink
*/
@@ -62,7 +63,9 @@ public abstract class HyperLinkObject {
/**
* set the object that will be the target of the hyperlink
- * @param object the targeted object
+ *
+ * @param object
+ * the targeted object
*/
public void setObject(Object object) {
this.object = object;
@@ -70,30 +73,42 @@ public abstract class HyperLinkObject {
/**
* set a boolean in order to make this hyperlink as default
- * @param isDefault true or false
+ *
+ * @param isDefault
+ * true or false
*/
- public void setIsDefault(boolean isDefault){
- this.isDefault= isDefault;
+ public void setIsDefault(boolean isDefault) {
+ this.isDefault = isDefault;
}
+
/**
*
* @return true is the hyperlink is default
*/
- public boolean getIsDefault(){
+ public boolean getIsDefault() {
return this.isDefault;
}
-
- /**
- * Used to execute an action when the hyperlink object is selected and clicked
- * for example can open a new editor or a diagram...
- */
- public abstract void executeSelectPressed();
-
+
/**
* Used to execute an action when the hyperlink object is selected and clicked to be edited
-
- * @param list of hyperlink that are containted by a graphical element
- * @param amodel the top package root element
+ *
+ * @param list
+ * of hyperlink that are containted by a graphical element
+ * @param amodel
+ * the top package root element
*/
public abstract void executeEditMousePressed(List<HyperLinkObject> list, EObject amodel);
+
+ /**
+ * Tells whether openLink() should be called within an EMF command
+ *
+ * @return
+ */
+ public abstract boolean needsOpenCommand();
+
+ /**
+ * Opens the current hyperlink.
+ */
+ public abstract void openLink();
+
}
diff --git a/plugins/infra/org.eclipse.papyrus.infra.hyperlink/src/org/eclipse/papyrus/infra/hyperlink/object/HyperLinkWeb.java b/plugins/infra/org.eclipse.papyrus.infra.hyperlink/src/org/eclipse/papyrus/infra/hyperlink/object/HyperLinkWeb.java
index 206a2f8188f..8da7c3cf3e8 100644
--- a/plugins/infra/org.eclipse.papyrus.infra.hyperlink/src/org/eclipse/papyrus/infra/hyperlink/object/HyperLinkWeb.java
+++ b/plugins/infra/org.eclipse.papyrus.infra.hyperlink/src/org/eclipse/papyrus/infra/hyperlink/object/HyperLinkWeb.java
@@ -23,8 +23,8 @@ import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.browser.IWorkbenchBrowserSupport;
/**
- * this is an hyperlink to manage web link (it open a web browser when it is selected)
- *
+ * this is an hyperlink to manage web link (it open a web browser when it is selected)
+ *
*/
public class HyperLinkWeb extends HyperLinkObject {
@@ -41,31 +41,37 @@ public class HyperLinkWeb extends HyperLinkObject {
/**
*
* @see org.eclipse.papyrus.infra.hyperlink.object.HyperLinkObject#executeSelectPressed()
- *
+ *
*/
@Override
- public void executeSelectPressed() {
+ public void openLink() {
try {
// this is an url
PlatformUI.getWorkbench().getBrowserSupport().createBrowser(IWorkbenchBrowserSupport.AS_EXTERNAL, "aCustomId", "url", "url").openURL(new URL(this.getHyperLinkWeb())); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
} catch (Exception e) {
Activator.log.error(e);
}
-
+
}
-/**
- *
- * @see org.eclipse.papyrus.infra.hyperlink.object.HyperLinkObject#executeEditMousePressed(java.util.List, org.eclipse.uml2.uml.Package)
- *
- */
+
+ /**
+ *
+ * @see org.eclipse.papyrus.infra.hyperlink.object.HyperLinkObject#executeEditMousePressed(java.util.List, org.eclipse.uml2.uml.Package)
+ *
+ */
@Override
- public void executeEditMousePressed(List<HyperLinkObject> list,EObject amodel) {
+ public void executeEditMousePressed(List<HyperLinkObject> list, EObject amodel) {
EditorHyperLinkWebShell editor = new EditorHyperLinkWebShell();
editor.setHyperLinkWeb(this);
editor.open();
int index = list.indexOf(this);
list.remove(this);
list.add(index, editor.getHyperLinkWeb());
-
+
+ }
+
+ @Override
+ public boolean needsOpenCommand() {
+ return false;
}
}
diff --git a/plugins/infra/org.eclipse.papyrus.infra.hyperlink/src/org/eclipse/papyrus/infra/hyperlink/ui/EditorLookForEditorShell.java b/plugins/infra/org.eclipse.papyrus.infra.hyperlink/src/org/eclipse/papyrus/infra/hyperlink/ui/EditorLookForEditorShell.java
index bcb37b62929..c1c9834ff8c 100644
--- a/plugins/infra/org.eclipse.papyrus.infra.hyperlink/src/org/eclipse/papyrus/infra/hyperlink/ui/EditorLookForEditorShell.java
+++ b/plugins/infra/org.eclipse.papyrus.infra.hyperlink/src/org/eclipse/papyrus/infra/hyperlink/ui/EditorLookForEditorShell.java
@@ -14,10 +14,14 @@
package org.eclipse.papyrus.infra.hyperlink.ui;
import java.util.Iterator;
+import java.util.LinkedList;
+import java.util.List;
import org.eclipse.emf.common.notify.AdapterFactory;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.edit.provider.ComposedAdapterFactory;
+import org.eclipse.emf.transaction.RecordingCommand;
+import org.eclipse.emf.transaction.TransactionalEditingDomain;
import org.eclipse.jface.viewers.ILabelProvider;
import org.eclipse.jface.viewers.ISelectionChangedListener;
import org.eclipse.jface.viewers.IStructuredSelection;
@@ -31,10 +35,10 @@ import org.eclipse.papyrus.commands.ICreationCommandRegistry;
import org.eclipse.papyrus.infra.core.editorsfactory.IPageIconsRegistry;
import org.eclipse.papyrus.infra.core.extension.NotFoundException;
import org.eclipse.papyrus.infra.core.resource.ModelSet;
-import org.eclipse.papyrus.infra.core.sasheditor.contentprovider.IPageMngr;
+import org.eclipse.papyrus.infra.core.sasheditor.contentprovider.IPageManager;
import org.eclipse.papyrus.infra.core.services.ServiceException;
import org.eclipse.papyrus.infra.core.services.ServicesRegistry;
-import org.eclipse.papyrus.infra.emf.providers.strategy.SemanticEMFContentProvider;
+import org.eclipse.papyrus.infra.emf.providers.MoDiscoContentProvider;
import org.eclipse.papyrus.infra.emf.utils.EMFHelper;
import org.eclipse.papyrus.infra.emf.utils.ServiceUtilsForEObject;
import org.eclipse.papyrus.infra.hyperlink.Activator;
@@ -123,7 +127,16 @@ public class EditorLookForEditorShell extends AbstractLookForEditorShell {
@Override
public void widgetSelected(SelectionEvent e) {
try {
- EObject elt = (EObject)((IStructuredSelection)treeViewer.getSelection()).getFirstElement();
+ if(treeViewer.getSelection().isEmpty()) {
+ return;
+ }
+
+ IStructuredSelection selection = (IStructuredSelection)treeViewer.getSelection();
+
+ EObject elt = EMFHelper.getEObject(selection.getFirstElement());
+ if(elt == null) {
+ return;
+ }
setContainer(elt);
ModelSet modelSet = ServiceUtilsForEObject.getInstance().getModelSet(elt);
@@ -132,10 +145,8 @@ public class EditorLookForEditorShell extends AbstractLookForEditorShell {
creationCommand.createDiagram(modelSet, container, null);
// refresh several filtered tree
- getDiagramfilteredTree().getViewer().setInput(null);
- getDiagramfilteredTree().getViewer().setInput(""); //$NON-NLS-1$
- getModeFilteredTree().getViewer().setInput(null);
- getModeFilteredTree().getViewer().setInput(model.eResource());
+ getDiagramfilteredTree().getViewer().refresh();
+ getModeFilteredTree().getViewer().refresh();
} catch (NotFoundException ex) {
Activator.log.error(ex);
} catch (ServiceException ex) {
@@ -221,9 +232,9 @@ public class EditorLookForEditorShell extends AbstractLookForEditorShell {
}
treeViewer.setLabelProvider(labelProvider);
- //treeViewer.setContentProvider(new CustomAdapterFactoryContentProvider(adapterFactory));
- treeViewer.setContentProvider(new SemanticEMFContentProvider(new EObject[]{ amodel }));
- // treeViewer.setContentProvider(new CustomizableModelContentProvider());
+ // treeViewer.setContentProvider(new CustomAdapterFactoryContentProvider(adapterFactory));
+ // treeViewer.setContentProvider(new SemanticEMFContentProvider(amodel)); //This content provider will only display the selected element, instead of the root element
+ treeViewer.setContentProvider(new MoDiscoContentProvider()); //FIXME: Use a standard, non-deprecated content provider.
//treeViewer.setInput(model.eResource());
treeViewer.setInput(registry);
@@ -240,7 +251,7 @@ public class EditorLookForEditorShell extends AbstractLookForEditorShell {
diagramListTreeViewer.setContentProvider(new EditorListContentProvider(model));
- diagramListTreeViewer.setInput(" "); //$NON-NLS-1$
+ diagramListTreeViewer.setInput(""); //$NON-NLS-1$
// add listner on the new button to display menu for each diagram
diagramMenuButton = new Menu(getNewDiagrambutton());
@@ -267,21 +278,40 @@ public class EditorLookForEditorShell extends AbstractLookForEditorShell {
IStructuredSelection iSelection = (IStructuredSelection)getModeFilteredTree().getViewer().getSelection();
Iterator<?> iterator = iSelection.iterator();
- IPageMngr pageManager;
+ final IPageManager pageManager;
+ TransactionalEditingDomain editingDomain;
try {
- pageManager = ServiceUtilsForEObject.getInstance().getIPageMngr(model);
+ pageManager = ServiceUtilsForEObject.getInstance().getIPageManager(model);
+ editingDomain = ServiceUtilsForEObject.getInstance().getTransactionalEditingDomain(model);
} catch (ServiceException ex) {
Activator.log.error(ex);
return;
}
+ final List<Object> pagesToDelete = new LinkedList<Object>();
while(iterator.hasNext()) {
- pageManager.removePage(iterator.next());
+ EObject selectedElement = EMFHelper.getEObject(iterator.next());
+ if(pageManager.allPages().contains(selectedElement)) {
+ pagesToDelete.add(selectedElement);
+ }
}
- getDiagramfilteredTree().getViewer().setInput(null);
- getDiagramfilteredTree().getViewer().setInput(""); //$NON-NLS-1$
- getModeFilteredTree().getViewer().setInput(null);
- getModeFilteredTree().getViewer().setInput(model.eResource());
+
+ if(pagesToDelete.isEmpty()) {
+ return;
+ }
+
+ editingDomain.getCommandStack().execute(new RecordingCommand(editingDomain, "Delete diagrams") {
+
+ @Override
+ protected void doExecute() {
+ for(Object page : pagesToDelete) {
+ pageManager.removePage(page);
+ }
+ }
+ });
+
+ //getDiagramfilteredTree().getViewer().setInput(""); //$NON-NLS-1$
+ getModeFilteredTree().getViewer().refresh();
}
});
diff --git a/plugins/infra/org.eclipse.papyrus.infra.hyperlink/src/org/eclipse/papyrus/infra/hyperlink/util/EditorListContentProvider.java b/plugins/infra/org.eclipse.papyrus.infra.hyperlink/src/org/eclipse/papyrus/infra/hyperlink/util/EditorListContentProvider.java
index ce121ef5984..b7603596d8f 100644
--- a/plugins/infra/org.eclipse.papyrus.infra.hyperlink/src/org/eclipse/papyrus/infra/hyperlink/util/EditorListContentProvider.java
+++ b/plugins/infra/org.eclipse.papyrus.infra.hyperlink/src/org/eclipse/papyrus/infra/hyperlink/util/EditorListContentProvider.java
@@ -19,7 +19,7 @@ import java.util.List;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.jface.viewers.ITreeContentProvider;
import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.papyrus.infra.core.sasheditor.contentprovider.IPageMngr;
+import org.eclipse.papyrus.infra.core.sasheditor.contentprovider.IPageManager;
import org.eclipse.papyrus.infra.emf.utils.ServiceUtilsForEObject;
import org.eclipse.papyrus.infra.hyperlink.Activator;
@@ -63,7 +63,7 @@ public class EditorListContentProvider implements ITreeContentProvider {
*/
public Object[] getElements(Object inputElement) {
try {
- IPageMngr iPageMngr = ServiceUtilsForEObject.getInstance().getIPageMngr(model);
+ IPageManager iPageMngr = ServiceUtilsForEObject.getInstance().getIPageManager(model);
Object[] result = iPageMngr.allPages().toArray();
List<Object> res = new ArrayList<Object>();
diff --git a/plugins/infra/services/org.eclipse.papyrus.infra.services.resourceloading/src/org/eclipse/papyrus/infra/services/resourceloading/strategies/AskUserStrategy.java b/plugins/infra/services/org.eclipse.papyrus.infra.services.resourceloading/src/org/eclipse/papyrus/infra/services/resourceloading/strategies/AskUserStrategy.java
index 24b401a2940..a1d842acfe4 100644
--- a/plugins/infra/services/org.eclipse.papyrus.infra.services.resourceloading/src/org/eclipse/papyrus/infra/services/resourceloading/strategies/AskUserStrategy.java
+++ b/plugins/infra/services/org.eclipse.papyrus.infra.services.resourceloading/src/org/eclipse/papyrus/infra/services/resourceloading/strategies/AskUserStrategy.java
@@ -25,8 +25,7 @@ import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.emf.ecore.util.EcoreUtil;
import org.eclipse.papyrus.infra.core.editor.CoreMultiDiagramEditor;
import org.eclipse.papyrus.infra.core.resource.ModelSet;
-import org.eclipse.papyrus.infra.core.sasheditor.contentprovider.IPageMngr;
-import org.eclipse.papyrus.infra.core.sasheditor.di.contentprovider.DiSashModelMngr;
+import org.eclipse.papyrus.infra.core.sasheditor.contentprovider.IPageManager;
import org.eclipse.papyrus.infra.core.services.ServiceException;
import org.eclipse.papyrus.infra.services.resourceloading.ILoadingStrategy;
import org.eclipse.papyrus.infra.widgets.toolbox.notification.INotification;
@@ -323,7 +322,7 @@ public class AskUserStrategy implements ILoadingStrategy {
}
}
new RefreshRunnable(modelSet, null, getInitialURI(), true, true).run(editor);
- };
+ }
};
}
@@ -738,9 +737,7 @@ public class AskUserStrategy implements ILoadingStrategy {
*/
public class RefreshRunnable {
- protected DiSashModelMngr sashModelMngr;
-
- protected IPageMngr pageMngr;
+ protected IPageManager pageMngr;
protected URI uri;
@@ -763,9 +760,8 @@ public class AskUserStrategy implements ILoadingStrategy {
public void run(CoreMultiDiagramEditor editor) {
final Set<URI> alreadyLoaded = new HashSet<URI>();
try {
- sashModelMngr = editor.getServicesRegistry().getService(DiSashModelMngr.class);
- pageMngr = sashModelMngr.getIPageMngr();
- List<Object> allPages = sashModelMngr.getIPageMngr().allPages();
+ pageMngr = editor.getServicesRegistry().getService(IPageManager.class);
+ List<Object> allPages = pageMngr.allPages();
// the uri is added after getting all the pages. If it is done
// before, the eobjects are resolved
NotificationBuilder error = NotificationBuilder.createAsyncPopup(Messages.AskUserStrategy_ERROR, String.format(Messages.AskUserStrategy_UNABLE_TO_LOAD, uri != null ? uri.toString() : Messages.AskUserStrategy_12)).setType(Type.ERROR).setDelay(2000);
@@ -802,8 +798,7 @@ public class AskUserStrategy implements ILoadingStrategy {
URI eobjectURI = EcoreUtil.getURI(eobject);
if(refreshAll || (refreshTab && eobjectURI.trimFileExtension().trimFragment().equals(uri))) {
// TODO improve this when an update is created
- pageMngr.closePage(o);
- pageMngr.openPage(eobject);
+ pageMngr.selectPage(eobject);
}
}
}
diff --git a/plugins/infra/services/org.eclipse.papyrus.infra.services.resourceloading/src/org/eclipse/papyrus/infra/services/resourceloading/util/LoadingUtils.java b/plugins/infra/services/org.eclipse.papyrus.infra.services.resourceloading/src/org/eclipse/papyrus/infra/services/resourceloading/util/LoadingUtils.java
index 1da9cb79897..1a8fb06f784 100644
--- a/plugins/infra/services/org.eclipse.papyrus.infra.services.resourceloading/src/org/eclipse/papyrus/infra/services/resourceloading/util/LoadingUtils.java
+++ b/plugins/infra/services/org.eclipse.papyrus.infra.services.resourceloading/src/org/eclipse/papyrus/infra/services/resourceloading/util/LoadingUtils.java
@@ -38,6 +38,7 @@ import org.eclipse.papyrus.infra.core.editor.CoreMultiDiagramEditor;
import org.eclipse.papyrus.infra.core.editor.IMultiDiagramEditor;
import org.eclipse.papyrus.infra.core.resource.ModelSet;
import org.eclipse.papyrus.infra.core.resource.sasheditor.DiModel;
+import org.eclipse.papyrus.infra.core.sasheditor.contentprovider.IPageManager;
import org.eclipse.papyrus.infra.core.sasheditor.contentprovider.IPageMngr;
import org.eclipse.papyrus.infra.core.sasheditor.di.contentprovider.DiSashModelMngr;
import org.eclipse.papyrus.infra.core.services.ServiceException;
@@ -79,8 +80,7 @@ public class LoadingUtils {
if(editor instanceof CoreMultiDiagramEditor) {
CoreMultiDiagramEditor core = (CoreMultiDiagramEditor)editor;
try {
- DiSashModelMngr sashModelMngr = core.getServicesRegistry().getService(DiSashModelMngr.class);
- IPageMngr pageMngr = sashModelMngr.getIPageMngr();
+ IPageManager pageMngr = core.getServicesRegistry().getService(IPageManager.class);
List<Object> allPages = pageMngr.allPages();
// mark progress
monitor.beginTask(Messages.LoadingUtils_RefreshPagesTask, allPages.size());
@@ -100,8 +100,7 @@ public class LoadingUtils {
if(r != null) {
EObject newEObject = r.getEObject(uriProxy.fragment());
if(pageMngr.isOpen(newEObject)) {
- pageMngr.closePage(newEObject);
- pageMngr.openPage(newEObject);
+ pageMngr.selectPage(newEObject);
}
} else {
error.run();
@@ -174,8 +173,7 @@ public class LoadingUtils {
if(editor instanceof IMultiDiagramEditor) {
IMultiDiagramEditor core = (IMultiDiagramEditor)editor;
try {
- DiSashModelMngr sashModelMngr = core.getServicesRegistry().getService(DiSashModelMngr.class);
- IPageMngr pageMngr = sashModelMngr.getIPageMngr();
+ IPageManager pageMngr = core.getServicesRegistry().getService(IPageManager.class);
List<Object> allPages = pageMngr.allPages();
List<URI> pagesURIToOpen = new ArrayList<URI>(allPages.size());
List<URI> pagesURIToRefresh = new ArrayList<URI>(allPages.size());
diff --git a/plugins/infra/table/org.eclipse.papyrus.infra.table.common/src/org/eclipse/papyrus/infra/table/common/handlers/AbstractCreateNattableEditorCommand.java b/plugins/infra/table/org.eclipse.papyrus.infra.table.common/src/org/eclipse/papyrus/infra/table/common/handlers/AbstractCreateNattableEditorCommand.java
index 89a6b3e68a3..3d695ebe89e 100644
--- a/plugins/infra/table/org.eclipse.papyrus.infra.table.common/src/org/eclipse/papyrus/infra/table/common/handlers/AbstractCreateNattableEditorCommand.java
+++ b/plugins/infra/table/org.eclipse.papyrus.infra.table.common/src/org/eclipse/papyrus/infra/table/common/handlers/AbstractCreateNattableEditorCommand.java
@@ -65,7 +65,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.NotFoundException;
-import org.eclipse.papyrus.infra.core.sasheditor.contentprovider.IPageMngr;
+import org.eclipse.papyrus.infra.core.sasheditor.contentprovider.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;
@@ -211,7 +211,7 @@ public abstract class AbstractCreateNattableEditorCommand extends AbstractHandle
Object editorModel = createEditorModel(serviceRegistry);
// Get the mngr allowing to add/open new editor.
- IPageMngr pageMngr = ServiceUtils.getInstance().getIPageMngr(serviceRegistry);
+ IPageManager pageMngr = ServiceUtils.getInstance().getIPageManager(serviceRegistry);
// add the new editor model to the sash.
pageMngr.openPage(editorModel);
diff --git a/plugins/infra/table/org.eclipse.papyrus.infra.table.modelexplorer/src/org/eclipse/papyrus/infra/table/modelexplorer/handlers/DeleteTableHandler.java b/plugins/infra/table/org.eclipse.papyrus.infra.table.modelexplorer/src/org/eclipse/papyrus/infra/table/modelexplorer/handlers/DeleteTableHandler.java
index 7e15b180165..6c9a9372551 100644
--- a/plugins/infra/table/org.eclipse.papyrus.infra.table.modelexplorer/src/org/eclipse/papyrus/infra/table/modelexplorer/handlers/DeleteTableHandler.java
+++ b/plugins/infra/table/org.eclipse.papyrus.infra.table.modelexplorer/src/org/eclipse/papyrus/infra/table/modelexplorer/handlers/DeleteTableHandler.java
@@ -23,7 +23,7 @@ import org.eclipse.emf.transaction.TransactionalEditingDomain;
import org.eclipse.gmf.runtime.emf.type.core.requests.DestroyElementRequest;
import org.eclipse.papyrus.commands.DestroyElementPapyrusCommand;
import org.eclipse.papyrus.commands.wrappers.GMFtoEMFCommandWrapper;
-import org.eclipse.papyrus.infra.core.sasheditor.contentprovider.IPageMngr;
+import org.eclipse.papyrus.infra.core.sasheditor.contentprovider.IPageManager;
import org.eclipse.papyrus.infra.table.instance.papyrustableinstance.PapyrusTableInstance;
/**
@@ -44,7 +44,7 @@ public class DeleteTableHandler extends AbstractTableModelExplorerHandler {
@Override
protected Command getCommand() {
TransactionalEditingDomain editingDomain = getEditingDomain();
- final IPageMngr pageMngr = getPageManager();
+ final IPageManager pageMngr = getPageManager();
List<PapyrusTableInstance> tables = getSelectedTables();
@@ -56,9 +56,6 @@ public class DeleteTableHandler extends AbstractTableModelExplorerHandler {
@Override
protected void doExecute() {
- if(pageMngr.isOpen(table)) {
- pageMngr.closePage(table);
- }
pageMngr.removePage(table);
}
};
diff --git a/plugins/infra/table/org.eclipse.papyrus.infra.table.modelexplorer/src/org/eclipse/papyrus/infra/table/modelexplorer/handlers/DuplicateTableHandler.java b/plugins/infra/table/org.eclipse.papyrus.infra.table.modelexplorer/src/org/eclipse/papyrus/infra/table/modelexplorer/handlers/DuplicateTableHandler.java
index c4215e3f6ad..2c1d11697b0 100644
--- a/plugins/infra/table/org.eclipse.papyrus.infra.table.modelexplorer/src/org/eclipse/papyrus/infra/table/modelexplorer/handlers/DuplicateTableHandler.java
+++ b/plugins/infra/table/org.eclipse.papyrus.infra.table.modelexplorer/src/org/eclipse/papyrus/infra/table/modelexplorer/handlers/DuplicateTableHandler.java
@@ -22,7 +22,7 @@ import org.eclipse.emf.ecore.util.EcoreUtil;
import org.eclipse.emf.edit.command.AddCommand;
import org.eclipse.emf.transaction.RecordingCommand;
import org.eclipse.emf.transaction.TransactionalEditingDomain;
-import org.eclipse.papyrus.infra.core.sasheditor.contentprovider.IPageMngr;
+import org.eclipse.papyrus.infra.core.sasheditor.contentprovider.IPageManager;
import org.eclipse.papyrus.infra.table.instance.papyrustableinstance.PapyrusTableInstance;
import org.eclipse.papyrus.infra.table.modelexplorer.messages.Messages;
@@ -43,7 +43,7 @@ public class DuplicateTableHandler extends AbstractTableModelExplorerHandler {
@Override
protected Command getCommand() {
TransactionalEditingDomain editingDomain = getEditingDomain();
- final IPageMngr pageManager = getPageManager();
+ final IPageManager pageManager = getPageManager();
List<PapyrusTableInstance> tables = getSelectedTables();
if(editingDomain != null && pageManager != null && !tables.isEmpty()) {
@@ -62,7 +62,7 @@ public class DuplicateTableHandler extends AbstractTableModelExplorerHandler {
Command addGmfDiagramCmd = new AddCommand(editingDomain, table.eResource().getContents(), newTable);
// EMFCommandOperation operation = new EMFCommandOperation(editingDomain, addGmfDiagramCmd);
- Command sashOpenCmd = new RecordingCommand(editingDomain) {
+ Command sashOpenCmd = new RecordingCommand(editingDomain, "Open duplicated table") {
@Override
protected void doExecute() {

Back to the top