1
|
/**
|
2
|
* Copyright (C) 2015 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
|
package eu.etaxonomy.taxeditor.preference.menu;
|
10
|
|
11
|
import org.eclipse.jface.preference.PreferencePage;
|
12
|
import org.eclipse.jface.resource.ImageDescriptor;
|
13
|
import org.eclipse.swt.SWT;
|
14
|
import org.eclipse.swt.layout.GridData;
|
15
|
import org.eclipse.swt.layout.GridLayout;
|
16
|
import org.eclipse.swt.widgets.Button;
|
17
|
import org.eclipse.swt.widgets.Composite;
|
18
|
|
19
|
import eu.etaxonomy.taxeditor.l10n.Messages;
|
20
|
import eu.etaxonomy.taxeditor.preference.IE4PreferencePage;
|
21
|
import eu.etaxonomy.taxeditor.preference.PreferencesUtil;
|
22
|
|
23
|
/**
|
24
|
* @author cmathew
|
25
|
* @date 30 Jul 2015
|
26
|
*
|
27
|
*/
|
28
|
public abstract class CdmPreferencePage extends PreferencePage implements IE4PreferencePage {
|
29
|
|
30
|
private boolean isApply;
|
31
|
|
32
|
protected boolean isAdminPreference;
|
33
|
|
34
|
|
35
|
public CdmPreferencePage() {
|
36
|
this(null, null);
|
37
|
}
|
38
|
|
39
|
public CdmPreferencePage(String title) {
|
40
|
this(title, null);
|
41
|
}
|
42
|
|
43
|
public CdmPreferencePage(String title, ImageDescriptor image) {
|
44
|
super(title, image);
|
45
|
|
46
|
init();
|
47
|
}
|
48
|
|
49
|
public void init() {
|
50
|
setPreferenceStore(PreferencesUtil.getPreferenceStore());
|
51
|
}
|
52
|
|
53
|
@Override
|
54
|
public boolean performOk() {
|
55
|
if (isValid()){
|
56
|
return super.performOk();
|
57
|
}return false;
|
58
|
}
|
59
|
|
60
|
@Override
|
61
|
public boolean performCancel() {
|
62
|
|
63
|
return super.performCancel();
|
64
|
}
|
65
|
|
66
|
@Override
|
67
|
public void performApply() {
|
68
|
isApply = true;
|
69
|
super.performApply();
|
70
|
isApply = false;
|
71
|
}
|
72
|
|
73
|
protected Composite createComposite(Composite composite) {
|
74
|
Composite activateComp = new Composite(composite, SWT.NULL);
|
75
|
GridLayout layout = new GridLayout();
|
76
|
layout.numColumns = 2;
|
77
|
activateComp.setLayout(layout);
|
78
|
GridData gridData = new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_FILL);
|
79
|
|
80
|
activateComp.setLayoutData(gridData);
|
81
|
return activateComp;
|
82
|
}
|
83
|
|
84
|
|
85
|
protected GridData createTextGridData() {
|
86
|
GridData sepGrid = new GridData(GridData.FILL_HORIZONTAL);
|
87
|
sepGrid.horizontalSpan = 2;
|
88
|
return sepGrid;
|
89
|
}
|
90
|
|
91
|
protected void getValues(){
|
92
|
|
93
|
}
|
94
|
|
95
|
|
96
|
protected Button createAllowOverrideButton(Composite activateComp) {
|
97
|
final Button allowOverrideCheckButton = new Button(activateComp, SWT.CHECK);
|
98
|
String overrideString;
|
99
|
if (isAdminPreference){
|
100
|
overrideString = Messages.GeneralPreference_allowOverride;
|
101
|
}else{
|
102
|
overrideString = Messages.GeneralPreference_override;
|
103
|
}
|
104
|
allowOverrideCheckButton.setText(overrideString);
|
105
|
GridData grid = new GridData();
|
106
|
grid.horizontalAlignment = SWT.END;
|
107
|
allowOverrideCheckButton.setLayoutData(grid);
|
108
|
return allowOverrideCheckButton;
|
109
|
}
|
110
|
|
111
|
|
112
|
|
113
|
}
|