1 /*******************************************************************************
\r
2 * Copyright (c) 2012 Association for Decentralized Information Management
\r
3 * in 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
10 * Semantum Oy - initial API and implementation
\r
11 *******************************************************************************/
\r
12 package org.simantics.workbench.internal.preferences;
\r
14 import org.eclipse.core.runtime.preferences.InstanceScope;
\r
15 import org.eclipse.jface.preference.BooleanFieldEditor;
\r
16 import org.eclipse.jface.preference.FieldEditorPreferencePage;
\r
17 import org.eclipse.jface.preference.IPreferenceStore;
\r
18 import org.eclipse.jface.preference.IntegerFieldEditor;
\r
19 import org.eclipse.ui.IWorkbench;
\r
20 import org.eclipse.ui.IWorkbenchPreferencePage;
\r
21 import org.eclipse.ui.preferences.ScopedPreferenceStore;
\r
22 import org.simantics.AutosavePreferences;
\r
23 import org.simantics.AutosaveVirtualGraphs;
\r
26 * @author Tuukka Lehtonen <tuukka.lehtonen@semantum.fi>
\r
28 public class AutosavePreferencePage extends FieldEditorPreferencePage implements IWorkbenchPreferencePage {
\r
30 public AutosavePreferencePage() {
\r
33 IPreferenceStore pf = new ScopedPreferenceStore(InstanceScope.INSTANCE, AutosavePreferences.P_NODE);
\r
34 setPreferenceStore( pf );
\r
38 protected void createFieldEditors() {
\r
39 BooleanFieldEditor autosaveEnabled = new BooleanFieldEditor(
\r
40 AutosavePreferences.P_VG_AUTOSAVE_ENABLED,
\r
41 "Virtual Graph autosave enabled",
\r
42 getFieldEditorParent());
\r
43 addField(autosaveEnabled);
\r
45 IntegerFieldEditor autosaveInterval = new IntegerFieldEditor(
\r
46 AutosavePreferences.P_VG_AUTOSAVE_INTERVAL,
\r
47 "Virtual Graph autosave interval (seconds)",
\r
48 getFieldEditorParent());
\r
49 autosaveInterval.setValidRange(1, Integer.MAX_VALUE);
\r
50 autosaveInterval.setErrorMessage("Autosave interval must be positive");
\r
51 addField(autosaveInterval);
\r
55 public boolean performOk() {
\r
56 if(super.performOk()) {
\r
57 AutosaveVirtualGraphs.saveVirtualGraphsPeriodically();
\r
65 public void init(IWorkbench workbench) {
\r