]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.charts/src/org/simantics/charts/preference/ChartPreferencePage.java
Faster bounds calculation for zoom to selection and navigate to target
[simantics/platform.git] / bundles / org.simantics.charts / src / org / simantics / charts / preference / ChartPreferencePage.java
1 /*******************************************************************************
2  * Copyright (c) 2011 Association for Decentralized Information Management in
3  * Industry THTH ry.
4  * All rights reserved. This program and the accompanying materials
5  * are made available under the terms of the Eclipse Public License v1.0
6  * which accompanies this distribution, and is available at
7  * http://www.eclipse.org/legal/epl-v10.html
8  *
9  * Contributors:
10  *     VTT Technical Research Centre of Finland - initial API and implementation
11  *******************************************************************************/
12 package org.simantics.charts.preference;
13
14 import org.eclipse.jface.preference.BooleanFieldEditor;
15 import org.eclipse.jface.preference.FieldEditorPreferencePage;
16 import org.eclipse.jface.preference.IntegerFieldEditor;
17 import org.eclipse.jface.preference.RadioGroupFieldEditor;
18 import org.eclipse.swt.widgets.Composite;
19 import org.eclipse.ui.IWorkbench;
20 import org.eclipse.ui.IWorkbenchPreferencePage;
21 import org.simantics.charts.Activator;
22 import org.simantics.trend.configuration.ItemPlacement;
23 import org.simantics.trend.configuration.TimeFormat;
24 import org.simantics.trend.configuration.LineQuality;
25
26 /**
27  * @author Toni Kalajainen
28  */
29 public class ChartPreferencePage extends FieldEditorPreferencePage implements IWorkbenchPreferencePage {
30
31     private IntegerFieldEditor fRedrawIntervalEditor = null;
32     private IntegerFieldEditor fAutoscaleIntervalEditor = null;
33     private BooleanFieldEditor fDrawSamplesEditor = null;
34     private RadioGroupFieldEditor fTimeFormatEditor = null;
35     private RadioGroupFieldEditor fItemPlacementEditor = null;
36     private RadioGroupFieldEditor fValueFormatEditor = null;
37     private RadioGroupFieldEditor fLineQualityEditor = null;
38     private RadioGroupFieldEditor fTextQualityEditor = null;
39
40
41     /**
42      * Create the console page.
43      */
44     public ChartPreferencePage() {
45         super(GRID);
46
47         //setDescription("Chart prefrences");
48         setPreferenceStore(Activator.getDefault().getPreferenceStore());
49     }
50
51     /* (non-Javadoc)
52      * @see org.eclipse.jface.preference.PreferencePage#createControl(Composite)
53      */
54     @Override
55     public void createControl(Composite parent) {
56         super.createControl(parent);
57     }
58
59     /**
60      * Create all field editors for this page
61      */
62     @Override
63     public void createFieldEditors() {
64         fRedrawIntervalEditor = new IntegerFieldEditor(ChartPreferences.P_REDRAW_INTERVAL, Messages.ChartPreferencePage_redrawIntervalLabel, getFieldEditorParent());
65         fRedrawIntervalEditor.setValidRange(1, Integer.MAX_VALUE);
66         fRedrawIntervalEditor.setErrorMessage(Messages.ChartPreferencePage_redrawIntervalInvalid);
67         addField(fRedrawIntervalEditor);
68
69         fAutoscaleIntervalEditor = new IntegerFieldEditor(ChartPreferences.P_AUTOSCALE_INTERVAL, Messages.ChartPreferencePage_autoscaleIntervalLabel, getFieldEditorParent());
70         fAutoscaleIntervalEditor.setValidRange(1, Integer.MAX_VALUE);
71         fAutoscaleIntervalEditor.setErrorMessage(Messages.ChartPreferencePage_autoscaleIntervalInvalid);
72         addField(fAutoscaleIntervalEditor);
73
74         fDrawSamplesEditor = new BooleanFieldEditor(ChartPreferences.P_DRAW_SAMPLES, Messages.ChartPreferencePage_drawSamplesLabel, getFieldEditorParent());
75         addField(fDrawSamplesEditor);
76         
77         fTimeFormatEditor = new RadioGroupFieldEditor(
78                         ChartPreferences.P_TIMEFORMAT,
79                         "Preferred time format",
80                         1,
81                         new String[][] {
82                                 new String[] {"Time", TimeFormat.Time.name()},  
83                                 new String[] {"Decimal", TimeFormat.Decimal.name()}     
84                         },
85                         getFieldEditorParent());
86         addField(fTimeFormatEditor);
87         
88         fValueFormatEditor = new RadioGroupFieldEditor(
89                         ChartPreferences.P_VALUEFORMAT,
90                         "Preferred value format",
91                         1,
92                         new String[][] {
93                                 new String[] {"Default", "Default"},    
94                                 new String[] {"Currency", "Currency"},
95                                 new String[] {"Scientific", "Scientific"},      
96                                 new String[] {"Engineering", "Engineering"}     
97                         },
98                         getFieldEditorParent());
99         addField(fValueFormatEditor);
100
101         fItemPlacementEditor = new RadioGroupFieldEditor(
102                         ChartPreferences.P_ITEMPLACEMENT,
103                         "Item autoscale placement",
104                         1,
105                         new String[][] {
106                                 new String[] {"Stacked", ItemPlacement.Stacked.name()}, 
107                                 new String[] {"Overlapping", ItemPlacement.Overlapping.name()}  
108                         },
109                         getFieldEditorParent());
110         addField(fItemPlacementEditor);
111
112         fLineQualityEditor = new RadioGroupFieldEditor(
113                         ChartPreferences.P_LINEQUALITY,
114                         "Line Quality",
115                         1,
116                         new String[][] {
117                                 new String[] {"Normal", LineQuality.Normal.name()},     
118                                 new String[] {"Anti-alias", LineQuality.Antialias.name()}       
119                         },
120                         getFieldEditorParent());
121         addField( fLineQualityEditor );
122         
123         fTextQualityEditor = new RadioGroupFieldEditor(
124                         ChartPreferences.P_TEXTQUALITY,
125                         "Text Quality",
126                         1,
127                         new String[][] {
128                                 new String[] {"Normal", LineQuality.Normal.name()},     
129                                 new String[] {"Anti-alias", LineQuality.Antialias.name()}       
130                         },
131                         getFieldEditorParent());
132         addField( fTextQualityEditor );
133         
134     }
135
136     /**
137      * @see IWorkbenchPreferencePage#init(IWorkbench)
138      */
139     @Override
140     public void init(IWorkbench workbench) {
141     }
142
143
144 }