1
|
/**
|
2
|
* Copyright (C) 2007 EDIT
|
3
|
* European Distributed Institute of Taxonomy
|
4
|
* http://www.e-taxonomy.eu
|
5
|
*
|
6
|
* The contents of this file are subject to the Mozilla Public License Version 1.1
|
7
|
* See LICENSE.TXT at the top of this package for the full license terms.
|
8
|
*/
|
9
|
|
10
|
package eu.etaxonomy.taxeditor.preference;
|
11
|
|
12
|
import org.eclipse.jface.preference.PreferencePage;
|
13
|
import org.eclipse.swt.SWT;
|
14
|
import org.eclipse.swt.events.SelectionAdapter;
|
15
|
import org.eclipse.swt.events.SelectionEvent;
|
16
|
import org.eclipse.swt.layout.GridLayout;
|
17
|
import org.eclipse.swt.widgets.Button;
|
18
|
import org.eclipse.swt.widgets.Composite;
|
19
|
import org.eclipse.swt.widgets.Control;
|
20
|
import org.eclipse.ui.IWorkbench;
|
21
|
import org.eclipse.ui.IWorkbenchPreferencePage;
|
22
|
|
23
|
import eu.etaxonomy.taxeditor.model.Resources;
|
24
|
|
25
|
/**
|
26
|
* @author p.ciardelli
|
27
|
* @created 01.07.2008
|
28
|
* @version 1.0
|
29
|
*/
|
30
|
public class InitializeDbPreferences extends PreferencePage implements
|
31
|
IWorkbenchPreferencePage {
|
32
|
|
33
|
public static final String PLUGIN_ID = "eu.etaxonomy.taxeditor.preferences.initdb";
|
34
|
|
35
|
private Button btnInit;
|
36
|
// private Button btnTestData;
|
37
|
|
38
|
public InitializeDbPreferences() {
|
39
|
super();
|
40
|
setDescription("If you choose this option, taxonomic tree will be empty next time the Editor is started.");
|
41
|
}
|
42
|
|
43
|
/**
|
44
|
* Create contents of the preference page
|
45
|
* @param parent
|
46
|
*/
|
47
|
@Override
|
48
|
public Control createContents(Composite parent) {
|
49
|
|
50
|
Composite container = new Composite(parent, SWT.NULL);
|
51
|
container.setLayout(new GridLayout());
|
52
|
|
53
|
btnInit = new Button(container, SWT.CHECK);
|
54
|
btnInit.setText("Initialize datastore on next application start");
|
55
|
btnInit.addSelectionListener(new SelectionAdapter() {
|
56
|
|
57
|
@Override
|
58
|
public void widgetSelected(SelectionEvent e) {
|
59
|
if (btnInit.getSelection() == true) {
|
60
|
|
61
|
// Enable test data option
|
62
|
// btnTestData.setEnabled(true);
|
63
|
|
64
|
} else {
|
65
|
|
66
|
// Disable test data option, set selected to "false"
|
67
|
// btnTestData.setEnabled(false);
|
68
|
// btnTestData.setSelection(false);
|
69
|
}
|
70
|
}
|
71
|
|
72
|
});
|
73
|
|
74
|
return container;
|
75
|
}
|
76
|
|
77
|
/**
|
78
|
* Initialize the preference page
|
79
|
*/
|
80
|
public void init(IWorkbench workbench) {
|
81
|
setPreferenceStore(PreferencesUtil.getPreferenceStore());
|
82
|
}
|
83
|
|
84
|
@Override
|
85
|
protected void performDefaults() {
|
86
|
btnInit.setSelection(false);
|
87
|
// btnTestData.setSelection(false);
|
88
|
super.performDefaults();
|
89
|
}
|
90
|
|
91
|
@Override
|
92
|
public boolean performOk() {
|
93
|
boolean doReinitialize = !(btnInit.getSelection());
|
94
|
// boolean doInitTestdata = btnTestData.getSelection();
|
95
|
|
96
|
PreferencesUtil.getPreferenceStore().setValue(Resources.INITIALIZED, doReinitialize);
|
97
|
// UiUtil.getPrefStore().setValue(ITaxEditorConstants.INITIALIZE_W_TESTDATA, doInitTestdata);
|
98
|
return true;
|
99
|
}
|
100
|
}
|