From e0a8e49931463fc45b78626c282f9c9af83d5b0b Mon Sep 17 00:00:00 2001 From: villberg Date: Thu, 10 Apr 2014 08:48:20 +0000 Subject: [PATCH] Fixes after changes refs #4810 git-svn-id: https://www.simantics.org/svn/simantics/sysdyn/trunk@29274 ac1ea38d-2e2b-0410-8846-a27921b304fc --- .../chart/properties/AdjustableTab.java | 10 +-- .../LabelPropertyTabContributor.java | 66 ++++--------------- .../sysdyn/ui/properties/CommentTab.java | 9 ++- 3 files changed, 20 insertions(+), 65 deletions(-) diff --git a/org.simantics.jfreechart/src/org/simantics/jfreechart/chart/properties/AdjustableTab.java b/org.simantics.jfreechart/src/org/simantics/jfreechart/chart/properties/AdjustableTab.java index da4bae8c..f9c30701 100644 --- a/org.simantics.jfreechart/src/org/simantics/jfreechart/chart/properties/AdjustableTab.java +++ b/org.simantics.jfreechart/src/org/simantics/jfreechart/chart/properties/AdjustableTab.java @@ -98,10 +98,10 @@ public abstract class AdjustableTab extends LabelPropertyTabContributor { */ protected abstract void createControlLayoutHorizontal(boolean wideScreen); - @Override - public void dispose() { - if(controlListener != null && spp != null) - spp.removeControlListener(controlListener); - } +// @Override +// public void dispose() { +// if(controlListener != null && spp != null) +// spp.removeControlListener(controlListener); +// } } diff --git a/org.simantics.jfreechart/src/org/simantics/jfreechart/chart/properties/LabelPropertyTabContributor.java b/org.simantics.jfreechart/src/org/simantics/jfreechart/chart/properties/LabelPropertyTabContributor.java index 045b4d31..8c0441c4 100644 --- a/org.simantics.jfreechart/src/org/simantics/jfreechart/chart/properties/LabelPropertyTabContributor.java +++ b/org.simantics.jfreechart/src/org/simantics/jfreechart/chart/properties/LabelPropertyTabContributor.java @@ -12,59 +12,33 @@ package org.simantics.jfreechart.chart.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.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.layer0.variable.Variable; -import org.simantics.db.management.ISessionContext; -import org.simantics.db.procedure.AsyncListener; import org.simantics.db.request.Read; import org.simantics.layer0.Layer0; import org.simantics.modeling.ModelingResources; import org.simantics.selectionview.PropertyTabContributorImpl; -import org.simantics.ui.SimanticsUI; -import org.simantics.utils.datastructures.Callback; import org.simantics.utils.ui.AdaptionUtils; 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 Variable variable = AdaptionUtils.adaptToSingle(forSelection, Variable.class); - final Resource resource = AdaptionUtils.adaptToSingle(forSelection, Resource.class); - if(resource == null && variable == null) { - updateCallback.run("Selection properties"); - return; - } + public Read getPartNameReadRequest(final ISelection forSelection) { - SimanticsUI.getSession().asyncRequest(new Read() { + return new Read() { @Override public String perform(ReadGraph graph) throws DatabaseException { Layer0 l0 = Layer0.getInstance(graph); ModelingResources mr = ModelingResources.getInstance(graph); + + final Variable variable = AdaptionUtils.adaptToSingle(forSelection, Variable.class); + final Resource resource = AdaptionUtils.adaptToSingle(forSelection, Resource.class); + if(resource == null && variable == null) { + return "Selection"; + } Resource r; if(variable != null) { @@ -84,27 +58,9 @@ public abstract class LabelPropertyTabContributor extends PropertyTabContributor return label; return "No name for selection"; } - }, new AsyncListener() { - - @Override - public void execute(AsyncReadGraph graph, String result) { - updateCallback.run(result); - } - - @Override - public void exception(AsyncReadGraph graph, Throwable throwable) { - - } - - @Override - public boolean isDisposed() { - return isDisposed; - } - }); + + }; + } - @Override - protected void dispose() { - this.isDisposed = true; - } } diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/CommentTab.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/CommentTab.java index 3d7183e6..0b6c00c1 100644 --- a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/CommentTab.java +++ b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/CommentTab.java @@ -25,7 +25,6 @@ import org.simantics.browsing.ui.swt.widgets.impl.WidgetSupport; import org.simantics.db.management.ISessionContext; import org.simantics.diagram.stubs.DiagramResource; import org.simantics.jfreechart.chart.properties.LabelPropertyTabContributor; -import org.simantics.utils.datastructures.Callback; /** * Tab for editing diagram comments @@ -35,10 +34,10 @@ import org.simantics.utils.datastructures.Callback; */ public class CommentTab extends LabelPropertyTabContributor { - @Override - public void updatePartName(ISelection forSelection, final Callback updateCallback) { - updateCallback.run("Comment"); - } + @Override + public String getPartName(ISelection forSelection) { + return "Comment"; + } @Override public void createControls(Composite body, IWorkbenchSite site, ISessionContext context, WidgetSupport support) { -- 2.47.1