Author: snjeza
Date: 2011-12-29 17:55:23 -0500 (Thu, 29 Dec 2011)
New Revision: 37580
Modified:
trunk/central/plugins/org.jboss.tools.central/src/org/jboss/tools/central/JBossCentralActivator.java
trunk/central/plugins/org.jboss.tools.central/src/org/jboss/tools/central/editors/JBossCentralEditor.java
trunk/central/plugins/org.jboss.tools.central/src/org/jboss/tools/central/editors/xpl/DiscoveryViewer.java
trunk/central/plugins/org.jboss.tools.central/src/org/jboss/tools/central/jobs/AbstractRefreshJob.java
trunk/central/plugins/org.jboss.tools.central/src/org/jboss/tools/central/jobs/RefreshDiscoveryJob.java
trunk/central/plugins/org.jboss.tools.central/src/org/jboss/tools/central/jobs/RefreshTutorialsJob.java
Log:
JBIDE-10332 central refresh job still running after shutdown started
Modified:
trunk/central/plugins/org.jboss.tools.central/src/org/jboss/tools/central/JBossCentralActivator.java
===================================================================
---
trunk/central/plugins/org.jboss.tools.central/src/org/jboss/tools/central/JBossCentralActivator.java 2011-12-29
22:37:16 UTC (rev 37579)
+++
trunk/central/plugins/org.jboss.tools.central/src/org/jboss/tools/central/JBossCentralActivator.java 2011-12-29
22:55:23 UTC (rev 37580)
@@ -25,8 +25,10 @@
import org.eclipse.core.runtime.IExtensionPoint;
import org.eclipse.core.runtime.IExtensionRegistry;
import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.Status;
+import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.core.runtime.preferences.IEclipsePreferences;
import org.eclipse.core.runtime.preferences.InstanceScope;
import org.eclipse.jface.dialogs.MessageDialog;
@@ -71,6 +73,8 @@
*/
public class JBossCentralActivator extends AbstractUIPlugin {
+ public static final Object JBOSS_CENTRAL_FAMILY = new Object();
+
public static final String JBOSS_DISCOVERY_DIRECTORY =
"jboss.discovery.directory.url";
public static final String ICON = "icon";
@@ -171,6 +175,9 @@
* )
*/
public void stop(BundleContext context) throws Exception {
+ Job.getJobManager().cancel(JBOSS_CENTRAL_FAMILY);
+ Job.getJobManager().join(JBOSS_CENTRAL_FAMILY, new NullProgressMonitor());
+
plugin = null;
bundleContext = null;
tutorialCategories = null;
Modified:
trunk/central/plugins/org.jboss.tools.central/src/org/jboss/tools/central/editors/JBossCentralEditor.java
===================================================================
---
trunk/central/plugins/org.jboss.tools.central/src/org/jboss/tools/central/editors/JBossCentralEditor.java 2011-12-29
22:37:16 UTC (rev 37579)
+++
trunk/central/plugins/org.jboss.tools.central/src/org/jboss/tools/central/editors/JBossCentralEditor.java 2011-12-29
22:55:23 UTC (rev 37580)
@@ -17,6 +17,9 @@
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.core.runtime.OperationCanceledException;
+import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.jface.action.ControlContribution;
import org.eclipse.jface.action.GroupMarker;
import org.eclipse.jface.action.IToolBarManager;
@@ -45,6 +48,9 @@
import org.jboss.tools.central.actions.OpenJBossBlogsHandler;
import org.jboss.tools.central.editors.xpl.TextSearchControl;
import org.jboss.tools.central.jobs.RefreshBlogsJob;
+import org.jboss.tools.central.jobs.RefreshDiscoveryJob;
+import org.jboss.tools.central.jobs.RefreshNewsJob;
+import org.jboss.tools.central.jobs.RefreshTutorialsJob;
/**
*
@@ -86,7 +92,14 @@
softwareImage.dispose();
softwareImage = null;
}
- RefreshBlogsJob.INSTANCE.cancel();
+ Job.getJobManager().cancel(JBossCentralActivator.JBOSS_CENTRAL_FAMILY);
+ try {
+ Job.getJobManager().join(JBossCentralActivator.JBOSS_CENTRAL_FAMILY, new
NullProgressMonitor());
+ } catch (OperationCanceledException e) {
+ // ignore
+ } catch (InterruptedException e) {
+ // ignore
+ }
super.dispose();
}
Modified:
trunk/central/plugins/org.jboss.tools.central/src/org/jboss/tools/central/editors/xpl/DiscoveryViewer.java
===================================================================
---
trunk/central/plugins/org.jboss.tools.central/src/org/jboss/tools/central/editors/xpl/DiscoveryViewer.java 2011-12-29
22:37:16 UTC (rev 37579)
+++
trunk/central/plugins/org.jboss.tools.central/src/org/jboss/tools/central/editors/xpl/DiscoveryViewer.java 2011-12-29
22:55:23 UTC (rev 37580)
@@ -583,6 +583,9 @@
public void createBodyContents() {
// remove any existing contents
+ if (body == null || body.isDisposed()) {
+ return;
+ }
for (Control child : body.getChildren()) {
child.dispose();
}
@@ -1050,11 +1053,17 @@
}
private void discoveryUpdated(final boolean wasCancelled) {
+ if (body == null || body.isDisposed()) {
+ return;
+ }
Display.getDefault().syncExec(new Runnable() {
@Override
public void run() {
createBodyContents();
+ if (body == null || body.isDisposed()) {
+ return;
+ }
if (discovery != null && !wasCancelled) {
int categoryWithConnectorCount = 0;
for (DiscoveryCategory category : discovery.getCategories()) {
@@ -1499,6 +1508,9 @@
try {
result[0] = connectorDiscovery.performDiscovery(monitor);
} finally {
+ if (monitor.isCanceled()) {
+ return;
+ }
DiscoveryViewer.this.discovery = connectorDiscovery;
postDiscovery(connectorDiscovery);
@@ -1516,9 +1528,11 @@
} catch (InvocationTargetException e) {
IStatus status = computeStatus(e,
Messages.ConnectorDiscoveryWizardMainPage_unexpectedException);
StatusManager.getManager().handle(status, StatusManager.SHOW | StatusManager.BLOCK |
StatusManager.LOG);
+ return;
} catch (InterruptedException e) {
// cancelled by user so nothing to do here.
wasCancelled = true;
+ return;
}
if (discovery != null) {
discoveryUpdated(wasCancelled);
@@ -1537,6 +1551,7 @@
} catch (InterruptedException e) {
// cancelled by user so nothing to do here.
wasCancelled = true;
+ return;
}
}
// createBodyContents() shouldn't be necessary but for some
@@ -1555,6 +1570,9 @@
Display.getDefault().syncExec(new Runnable() {
@Override
public void run() {
+ if (body == null || body.isDisposed()) {
+ return;
+ }
body.setData("discoveryComplete", "true"); //$NON-NLS-1$
//$NON-NLS-2$
}
});
Modified:
trunk/central/plugins/org.jboss.tools.central/src/org/jboss/tools/central/jobs/AbstractRefreshJob.java
===================================================================
---
trunk/central/plugins/org.jboss.tools.central/src/org/jboss/tools/central/jobs/AbstractRefreshJob.java 2011-12-29
22:37:16 UTC (rev 37579)
+++
trunk/central/plugins/org.jboss.tools.central/src/org/jboss/tools/central/jobs/AbstractRefreshJob.java 2011-12-29
22:55:23 UTC (rev 37580)
@@ -271,5 +271,10 @@
public void setNeedsRefresh(boolean needRefresh) {
this.needsRefresh = needRefresh;
}
+
+ @Override
+ public boolean belongsTo(Object family) {
+ return family == JBossCentralActivator.JBOSS_CENTRAL_FAMILY;
+ }
}
Modified:
trunk/central/plugins/org.jboss.tools.central/src/org/jboss/tools/central/jobs/RefreshDiscoveryJob.java
===================================================================
---
trunk/central/plugins/org.jboss.tools.central/src/org/jboss/tools/central/jobs/RefreshDiscoveryJob.java 2011-12-29
22:37:16 UTC (rev 37579)
+++
trunk/central/plugins/org.jboss.tools.central/src/org/jboss/tools/central/jobs/RefreshDiscoveryJob.java 2011-12-29
22:55:23 UTC (rev 37580)
@@ -50,5 +50,10 @@
}
return Status.OK_STATUS;
}
+
+ @Override
+ public boolean belongsTo(Object family) {
+ return family == JBossCentralActivator.JBOSS_CENTRAL_FAMILY;
+ }
}
Modified:
trunk/central/plugins/org.jboss.tools.central/src/org/jboss/tools/central/jobs/RefreshTutorialsJob.java
===================================================================
---
trunk/central/plugins/org.jboss.tools.central/src/org/jboss/tools/central/jobs/RefreshTutorialsJob.java 2011-12-29
22:37:16 UTC (rev 37579)
+++
trunk/central/plugins/org.jboss.tools.central/src/org/jboss/tools/central/jobs/RefreshTutorialsJob.java 2011-12-29
22:55:23 UTC (rev 37580)
@@ -119,4 +119,8 @@
return tutorialCategories;
}
+ @Override
+ public boolean belongsTo(Object family) {
+ return family == JBossCentralActivator.JBOSS_CENTRAL_FAMILY;
+ }
}
Show replies by date