1 package org.simantics.sysdyn.ui.validation;
\r
3 import java.util.Collection;
\r
5 import org.simantics.browsing.ui.swt.widgets.TrackedText;
\r
6 import org.simantics.browsing.ui.swt.widgets.impl.WidgetSupport;
\r
7 import org.simantics.jfreechart.chart.properties.AllVariablesOfModel;
\r
8 import org.simantics.jfreechart.chart.properties.ChartVariable;
\r
9 import org.simantics.jfreechart.chart.properties.VariableExistsValidator;
\r
10 import org.simantics.db.Resource;
\r
11 import org.simantics.db.management.ISessionContext;
\r
12 import org.simantics.db.procedure.Listener;
\r
13 import org.simantics.ui.SimanticsUI;
\r
14 import org.simantics.utils.ui.AdaptionUtils;
\r
16 public class ParameterExistsValidator extends VariableExistsValidator {
\r
18 public ParameterExistsValidator(WidgetSupport support, TrackedText text) {
\r
19 super(support, text);
\r
23 public void setInput(ISessionContext context, Object input) {
\r
24 final Resource resource = AdaptionUtils.adaptToSingle(input, Resource.class);
\r
25 if(resource == null)
\r
28 SimanticsUI.getSession().asyncRequest(
\r
29 new AllVariablesOfModel(resource)
\r
30 , new Listener<Collection<ChartVariable>>() {
\r
33 public void execute(Collection<ChartVariable> variables) {
\r
34 ParameterExistsValidator.this.variables = variables;
\r
38 public void exception(Throwable t) {
\r
39 t.printStackTrace();
\r
43 public boolean isDisposed() {
\r
44 return ParameterExistsValidator.this.text.isDisposed();
\r