]> gerrit.simantics Code Review - simantics/sysdyn.git/blob
7ea26a41a046f51fcdcabb00a61a40bce6d91e00
[simantics/sysdyn.git] /
1 /*******************************************************************************\r
2  * Copyright (c) 2007, 2011 Association for Decentralized Information Management in\r
3  * Industry THTH ry.\r
4  * All rights reserved. This program and the accompanying materials\r
5  * are made available under the terms of the Eclipse Public License v1.0\r
6  * which accompanies this distribution, and is available at\r
7  * http://www.eclipse.org/legal/epl-v10.html\r
8  *\r
9  * Contributors:\r
10  *     VTT Technical Research Centre of Finland - initial API and implementation\r
11  *******************************************************************************/\r
12 package org.simantics.sysdyn.ui.trend.chart.properties.pie;\r
13 \r
14 import org.eclipse.jface.layout.GridDataFactory;\r
15 import org.eclipse.jface.layout.GridLayoutFactory;\r
16 import org.eclipse.swt.SWT;\r
17 import org.eclipse.swt.widgets.Composite;\r
18 import org.eclipse.swt.widgets.Label;\r
19 import org.simantics.browsing.ui.swt.widgets.Button;\r
20 import org.simantics.browsing.ui.swt.widgets.StringPropertyFactory;\r
21 import org.simantics.browsing.ui.swt.widgets.StringPropertyModifier;\r
22 import org.simantics.browsing.ui.swt.widgets.TrackedText;\r
23 import org.simantics.browsing.ui.swt.widgets.impl.WidgetSupport;\r
24 import org.simantics.db.management.ISessionContext;\r
25 import org.simantics.layer0.Layer0;\r
26 import org.simantics.sysdyn.JFreeChartResource;\r
27 import org.simantics.sysdyn.ui.properties.widgets.factories.DoublePropertyFactory;\r
28 import org.simantics.sysdyn.ui.properties.widgets.factories.DoublePropertyModifier;\r
29 import org.simantics.sysdyn.ui.trend.chart.properties.BooleanPropertyFactory;\r
30 import org.simantics.sysdyn.ui.trend.chart.properties.BooleanSelectionListener;\r
31 import org.simantics.sysdyn.ui.trend.chart.properties.ColorPicker;\r
32 import org.simantics.sysdyn.ui.trend.chart.properties.DoubleValidator;\r
33 import org.simantics.sysdyn.ui.trend.chart.properties.JFreeChartPropertyColorProvider;\r
34 import org.simantics.sysdyn.ui.trend.chart.properties.RVIFactory;\r
35 import org.simantics.sysdyn.ui.trend.chart.properties.RVIModifier;\r
36 import org.simantics.sysdyn.ui.trend.chart.properties.RangeComposite;\r
37 import org.simantics.sysdyn.ui.trend.chart.properties.VariableExistsValidator;\r
38 \r
39 /**\r
40  * Composite containing the properties of a series\r
41  * @author Teemu Lempinen\r
42  *\r
43  */\r
44 public class PieSeriesPropertyComposite extends Composite {\r
45     \r
46     private TrackedText variable, label, time;\r
47     \r
48     public PieSeriesPropertyComposite(Composite parent, ISessionContext context, WidgetSupport support, int style) {\r
49         super(parent, style);\r
50         \r
51         GridLayoutFactory.fillDefaults().margins(3, 3).numColumns(2).applyTo(this);\r
52 \r
53         // Variable for the series\r
54         Label label = new Label(this, SWT.NONE);\r
55         label.setText("Variable:");\r
56         GridDataFactory.fillDefaults().align(SWT.END, SWT.FILL).applyTo(label);\r
57 \r
58         variable = new TrackedText(this, support, SWT.BORDER);\r
59         variable.setTextFactory(new RVIFactory());\r
60         variable.addModifyListener(new RVIModifier(variable.getWidget(), support));\r
61         variable.setInputValidator(new VariableExistsValidator(support, variable));\r
62         variable.setColorProvider(new JFreeChartPropertyColorProvider(this.variable.getResourceManager()));\r
63         GridDataFactory.fillDefaults().grab(true, false).applyTo(this.variable.getWidget());\r
64 \r
65         // Range\r
66         label = new Label(this, SWT.NONE);\r
67         label.setText("Range:");\r
68         GridDataFactory.fillDefaults().align(SWT.END, SWT.CENTER).applyTo(label);\r
69         \r
70         RangeComposite rangeComposite = new RangeComposite(this, context, support, SWT.NONE);\r
71         GridDataFactory.fillDefaults().grab(true, false).applyTo(rangeComposite);\r
72         \r
73         \r
74         // Label to be displayed in chart for this series\r
75         label = new Label(this, SWT.NONE);\r
76         label.setText("Label:");\r
77         GridDataFactory.fillDefaults().align(SWT.END, SWT.FILL).applyTo(label);\r
78 \r
79         this.label = new TrackedText(this, support, SWT.BORDER);\r
80         this.label.setTextFactory(new StringPropertyFactory(Layer0.URIs.HasLabel, ""));\r
81         this.label.addModifyListener(new StringPropertyModifier(context, Layer0.URIs.HasLabel));\r
82         this.label.setColorProvider(new JFreeChartPropertyColorProvider(this.label.getResourceManager()));\r
83         GridDataFactory.fillDefaults().grab(true, false).applyTo(this.label.getWidget());\r
84 \r
85         // Color\r
86         label = new Label(this, SWT.NONE);\r
87         label.setText("Color:");\r
88         GridDataFactory.fillDefaults().align(SWT.END, SWT.CENTER).applyTo(label);\r
89 \r
90         Composite colorPicker = new ColorPicker(this, context, support, SWT.NONE);\r
91         GridDataFactory.fillDefaults().grab(true, false).applyTo(colorPicker);\r
92 \r
93         // Time\r
94         label = new Label(this, SWT.NONE);\r
95         GridDataFactory.fillDefaults().align(SWT.END, SWT.FILL).applyTo(label);\r
96         label.setText("Time:");\r
97         \r
98         Composite composite = new Composite(this, SWT.NONE);\r
99         GridDataFactory.fillDefaults().applyTo(composite);\r
100         GridLayoutFactory.fillDefaults().applyTo(composite);\r
101         \r
102         time = new org.simantics.browsing.ui.swt.widgets.TrackedText(composite, support, SWT.BORDER);\r
103         time.setTextFactory(new DoublePropertyFactory(JFreeChartResource.URIs.Series_time));\r
104         time.addModifyListener(new DoublePropertyModifier(context, JFreeChartResource.URIs.Series_time));\r
105         time.setInputValidator(new DoubleValidator(true));\r
106         time.setColorProvider(new JFreeChartPropertyColorProvider(time.getResourceManager()));\r
107         GridDataFactory.fillDefaults().applyTo(time.getWidget());\r
108         \r
109         // Exploded\r
110         label = new Label(this, SWT.NONE);\r
111         label.setText("");\r
112         GridDataFactory.fillDefaults().align(SWT.END, SWT.FILL).applyTo(label);\r
113         \r
114         Button exploded = new Button(this, support, SWT.CHECK);\r
115         exploded.setText("Exploded");\r
116         exploded.addSelectionListener(new BooleanSelectionListener(context, JFreeChartResource.URIs.Series_exploded));\r
117         exploded.setSelectionFactory(new BooleanPropertyFactory(JFreeChartResource.URIs.Series_exploded));\r
118         GridDataFactory.fillDefaults().applyTo(exploded.getWidget());\r
119     }\r
120 \r
121 }\r