]> gerrit.simantics Code Review - simantics/sysdyn.git/blob
0fb44b63eeee57853d80771200a10c0bc019241e
[simantics/sysdyn.git] /
1 package org.simantics.sysdyn.ui.validation;\r
2 \r
3 import java.util.Collection;\r
4 \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
15 \r
16 public class ParameterExistsValidator extends VariableExistsValidator {\r
17 \r
18         public ParameterExistsValidator(WidgetSupport support, TrackedText text) {\r
19                 super(support, text);\r
20         }\r
21 \r
22     @Override\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
26             return;\r
27         \r
28         SimanticsUI.getSession().asyncRequest(\r
29                 new AllVariablesOfModel(resource)\r
30         , new Listener<Collection<ChartVariable>>() {\r
31 \r
32             @Override\r
33             public void execute(Collection<ChartVariable> variables) {\r
34                  ParameterExistsValidator.this.variables = variables;\r
35             }\r
36 \r
37             @Override\r
38             public void exception(Throwable t) {\r
39                 t.printStackTrace();\r
40             }\r
41 \r
42             @Override\r
43             public boolean isDisposed() {\r
44                 return ParameterExistsValidator.this.text.isDisposed();\r
45             }\r
46 \r
47         }); \r
48     }\r
49 \r
50 }\r