code review - do not show error dialog inside operation
diff --git a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/ide/undo/AbstractWorkspaceOperation.java b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/ide/undo/AbstractWorkspaceOperation.java
index 34f9d6c..1436c4c 100644
--- a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/ide/undo/AbstractWorkspaceOperation.java
+++ b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/ide/undo/AbstractWorkspaceOperation.java
@@ -32,7 +32,6 @@
import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.jobs.ISchedulingRule;
import org.eclipse.jface.action.Action;
-import org.eclipse.jface.dialogs.ErrorDialog;
import org.eclipse.osgi.util.NLS;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.PlatformUI;
@@ -44,8 +43,9 @@
* An AbstractWorkspaceOperation represents an undoable operation that affects
* the workspace. It handles common workspace operation activities such as
* tracking which resources are affected by an operation, prompting the user
- * when there are possible side effects of operations, error handling for core
- * exceptions, etc. Clients may call the public API from a background thread.
+ * when there are possible side effects of operations, building execution
+ * exceptions from core exceptions, etc. Clients may call the public API from a
+ * background thread.
*
* This class is not intended to be subclassed by clients.
*
@@ -182,9 +182,8 @@
/**
* Execute the specified operation. This implementation executes the
* operation in a workspace runnable and catches any CoreExceptions
- * resulting from the operation. An error dialog is shown to the user if a
- * CoreException occurs and the exception is propagated as an
- * ExecutionException if specified by the core exception handler
+ * resulting from the operation. Unhandled CoreExceptions are propagated as
+ * ExecutionExceptions.
*
* @param monitor
* the progress monitor to use for the operation
@@ -213,27 +212,9 @@
}
}, getExecuteSchedulingRule(), IWorkspace.AVOID_UPDATE, null);
} catch (final CoreException e) {
- final boolean[] propagateException = new boolean[1];
- getShell(uiInfo).getDisplay().syncExec(new Runnable() {
- public void run() {
- propagateException[0] = handleCoreException(
- e,
- getShell(uiInfo),
- NLS
- .bind(
- UndoMessages.AbstractWorkspaceOperation_ExecuteErrorTitle,
- getLabel()));
-
- }
-
- });
- if (propagateException[0]) {
- throw new ExecutionException(
- NLS
- .bind(
- UndoMessages.AbstractWorkspaceOperation_ExecuteErrorTitle,
- getLabel()), e);
- }
+ throw new ExecutionException(NLS.bind(
+ UndoMessages.AbstractWorkspaceOperation_ExecuteErrorTitle,
+ getLabel()), e);
}
isValid = true;
return Status.OK_STATUS;
@@ -242,9 +223,8 @@
/**
* Redo the specified operation. This implementation redoes the operation in
* a workspace runnable and catches any CoreExceptions resulting from the
- * operation. An error dialog is shown to the user if a CoreException occurs
- * and the exception is propagated as an ExecutionException if specified by
- * the core exception handler.
+ * operation. Unhandled CoreExceptions are propagated as
+ * ExecutionExceptions.
*
* @param monitor
* the progress monitor to use for the operation
@@ -272,24 +252,10 @@
}
}, getRedoSchedulingRule(), IWorkspace.AVOID_UPDATE, null);
} catch (final CoreException e) {
- final boolean[] propagateException = new boolean[1];
- getShell(uiInfo).getDisplay().syncExec(new Runnable() {
- public void run() {
- propagateException[0] = handleCoreException(
- e,
- getShell(uiInfo),
- NLS
- .bind(
- UndoMessages.AbstractWorkspaceOperation_RedoErrorTitle,
- getLabel()));
- }
+ throw new ExecutionException(NLS.bind(
+ UndoMessages.AbstractWorkspaceOperation_RedoErrorTitle,
+ getLabel()), e);
- });
- if (propagateException[0]) {
- throw new ExecutionException(NLS.bind(
- UndoMessages.AbstractWorkspaceOperation_RedoErrorTitle,
- getLabel()), e);
- }
}
isValid = true;
return Status.OK_STATUS;
@@ -298,9 +264,8 @@
/**
* Undo the specified operation. This implementation undoes the operation in
* a workspace runnable and catches any CoreExceptions resulting from the
- * operation. An error dialog is shown to the user if a CoreException occurs
- * and the exception is propagated as an ExecutionException if specified by
- * the core exception handler.
+ * operation. Unhandled CoreExceptions are propagated as
+ * ExecutionExceptions.
*
* @param monitor
* the progress monitor to use for the operation
@@ -328,25 +293,10 @@
}
}, getUndoSchedulingRule(), IWorkspace.AVOID_UPDATE, null);
} catch (final CoreException e) {
- final boolean[] propagateException = new boolean[1];
- getShell(uiInfo).getDisplay().syncExec(new Runnable() {
- public void run() {
- propagateException[0] = handleCoreException(
- e,
- getShell(uiInfo),
- NLS
- .bind(
- UndoMessages.AbstractWorkspaceOperation_UndoErrorTitle,
- getLabel()));
+ throw new ExecutionException(NLS.bind(
+ UndoMessages.AbstractWorkspaceOperation_UndoErrorTitle,
+ getLabel()), e);
- }
-
- });
- if (propagateException[0]) {
- throw new ExecutionException(NLS.bind(
- UndoMessages.AbstractWorkspaceOperation_UndoErrorTitle,
- getLabel()), e);
- }
}
isValid = true;
return Status.OK_STATUS;
@@ -705,49 +655,6 @@
}
/**
- * Handle the core exception that occurred while trying to execute, undo, or
- * redo the operation, returning a boolean to indicate whether this
- * exception should cause a {@link ExecutionException} to be thrown.
- *
- * It is safe to access UI in this method. The default implementation is to
- * show an error dialog, but subclasses may override this method to swallow
- * certain exceptions or handle them differently.
- *
- * If the only difference in handling the exception is to show a different
- * error message, subclasses should override
- * {@link #getErrorMessage(CoreException)} instead.
- *
- * @param e
- * the CoreException
- * @param shell
- * the shell to be used for showing any UI information
- * @param errorTitle
- * the title to be used in the error dialog.
- * @return a boolean indicating whether this exception should be propagated
- * to the caller as an ExecutionException
- */
- protected boolean handleCoreException(CoreException e, Shell shell,
- String errorTitle) {
- ErrorDialog.openError(shell, errorTitle, getErrorMessage(e), e
- .getStatus());
- return true;
- }
-
- /**
- * Return the specific error message to use when the specified core
- * exception occurs, or <code>null</code> to indicate that the the
- * exception's message should be used.
- *
- * @param e
- * the CoreException
- * @return the string to be used in any shown error message, or
- * <code>null</code> if the exception's message should be shown.
- */
- protected String getErrorMessage(CoreException e) {
- return null;
- }
-
- /**
* Return a scheduling rule appropriate for executing this operation.
*
* The default implementation is to return a rule that locks out the entire
diff --git a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/ide/undo/CreateProjectOperation.java b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/ide/undo/CreateProjectOperation.java
index 313f1b1..d29c294 100644
--- a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/ide/undo/CreateProjectOperation.java
+++ b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/ide/undo/CreateProjectOperation.java
@@ -12,11 +12,7 @@
package org.eclipse.ui.ide.undo;
import org.eclipse.core.resources.IProjectDescription;
-import org.eclipse.core.resources.IResourceStatus;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.osgi.util.NLS;
import org.eclipse.ui.internal.ide.undo.ProjectDescription;
-import org.eclipse.ui.internal.ide.undo.UndoMessages;
/**
* A CreateProjectOperation represents an undoable operation for creating a
@@ -48,26 +44,4 @@
super(new ProjectDescription[] { new ProjectDescription(
projectDescription) }, label);
}
-
- /*
- * (non-Javadoc)
- *
- * Overridden to return a specific error message for the existence of a case
- * variant of a project.
- *
- * @see org.eclipse.ui.ide.undo.AbstractWorkspaceOperation#getErrorMessage(org.eclipse.core.runtime.CoreException)
- */
- protected String getErrorMessage(CoreException e) {
- if (e.getStatus().getCode() == IResourceStatus.CASE_VARIANT_EXISTS) {
- if (resourceDescriptions != null
- && resourceDescriptions.length == 1) {
- ProjectDescription project = (ProjectDescription) resourceDescriptions[0];
- return NLS
- .bind(
- UndoMessages.CreateProjectOperation_caseVariantExistsError,
- project.getName());
- }
- }
- return super.getErrorMessage(e);
- }
}
diff --git a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/undo/UndoMessages.java b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/undo/UndoMessages.java
index abe9672..2bbe60e 100644
--- a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/undo/UndoMessages.java
+++ b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/undo/UndoMessages.java
@@ -59,7 +59,6 @@
public static String AbstractCopyOrMoveResourcesOperation_moveProjectProgress;
public static String DeleteResourcesOperation_DeletingProjectContentWarning;
- public static String CreateProjectOperation_caseVariantExistsError;
public static String ProjectDescription_NewProjectProgress;
public static String FileDescription_NewFileProgress;
diff --git a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/undo/messages.properties b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/undo/messages.properties
index 7ac3f01..93fd375 100644
--- a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/undo/messages.properties
+++ b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/undo/messages.properties
@@ -43,8 +43,6 @@
DeleteResourcesOperation_DeletingProjectContentWarning=Deleting project content will erase all of the file and folder history for the project. Undo will not restore the content.
-CreateProjectOperation_caseVariantExistsError = The underlying file system is case insensitive. There is an existing project which conflicts with ''{0}''.
-
MoveProjectOperation_Progress = Moving project...
ProjectDescription_NewProjectProgress=Creating new project...