summaryrefslogtreecommitdiffstatsabout
diff options
context:
space:
mode:
authorJens Baumgart2010-04-27 07:10:43 (EDT)
committer Chris Aniszczyk2010-04-27 09:37:22 (EDT)
commitce2477db86e4ee2131fe1565c6ef65bb4b1efe21 (patch)
tree6795e2900acc665233045cccb7d8ab906ba80747
parent70353242991531860eb1ac930caeea00d02d4697 (diff)
downloadegit-ce2477db86e4ee2131fe1565c6ef65bb4b1efe21.zip
egit-ce2477db86e4ee2131fe1565c6ef65bb4b1efe21.tar.gz
egit-ce2477db86e4ee2131fe1565c6ef65bb4b1efe21.tar.bz2
Fix error handling in some actionsrefs/changes/06/606/3
Some missing error logging was added. Change-Id: Ice7612f46d46b088fe99bef82a851c4191c7fd9e Signed-off-by: Jens Baumgart <jens.baumgart@sap.com> Signed-off-by: Chris Aniszczyk <caniszczyk@gmail.com>
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/Activator.java60
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/actions/DiscardChangesAction.java14
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/actions/ResetAction.java5
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/actions/Track.java6
4 files changed, 53 insertions, 32 deletions
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/Activator.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/Activator.java
index 4ea7b02..ec025bc 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/Activator.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/Activator.java
@@ -40,7 +40,10 @@ import org.eclipse.jgit.lib.RepositoryListener;
import org.eclipse.jgit.transport.SshSessionFactory;
import org.eclipse.jsch.core.IJSchService;
import org.eclipse.osgi.service.debug.DebugOptions;
+import org.eclipse.swt.graphics.Font;
import org.eclipse.ui.plugin.AbstractUIPlugin;
+import org.eclipse.ui.statushandlers.StatusManager;
+import org.eclipse.ui.themes.ITheme;
import org.osgi.framework.BundleContext;
import org.osgi.framework.ServiceReference;
import org.osgi.util.tracker.ServiceTracker;
@@ -80,30 +83,55 @@ public class Activator extends AbstractUIPlugin {
return getDefault().getBundle().getSymbolicName();
}
+ /**
+ * Handle an error. The error is logged. If <code>show</code> is
+ * <code>true</code> the error is shown to the user.
+ *
+ * @param message a localized message
+ * @param throwable
+ * @param show
+ */
+ public static void handleError(String message, Throwable throwable,
+ boolean show) {
+ IStatus status = new Status(IStatus.ERROR, getPluginId(), message,
+ throwable);
+ int style = StatusManager.LOG;
+ if (show)
+ style |= StatusManager.SHOW;
+ StatusManager.getManager().handle(status, style);
+ }
+
+ /**
+ * Get the theme used by this plugin.
+ *
+ * @return our theme.
+ */
+ public static ITheme getTheme() {
+ return plugin.getWorkbench().getThemeManager().getCurrentTheme();
+ }
/**
- * Instantiate an error status.
+ * Get a font known to this plugin.
*
- * @param message
- * description of the error
- * @param thr
- * cause of the error or null
- * @return an initialized error status
+ * @param id
+ * one of our THEME_* font preference ids (see
+ * {@link UIPreferences});
+ * @return the configured font, borrowed from the registry.
*/
- public static IStatus error(final String message, final Throwable thr) {
- return new Status(IStatus.ERROR, getPluginId(), 0, message, thr);
+ public static Font getFont(final String id) {
+ return getTheme().getFontRegistry().get(id);
}
/**
- * Log an error via the Eclipse logging routines.
+ * Get a font known to this plugin, but with bold style applied over top.
*
- * @param message
- * @param thr
- * cause of error
+ * @param id
+ * one of our THEME_* font preference ids (see
+ * {@link UIPreferences});
+ * @return the configured font, borrowed from the registry.
*/
- public static void logError(final String message, final Throwable thr) {
- getDefault().getLog().log(
- new Status(IStatus.ERROR, getPluginId(), 0, message, thr));
+ public static Font getBoldFont(final String id) {
+ return getTheme().getFontRegistry().getBold(id);
}
private RCS rcs;
@@ -199,7 +227,7 @@ public class Activator extends AbstractUIPlugin {
getJobManager().beginRule(rule, monitor);
p.refreshLocal(IResource.DEPTH_INFINITE, new SubProgressMonitor(monitor, 1));
} catch (CoreException e) {
- logError(UIText.Activator_refreshFailed, e);
+ handleError(UIText.Activator_refreshFailed, e, false);
return new Status(IStatus.ERROR, getPluginId(), e.getMessage());
} finally {
getJobManager().endRule(rule);
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/actions/DiscardChangesAction.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/actions/DiscardChangesAction.java
index 6d21cdd..a169a7d 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/actions/DiscardChangesAction.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/actions/DiscardChangesAction.java
@@ -17,6 +17,7 @@ import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.egit.core.project.RepositoryMapping;
+import org.eclipse.egit.ui.Activator;
import org.eclipse.egit.ui.UIText;
import org.eclipse.jface.action.IAction;
import org.eclipse.jface.dialogs.MessageDialog;
@@ -51,15 +52,10 @@ public class DiscardChangesAction extends RepositoryAction{
for (IResource res : allFiles) {
try {
discardChange(res);
-
} catch (IOException e1) {
- MessageDialog.openError(getShell(),
- UIText.DiscardChangesAction_unexpectedErrorTitle,
- UIText.DiscardChangesAction_unexpectedErrorMessage);
+ Activator.handleError(UIText.DiscardChangesAction_unexpectedErrorMessage, e1, true);
}catch (RuntimeException e2) {
- MessageDialog.openError(getShell(),
- UIText.DiscardChangesAction_unexpectedErrorTitle,
- UIText.DiscardChangesAction_unexpectedIndexErrorMessage);
+ Activator.handleError(UIText.DiscardChangesAction_unexpectedIndexErrorMessage, e2, true);
}
}
@@ -79,9 +75,7 @@ public class DiscardChangesAction extends RepositoryAction{
try {
res.refreshLocal(0, new NullProgressMonitor());
} catch (CoreException e1) {
- MessageDialog.openError(getShell(),
- UIText.DiscardChangesAction_refreshErrorTitle,
- UIText.DiscardChangesAction_refreshErrorMessage);
+ Activator.handleError(UIText.DiscardChangesAction_refreshErrorMessage, e1, true);
}
repository.getIndex().write();
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/actions/ResetAction.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/actions/ResetAction.java
index d297271..a6cc1f8 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/actions/ResetAction.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/actions/ResetAction.java
@@ -16,6 +16,7 @@ import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.egit.core.op.ResetOperation;
import org.eclipse.egit.core.op.ResetOperation.ResetType;
+import org.eclipse.egit.ui.Activator;
import org.eclipse.egit.ui.UIText;
import org.eclipse.egit.ui.internal.decorators.GitLightweightDecorator;
import org.eclipse.egit.ui.internal.dialogs.BranchSelectionDialog;
@@ -67,9 +68,9 @@ public class ResetAction extends RepositoryAction {
}
});
} catch (InvocationTargetException e) {
- MessageDialog.openError(getShell(),UIText.ResetAction_resetFailed, e.getMessage());
+ Activator.handleError(UIText.ResetAction_resetFailed, e, true);
} catch (InterruptedException e) {
- MessageDialog.openError(getShell(),UIText.ResetAction_resetFailed, e.getMessage());
+ Activator.handleError(UIText.ResetAction_resetFailed, e, true);
}
}
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/actions/Track.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/actions/Track.java
index fe5bd62..68a48e4 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/actions/Track.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/actions/Track.java
@@ -19,7 +19,6 @@ import org.eclipse.egit.core.op.TrackOperation;
import org.eclipse.egit.ui.Activator;
import org.eclipse.egit.ui.UIText;
import org.eclipse.jface.action.IAction;
-import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.operation.IRunnableWithProgress;
/**
@@ -47,10 +46,9 @@ public class Track extends RepositoryAction {
}
});
} catch (InvocationTargetException e) {
- Activator.logError(UIText.Track_error, e);
- MessageDialog.openError(getShell(), UIText.Track_error, UIText.Track_see_log);
+ Activator.handleError(UIText.Track_error, e, true);
} catch (InterruptedException e) {
- MessageDialog.openError(getShell(), UIText.Track_error, e.getMessage());
+ Activator.handleError(UIText.Track_error, e, true);
}
}