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.store.preference;
|
11
|
|
12
|
import org.apache.log4j.Logger;
|
13
|
import org.eclipse.jface.preference.PreferencePage;
|
14
|
import org.eclipse.swt.SWT;
|
15
|
import org.eclipse.swt.events.SelectionAdapter;
|
16
|
import org.eclipse.swt.events.SelectionEvent;
|
17
|
import org.eclipse.swt.layout.GridLayout;
|
18
|
import org.eclipse.swt.widgets.Button;
|
19
|
import org.eclipse.swt.widgets.Composite;
|
20
|
import org.eclipse.swt.widgets.Control;
|
21
|
import org.eclipse.ui.IWorkbench;
|
22
|
import org.eclipse.ui.IWorkbenchPreferencePage;
|
23
|
|
24
|
import eu.etaxonomy.taxeditor.store.model.Resources;
|
25
|
|
26
|
/**
|
27
|
* @author p.ciardelli
|
28
|
* @created 01.07.2008
|
29
|
* @version 1.0
|
30
|
*/
|
31
|
public class InitializeDbPreferences extends PreferencePage implements
|
32
|
IWorkbenchPreferencePage {
|
33
|
private static final Logger logger = Logger
|
34
|
.getLogger(InitializeDbPreferences.class);
|
35
|
|
36
|
public static final String PLUGIN_ID = "eu.etaxonomy.taxeditor.preferences.initdb";
|
37
|
|
38
|
private Button btnInit;
|
39
|
// private Button btnTestData;
|
40
|
|
41
|
public InitializeDbPreferences() {
|
42
|
super();
|
43
|
setDescription("If you choose this option, taxonomic tree will be empty next time the Editor is started.");
|
44
|
}
|
45
|
|
46
|
/**
|
47
|
* Create contents of the preference page
|
48
|
* @param parent
|
49
|
*/
|
50
|
@Override
|
51
|
public Control createContents(Composite parent) {
|
52
|
|
53
|
Composite container = new Composite(parent, SWT.NULL);
|
54
|
container.setLayout(new GridLayout());
|
55
|
|
56
|
btnInit = new Button(container, SWT.CHECK);
|
57
|
btnInit.setText("Initialize datastore on next application start");
|
58
|
btnInit.addSelectionListener(new SelectionAdapter() {
|
59
|
|
60
|
@Override
|
61
|
public void widgetSelected(SelectionEvent e) {
|
62
|
if (btnInit.getSelection() == true) {
|
63
|
|
64
|
// Enable test data option
|
65
|
// btnTestData.setEnabled(true);
|
66
|
|
67
|
} else {
|
68
|
|
69
|
// Disable test data option, set selected to "false"
|
70
|
// btnTestData.setEnabled(false);
|
71
|
// btnTestData.setSelection(false);
|
72
|
}
|
73
|
}
|
74
|
|
75
|
});
|
76
|
|
77
|
// btnTestData = new Button(container, SWT.CHECK);
|
78
|
// btnTestData.setEnabled(false);
|
79
|
// final GridData gridData = new GridData();
|
80
|
// gridData.horizontalIndent = 20;
|
81
|
// btnTestData.setLayoutData(gridData);
|
82
|
// btnTestData.setText("Initialize with Palmweb test data");
|
83
|
|
84
|
return container;
|
85
|
}
|
86
|
|
87
|
/**
|
88
|
* Initialize the preference page
|
89
|
*/
|
90
|
public void init(IWorkbench workbench) {
|
91
|
setPreferenceStore(PreferencesUtil.getPrefStore());
|
92
|
}
|
93
|
|
94
|
@Override
|
95
|
protected void performDefaults() {
|
96
|
btnInit.setSelection(false);
|
97
|
// btnTestData.setSelection(false);
|
98
|
super.performDefaults();
|
99
|
}
|
100
|
|
101
|
@Override
|
102
|
public boolean performOk() {
|
103
|
boolean doReinitialize = !(btnInit.getSelection());
|
104
|
// boolean doInitTestdata = btnTestData.getSelection();
|
105
|
|
106
|
PreferencesUtil.getPrefStore().setValue(Resources.INITIALIZED, doReinitialize);
|
107
|
// UiUtil.getPrefStore().setValue(ITaxEditorConstants.INITIALIZE_W_TESTDATA, doInitTestdata);
|
108
|
return true;
|
109
|
}
|
110
|
}
|