Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMaxime Porhel2015-03-05 10:00:44 +0000
committerEsteban DUGUEPEROUX2015-04-21 07:42:22 +0000
commit8bf7b72c5ab56fb559ae5b0078d49f3337548ff0 (patch)
tree267f65a5280d184f54adc1b2d33714a316683d21
parent531ea1702c7805135e52b5acebd94b4d90becaa5 (diff)
downloadorg.eclipse.sirius-8bf7b72c5ab56fb559ae5b0078d49f3337548ff0.tar.gz
org.eclipse.sirius-8bf7b72c5ab56fb559ae5b0078d49f3337548ff0.tar.xz
org.eclipse.sirius-8bf7b72c5ab56fb559ae5b0078d49f3337548ff0.zip
[458050] Have a popup on session saving failure
- Remove use of IStatus in DAnalysisSessionImpl.doSave() to have exception thrown and have error popup from WorkbenchErrorHandler.handle() displayed. - Update DAnalysisSessionTests.testSaveSessionWithErrorDuringSave() to test the throwing of exception during saving. Bug: 458050 Change-Id: If8b1819a5a78152f92d6dd54f2522434c7a4c085 Signed-off-by: Maxime Porhel <maxime.porhel@obeo.fr> Signed-off-by: Esteban Dugueperoux <esteban.dugueperoux@obeo.fr>
-rw-r--r--plugins/org.eclipse.sirius.tests.junit/src/org/eclipse/sirius/tests/unit/api/session/DAnalysisSessionTests.java16
-rw-r--r--plugins/org.eclipse.sirius/src/org/eclipse/sirius/business/internal/session/danalysis/DAnalysisSessionImpl.java27
-rw-r--r--plugins/org.eclipse.sirius/src/org/eclipse/sirius/business/internal/session/danalysis/Saver.java1
3 files changed, 11 insertions, 33 deletions
diff --git a/plugins/org.eclipse.sirius.tests.junit/src/org/eclipse/sirius/tests/unit/api/session/DAnalysisSessionTests.java b/plugins/org.eclipse.sirius.tests.junit/src/org/eclipse/sirius/tests/unit/api/session/DAnalysisSessionTests.java
index 9d8ac83ad9..c63e39657f 100644
--- a/plugins/org.eclipse.sirius.tests.junit/src/org/eclipse/sirius/tests/unit/api/session/DAnalysisSessionTests.java
+++ b/plugins/org.eclipse.sirius.tests.junit/src/org/eclipse/sirius/tests/unit/api/session/DAnalysisSessionTests.java
@@ -17,7 +17,6 @@ import java.util.List;
import java.util.Map;
import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.emf.common.util.URI;
import org.eclipse.emf.ecore.EObject;
@@ -164,15 +163,12 @@ public class DAnalysisSessionTests extends SiriusDiagramTestCase {
doOpenAllRepresentations();
assertTrue("The session should be dirty.", editors.get(0).isDirty());
// Try to save the session
- session.save(new NullProgressMonitor());
- assertTrue("An error is expected during this save", doesAnErrorOccurs());
- Collection<IStatus> statuses = errors.get("org.eclipse.core.runtime");
- assertTrue("It should be only one error.", statuses != null && statuses.size() == 1);
- IStatus status = statuses.iterator().next();
- assertTrue("The exception should be a RuntimeException", status.getException() instanceof RuntimeException);
- assertEquals("The message should be the one logged in DAnalysisSessionImpl.doSave(Map<?, ?>, IProgressMonitor, boolean)", "Error while saving the session", status.getMessage());
- // Clear the errors to avoid a fail during tear down
- errors.clear();
+ try {
+ session.save(new NullProgressMonitor());
+ fail("A RuntimeException should be thrown");
+ } catch (RuntimeException e) {
+
+ }
doCleanup();
}
diff --git a/plugins/org.eclipse.sirius/src/org/eclipse/sirius/business/internal/session/danalysis/DAnalysisSessionImpl.java b/plugins/org.eclipse.sirius/src/org/eclipse/sirius/business/internal/session/danalysis/DAnalysisSessionImpl.java
index 2d4563eff5..d2f0d14b2e 100644
--- a/plugins/org.eclipse.sirius/src/org/eclipse/sirius/business/internal/session/danalysis/DAnalysisSessionImpl.java
+++ b/plugins/org.eclipse.sirius/src/org/eclipse/sirius/business/internal/session/danalysis/DAnalysisSessionImpl.java
@@ -18,7 +18,6 @@ import java.util.List;
import java.util.Map;
import java.util.Set;
-import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.ListenerList;
@@ -833,11 +832,8 @@ public class DAnalysisSessionImpl extends DAnalysisSessionEObjectImpl implements
* @param runExclusive
* whether or not to execute the saving in an exclusive
* transaction.
- * @return the result of the save operation.
*/
- protected IStatus doSave(final Map<?, ?> options, final IProgressMonitor monitor, boolean runExclusive) {
- IStatus status = Status.OK_STATUS;
-
+ protected void doSave(final Map<?, ?> options, final IProgressMonitor monitor, boolean runExclusive) {
try {
monitor.beginTask("Session saving", 3);
final Collection<Resource> allResources = Lists.newArrayList();
@@ -849,17 +845,8 @@ public class DAnalysisSessionImpl extends DAnalysisSessionEObjectImpl implements
RunnableWithResult<Collection<Resource>> save = new RunnableWithResult.Impl<Collection<Resource>>() {
@Override
public void run() {
- try {
- Collection<Resource> savedResources = getSavingPolicy().save(allResources, options, new SubProgressMonitor(monitor, 7));
- setResult(savedResources);
- setStatus(Status.OK_STATUS);
- // CHECKSTYLE:OFF
- } catch (Throwable e) {
- // CHECKSTYLE:ON
- Status status = new Status(IStatus.ERROR, SiriusPlugin.ID, "Error while saving the session", e);
- setStatus(status);
- SiriusPlugin.getDefault().error("Save failed", new CoreException(status));
- }
+ Collection<Resource> savedResources = getSavingPolicy().save(allResources, options, new SubProgressMonitor(monitor, 7));
+ setResult(savedResources);
}
};
if (runExclusive && !saver.domainDisposed.get()) {
@@ -874,11 +861,7 @@ public class DAnalysisSessionImpl extends DAnalysisSessionEObjectImpl implements
}
Collection<Resource> savedResources = save.getResult();
- if (savedResources == null) {
- // If the savedResources list is null, something went wrong and
- // has already been logged.
- status = save.getStatus();
- } else {
+ if (savedResources != null) {
CommandStack commandStack = transactionalEditingDomain.getCommandStack();
if (commandStack instanceof BasicCommandStack) {
((BasicCommandStack) commandStack).saveIsDone();
@@ -895,8 +878,6 @@ public class DAnalysisSessionImpl extends DAnalysisSessionEObjectImpl implements
} finally {
monitor.done();
}
-
- return status;
}
@Override
diff --git a/plugins/org.eclipse.sirius/src/org/eclipse/sirius/business/internal/session/danalysis/Saver.java b/plugins/org.eclipse.sirius/src/org/eclipse/sirius/business/internal/session/danalysis/Saver.java
index b61ffd1c60..1ff2611600 100644
--- a/plugins/org.eclipse.sirius/src/org/eclipse/sirius/business/internal/session/danalysis/Saver.java
+++ b/plugins/org.eclipse.sirius/src/org/eclipse/sirius/business/internal/session/danalysis/Saver.java
@@ -116,6 +116,7 @@ final class Saver extends TransactionalEditingDomainListenerImpl {
if (workspaceRoot != null) {
try {
workspaceRoot.getWorkspace().run(new IWorkspaceRunnable() {
+ @Override
public void run(final IProgressMonitor progressMonitor) throws CoreException {
wrappedSave(options, progressMonitor, runExclusive);
}

Back to the top