org.eclipse.equinox.app,
org.eclipse.equinox.p2.repository.metadata,
org.osgi.framework,
- org.osgi.service.packageadmin
+ org.osgi.service.packageadmin,
+ org.springframework.remoting
Require-Bundle: org.eclipse.ui,
org.eclipse.core.runtime,
eu.etaxonomy.taxeditor.store,
import org.eclipse.ui.application.WorkbenchWindowAdvisor;
import org.eclipse.ui.statushandlers.AbstractStatusHandler;
import org.eclipse.ui.statushandlers.StatusAdapter;
+import org.springframework.remoting.RemoteAccessException;
+import org.springframework.remoting.RemoteConnectFailureException;
import eu.etaxonomy.taxeditor.model.MessagingUtils;
public class ApplicationWorkbenchAdvisor extends WorkbenchAdvisor {
private CdmStatusHandler cdmStatusHandler;
+
/*
* (non-Javadoc)
* @see org.eclipse.ui.application.WorkbenchAdvisor#createWorkbenchWindowAdvisor(org.eclipse.ui.application.IWorkbenchWindowConfigurer)
*/
class CdmStatusHandler extends AbstractStatusHandler {
+ private Throwable previousT;
/* (non-Javadoc)
* @see org.eclipse.ui.statushandlers.AbstractStatusHandler#handle(org.eclipse.ui.statushandlers.StatusAdapter, int)
*/
@Override
public void handle(StatusAdapter statusAdapter, int style)
{
+
if(statusAdapter.getStatus().matches(IStatus.ERROR)) {
IStatus status = statusAdapter.getStatus();
Throwable t = statusAdapter.getStatus().getException();
+ // NOTE : the global status handling mechanism in the case of
+ // runtime exceptions is called twice, once by the application
+ // throwing the exception and then by the rcp logging mechanism
+ // The check below is to make sure that the same exception is
+ // not shown twice in succession.
+ if(t != null && previousT == t) {
+ return;
+ }
+ previousT = t;
// NOTE : Currently we only allow RuntimeExceptions since
// allowing all kinds of exceptions would also include
// those in generated status objects coming from from logging triggers
// leading to a recursive infinite loop of :
// initial exception thrown -> status handling -> dialog opening + logging of status ->
// status handling -> dialog opening + logging of status ... and so on
- if(t != null && t instanceof RuntimeException && ! "Widget is disposed".equals(t.getMessage())){
- MessagingUtils.errorDialog("Unexpected error",
- null,
- MessagingUtils.UNEXPECTED_ERROR_MESSAGE,
- statusAdapter.getStatus().getPlugin(),
- t,
- true);
- }
+ if(t != null &&
+ t instanceof RuntimeException &&
+ ! "Widget is disposed".equals(t.getMessage()) &&
+ ! handleKnownRuntimeException(t,statusAdapter.getStatus().getPlugin())) {
+
+ MessagingUtils.errorDialog("Unexpected error",
+ null,
+ MessagingUtils.UNEXPECTED_ERROR_MESSAGE,
+ statusAdapter.getStatus().getPlugin(),
+ t,
+ true);
+
+ }
+ }
+ }
+
+ private boolean handleKnownRuntimeException(Throwable t, String pluginId) {
+ if(t instanceof RemoteConnectFailureException ||
+ t.getCause() instanceof RemoteConnectFailureException) {
+ MessagingUtils.errorDialog("Connection Failure",
+ null,
+ MessagingUtils.CONNECTION_FAILURE_MESSAGE + System.getProperty("line.separator"),
+ pluginId,
+ t,
+ true,
+ false);
+ return true;
+ }
+ if(t instanceof RemoteAccessException ||
+ t.getCause() instanceof RemoteAccessException) {
+ MessagingUtils.errorDialog("Remote Access Error",
+ null,
+ MessagingUtils.REMOTE_ACCESS_FAILURE_MESSAGE + System.getProperty("line.separator"),
+ pluginId,
+ t,
+ true,
+ false);
+ return true;
}
+ return false;
}
}
String dialogTitle,
String message,
IStatus status,
- String stackTrace) {
+ String stackTrace,
+ boolean showStatusMessage) {
super(parentShell,
dialogTitle,
message, status,
IStatus.OK| IStatus.INFO | IStatus.WARNING | IStatus.ERROR);
this.stackTrace = stackTrace;
-
-
+ String statusMessage = "";
+ if(showStatusMessage) {
+ statusMessage = status.getMessage();
+ }
+ this.message = message == null ? statusMessage : message + "\n " + statusMessage;
}
- /**
- * @param parentShell
- * @param dialogTitle
- * @param message
- * @param status
- * @param stackTrace
- */
- public CdmErrorDialog(Shell parentShell,
- String dialogTitle,
- String message,
- IStatus status,
- String stackTrace,
- Object[] updatedObjects) {
- this(parentShell, dialogTitle, message, status, stackTrace);
- this.message = message == null ? status.getMessage()
- : message + "\n " + status.getMessage(); //$NON-NLS-1$
- }
/**
* @param parentShell
String dialogTitle,
String message,
IStatus status) {
- this(parentShell, dialogTitle, message, status, "");
+ this(parentShell, dialogTitle, message, status, "", true);
}
/* (non-Javadoc)
public final static String UNEXPECTED_ERROR_MESSAGE = "This is an unexpected error.";
public final static String CONTACT_MESSAGE = System.getProperty("line.separator") + "Please contact EDIT Support (EditSupport@bgbm.org) with the error trace below (click on the 'Details' button).";
public final static String DEFAULT_MESSAGE = "Error thrown but no associated message";
+ public final static String CONNECTION_FAILURE_MESSAGE = "The connection to the remote server has been broken";
+ public final static String REMOTE_ACCESS_FAILURE_MESSAGE = "Problem accessing remote server";
/**
* Gets the Log4J logger for a given class
final Throwable t,
final List<String> contextInfo,
final String message,
- final MultiStatus status) {
+ final MultiStatus status,
+ final boolean showReason) {
Display.getDefault().asyncExec(new Runnable() {
@Override
public void run() {
String stackTraceWithContext = getStackTraceAndContextInfo(t, contextInfo);
- CdmErrorDialog ced = new CdmErrorDialog(AbstractUtility.getShell(), title, message, status, stackTraceWithContext);
+ CdmErrorDialog ced = new CdmErrorDialog(AbstractUtility.getShell(), title, message, status, stackTraceWithContext, showReason);
ced.open();
Class<? extends Object> clazz = source != null ? source.getClass() : this.getClass();
});
}
+ public static void errorDialog(final String title,
+ final Object source,
+ final String message,
+ final String pluginId,
+ final Throwable t,
+ boolean addContactMesg) {
+ errorDialog(title, source, message, pluginId, t, addContactMesg, true);
+
+ }
/**
* Displays a {@link eu.etaxonomy.taxeditor.model.CdmErrorDialog}.
*
final String message,
final String pluginId,
final Throwable t,
- boolean addContactMesg) {
+ boolean addContactMesg,
+ boolean showReason) {
Throwable throwable = t;
StringBuffer sbStackTrace = new StringBuffer();
throwable.toString(),
throwable);
- errorDialog(title, source, throwable, contextInfo, finalMessage, ms);
+ errorDialog(title, source, throwable, contextInfo, finalMessage, ms, showReason);
}
/**