tmf: Move plugins to the Trace Compass namespace
[deliverable/tracecompass.git] / org.eclipse.linuxtools.tracing.rcp.ui / src / org / eclipse / linuxtools / internal / tracing / rcp / ui / ApplicationWorkbenchAdvisor.java
index 3f2617470f71dbd0bdf237cf6608e6f32d0072fa..5673f8c1023d58d6ae8c04205a9e587fc4953679 100644 (file)
  **********************************************************************/
 package org.eclipse.linuxtools.internal.tracing.rcp.ui;
 
+import java.lang.reflect.InvocationTargetException;
 import java.net.URL;
 
 import org.eclipse.core.resources.IWorkspace;
 import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
 import org.eclipse.core.runtime.FileLocator;
 import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.MultiStatus;
 import org.eclipse.core.runtime.Path;
 import org.eclipse.core.runtime.Platform;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.jface.dialogs.ErrorDialog;
+import org.eclipse.jface.dialogs.ProgressMonitorDialog;
+import org.eclipse.jface.operation.IRunnableWithProgress;
 import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.linuxtools.internal.tracing.rcp.ui.messages.Messages;
 import org.eclipse.ui.application.IWorkbenchConfigurer;
 import org.eclipse.ui.application.IWorkbenchWindowConfigurer;
 import org.eclipse.ui.application.WorkbenchAdvisor;
@@ -42,8 +52,7 @@ public class ApplicationWorkbenchAdvisor extends WorkbenchAdvisor {
     // Constants
     // ------------------------------------------------------------------------
     // The default perspective
-    private static final String PERSPECTIVE_ID = "org.eclipse.linuxtools.lttng2.kernel.ui.perspective"; //$NON-NLS-1$
-
+    private static final String PERSPECTIVE_ID = "org.eclipse.linuxtools.tmf.ui.perspective"; //$NON-NLS-1$
 
     private final static String ICONS_PATH = "$nl$/icons/full/"; //$NON-NLS-1$
     private final static String PATH_ELOCALTOOL = ICONS_PATH + "elcl16/"; //$NON-NLS-1$
@@ -83,6 +92,34 @@ public class ApplicationWorkbenchAdvisor extends WorkbenchAdvisor {
         IDE.registerAdapters();
     }
 
+    @Override
+    public void postShutdown() {
+        // Save workspace
+        final MultiStatus status = new MultiStatus(TracingRcpPlugin.PLUGIN_ID, 1, Messages.Application_WorkspaceSavingError, null);
+        try {
+            IRunnableWithProgress runnable = new IRunnableWithProgress() {
+                @Override
+                public void run(IProgressMonitor monitor) {
+                    try {
+                        IWorkspace ws = ResourcesPlugin.getWorkspace();
+                        status.merge(ws.save(true, monitor));
+                    } catch (CoreException e) {
+                        status.merge(e.getStatus());
+                    }
+                }
+            };
+            new ProgressMonitorDialog(null).run(true, true, runnable);
+        } catch (InvocationTargetException e) {
+            status.merge(new Status(IStatus.ERROR, TracingRcpPlugin.PLUGIN_ID, Messages.Application_InternalError, e.getTargetException()));
+        } catch (InterruptedException e) {
+            status.merge(Status.CANCEL_STATUS);
+        }
+        if (!status.isOK()) {
+            ErrorDialog.openError(null, Messages.Application_WorkspaceSavingError, null, status, IStatus.ERROR | IStatus.WARNING);
+            TracingRcpPlugin.getDefault().getLog().log(status);
+        }
+    }
+
     // ------------------------------------------------------------------------
     // Helper methods
     // ------------------------------------------------------------------------
This page took 0.026075 seconds and 5 git commands to generate.