Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrew M Finkbeiner2013-01-24 18:16:41 -0500
committerAndrew M Finkbeiner2013-01-24 18:16:41 -0500
commit2c91a6ad9567b5cd56747c58216ba2d388e546b5 (patch)
tree5e8dcfb7755d239cb0c2437d43c724995678f003 /plugins/org.eclipse.osee.framework.ui.workspacebundleloader
parent2959ff7742569d3db74a0283a047207c0abf58e4 (diff)
downloadorg.eclipse.osee-2c91a6ad9567b5cd56747c58216ba2d388e546b5.tar.gz
org.eclipse.osee-2c91a6ad9567b5cd56747c58216ba2d388e546b5.tar.xz
org.eclipse.osee-2c91a6ad9567b5cd56747c58216ba2d388e546b5.zip
bug[ats_WM6V1]: Clean up ws bundle shutdown
Diffstat (limited to 'plugins/org.eclipse.osee.framework.ui.workspacebundleloader')
-rw-r--r--plugins/org.eclipse.osee.framework.ui.workspacebundleloader/src/org/eclipse/osee/framework/ui/workspacebundleloader/SafeWorkspaceTracker.java59
-rw-r--r--plugins/org.eclipse.osee.framework.ui.workspacebundleloader/src/org/eclipse/osee/framework/ui/workspacebundleloader/WorkspaceBundleLoadCoordinator.java42
2 files changed, 88 insertions, 13 deletions
diff --git a/plugins/org.eclipse.osee.framework.ui.workspacebundleloader/src/org/eclipse/osee/framework/ui/workspacebundleloader/SafeWorkspaceTracker.java b/plugins/org.eclipse.osee.framework.ui.workspacebundleloader/src/org/eclipse/osee/framework/ui/workspacebundleloader/SafeWorkspaceTracker.java
index a2d14e26d36..e007ce3f300 100644
--- a/plugins/org.eclipse.osee.framework.ui.workspacebundleloader/src/org/eclipse/osee/framework/ui/workspacebundleloader/SafeWorkspaceTracker.java
+++ b/plugins/org.eclipse.osee.framework.ui.workspacebundleloader/src/org/eclipse/osee/framework/ui/workspacebundleloader/SafeWorkspaceTracker.java
@@ -18,12 +18,17 @@ import org.eclipse.core.resources.IWorkspace;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.SubMonitor;
+import org.eclipse.core.runtime.jobs.IJobChangeEvent;
+import org.eclipse.core.runtime.jobs.Job;
+import org.eclipse.core.runtime.jobs.JobChangeAdapter;
import org.eclipse.osee.framework.core.operation.AbstractOperation;
+import org.eclipse.osee.framework.core.operation.OperationJob;
import org.eclipse.osee.framework.logging.OseeLog;
import org.eclipse.osee.framework.plugin.core.util.Jobs;
import org.eclipse.osee.framework.plugin.core.util.OseeData;
import org.eclipse.osee.framework.ui.plugin.workspace.SafeWorkspaceAccess;
import org.eclipse.osee.framework.ui.workspacebundleloader.internal.Activator;
+import org.eclipse.swt.widgets.Display;
import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.IWorkbenchListener;
import org.eclipse.ui.PlatformUI;
@@ -137,11 +142,63 @@ public class SafeWorkspaceTracker extends ServiceTracker implements IJarChangeLi
@Override
public boolean preShutdown(IWorkbench workbench, boolean forced) {
- unloadBundles();
+ JobComplete jobComplete = new JobComplete();
+ Job job = new OperationJob(new PrecompileShutdown("Closing Precompiled Libraries", Activator.BUNDLE_ID));
+ job.setPriority(Job.INTERACTIVE);
+ Jobs.startJob(job, false, jobComplete);
+ for(int i = 0; i < 100 && !jobComplete.isDone(); i++){//wait up to 10 seconds or until job completion
+ yieldDisplay100ms();
+ }
return true;
}
+ private static class JobComplete extends JobChangeAdapter {
+ private volatile boolean done = false;
+
+ public boolean isDone() {
+ return done;
+ }
+
+ @Override
+ public void done(IJobChangeEvent event) {
+ done = true;
+ }
+ }
+
+ private class PrecompileShutdown extends AbstractOperation {
+ public PrecompileShutdown(String operationName, String pluginId) {
+ super(operationName, pluginId);
+ }
+
+ @Override
+ protected void doWork(IProgressMonitor monitor) throws Exception {
+ bundleCoordinator.uninstallBundles();
+ }
+ }
+
@Override
public void postShutdown(IWorkbench workbench) {
}
+
+
+ /**
+ * This method gives UI updates that happen from bundle unloading to happen before the workbench shuts down, view shutdown
+ * and extension point registry based UI updates. If we don't do this we get unexpected errors in logView and other places.
+ */
+ private void yieldDisplay100ms(){
+ while(Display.getCurrent().readAndDispatch()){
+ }
+ try {
+ Thread.sleep(50);
+ } catch (InterruptedException e) {
+ }
+ while(Display.getCurrent().readAndDispatch()){
+ }
+ try {
+ Thread.sleep(50);
+ } catch (InterruptedException e) {
+ }
+ while(Display.getCurrent().readAndDispatch()){
+ }
+ }
}
diff --git a/plugins/org.eclipse.osee.framework.ui.workspacebundleloader/src/org/eclipse/osee/framework/ui/workspacebundleloader/WorkspaceBundleLoadCoordinator.java b/plugins/org.eclipse.osee.framework.ui.workspacebundleloader/src/org/eclipse/osee/framework/ui/workspacebundleloader/WorkspaceBundleLoadCoordinator.java
index 53a8d29d5dc..5dd53e35f23 100644
--- a/plugins/org.eclipse.osee.framework.ui.workspacebundleloader/src/org/eclipse/osee/framework/ui/workspacebundleloader/WorkspaceBundleLoadCoordinator.java
+++ b/plugins/org.eclipse.osee.framework.ui.workspacebundleloader/src/org/eclipse/osee/framework/ui/workspacebundleloader/WorkspaceBundleLoadCoordinator.java
@@ -36,6 +36,7 @@ import org.eclipse.ui.IViewReference;
import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.IWorkbenchPage;
import org.eclipse.ui.IWorkbenchPart;
+import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.PartInitException;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.WorkbenchException;
@@ -112,22 +113,24 @@ public class WorkspaceBundleLoadCoordinator {
}
-
- public synchronized void uninstallBundles(){
+ private void saveAndCloseViews(){
PlatformUI.getWorkbench().getDisplay().syncExec(new Runnable(){
@Override
public void run() {
saveAndCloseManagedViews();
- for(BundleInfoLite info:managedArea.getInstalledBundles()){
- try {
- info.uninstall();
- } catch (BundleException e) {
- OseeLog.log(WorkspaceBundleLoadCoordinator.class, Level.WARNING, e);
- }
- }
}
});
-
+ }
+
+ public synchronized void uninstallBundles(){
+ saveAndCloseViews();
+ for(BundleInfoLite info:managedArea.getInstalledBundles()){
+ try {
+ info.uninstall();
+ } catch (BundleException e) {
+ OseeLog.log(WorkspaceBundleLoadCoordinator.class, Level.WARNING, e);
+ }
+ }
if(wiring != null){
wiring.refreshBundles(null);
}
@@ -137,8 +140,22 @@ public class WorkspaceBundleLoadCoordinator {
Set<String> managedViewIds = determineManagedViews();
IWorkbench workbench = PlatformUI.getWorkbench();
- if (managedArea.getInstalledBundles().size() > 0 && workbench != null && workbench.getActiveWorkbenchWindow() != null){
- IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
+ if (managedArea.getInstalledBundles().size() > 0 && workbench != null){
+ IWorkbenchPage page = null;
+ if(PlatformUI.getWorkbench().getActiveWorkbenchWindow() == null){
+ IWorkbenchWindow[] windows = workbench.getWorkbenchWindows();
+ for(IWorkbenchWindow win :windows){
+ page = win.getActivePage();
+ if(page != null){
+ break;
+ }
+ }
+ } else {
+ page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
+ }
+ if(page == null){
+ return;
+ }
IPerspectiveDescriptor originalPerspective = page.getPerspective();
XMLMemento memento = XMLMemento.createWriteRoot(TAG_OTE_PRECOMPILED);
//find the view in other perspectives
@@ -564,4 +581,5 @@ public class WorkspaceBundleLoadCoordinator {
}
}
}
+
}

Back to the top