package org.simantics.jfreechart.chart.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.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.layer0.variable.Variable;\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
import org.simantics.modeling.ModelingResources;\r
import org.simantics.selectionview.PropertyTabContributorImpl;\r
-import org.simantics.ui.SimanticsUI;\r
-import org.simantics.utils.datastructures.Callback;\r
import org.simantics.utils.ui.AdaptionUtils;\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 Variable variable = AdaptionUtils.adaptToSingle(forSelection, Variable.class);\r
- final Resource resource = AdaptionUtils.adaptToSingle(forSelection, Resource.class);\r
- if(resource == null && variable == null) {\r
- updateCallback.run("Selection properties");\r
- return;\r
- }\r
+ public Read<String> getPartNameReadRequest(final ISelection forSelection) {\r
\r
- SimanticsUI.getSession().asyncRequest(new Read<String>() {\r
+ return new Read<String>() {\r
\r
@Override\r
public String perform(ReadGraph graph) throws DatabaseException {\r
Layer0 l0 = Layer0.getInstance(graph);\r
ModelingResources mr = ModelingResources.getInstance(graph);\r
+\r
+ final Variable variable = AdaptionUtils.adaptToSingle(forSelection, Variable.class);\r
+ final Resource resource = AdaptionUtils.adaptToSingle(forSelection, Resource.class);\r
+ if(resource == null && variable == null) {\r
+ return "Selection";\r
+ }\r
\r
Resource r;\r
if(variable != null) {\r
return label;\r
return "No name for selection";\r
}\r
- }, new AsyncListener<String>() {\r
-\r
- @Override\r
- public void execute(AsyncReadGraph graph, String result) {\r
- updateCallback.run(result);\r
- }\r
-\r
- @Override\r
- public void exception(AsyncReadGraph graph, Throwable throwable) {\r
-\r
- }\r
-\r
- @Override\r
- public boolean isDisposed() {\r
- return isDisposed;\r
- }\r
- });\r
+ \r
+ };\r
+ \r
}\r
\r
- @Override\r
- protected void dispose() {\r
- this.isDisposed = true;\r
- }\r
}\r
import org.simantics.db.management.ISessionContext;\r
import org.simantics.diagram.stubs.DiagramResource;\r
import org.simantics.jfreechart.chart.properties.LabelPropertyTabContributor;\r
-import org.simantics.utils.datastructures.Callback;\r
\r
/**\r
* Tab for editing diagram comments\r
*/\r
public class CommentTab extends LabelPropertyTabContributor {\r
\r
- @Override\r
- public void updatePartName(ISelection forSelection, final Callback<String> updateCallback) {\r
- updateCallback.run("Comment");\r
- }\r
+ @Override\r
+ public String getPartName(ISelection forSelection) {\r
+ return "Comment";\r
+ }\r
\r
@Override\r
public void createControls(Composite body, IWorkbenchSite site, ISessionContext context, WidgetSupport support) {\r