1 /*******************************************************************************
\r
2 * Copyright (c) 2007, 2011 Association for Decentralized Information Management in
\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
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
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
39 * Composite containing the properties of a series
\r
40 * @author Teemu Lempinen
\r
43 public class PieSeriesPropertyComposite extends Composite {
\r
45 private TrackedText variable, label, time;
\r
47 public PieSeriesPropertyComposite(Composite parent, ISessionContext context, WidgetSupport support, int style) {
\r
48 super(parent, style);
\r
50 GridLayoutFactory.fillDefaults().margins(3, 3).numColumns(2).applyTo(this);
\r
52 // Variable for the series
\r
53 Label label = new Label(this, SWT.NONE);
\r
54 label.setText("Variable:");
\r
55 GridDataFactory.fillDefaults().align(SWT.END, SWT.FILL).applyTo(label);
\r
57 variable = new TrackedText(this, support, SWT.BORDER);
\r
58 variable.setTextFactory(new RVIFactory());
\r
59 variable.addModifyListener(new RVIModifier(variable.getWidget(), support));
\r
60 variable.setColorProvider(new JFreeChartPropertyColorProvider(this.variable.getResourceManager()));
\r
61 GridDataFactory.fillDefaults().grab(true, false).applyTo(this.variable.getWidget());
\r
64 label = new Label(this, SWT.NONE);
\r
65 label.setText("Range:");
\r
66 GridDataFactory.fillDefaults().align(SWT.END, SWT.CENTER).applyTo(label);
\r
68 RangeComposite rangeComposite = new RangeComposite(this, context, support, SWT.NONE);
\r
69 GridDataFactory.fillDefaults().grab(true, false).applyTo(rangeComposite);
\r
72 // Label to be displayed in chart for this series
\r
73 label = new Label(this, SWT.NONE);
\r
74 label.setText("Label:");
\r
75 GridDataFactory.fillDefaults().align(SWT.END, SWT.FILL).applyTo(label);
\r
77 this.label = new TrackedText(this, support, SWT.BORDER);
\r
78 this.label.setTextFactory(new StringPropertyFactory(Layer0.URIs.HasLabel, ""));
\r
79 this.label.addModifyListener(new StringPropertyModifier(context, Layer0.URIs.HasLabel));
\r
80 this.label.setColorProvider(new JFreeChartPropertyColorProvider(this.label.getResourceManager()));
\r
81 GridDataFactory.fillDefaults().grab(true, false).applyTo(this.label.getWidget());
\r
84 label = new Label(this, SWT.NONE);
\r
85 label.setText("Color:");
\r
86 GridDataFactory.fillDefaults().align(SWT.END, SWT.CENTER).applyTo(label);
\r
88 Composite colorPicker = new ColorPicker(this, context, support, SWT.NONE);
\r
89 GridDataFactory.fillDefaults().grab(true, false).applyTo(colorPicker);
\r
92 label = new Label(this, SWT.NONE);
\r
93 GridDataFactory.fillDefaults().align(SWT.END, SWT.FILL).applyTo(label);
\r
94 label.setText("Time:");
\r
96 Composite composite = new Composite(this, SWT.NONE);
\r
97 GridDataFactory.fillDefaults().applyTo(composite);
\r
98 GridLayoutFactory.fillDefaults().applyTo(composite);
\r
100 time = new org.simantics.browsing.ui.swt.widgets.TrackedText(composite, support, SWT.BORDER);
\r
101 time.setTextFactory(new DoublePropertyFactory(JFreeChartResource.URIs.Series_time));
\r
102 time.addModifyListener(new DoublePropertyModifier(context, JFreeChartResource.URIs.Series_time));
\r
103 time.setInputValidator(new DoubleValidator(true));
\r
104 time.setColorProvider(new JFreeChartPropertyColorProvider(time.getResourceManager()));
\r
105 GridDataFactory.fillDefaults().applyTo(time.getWidget());
\r
108 label = new Label(this, SWT.NONE);
\r
110 GridDataFactory.fillDefaults().align(SWT.END, SWT.FILL).applyTo(label);
\r
112 Button exploded = new Button(this, support, SWT.CHECK);
\r
113 exploded.setText("Exploded");
\r
114 exploded.addSelectionListener(new BooleanSelectionListener(context, JFreeChartResource.URIs.Series_exploded));
\r
115 exploded.setSelectionFactory(new BooleanPropertyFactory(JFreeChartResource.URIs.Series_exploded));
\r
116 GridDataFactory.fillDefaults().applyTo(exploded.getWidget());
\r