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
\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
\r
@Override\r
public boolean isDisposed() {\r
- return false;\r
+ return isDisposed;\r
}\r
});\r
} catch (DatabaseException e) {\r
}\r
\r
}\r
+ \r
+ @Override\r
+ protected void dispose() {\r
+ this.isDisposed = true;\r
+ }\r
}\r