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