]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.workbench/src/org/simantics/workbench/internal/SimanticsWorkbenchAdvisor.java
Simantics Console
[simantics/platform.git] / bundles / org.simantics.workbench / src / org / simantics / workbench / internal / SimanticsWorkbenchAdvisor.java
index cb1ee16d315c28d197016d491130a77d38c98e1c..f5bda18b0a137816c209b12972bfeb346605eb2e 100644 (file)
@@ -82,7 +82,9 @@ import org.eclipse.ui.internal.progress.ProgressMonitorJobsDialog;
 import org.eclipse.ui.keys.IBindingService;
 import org.eclipse.ui.progress.IProgressService;
 import org.eclipse.ui.statushandlers.AbstractStatusHandler;
 import org.eclipse.ui.keys.IBindingService;
 import org.eclipse.ui.progress.IProgressService;
 import org.eclipse.ui.statushandlers.AbstractStatusHandler;
+import org.eclipse.ui.statushandlers.StatusAdapter;
 import org.osgi.framework.Bundle;
 import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleContext;
 import org.osgi.framework.ServiceReference;
 import org.osgi.framework.Version;
 import org.simantics.CancelStartupException;
 import org.osgi.framework.ServiceReference;
 import org.osgi.framework.Version;
 import org.simantics.CancelStartupException;
@@ -92,6 +94,7 @@ import org.simantics.SimanticsPlatform;
 import org.simantics.SimanticsPlatform.OntologyRecoveryPolicy;
 import org.simantics.SimanticsPlatform.RecoveryPolicy;
 import org.simantics.TimingProgressMonitor;
 import org.simantics.SimanticsPlatform.OntologyRecoveryPolicy;
 import org.simantics.SimanticsPlatform.RecoveryPolicy;
 import org.simantics.TimingProgressMonitor;
+import org.simantics.UnhandledExceptionService;
 import org.simantics.application.arguments.IArguments;
 import org.simantics.application.arguments.SimanticsArguments;
 import org.simantics.db.common.Indexing;
 import org.simantics.application.arguments.IArguments;
 import org.simantics.application.arguments.SimanticsArguments;
 import org.simantics.db.common.Indexing;
@@ -102,6 +105,7 @@ import org.simantics.ui.SimanticsUI;
 import org.simantics.ui.jobs.SessionGarbageCollectorJob;
 import org.simantics.ui.workbench.PerspectiveBarsActivator;
 import org.simantics.ui.workbench.PerspectiveContextActivator;
 import org.simantics.ui.jobs.SessionGarbageCollectorJob;
 import org.simantics.ui.workbench.PerspectiveBarsActivator;
 import org.simantics.ui.workbench.PerspectiveContextActivator;
+import org.simantics.ui.workbench.WorkbenchShutdownService;
 import org.simantics.utils.logging.TimeLogger;
 import org.simantics.utils.ui.dialogs.ShowError;
 import org.simantics.utils.ui.dialogs.ShowMessage;
 import org.simantics.utils.logging.TimeLogger;
 import org.simantics.utils.ui.dialogs.ShowError;
 import org.simantics.utils.ui.dialogs.ShowMessage;
@@ -1133,17 +1137,17 @@ public class SimanticsWorkbenchAdvisor extends WorkbenchAdvisor {
      *         location is not being shown
      */
     public String getWorkspaceLocation() {
      *         location is not being shown
      */
     public String getWorkspaceLocation() {
-               // read command line, which has priority
-               IEclipseContext context = getWorkbenchConfigurer().getWorkbench().getService(IEclipseContext.class);
-               String location = context != null ? (String) context.get(E4Workbench.FORCED_SHOW_LOCATION) : null;
-               if (location != null) {
-                       return location;
-               }
-               // read the preference
-               if (IDEWorkbenchPlugin.getDefault().getPreferenceStore().getBoolean(IDEInternalPreferences.SHOW_LOCATION)) {
-                       return Platform.getLocation().toOSString();
-               }
-               return null;
+        // read command line, which has priority
+        IEclipseContext context = getWorkbenchConfigurer().getWorkbench().getService(IEclipseContext.class);
+        String location = context != null ? (String) context.get(E4Workbench.FORCED_SHOW_LOCATION) : null;
+        if (location != null) {
+            return location;
+        }
+        // read the preference
+        if (IDEWorkbenchPlugin.getDefault().getPreferenceStore().getBoolean(IDEInternalPreferences.SHOW_LOCATION)) {
+            return Platform.getLocation().toOSString();
+        }
+        return null;
     }
 
     /**
     }
 
     /**
@@ -1175,13 +1179,30 @@ public class SimanticsWorkbenchAdvisor extends WorkbenchAdvisor {
      *
      * @see org.eclipse.ui.application.WorkbenchAdvisor#getWorkbenchErrorHandler()
      */
      *
      * @see org.eclipse.ui.application.WorkbenchAdvisor#getWorkbenchErrorHandler()
      */
+
+    private AbstractStatusHandler workbenchErrorHandler = new AbstractStatusHandler() {
+
+        @Override
+        public void handle(StatusAdapter statusAdapter, int style) {
+            if (ideWorkbenchErrorHandler == null) {
+                ideWorkbenchErrorHandler = new IDEWorkbenchErrorHandler(
+                        getWorkbenchConfigurer());
+            }
+            ideWorkbenchErrorHandler.handle(statusAdapter, style);
+
+            BundleContext context = Activator.getDefault().getBundle().getBundleContext();
+            ServiceReference<?> ref = context.getServiceReference(UnhandledExceptionService.class.getName());
+            UnhandledExceptionService unhandled = (UnhandledExceptionService)context.getService(ref);
+            Throwable t = statusAdapter.getStatus().getException();
+            if(t != null)
+                unhandled.handle(t);
+
+        }
+    };
+
     @Override
     public AbstractStatusHandler getWorkbenchErrorHandler() {
     @Override
     public AbstractStatusHandler getWorkbenchErrorHandler() {
-        if (ideWorkbenchErrorHandler == null) {
-            ideWorkbenchErrorHandler = new IDEWorkbenchErrorHandler(
-                    getWorkbenchConfigurer());
-        }
-        return ideWorkbenchErrorHandler;
+        return workbenchErrorHandler;
     }
 
     /* (non-Javadoc)
     }
 
     /* (non-Javadoc)