Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian W. Damus2014-05-06 22:01:10 +0000
committerChristian W. Damus2014-05-06 22:01:10 +0000
commit868d14101a6833b1dc7d5f4b078563c0d048a297 (patch)
tree7206af20352c070177d2308e3b08dcbe3606abe5
parentcaf9fbf338869a3ec86d44e2f5da20463a69756b (diff)
downloadorg.eclipse.papyrus-868d14101a6833b1dc7d5f4b078563c0d048a297.tar.gz
org.eclipse.papyrus-868d14101a6833b1dc7d5f4b078563c0d048a297.tar.xz
org.eclipse.papyrus-868d14101a6833b1dc7d5f4b078563c0d048a297.zip
433371: [Model Explorer] Deleting a diagram keeps its tab open
https://bugs.eclipse.org/bugs/show_bug.cgi?id=433371 Rework the DeletePageAdvice as strictly a delete-dependents advice that precomputes the actual PageRefs to delete from the SashModel, so that it doesn't matter that the references from the PageRefs to the deleted diagrams are already removed by the time the advice command executes. Includes a JUnit integration test to trap future regressions.
-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.java47
-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.java7
-rw-r--r--plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/custom-src/org/eclipse/papyrus/infra/core/sasheditor/di/contentprovider/utils/IPageUtils.java101
-rw-r--r--plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/advice/DeletePageAdvice.java15
-rw-r--r--plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/advice/RemovePageHelper.java30
-rw-r--r--tests/junit/plugins/core/org.eclipse.papyrus.editor.integration.tests/META-INF/MANIFEST.MF3
-rw-r--r--tests/junit/plugins/core/org.eclipse.papyrus.editor.integration.tests/model/basic/delete_sash_page.di15
-rw-r--r--tests/junit/plugins/core/org.eclipse.papyrus.editor.integration.tests/model/basic/delete_sash_page.notation49
-rw-r--r--tests/junit/plugins/core/org.eclipse.papyrus.editor.integration.tests/model/basic/delete_sash_page.uml9
-rw-r--r--tests/junit/plugins/core/org.eclipse.papyrus.editor.integration.tests/src/org/eclipse/papyrus/editor/integration/tests/tests/PageManagerTests.java52
10 files changed, 302 insertions, 26 deletions
diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/custom-src/org/eclipse/papyrus/infra/core/sasheditor/di/contentprovider/internal/PageManagerImpl.java b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/custom-src/org/eclipse/papyrus/infra/core/sasheditor/di/contentprovider/internal/PageManagerImpl.java
index 121b4f67369..a4136bc4bdb 100644
--- a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/custom-src/org/eclipse/papyrus/infra/core/sasheditor/di/contentprovider/internal/PageManagerImpl.java
+++ b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/custom-src/org/eclipse/papyrus/infra/core/sasheditor/di/contentprovider/internal/PageManagerImpl.java
@@ -1,5 +1,5 @@
/*****************************************************************************
- * Copyright (c) 2013 Cedric Dumoulin.
+ * Copyright (c) 2013, 2014 Cedric Dumoulin, CEA, and others.
*
*
* All rights reserved. This program and the accompanying materials
@@ -9,6 +9,7 @@
*
* Contributors:
* Cedric Dumoulin Cedric.dumoulin@lifl.fr - Initial API and implementation
+ * Christian W. Damus (CEA) - bug 433371
*
*****************************************************************************/
@@ -21,9 +22,11 @@ import org.eclipse.core.runtime.Platform;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.papyrus.infra.core.sasheditor.contentprovider.IPageManager;
+import org.eclipse.papyrus.infra.core.sasheditor.di.contentprovider.Activator;
import org.eclipse.papyrus.infra.core.sasheditor.di.contentprovider.IOpenable;
import org.eclipse.papyrus.infra.core.sashwindows.di.SashWindowsMngr;
import org.eclipse.swt.widgets.Display;
+import org.osgi.framework.FrameworkUtil;
/**
@@ -119,4 +122,46 @@ public class PageManagerImpl extends PageMngrImpl implements IPageManager {
this.folderAndPageMngr = currentFolderAndPageMngr;
}
+
+ /**
+ * Executes an operation on my internal sash model.
+ *
+ * @param sashModelOperation
+ * the operation to execute
+ * @return the operation's result
+ *
+ * @throws IllegalAccessException
+ * on attempt to execute an operation defined by a client bundle
+ */
+ public <T> T execute(SashModelOperation<T> sashModelOperation) throws IllegalAccessException {
+ T result;
+
+ if(FrameworkUtil.getBundle(sashModelOperation.getClass()) != Activator.getDefault().getBundle()) {
+ throw new IllegalAccessException("Attempt to access bundle-private API."); //$NON-NLS-1$
+ }
+
+ ContentChangedEventProvider eventProvider = getContentChangedEventProvider();
+ final boolean deliver = eventProvider.isDeliver();
+
+ eventProvider.setDeliver(false);
+ try {
+ result = sashModelOperation.execute(diSashModel);
+ } finally {
+ eventProvider.setDeliver(deliver);
+ }
+
+ return result;
+ }
+
+ //
+ // Private interfaces
+ //
+
+ /**
+ * An operation on the internal sash model of a page manager.
+ */
+ public static interface SashModelOperation<T> {
+
+ T execute(SashWindowsMngr sashWindowsManager);
+ }
}
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 007d58a7055..ef80da365d1 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
@@ -1,5 +1,5 @@
/*****************************************************************************
- * Copyright (c) 2009 CEA LIST & LIFL
+ * Copyright (c) 2009, 2014 LIFL, CEA LIST, and others.
*
*
* All rights reserved. This program and the accompanying materials
@@ -9,6 +9,7 @@
*
* Contributors:
* Cedric Dumoulin Cedric.dumoulin@lifl.fr - Initial API and implementation
+ * Christian W. Damus (CEA) - bug 433371
*
*****************************************************************************/
@@ -198,5 +199,9 @@ public class PageMngrImpl implements IPageMngr {
public boolean isOpen(Object pageIdentifier) {
return diSashModel.getSashModel().lookupPage(pageIdentifier) != null;
}
+
+ ContentChangedEventProvider getContentChangedEventProvider() {
+ return contentChangedEventProvider;
+ }
}
diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/custom-src/org/eclipse/papyrus/infra/core/sasheditor/di/contentprovider/utils/IPageUtils.java b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/custom-src/org/eclipse/papyrus/infra/core/sasheditor/di/contentprovider/utils/IPageUtils.java
index 18170fc15c6..0830feb8d35 100644
--- a/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/custom-src/org/eclipse/papyrus/infra/core/sasheditor/di/contentprovider/utils/IPageUtils.java
+++ b/plugins/infra/core/org.eclipse.papyrus.infra.core.sasheditor.di/custom-src/org/eclipse/papyrus/infra/core/sasheditor/di/contentprovider/utils/IPageUtils.java
@@ -1,5 +1,5 @@
/*****************************************************************************
- * Copyright (c) 2010 LIFL & CEA LIST.
+ * Copyright (c) 2010, 2014 LIFL, CEA LIST, and others.
*
*
* All rights reserved. This program and the accompanying materials
@@ -9,14 +9,29 @@
*
* Contributors:
* Cedric Dumoulin (LIFL) cedric.dumoulin@lifl.fr - Initial API and implementation
+ * Christian W. Damus (CEA) - bug 433371
*
*****************************************************************************/
package org.eclipse.papyrus.infra.core.sasheditor.di.contentprovider.utils;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.eclipse.emf.common.command.Command;
+import org.eclipse.emf.ecore.EObject;
+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.di.contentprovider.internal.PageManagerImpl;
+import org.eclipse.papyrus.infra.core.sasheditor.di.contentprovider.internal.PageManagerImpl.SashModelOperation;
import org.eclipse.papyrus.infra.core.sasheditor.editor.IPage;
import org.eclipse.papyrus.infra.core.sasheditor.editor.ISashWindowsContainer;
import org.eclipse.papyrus.infra.core.sashwindows.di.PageRef;
+import org.eclipse.papyrus.infra.core.sashwindows.di.SashModel;
+import org.eclipse.papyrus.infra.core.sashwindows.di.SashWindowsMngr;
+import org.eclipse.papyrus.infra.core.sashwindows.di.TabFolder;
+import org.eclipse.papyrus.infra.core.sashwindows.di.util.DiSwitch;
/**
@@ -64,4 +79,88 @@ public class IPageUtils {
container.visit( visitor);
return visitor.getResult();
}
+
+ /**
+ * Obtains a command that will close all of the pages in the given {@code pageManager} that reference the specified {@code pageIdentifier},
+ * regardless of whether they still reference that identifier at the time of execution (this is the "memoization").
+ *
+ * @param domain
+ * the editing domain in which the command will be executed
+ * @param pageManager
+ * the page manager for which to construct the command
+ * @param pageIdentifier
+ * the identifier of the page(s) to be removed
+ *
+ * @return the memoized close-all-pages command, or {@code null} if there are no pages to close
+ */
+ public static Command getMemoizedCloseAllPagesCommand(final TransactionalEditingDomain domain, final IPageManager pageManager, final Object pageIdentifier) {
+ Command result = null;
+
+ final PageManagerImpl pageMan = (PageManagerImpl)pageManager;
+
+ final Map<PageRef, TabFolder> pages = execute(pageMan, new SashModelOperation<Map<PageRef, TabFolder>>() {
+
+ @Override
+ public Map<PageRef, TabFolder> execute(SashWindowsMngr sashWindowsManager) {
+ return new DiSwitch<Map<PageRef, TabFolder>>() {
+
+ private Map<PageRef, TabFolder> pages = new HashMap<PageRef, TabFolder>();
+
+ @Override
+ public Map<PageRef, TabFolder> defaultCase(EObject object) {
+ for(EObject next : object.eContents()) {
+ doSwitch(next);
+ }
+ return pages;
+ }
+
+ @Override
+ public Map<PageRef, TabFolder> casePageRef(PageRef object) {
+ if(object.getPageIdentifier() == pageIdentifier) {
+ pages.put(object, object.getParent());
+ }
+ return pages;
+ }
+ }.doSwitch(sashWindowsManager.getSashModel());
+ }
+ });
+
+
+ if(!pages.isEmpty()) {
+ final SashModelOperation<Void> removeOp = new SashModelOperation<Void>() {
+
+ @Override
+ public Void execute(SashWindowsMngr sashWindowsManager) {
+ SashModel sashModel = sashWindowsManager.getSashModel();
+ for(Map.Entry<PageRef, TabFolder> next : pages.entrySet()) {
+ PageRef page = next.getKey();
+ TabFolder folder = next.getValue();
+
+ folder.getChildren().remove(page);
+ sashModel.removeEmptyFolder(folder);
+ }
+ return null;
+ }
+ };
+
+ result = new RecordingCommand(domain, "Remove Editor Page(s)") { //$NON-NLS-1$
+
+ @Override
+ protected void doExecute() {
+ IPageUtils.execute(pageMan, removeOp);
+ }
+ };
+ }
+
+ return result;
+ }
+
+ private static <T> T execute(PageManagerImpl pageManager, SashModelOperation<T> sashOperation) {
+ try {
+ return pageManager.execute(sashOperation);
+ } catch (IllegalAccessException e) {
+ // Won't happen because this is our own operation
+ throw new IllegalAccessError(e.getLocalizedMessage());
+ }
+ }
}
diff --git a/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/advice/DeletePageAdvice.java b/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/advice/DeletePageAdvice.java
index 8137e18e621..aca59b0a751 100644
--- a/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/advice/DeletePageAdvice.java
+++ b/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/advice/DeletePageAdvice.java
@@ -1,5 +1,5 @@
/*****************************************************************************
- * Copyright (c) 2013 CEA LIST.
+ * Copyright (c) 2013, 2014 CEA LIST and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
@@ -8,6 +8,8 @@
*
* Contributors:
* Camille Letavernier (CEA LIST) camille.letavernier@cea.fr - Initial API and implementation
+ * Christian W. Damus (CEA) - bug 433371
+ *
*****************************************************************************/
package org.eclipse.papyrus.infra.emf.advice;
@@ -15,7 +17,6 @@ import org.eclipse.emf.ecore.EObject;
import org.eclipse.gmf.runtime.common.core.command.ICommand;
import org.eclipse.gmf.runtime.emf.type.core.edithelper.AbstractEditHelperAdvice;
import org.eclipse.gmf.runtime.emf.type.core.requests.DestroyDependentsRequest;
-import org.eclipse.gmf.runtime.emf.type.core.requests.DestroyElementRequest;
/**
* An EditHelperAdvice which applies to all Papyrus page identifiers (i.e. Tables, Diagrams, ...)
@@ -29,16 +30,6 @@ import org.eclipse.gmf.runtime.emf.type.core.requests.DestroyElementRequest;
public class DeletePageAdvice extends AbstractEditHelperAdvice {
@Override
- public ICommand getBeforeDestroyElementCommand(DestroyElementRequest request) {
- final EObject objectToDestroy = request.getElementToDestroy();
- if(objectToDestroy == null) {
- return null;
- }
-
- return RemovePageHelper.getRemovePageCommand(request.getEditingDomain(), objectToDestroy);
- }
-
- @Override
protected ICommand getBeforeDestroyDependentsCommand(DestroyDependentsRequest request) {
final EObject objectToDestroy = request.getElementToDestroy();
if(objectToDestroy == null) {
diff --git a/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/advice/RemovePageHelper.java b/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/advice/RemovePageHelper.java
index 0a2c572e8ca..f633c8ea851 100644
--- a/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/advice/RemovePageHelper.java
+++ b/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/advice/RemovePageHelper.java
@@ -1,5 +1,5 @@
/*****************************************************************************
- * Copyright (c) 2013 CEA LIST.
+ * Copyright (c) 2013, 2014 CEA LIST and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
@@ -8,18 +8,22 @@
*
* Contributors:
* Camille Letavernier (CEA LIST) camille.letavernier@cea.fr - Initial API and implementation
+ * Christian W. Damus (CEA) - bug 433371
+ *
*****************************************************************************/
package org.eclipse.papyrus.infra.emf.advice;
import org.eclipse.core.commands.ExecutionException;
import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.emf.common.command.Command;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.transaction.TransactionalEditingDomain;
import org.eclipse.gmf.runtime.common.core.command.CommandResult;
import org.eclipse.gmf.runtime.common.core.command.ICommand;
import org.eclipse.gmf.runtime.emf.commands.core.command.AbstractTransactionalCommand;
import org.eclipse.papyrus.infra.core.sasheditor.contentprovider.IPageManager;
+import org.eclipse.papyrus.infra.core.sasheditor.di.contentprovider.utils.IPageUtils;
import org.eclipse.papyrus.infra.core.services.ServiceException;
import org.eclipse.papyrus.infra.emf.utils.ServiceUtilsForEObject;
@@ -35,14 +39,22 @@ public class RemovePageHelper {
try {
final IPageManager pageManager = ServiceUtilsForEObject.getInstance().getIPageManager(elementToDestroy);
if(pageManager.allPages().contains(elementToDestroy)) {
- return new AbstractTransactionalCommand(editingDomain, "Delete page", null) { //$NON-NLS-1$
-
- @Override
- protected CommandResult doExecuteWithResult(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
- pageManager.removePage(elementToDestroy);
- return CommandResult.newOKCommandResult();
- }
- };
+ final Command command = IPageUtils.getMemoizedCloseAllPagesCommand(editingDomain, pageManager, elementToDestroy);
+ if (command != null) {
+ return new AbstractTransactionalCommand(editingDomain, "Delete page", null) { //$NON-NLS-1$
+
+ @Override
+ public boolean canExecute() {
+ return command.canExecute();
+ }
+
+ @Override
+ protected CommandResult doExecuteWithResult(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
+ command.execute();
+ return CommandResult.newOKCommandResult();
+ }
+ };
+ }
}
} catch (ServiceException ex) {
//Ignore
diff --git a/tests/junit/plugins/core/org.eclipse.papyrus.editor.integration.tests/META-INF/MANIFEST.MF b/tests/junit/plugins/core/org.eclipse.papyrus.editor.integration.tests/META-INF/MANIFEST.MF
index 9c2182c2a67..c54ab8025a2 100644
--- a/tests/junit/plugins/core/org.eclipse.papyrus.editor.integration.tests/META-INF/MANIFEST.MF
+++ b/tests/junit/plugins/core/org.eclipse.papyrus.editor.integration.tests/META-INF/MANIFEST.MF
@@ -28,7 +28,8 @@ Require-Bundle: org.eclipse.ui,
com.google.guava;bundle-version="11.0.0",
org.eclipse.papyrus.infra.nattable.common;bundle-version="1.0.0",
org.eclipse.papyrus.infra.nattable;bundle-version="1.0.0",
- org.eclipse.papyrus.uml.nattable.menu;bundle-version="1.0.0"
+ org.eclipse.papyrus.uml.nattable.menu;bundle-version="1.0.0",
+ org.eclipse.papyrus.uml.diagram.sequence;bundle-version="1.0.0"
Export-Package: org.eclipse.papyrus.editor.integration.tests,
org.eclipse.papyrus.editor.integration.tests.tests
Bundle-Vendor: Eclipse Modeling Project
diff --git a/tests/junit/plugins/core/org.eclipse.papyrus.editor.integration.tests/model/basic/delete_sash_page.di b/tests/junit/plugins/core/org.eclipse.papyrus.editor.integration.tests/model/basic/delete_sash_page.di
new file mode 100644
index 00000000000..91d2aeda26a
--- /dev/null
+++ b/tests/junit/plugins/core/org.eclipse.papyrus.editor.integration.tests/model/basic/delete_sash_page.di
@@ -0,0 +1,15 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<di:SashWindowsMngr xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:di="http://www.eclipse.org/papyrus/0.7.0/sashdi">
+ <sashModel currentSelection="//@sashModel/@windows.0/@children.1">
+ <windows>
+ <children xsi:type="di:TabFolder">
+ <children>
+ <emfPageIdentifier href="delete_sash_page.notation#_simUYNVWEeOoXOFyw97Vng"/>
+ </children>
+ <children>
+ <emfPageIdentifier href="delete_sash_page.notation#_yjT5oNVWEeOoXOFyw97Vng"/>
+ </children>
+ </children>
+ </windows>
+ </sashModel>
+</di:SashWindowsMngr>
diff --git a/tests/junit/plugins/core/org.eclipse.papyrus.editor.integration.tests/model/basic/delete_sash_page.notation b/tests/junit/plugins/core/org.eclipse.papyrus.editor.integration.tests/model/basic/delete_sash_page.notation
new file mode 100644
index 00000000000..f69e268e509
--- /dev/null
+++ b/tests/junit/plugins/core/org.eclipse.papyrus.editor.integration.tests/model/basic/delete_sash_page.notation
@@ -0,0 +1,49 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<xmi:XMI xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:css="http://www.eclipse.org/papyrus/infra/gmfdiag/css" xmlns:notation="http://www.eclipse.org/gmf/runtime/1.0.2/notation" xmlns:style="http://www.eclipse.org/papyrus/infra/viewpoints/policy/style" xmlns:uml="http://www.eclipse.org/uml2/5.0.0/UML">
+ <notation:Diagram xmi:id="_simUYNVWEeOoXOFyw97Vng" type="PapyrusUMLClassDiagram" name="classes" measurementUnit="Pixel">
+ <children xmi:type="notation:Shape" xmi:id="_vz67MNVWEeOoXOFyw97Vng" type="2008">
+ <children xmi:type="notation:DecorationNode" xmi:id="_vz-lkNVWEeOoXOFyw97Vng" type="5029"/>
+ <children xmi:type="notation:BasicCompartment" xmi:id="_v0CP8NVWEeOoXOFyw97Vng" type="7017">
+ <styles xmi:type="notation:TitleStyle" xmi:id="_v0CP8dVWEeOoXOFyw97Vng"/>
+ <styles xmi:type="notation:SortingStyle" xmi:id="_v0CP8tVWEeOoXOFyw97Vng"/>
+ <styles xmi:type="notation:FilteringStyle" xmi:id="_v0CP89VWEeOoXOFyw97Vng"/>
+ <layoutConstraint xmi:type="notation:Bounds" xmi:id="_v0CP9NVWEeOoXOFyw97Vng"/>
+ </children>
+ <children xmi:type="notation:BasicCompartment" xmi:id="_v0C3ANVWEeOoXOFyw97Vng" type="7018">
+ <styles xmi:type="notation:TitleStyle" xmi:id="_v0C3AdVWEeOoXOFyw97Vng"/>
+ <styles xmi:type="notation:SortingStyle" xmi:id="_v0C3AtVWEeOoXOFyw97Vng"/>
+ <styles xmi:type="notation:FilteringStyle" xmi:id="_v0C3A9VWEeOoXOFyw97Vng"/>
+ <layoutConstraint xmi:type="notation:Bounds" xmi:id="_v0C3BNVWEeOoXOFyw97Vng"/>
+ </children>
+ <children xmi:type="notation:BasicCompartment" xmi:id="_v0C3BdVWEeOoXOFyw97Vng" type="7019">
+ <styles xmi:type="notation:TitleStyle" xmi:id="_v0C3BtVWEeOoXOFyw97Vng"/>
+ <styles xmi:type="notation:SortingStyle" xmi:id="_v0C3B9VWEeOoXOFyw97Vng"/>
+ <styles xmi:type="notation:FilteringStyle" xmi:id="_v0C3CNVWEeOoXOFyw97Vng"/>
+ <layoutConstraint xmi:type="notation:Bounds" xmi:id="_v0C3CdVWEeOoXOFyw97Vng"/>
+ </children>
+ <element xmi:type="uml:Class" href="delete_sash_page.uml#_vzHp8NVWEeOoXOFyw97Vng"/>
+ <layoutConstraint xmi:type="notation:Bounds" xmi:id="_vz67MdVWEeOoXOFyw97Vng" x="98" y="142"/>
+ </children>
+ <styles xmi:type="notation:DiagramStyle" xmi:id="_simUYdVWEeOoXOFyw97Vng"/>
+ <styles xmi:type="style:PapyrusViewStyle" xmi:id="_simUYtVWEeOoXOFyw97Vng">
+ <owner xmi:type="uml:Model" href="delete_sash_page.uml#_sgZU8NVWEeOoXOFyw97Vng"/>
+ </styles>
+ <element xmi:type="uml:Model" href="delete_sash_page.uml#_sgZU8NVWEeOoXOFyw97Vng"/>
+ </notation:Diagram>
+ <notation:Diagram xmi:id="_yjT5oNVWEeOoXOFyw97Vng" type="PapyrusUMLSequenceDiagram" name="SeqDiagram" measurementUnit="Pixel">
+ <children xmi:type="notation:Shape" xmi:id="_yjT5odVWEeOoXOFyw97Vng" type="2001">
+ <children xmi:type="notation:DecorationNode" xmi:id="_yjT5otVWEeOoXOFyw97Vng" type="5001"/>
+ <children xmi:type="notation:DecorationNode" xmi:id="_yjT5o9VWEeOoXOFyw97Vng" type="7001">
+ <layoutConstraint xmi:type="notation:Bounds" xmi:id="_yjT5pNVWEeOoXOFyw97Vng"/>
+ </children>
+ <element xmi:type="uml:Interaction" href="delete_sash_page.uml#_yOvX0NVWEeOoXOFyw97Vng"/>
+ <layoutConstraint xmi:type="notation:Bounds" xmi:id="_yjT5pdVWEeOoXOFyw97Vng"/>
+ </children>
+ <styles xmi:type="notation:DiagramStyle" xmi:id="_yjT5ptVWEeOoXOFyw97Vng"/>
+ <styles xmi:type="style:PapyrusViewStyle" xmi:id="_yjT5p9VWEeOoXOFyw97Vng">
+ <owner xmi:type="uml:Class" href="delete_sash_page.uml#_vzHp8NVWEeOoXOFyw97Vng"/>
+ </styles>
+ <element xmi:type="uml:Interaction" href="delete_sash_page.uml#_yOvX0NVWEeOoXOFyw97Vng"/>
+ </notation:Diagram>
+ <css:ModelStyleSheets xmi:id="_mYXeYNVkEeOI4Kq2eB46WA"/>
+</xmi:XMI>
diff --git a/tests/junit/plugins/core/org.eclipse.papyrus.editor.integration.tests/model/basic/delete_sash_page.uml b/tests/junit/plugins/core/org.eclipse.papyrus.editor.integration.tests/model/basic/delete_sash_page.uml
new file mode 100644
index 00000000000..7aa02902acd
--- /dev/null
+++ b/tests/junit/plugins/core/org.eclipse.papyrus.editor.integration.tests/model/basic/delete_sash_page.uml
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<uml:Model xmi:version="20131001" xmlns:xmi="http://www.omg.org/spec/XMI/20131001" xmlns:uml="http://www.eclipse.org/uml2/5.0.0/UML" xmi:id="_sgZU8NVWEeOoXOFyw97Vng" name="delete_sash_page">
+ <packageImport xmi:type="uml:PackageImport" xmi:id="_sgZU8dVWEeOoXOFyw97Vng">
+ <importedPackage xmi:type="uml:Model" href="pathmap://UML_LIBRARIES/UMLPrimitiveTypes.library.uml#_0"/>
+ </packageImport>
+ <packagedElement xmi:type="uml:Class" xmi:id="_vzHp8NVWEeOoXOFyw97Vng" name="Class1" classifierBehavior="_yOvX0NVWEeOoXOFyw97Vng">
+ <ownedBehavior xmi:type="uml:Interaction" xmi:id="_yOvX0NVWEeOoXOFyw97Vng" name="Interaction"/>
+ </packagedElement>
+</uml:Model>
diff --git a/tests/junit/plugins/core/org.eclipse.papyrus.editor.integration.tests/src/org/eclipse/papyrus/editor/integration/tests/tests/PageManagerTests.java b/tests/junit/plugins/core/org.eclipse.papyrus.editor.integration.tests/src/org/eclipse/papyrus/editor/integration/tests/tests/PageManagerTests.java
index 3d33ff5fe0b..f2ad8aa3224 100644
--- a/tests/junit/plugins/core/org.eclipse.papyrus.editor.integration.tests/src/org/eclipse/papyrus/editor/integration/tests/tests/PageManagerTests.java
+++ b/tests/junit/plugins/core/org.eclipse.papyrus.editor.integration.tests/src/org/eclipse/papyrus/editor/integration/tests/tests/PageManagerTests.java
@@ -1,5 +1,5 @@
/*****************************************************************************
- * Copyright (c) 2013 CEA LIST.
+ * Copyright (c) 2013, 2014 CEA LIST and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
@@ -8,9 +8,16 @@
*
* Contributors:
* Camille Letavernier (CEA LIST) camille.letavernier@cea.fr - Initial API and implementation
+ * Christian W. Damus (CEA) - bug 433371
+ *
*****************************************************************************/
package org.eclipse.papyrus.editor.integration.tests.tests;
+import static org.hamcrest.CoreMatchers.hasItem;
+import static org.hamcrest.CoreMatchers.instanceOf;
+import static org.hamcrest.CoreMatchers.not;
+import static org.hamcrest.MatcherAssert.assertThat;
+
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.ResourcesPlugin;
@@ -47,10 +54,13 @@ import org.eclipse.papyrus.junit.utils.EditorUtils;
import org.eclipse.papyrus.uml.diagram.clazz.CreateClassDiagramCommand;
import org.eclipse.papyrus.uml.diagram.clazz.UmlClassDiagramForMultiEditor;
import org.eclipse.papyrus.uml.diagram.common.commands.CreateUMLModelCommand;
+import org.eclipse.papyrus.uml.diagram.sequence.UmlSequenceDiagramForMultiEditor;
import org.eclipse.papyrus.uml.diagram.timing.custom.UmlTimingDiagramForMultiEditor;
import org.eclipse.papyrus.uml.tools.model.UmlModel;
import org.eclipse.papyrus.uml.tools.model.UmlUtils;
import org.eclipse.swt.widgets.Display;
+import org.eclipse.uml2.uml.Behavior;
+import org.eclipse.uml2.uml.BehavioredClassifier;
import org.eclipse.uml2.uml.Element;
import org.eclipse.uml2.uml.Model;
import org.junit.Assert;
@@ -298,6 +308,18 @@ public class PageManagerTests extends AbstractEditorIntegrationTest {
testPageDeletion(diagram, UmlClassDiagramForMultiEditor.class);
}
+ @Test
+ public void testDiagramIndirectDeletion_bug433371() throws Exception {
+ initModel("bug433371", "delete_sash_page", getBundle());
+ ModelSet modelSet = getModelSet();
+ final Diagram diagram = (Diagram)NotationUtils.getNotationModel(modelSet).getResource().getContents().get(1);
+
+ IPageManager pageManager = editor.getServicesRegistry().getService(IPageManager.class);
+ pageManager.selectPage(diagram); // Make sure the one we want deleted is active
+
+ testPageDeletion(diagram.getElement(), diagram, UmlSequenceDiagramForMultiEditor.class);
+ }
+
/**
* @author vincent lorenzo
* @throws Exception
@@ -392,6 +414,34 @@ public class PageManagerTests extends AbstractEditorIntegrationTest {
}
}
+ private void testPageDeletion(final EObject elementToDelete, final Object dependentPage, Class<?> expectedEditorClass) throws Exception {
+ final IPageManager pageManager = editor.getServicesRegistry().getService(IPageManager.class);
+
+ //Check initial state
+ assertThat("Page not open", pageManager.allPages(), hasItem(dependentPage));
+
+ assertThat("Wrong kind of page", editor.getActiveEditor(), instanceOf(expectedEditorClass));
+
+ TransactionalEditingDomain editingDomain = editor.getServicesRegistry().getService(TransactionalEditingDomain.class);
+
+ Element clazz = getRootUMLModel().getOwnedType("Class1");
+ Behavior toDelete = ((BehavioredClassifier)clazz).getOwnedBehaviors().get(0);
+ IElementEditService edit = ElementEditServiceUtils.getCommandProvider(clazz);
+ ICommand command = edit.getEditCommand(new DestroyElementRequest(toDelete, false));
+
+ editingDomain.getCommandStack().execute(GMFtoEMFCommandWrapper.wrap(command));
+
+ for(int i = 0; i < 3; i++) { //Undo/Redo 3 times
+ assertThat("The editor page should be closed", pageManager.allPages(), not(hasItem(dependentPage)));
+
+ editingDomain.getCommandStack().undo();
+
+ assertThat("The page has not been correctly restored", pageManager.allPages(), hasItem(dependentPage));
+
+ editingDomain.getCommandStack().redo();
+ }
+ }
+
@Test
public void testContainedDiagramDeletion() throws Exception {
initModel("deleteContainedDiagrams", "delete_contained_diagram", getBundle());

Back to the top