Skip to content
Snippets Groups Projects
Commit 6fd4414a authored by Simon Barner's avatar Simon Barner
Browse files

Merge branch '4169' into 'master'

4169: Install exception handler for command stack showing errors to user

Closes af3#4169

See merge request !155
parents 48cc9d15 e66bc49e
No related branches found
No related tags found
1 merge request!1554169: Install exception handler for command stack showing errors to user
AutoUndoCommandStack.java fc326adf66c6cea2354884cdc240da5f2f82689a GREEN
EMFTransactionalCommand.java ba4b5bead9768b6ce6c955b9238cd96cb722533c GREEN
EclipseResourceStorageService.java 5e60ef7628ea2ad4113cfebde939341e1b1f6cf2 GREEN
ModelContext.java 76eeaef7f56da5f0e288cf96792850be606b7757 GREEN
ModelContext.java 484298fe527a4b83a6dceaef5dd459f874f8b737 GREEN
NonDirtyingEMFTransactionalCommand.java d288ebe35d22442c603496b0c917fb99a8febeea GREEN
......@@ -20,6 +20,7 @@ import static org.eclipse.core.resources.IResource.DEPTH_ZERO;
import static org.eclipse.emf.common.util.URI.createPlatformResourceURI;
import static org.fortiss.tooling.kernel.utils.EMFResourceUtils.buildOptionsMap;
import static org.fortiss.tooling.kernel.utils.LoggingUtils.error;
import static org.fortiss.tooling.kernel.utils.LoggingUtils.showError;
import static org.fortiss.tooling.kernel.utils.LoggingUtils.warning;
import static org.fortiss.tooling.kernel.utils.UniqueIDUtils.generateMissingIDs;
......@@ -55,6 +56,8 @@ import org.eclipse.emf.ecore.util.Diagnostician;
import org.eclipse.emf.ecore.util.EContentAdapter;
import org.eclipse.emf.ecore.xmi.XMIResource;
import org.eclipse.emf.ecore.xml.type.AnyType;
import org.eclipse.emf.transaction.ExceptionHandler;
import org.eclipse.emf.transaction.RollbackException;
import org.eclipse.emf.transaction.TransactionalEditingDomain;
import org.fortiss.tooling.kernel.ToolingKernelActivator;
import org.fortiss.tooling.kernel.extension.data.ITopLevelElement;
......@@ -123,6 +126,18 @@ class ModelContext implements ITopLevelElement, CommandStackListener {
transactionalCommandStack = new AutoUndoCommandStack(editingDomain);
transactionalCommandStack.addCommandStackListener(this);
transactionalCommandStack.setExceptionHandler(new ExceptionHandler() {
@Override
public void handleException(Exception e) {
// Each original exception results into a RollbackException that undoes the changes
// of the failed command
if(!(e instanceof RollbackException)) {
showError(e.getMessage());
error(ToolingKernelActivator.getDefault(), e.getMessage(), e);
}
}
});
// Install adapter to maintain XMI IDs
resource.eAdapters().add(new EContentAdapter() {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment