]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.modeling.ui/src/org/simantics/modeling/ui/preferences/SubscriptionPreferencePage.java
(refs #7561) Allow extra parameters to the application of type alias
[simantics/platform.git] / bundles / org.simantics.modeling.ui / src / org / simantics / modeling / ui / preferences / SubscriptionPreferencePage.java
1 /*******************************************************************************
2  * Copyright (c) 2007, 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.modeling.ui.preferences;
13
14 import org.eclipse.core.runtime.preferences.InstanceScope;
15 import org.eclipse.jface.layout.GridDataFactory;
16 import org.eclipse.jface.layout.GridLayoutFactory;
17 import org.eclipse.jface.preference.FieldEditorPreferencePage;
18 import org.eclipse.jface.preference.IPreferenceStore;
19 import org.eclipse.swt.SWT;
20 import org.eclipse.swt.layout.FillLayout;
21 import org.eclipse.swt.widgets.Composite;
22 import org.eclipse.swt.widgets.Group;
23 import org.eclipse.ui.IWorkbench;
24 import org.eclipse.ui.IWorkbenchPreferencePage;
25 import org.eclipse.ui.preferences.ScopedPreferenceStore;
26 import org.simantics.modeling.preferences.SubscriptionPreferences;
27 import org.simantics.ui.workbench.preferences.NumberFieldEditor;
28
29 public class SubscriptionPreferencePage extends FieldEditorPreferencePage implements IWorkbenchPreferencePage {
30
31     private NumberFieldEditor fSubscriptionDeadbandEditor = null;
32     private NumberFieldEditor fSubscriptionIntervalEditor = null;
33     private NumberFieldEditor fSubscriptionGainEditor = null;
34     private NumberFieldEditor fSubscriptionBiasEditor = null;
35                 
36     /**
37      * Create the console page.
38      */
39     public SubscriptionPreferencePage() {
40         super(GRID);
41
42         //setDescription("Subscription preferences");
43         IPreferenceStore pf = new ScopedPreferenceStore(InstanceScope.INSTANCE, SubscriptionPreferences.P_NODE);
44         setPreferenceStore( pf );
45     }
46
47     /* (non-Javadoc)
48      * @see org.eclipse.jface.preference.PreferencePage#createControl(Composite)
49      */
50     @Override
51     public void createControl(Composite parent) {
52         super.createControl(parent);
53     }
54
55     /**
56      * Create all field editors for this page
57      */
58     @Override
59     public void createFieldEditors() {
60         Group newItemGroup = new Group(getFieldEditorParent(), SWT.NONE);
61         newItemGroup.setText("Default settings for new subscription items");
62         GridDataFactory.fillDefaults().grab(true, false).span(2, 1).applyTo(newItemGroup);
63         FillLayout fl = new FillLayout();
64         fl.marginWidth = 5;
65         fl.marginHeight = 5;
66         newItemGroup.setLayout(fl);
67         Composite newItemSettings = new Composite(newItemGroup, SWT.NONE);
68         GridLayoutFactory.fillDefaults().numColumns(2).applyTo(newItemSettings);
69
70         fSubscriptionIntervalEditor = new NumberFieldEditor(SubscriptionPreferences.P_SUBSCRIPTION_INTERVAL, "Sampling Interval (s)", newItemSettings);
71         fSubscriptionIntervalEditor.setValidRange(0, Double.MAX_VALUE);
72         fSubscriptionIntervalEditor.setErrorMessage("Default sampling interval value is invalid");
73         addField(fSubscriptionIntervalEditor);
74
75         fSubscriptionDeadbandEditor = new NumberFieldEditor(SubscriptionPreferences.P_SUBSCRIPTION_DEADBAND, "Deadband", newItemSettings);
76         fSubscriptionDeadbandEditor.setValidRange(0., Double.MAX_VALUE);
77         fSubscriptionDeadbandEditor.setErrorMessage("Default deadband value is invalid");
78         addField(fSubscriptionDeadbandEditor);
79
80         fSubscriptionGainEditor = new NumberFieldEditor(SubscriptionPreferences.P_SUBSCRIPTION_GAIN, "Gain", newItemSettings);
81         addField(fSubscriptionGainEditor);
82
83         fSubscriptionBiasEditor = new NumberFieldEditor(SubscriptionPreferences.P_SUBSCRIPTION_BIAS, "Bias", newItemSettings);
84         addField(fSubscriptionBiasEditor);
85     }
86
87     /**
88      * @see IWorkbenchPreferencePage#init(IWorkbench)
89      */
90     @Override
91     public void init(IWorkbench workbench) {
92     }
93
94
95 }