]> gerrit.simantics Code Review - simantics/sysdyn.git/commitdiff
Add dispose listener to make sure name listening receives the correct isDisposed...
authorlempinen <lempinen@ac1ea38d-2e2b-0410-8846-a27921b304fc>
Fri, 29 Apr 2011 06:37:12 +0000 (06:37 +0000)
committerlempinen <lempinen@ac1ea38d-2e2b-0410-8846-a27921b304fc>
Fri, 29 Apr 2011 06:37:12 +0000 (06:37 +0000)
git-svn-id: https://www.simantics.org/svn/simantics/sysdyn/trunk@20670 ac1ea38d-2e2b-0410-8846-a27921b304fc

org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/LabelPropertyTabContributor.java

index 2d9d76c65b06caa6632b95bd282ceef8f2d02c9e..36d6bd7a2af10a3cbad6e37b620d0dae60bc0c54 100644 (file)
@@ -1,11 +1,17 @@
 package org.simantics.sysdyn.ui.properties;\r
 \r
 import org.eclipse.jface.viewers.ISelection;\r
+import org.eclipse.swt.events.DisposeEvent;\r
+import org.eclipse.swt.events.DisposeListener;\r
+import org.eclipse.swt.widgets.Composite;\r
+import org.eclipse.ui.IWorkbenchSite;\r
 import org.simantics.browsing.ui.swt.PropertyTabContributorImpl;\r
+import org.simantics.browsing.ui.swt.widgets.impl.WidgetSupportImpl;\r
 import org.simantics.db.AsyncReadGraph;\r
 import org.simantics.db.ReadGraph;\r
 import org.simantics.db.Resource;\r
 import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.db.management.ISessionContext;\r
 import org.simantics.db.procedure.AsyncListener;\r
 import org.simantics.db.request.Read;\r
 import org.simantics.layer0.Layer0;\r
@@ -15,7 +21,23 @@ import org.simantics.utils.datastructures.Callback;
 \r
 public abstract class LabelPropertyTabContributor extends PropertyTabContributorImpl {\r
 \r
+       private boolean isDisposed = false;\r
        \r
+       \r
+       public void createControl(Composite parent, final IWorkbenchSite site, final ISessionContext context, final WidgetSupportImpl support) {\r
+               super.createControl(parent, site, context, support);\r
+               \r
+               // Add dispose listener to make sure name listening receives the correct isDisposed -value\r
+               parent.addDisposeListener(new DisposeListener() {\r
+                       \r
+                       @Override\r
+                       public void widgetDisposed(DisposeEvent e) {\r
+                               LabelPropertyTabContributor.this.dispose();\r
+                       }\r
+               });\r
+       }\r
+       \r
+       @Override\r
     public void updatePartName(ISelection forSelection, final Callback<String> updateCallback) {\r
        final Resource r = AdaptionUtils.adaptToSingle(forSelection, Resource.class);\r
        if(r == null) {\r
@@ -51,7 +73,7 @@ public abstract class LabelPropertyTabContributor extends PropertyTabContributor
 \r
                                @Override\r
                                public boolean isDisposed() {\r
-                                       return false;\r
+                                       return isDisposed;\r
                                }\r
                        });\r
                } catch (DatabaseException e) {\r
@@ -60,4 +82,9 @@ public abstract class LabelPropertyTabContributor extends PropertyTabContributor
                }\r
                \r
     }\r
+    \r
+    @Override\r
+    protected void dispose() {\r
+       this.isDisposed = true;\r
+    }\r
 }\r