1 package com.proalpha.pds.paconnector.utils;
3 import org.eclipse.core.runtime.IStatus;
4 import org.eclipse.core.runtime.Status;
5 import org.eclipse.jface.dialogs.MessageDialog;
6 import org.eclipse.swt.widgets.Display;
7 import org.eclipse.swt.widgets.Shell;
8 import org.eclipse.ui.plugin.AbstractUIPlugin;
20 public static void showMessage(Throwable exception) {
22 final Shell activeShell = Display.getDefault().getActiveShell();
23 final String title =
"Error occurred";
24 final String message = getMessage(exception);
26 Display.getDefault().syncExec(
new Runnable() {
30 MessageDialog.openError(activeShell, title, message);
43 Throwable exception) {
44 IStatus status = createStatus(IStatus.ERROR, plugin, exception);
46 plugin.getLog().log(status);
56 Throwable exception) {
57 IStatus status = createStatus(IStatus.WARNING, plugin, exception);
58 plugin.getLog().log(status);
62 private static IStatus createStatus(
int severity, AbstractUIPlugin plugin,
63 Throwable exception) {
64 final String pluginID = plugin.getBundle().getSymbolicName();
65 final String message = getMessage(exception);
67 return new Status(severity, pluginID, message, exception);
78 Throwable exception) {
80 showMessage(exception);
89 private static String getMessage(Throwable exception) {
90 return (exception.getMessage() !=
null) ? exception.getMessage()
91 : exception.getClass().getName();
static void logWarnigMessage(AbstractUIPlugin plugin, Throwable exception)
static void logErrorMessage(AbstractUIPlugin plugin, Throwable exception)
static void showAndLogErrorMessage(AbstractUIPlugin plugin, Throwable exception)