]> gerrit.simantics Code Review - simantics/sysdyn.git/blob
e77b9f8680924c1c27afeb7aa9076148727518a9
[simantics/sysdyn.git] /
1 package org.simantics.sysdyn.ui.properties;\r
2 \r
3 import org.eclipse.jface.layout.GridDataFactory;\r
4 import org.eclipse.jface.layout.GridLayoutFactory;\r
5 import org.eclipse.jface.resource.JFaceResources;\r
6 import org.eclipse.jface.resource.LocalResourceManager;\r
7 import org.eclipse.swt.SWT;\r
8 import org.eclipse.swt.custom.ScrolledComposite;\r
9 import org.eclipse.swt.widgets.Composite;\r
10 import org.eclipse.swt.widgets.Label;\r
11 import org.eclipse.ui.IWorkbenchSite;\r
12 import org.simantics.browsing.ui.swt.widgets.StringPropertyFactory;\r
13 import org.simantics.browsing.ui.swt.widgets.StringPropertyModifier;\r
14 import org.simantics.browsing.ui.swt.widgets.TrackedText;\r
15 import org.simantics.browsing.ui.swt.widgets.impl.WidgetSupport;\r
16 import org.simantics.db.management.ISessionContext;\r
17 import org.simantics.layer0.Layer0;\r
18 import org.simantics.sysdyn.SysdynResource;\r
19 import org.simantics.sysdyn.ui.properties.widgets.factories.DoublePropertyFactory;\r
20 import org.simantics.sysdyn.ui.properties.widgets.factories.DoublePropertyModifier;\r
21 import org.simantics.utils.ui.validators.DoubleValidator;\r
22 \r
23 /**\r
24  * Tab for displaying game experiment properties\r
25  * \r
26  * @author Teemu Lempinen\r
27  *\r
28  */\r
29 public class GameExperimentTab extends LabelPropertyTabContributor {\r
30 \r
31         @Override\r
32         public void createControls(Composite body, IWorkbenchSite site,\r
33                 ISessionContext context, WidgetSupport support) {\r
34                 \r
35         ScrolledComposite sc = new ScrolledComposite(body,  SWT.H_SCROLL | SWT.V_SCROLL);\r
36         GridDataFactory.fillDefaults().grab(true, true).applyTo(sc);\r
37         GridLayoutFactory.fillDefaults().applyTo(sc);\r
38         \r
39         Composite composite = new RemoveFocusBeforeExperimentComposite(sc, SWT.NONE);\r
40         GridDataFactory.fillDefaults().grab(true, true).applyTo(composite);\r
41         GridLayoutFactory.fillDefaults().margins(3, 3).numColumns(2).applyTo(composite);\r
42         \r
43         // Label\r
44         Label label = new Label(composite, SWT.NONE);\r
45         label.setText("Name");\r
46         \r
47         TrackedText name = new TrackedText(composite, support, SWT.BORDER);\r
48         name.setTextFactory(new StringPropertyFactory(Layer0.URIs.HasLabel));\r
49         name.addModifyListener(new StringPropertyModifier(context, Layer0.URIs.HasLabel));\r
50         name.addModifyListener(new StringPropertyModifier(context, Layer0.URIs.HasName));\r
51         name.setColorProvider(new SysdynBasicColorProvider(new LocalResourceManager(JFaceResources.getResources(), name.getWidget())));\r
52 \r
53         // Step duration (i.e. how many time units is one step in user's perspective)\r
54         label = new Label(composite, SWT.NONE);\r
55         label.setText("Step duration");\r
56         \r
57         TrackedText stepDuration = new TrackedText(composite, support, SWT.BORDER);\r
58         stepDuration.setTextFactory(new DoublePropertyFactory(SysdynResource.URIs.GameExperiment_stepDuration));\r
59         stepDuration.addModifyListener(new DoublePropertyModifier(context, SysdynResource.URIs.GameExperiment_stepDuration));\r
60         stepDuration.setInputValidator(new DoubleValidator());\r
61         stepDuration.setColorProvider(new SysdynBasicColorProvider(new LocalResourceManager(JFaceResources.getResources(), stepDuration.getWidget())));\r
62         GridDataFactory.fillDefaults().hint(300, SWT.DEFAULT).applyTo(name.getWidget());\r
63 \r
64         // Integrator step length (i.e. how long is a integration step in the simulator. This time is stepped until stepDuration is full)\r
65         label = new Label(composite, SWT.NONE);\r
66         label.setText("Integrator step length");\r
67         \r
68         TrackedText integratorStep = new TrackedText(composite, support, SWT.BORDER);\r
69         integratorStep.setTextFactory(new DoublePropertyFactory(SysdynResource.URIs.GameExperiment_stepLength));\r
70         integratorStep.addModifyListener(new DoublePropertyModifier(context, SysdynResource.URIs.GameExperiment_stepLength));\r
71         integratorStep.setInputValidator(new DoubleValidator());\r
72         integratorStep.setColorProvider(new SysdynBasicColorProvider(new LocalResourceManager(JFaceResources.getResources(), integratorStep.getWidget())));\r
73         \r
74         // Scrolled composite settings\r
75         sc.setContent(composite);\r
76         sc.setMinSize(composite.computeSize(SWT.DEFAULT, SWT.DEFAULT));\r
77         sc.setExpandHorizontal(true);\r
78         sc.setExpandVertical(true);\r
79                 \r
80         }\r
81 \r
82 }\r