code review - do not show error dialog inside operation
diff --git a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/ide/undo/WorkspaceUndoUtil.java b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/ide/undo/WorkspaceUndoUtil.java
index e4f204e..eb01025 100644
--- a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/ide/undo/WorkspaceUndoUtil.java
+++ b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/ide/undo/WorkspaceUndoUtil.java
@@ -690,11 +690,20 @@
return true;
}
- /*
+ /**
* Return the shell described by the specified adaptable, or the active
* shell if no shell has been specified in the adaptable.
+ *
+ * @param uiInfo
+ * the IAdaptable (or <code>null</code>) provided by the
+ * caller in order to supply UI information for prompting the
+ * user if necessary. When this parameter is not
+ * <code>null</code>, it contains an adapter for the
+ * org.eclipse.swt.widgets.Shell.class
+ *
+ * @return the Shell that can be used to show information
*/
- private static Shell getShell(IAdaptable uiInfo) {
+ public static Shell getShell(IAdaptable uiInfo) {
if (uiInfo != null) {
Shell shell = (Shell) uiInfo.getAdapter(Shell.class);
if (shell != null) {
diff --git a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/views/bookmarkexplorer/BookmarkAction.java b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/views/bookmarkexplorer/BookmarkAction.java
index 7366aba..5d4852c 100644
--- a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/views/bookmarkexplorer/BookmarkAction.java
+++ b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/views/bookmarkexplorer/BookmarkAction.java
@@ -13,8 +13,10 @@
import org.eclipse.core.commands.ExecutionException;
import org.eclipse.core.commands.operations.IUndoableOperation;
+import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.jface.dialogs.ErrorDialog;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.actions.SelectionProviderAction;
import org.eclipse.ui.internal.ide.IDEWorkbenchPlugin;
@@ -43,13 +45,18 @@
/**
* Execute the specified undoable operation
*/
- void execute(IUndoableOperation operation, String message,
+ void execute(IUndoableOperation operation, String title,
IProgressMonitor monitor, IAdaptable uiInfo) {
try {
PlatformUI.getWorkbench().getOperationSupport()
.getOperationHistory().execute(operation, monitor, uiInfo);
} catch (ExecutionException e) {
- IDEWorkbenchPlugin.log(message, e);
+ if (e.getCause() instanceof CoreException) {
+ ErrorDialog.openError(view.getShell(), title,
+ null, ((CoreException)e.getCause()).getStatus());
+ } else {
+ IDEWorkbenchPlugin.log(title, e);
+ }
}
}
diff --git a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/views/markers/internal/BookmarkView.java b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/views/markers/internal/BookmarkView.java
index 477135a..e74a82f 100644
--- a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/views/markers/internal/BookmarkView.java
+++ b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/views/markers/internal/BookmarkView.java
@@ -22,6 +22,7 @@
import org.eclipse.core.resources.IMarker;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.jface.action.IMenuManager;
+import org.eclipse.jface.dialogs.ErrorDialog;
import org.eclipse.jface.dialogs.IDialogSettings;
import org.eclipse.jface.viewers.CellEditor;
import org.eclipse.jface.viewers.ICellModifier;
@@ -99,10 +100,18 @@
}
}
} catch (ExecutionException e) {
- IDEWorkbenchPlugin.log(MarkerMessages.errorModifyingBookmark, e);
+ if (e.getCause() instanceof CoreException) {
+ ErrorDialog.openError(
+ getSite().getShell(),
+ MarkerMessages.errorModifyingBookmark, null, ((CoreException)e.getCause()).getStatus());
+ } else {
+ // something rather unexpected occurred.
+ IDEWorkbenchPlugin.log(MarkerMessages.errorModifyingBookmark, e);
+ }
} catch (CoreException e) {
- IDEWorkbenchPlugin.log(MarkerMessages.errorModifyingBookmark, e);
-
+ ErrorDialog.openError(
+ getSite().getShell(),
+ MarkerMessages.errorModifyingBookmark, null, e.getStatus());
}
}
}
diff --git a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/views/markers/internal/DialogMarkerProperties.java b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/views/markers/internal/DialogMarkerProperties.java
index 1145dbe..299d6c0 100644
--- a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/views/markers/internal/DialogMarkerProperties.java
+++ b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/views/markers/internal/DialogMarkerProperties.java
@@ -23,6 +23,7 @@
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.jface.dialogs.ErrorDialog;
import org.eclipse.jface.dialogs.IDialogConstants;
import org.eclipse.jface.dialogs.IDialogSettings;
import org.eclipse.jface.dialogs.TrayDialog;
@@ -535,7 +536,12 @@
.getOperationHistory().execute(op,
null, WorkspaceUndoUtil.getUIInfoAdapter(getShell()));
} catch (ExecutionException e) {
- IDEWorkbenchPlugin.log(e.getMessage(), e);
+ if (e.getCause() instanceof CoreException) {
+ ErrorDialog.openError(
+ getShell(),
+ MarkerMessages.Error, null, ((CoreException)e.getCause()).getStatus());
+ } else
+ IDEWorkbenchPlugin.log(e.getMessage(), e);
}
}
}
diff --git a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/views/markers/internal/MarkerSelectionProviderAction.java b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/views/markers/internal/MarkerSelectionProviderAction.java
index ffc1ad6..33af605 100644
--- a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/views/markers/internal/MarkerSelectionProviderAction.java
+++ b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/views/markers/internal/MarkerSelectionProviderAction.java
@@ -15,12 +15,15 @@
import org.eclipse.core.commands.ExecutionException;
import org.eclipse.core.commands.operations.IUndoableOperation;
import org.eclipse.core.resources.IMarker;
+import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.jface.dialogs.ErrorDialog;
import org.eclipse.jface.viewers.ISelectionProvider;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.actions.SelectionProviderAction;
+import org.eclipse.ui.ide.undo.WorkspaceUndoUtil;
import org.eclipse.ui.internal.ide.IDEWorkbenchPlugin;
/**
@@ -92,13 +95,20 @@
/**
* Execute the specified undoable operation
*/
- void execute(IUndoableOperation operation, String message,
+ void execute(IUndoableOperation operation, String title,
IProgressMonitor monitor, IAdaptable uiInfo) {
try {
PlatformUI.getWorkbench().getOperationSupport()
.getOperationHistory().execute(operation, monitor, uiInfo);
} catch (ExecutionException e) {
- IDEWorkbenchPlugin.log(message, e);
+ if (e.getCause() instanceof CoreException) {
+ ErrorDialog
+ .openError(WorkspaceUndoUtil.getShell(uiInfo), title,
+ null, ((CoreException) e.getCause())
+ .getStatus());
+ } else {
+ IDEWorkbenchPlugin.log(title, e);
+ }
}
}
}
diff --git a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/views/markers/internal/TaskView.java b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/views/markers/internal/TaskView.java
index ef65b7d..af8f3bc 100644
--- a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/views/markers/internal/TaskView.java
+++ b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/views/markers/internal/TaskView.java
@@ -18,9 +18,11 @@
import org.eclipse.core.commands.operations.IUndoContext;
import org.eclipse.core.commands.operations.IUndoableOperation;
import org.eclipse.core.resources.IMarker;
+import org.eclipse.core.runtime.CoreException;
import org.eclipse.jface.action.IMenuManager;
import org.eclipse.jface.action.IToolBarManager;
import org.eclipse.jface.action.Separator;
+import org.eclipse.jface.dialogs.ErrorDialog;
import org.eclipse.jface.dialogs.IDialogSettings;
import org.eclipse.jface.viewers.CellEditor;
import org.eclipse.jface.viewers.CheckboxCellEditor;
@@ -118,7 +120,14 @@
}
concreteMarker.refresh();
} catch (ExecutionException e) {
- IDEWorkbenchPlugin.log(MarkerMessages.errorModifyingTask, e);
+ if (e.getCause() instanceof CoreException) {
+ ErrorDialog.openError(
+ getSite().getShell(),
+ MarkerMessages.errorModifyingTask, null, ((CoreException)e.getCause()).getStatus());
+ } else {
+ // something rather unexpected occurred.
+ IDEWorkbenchPlugin.log(MarkerMessages.errorModifyingTask, e);
+ }
}
}
}
diff --git a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/views/tasklist/TaskAction.java b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/views/tasklist/TaskAction.java
index ca21807..a25309c 100644
--- a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/views/tasklist/TaskAction.java
+++ b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/views/tasklist/TaskAction.java
@@ -13,69 +13,78 @@
import org.eclipse.core.commands.ExecutionException;
import org.eclipse.core.commands.operations.IUndoableOperation;
+import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.jface.action.Action;
+import org.eclipse.jface.dialogs.ErrorDialog;
import org.eclipse.jface.dialogs.IDialogSettings;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.ide.undo.WorkspaceUndoUtil;
import org.eclipse.ui.internal.ide.IDEWorkbenchPlugin;
/**
- * This is the base class of all the local actions used
- * in the task list view.
+ * This is the base class of all the local actions used in the task list view.
*/
abstract class TaskAction extends Action {
- private TaskList taskList;
+ private TaskList taskList;
- /**
- * TaskAction constructor.
- */
- protected TaskAction(TaskList tasklist, String id) {
- super();
- this.taskList = tasklist;
- setId(id);
- }
+ /**
+ * TaskAction constructor.
+ */
+ protected TaskAction(TaskList tasklist, String id) {
+ super();
+ this.taskList = tasklist;
+ setId(id);
+ }
- /**
- * Returns the shell to use within actions.
- */
- protected Shell getShell() {
- return taskList.getSite().getShell();
- }
+ /**
+ * Returns the shell to use within actions.
+ */
+ protected Shell getShell() {
+ return taskList.getSite().getShell();
+ }
- /**
- * Returns the task list viewer.
- */
- protected TaskList getTaskList() {
- return taskList;
- }
+ /**
+ * Returns the task list viewer.
+ */
+ protected TaskList getTaskList() {
+ return taskList;
+ }
- /**
- * Stores the current state value of this toggle action
- * into the dialog store using action ID as a key.
- */
- protected void storeValue() {
- IDialogSettings workbenchSettings = TaskList.getPlugin()
- .getDialogSettings();
- IDialogSettings settings = workbenchSettings.getSection("TaskAction");//$NON-NLS-1$
- if (settings == null) {
+ /**
+ * Stores the current state value of this toggle action into the dialog
+ * store using action ID as a key.
+ */
+ protected void storeValue() {
+ IDialogSettings workbenchSettings = TaskList.getPlugin()
+ .getDialogSettings();
+ IDialogSettings settings = workbenchSettings.getSection("TaskAction");//$NON-NLS-1$
+ if (settings == null) {
settings = workbenchSettings.addNewSection("TaskAction");//$NON-NLS-1$
}
- settings.put(getId(), isChecked());
- }
-
+ settings.put(getId(), isChecked());
+ }
+
/**
* Execute the specified undoable operation
*/
- void execute(IUndoableOperation operation, String message,
+ void execute(IUndoableOperation operation, String title,
IProgressMonitor monitor, IAdaptable uiInfo) {
try {
PlatformUI.getWorkbench().getOperationSupport()
.getOperationHistory().execute(operation, monitor, uiInfo);
} catch (ExecutionException e) {
- IDEWorkbenchPlugin.log(message, e);
+ if (e.getCause() instanceof CoreException) {
+ ErrorDialog
+ .openError(WorkspaceUndoUtil.getShell(uiInfo), title,
+ null, ((CoreException) e.getCause())
+ .getStatus());
+ } else {
+ IDEWorkbenchPlugin.log(title, e);
+ }
}
}