**********************************************************************/
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;
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
// ------------------------------------------------------------------------