From 4843994cc1d99c2b51b4c6394299730d6c66e29f Mon Sep 17 00:00:00 2001 From: lempinen Date: Fri, 29 Apr 2011 06:37:12 +0000 Subject: [PATCH] Add dispose listener to make sure name listening receives the correct isDisposed -value git-svn-id: https://www.simantics.org/svn/simantics/sysdyn/trunk@20670 ac1ea38d-2e2b-0410-8846-a27921b304fc --- .../LabelPropertyTabContributor.java | 29 ++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/LabelPropertyTabContributor.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/LabelPropertyTabContributor.java index 2d9d76c6..36d6bd7a 100644 --- a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/LabelPropertyTabContributor.java +++ b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/LabelPropertyTabContributor.java @@ -1,11 +1,17 @@ package org.simantics.sysdyn.ui.properties; import org.eclipse.jface.viewers.ISelection; +import org.eclipse.swt.events.DisposeEvent; +import org.eclipse.swt.events.DisposeListener; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.ui.IWorkbenchSite; import org.simantics.browsing.ui.swt.PropertyTabContributorImpl; +import org.simantics.browsing.ui.swt.widgets.impl.WidgetSupportImpl; import org.simantics.db.AsyncReadGraph; import org.simantics.db.ReadGraph; import org.simantics.db.Resource; import org.simantics.db.exception.DatabaseException; +import org.simantics.db.management.ISessionContext; import org.simantics.db.procedure.AsyncListener; import org.simantics.db.request.Read; import org.simantics.layer0.Layer0; @@ -15,7 +21,23 @@ import org.simantics.utils.datastructures.Callback; public abstract class LabelPropertyTabContributor extends PropertyTabContributorImpl { + private boolean isDisposed = false; + + public void createControl(Composite parent, final IWorkbenchSite site, final ISessionContext context, final WidgetSupportImpl support) { + super.createControl(parent, site, context, support); + + // Add dispose listener to make sure name listening receives the correct isDisposed -value + parent.addDisposeListener(new DisposeListener() { + + @Override + public void widgetDisposed(DisposeEvent e) { + LabelPropertyTabContributor.this.dispose(); + } + }); + } + + @Override public void updatePartName(ISelection forSelection, final Callback updateCallback) { final Resource r = AdaptionUtils.adaptToSingle(forSelection, Resource.class); if(r == null) { @@ -51,7 +73,7 @@ public abstract class LabelPropertyTabContributor extends PropertyTabContributor @Override public boolean isDisposed() { - return false; + return isDisposed; } }); } catch (DatabaseException e) { @@ -60,4 +82,9 @@ public abstract class LabelPropertyTabContributor extends PropertyTabContributor } } + + @Override + protected void dispose() { + this.isDisposed = true; + } } -- 2.47.1