Author: adietish
Date: 2010-11-05 13:11:37 -0400 (Fri, 05 Nov 2010)
New Revision: 26308
Modified:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/ChangeLog
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/CVInstancesCategoryElement.java
Log:
[JBIDE-7506] remove cloud instance listener if viewer is disposed
Modified: trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/ChangeLog
===================================================================
--- trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/ChangeLog 2010-11-05 17:04:59
UTC (rev 26307)
+++ trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/ChangeLog 2010-11-05 17:11:37
UTC (rev 26308)
@@ -5,6 +5,8 @@
[JBIDE-7507] returns now icons to represent states (instead of texts)
* src/org/jboss/tools/deltacloud/ui/views/CVInstancesCategoryElement.java (.run):
[JBIDE-7503] added restore selection after refresh (viewer lost the selection before
this change)
+ (onDispose):
+ [JBIDE-7506] remove cloud instance listener if viewer is disposed
2010-11-04 André Dietisheim <adietish(a)redhat.com>
Modified:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/CVInstancesCategoryElement.java
===================================================================
---
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/CVInstancesCategoryElement.java 2010-11-05
17:04:59 UTC (rev 26307)
+++
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/CVInstancesCategoryElement.java 2010-11-05
17:11:37 UTC (rev 26308)
@@ -18,6 +18,8 @@
import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.jface.viewers.TreeViewer;
import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.swt.events.DisposeEvent;
+import org.eclipse.swt.events.DisposeListener;
import org.eclipse.swt.widgets.Display;
import org.jboss.tools.deltacloud.core.DeltaCloud;
import org.jboss.tools.deltacloud.core.DeltaCloudInstance;
@@ -34,9 +36,23 @@
this.viewer = viewer;
DeltaCloud cloud = (DeltaCloud) getElement();
cloud.addInstanceListListener(this);
+ viewer.getControl().addDisposeListener(onDispose());
this.category = this;
}
+ private DisposeListener onDispose() {
+ return new DisposeListener() {
+
+ @Override
+ public void widgetDisposed(DisposeEvent e) {
+ DeltaCloud cloud = (DeltaCloud) getElement();
+ if (cloud != null) {
+ cloud.removeInstanceListListener(CVInstancesCategoryElement.this);
+ }
+ }
+ };
+ }
+
protected void finalize() throws Throwable {
DeltaCloud cloud = (DeltaCloud) getElement();
cloud.removeInstanceListListener(this);
Show replies by date