1 /*******************************************************************************
2 * Copyright (c) 2007, 2011 Association for Decentralized Information Management in
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
10 * VTT Technical Research Centre of Finland - initial API and implementation
11 *******************************************************************************/
12 package org.simantics.modeling.ui.preferences;
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;
29 public class SubscriptionPreferencePage extends FieldEditorPreferencePage implements IWorkbenchPreferencePage {
31 private NumberFieldEditor fSubscriptionDeadbandEditor = null;
32 private NumberFieldEditor fSubscriptionIntervalEditor = null;
33 private NumberFieldEditor fSubscriptionGainEditor = null;
34 private NumberFieldEditor fSubscriptionBiasEditor = null;
37 * Create the console page.
39 public SubscriptionPreferencePage() {
42 //setDescription("Subscription preferences");
43 IPreferenceStore pf = new ScopedPreferenceStore(InstanceScope.INSTANCE, SubscriptionPreferences.P_NODE);
44 setPreferenceStore( pf );
48 * @see org.eclipse.jface.preference.PreferencePage#createControl(Composite)
51 public void createControl(Composite parent) {
52 super.createControl(parent);
56 * Create all field editors for this page
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();
66 newItemGroup.setLayout(fl);
67 Composite newItemSettings = new Composite(newItemGroup, SWT.NONE);
68 GridLayoutFactory.fillDefaults().numColumns(2).applyTo(newItemSettings);
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);
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);
80 fSubscriptionGainEditor = new NumberFieldEditor(SubscriptionPreferences.P_SUBSCRIPTION_GAIN, "Gain", newItemSettings);
81 addField(fSubscriptionGainEditor);
83 fSubscriptionBiasEditor = new NumberFieldEditor(SubscriptionPreferences.P_SUBSCRIPTION_BIAS, "Bias", newItemSettings);
84 addField(fSubscriptionBiasEditor);
88 * @see IWorkbenchPreferencePage#init(IWorkbench)
91 public void init(IWorkbench workbench) {