import eu.etaxonomy.taxeditor.operation.AbstractPostOperation;
import eu.etaxonomy.taxeditor.operation.IPostOperationEnabled;
+import eu.etaxonomy.taxeditor.store.StoreUtil;
import eu.etaxonomy.taxeditor.store.internal.TaxeditorStorePlugin;
import eu.etaxonomy.taxeditor.view.AbstractCdmDataViewer;
import eu.etaxonomy.taxeditor.view.detail.DetailsViewPart;
.getActivePage()
.showView(id, null, IWorkbenchPage.VIEW_VISIBLE);
} catch (PartInitException e) {
- error(AbstractUtility.class, "Could not open view: " + id, e);
- throw new RuntimeException(e);
+ errorDialog("Error opening view", AbstractUtility.class, "Could not open view: " + id, e);
+ return null;
}
}
Display.getDefault().asyncExec(new Runnable() {
public void run() {
- MessageDialog.openError(getShell(), title, message);
+ MessageDialog.openError(getShell(), title, message + getCauseRecursively(t));
Class<? extends Object> clazz = source != null ? source
.getClass() : this.getClass();
error(clazz, message, t);
}
+
+ private String getCauseRecursively(Throwable t) {
+ if(t == null){
+ return null;
+ }
+
+ if(t.getCause() != null){
+ return getCauseRecursively(t.getCause());
+ }else{
+ return String.format("\n\nException: %s\nMessage: %s", t.getClass().getSimpleName(), t.getMessage());
+ }
+
+ }
});
}
public void run(IProgressMonitor monitor)
throws InvocationTargetException, InterruptedException {
monitor.beginTask(operation.getLabel(), 100);
- IStatus status;
+ IStatus status = Status.CANCEL_STATUS;
try {
operation.addContext(IOperationHistory.GLOBAL_UNDO_CONTEXT);
status = getOperationHistory().execute(operation, monitor,
uiInfoAdapter);
} catch (ExecutionException e) {
- throw new RuntimeException(e);
+ errorDialog("Error executing operation", getClass(), String.format("An error occured while executing %s.", operation.getLabel()), e);
+ } finally {
+ monitor.done();
}
- monitor.done();
+
String statusString = status.equals(Status.OK_STATUS) ? "completed"
: "cancelled";
setStatusLine(operation.getLabel() + " " + statusString + ".");
try {
runInUI(runnable, null);
- } catch (InvocationTargetException e) {
- throw new RuntimeException(e);
- } catch (InterruptedException e) {
- throw new RuntimeException(e);
+ } catch (Exception e) {
+ errorDialog("Error executing operation", AbstractUtility.class, "An error occured while executing " + operation.getLabel(), e);
}
// // Start the main progress monitor.