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 = false;
|
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
|
|
50
|
|
51
|
public void init() {
|
52
|
setPreferenceStore(PreferencesUtil.getPreferenceStore());
|
53
|
}
|
54
|
|
55
|
@Override
|
56
|
public void createControl(Composite parent){
|
57
|
super.createControl(parent);
|
58
|
if (getApplyButton() != null){
|
59
|
this.getApplyButton().setEnabled(false);
|
60
|
}
|
61
|
|
62
|
}
|
63
|
|
64
|
@Override
|
65
|
public boolean performOk() {
|
66
|
if (isValid()){
|
67
|
return super.performOk();
|
68
|
}return false;
|
69
|
}
|
70
|
|
71
|
@Override
|
72
|
public boolean performCancel() {
|
73
|
|
74
|
return super.performCancel();
|
75
|
}
|
76
|
|
77
|
@Override
|
78
|
public void performApply() {
|
79
|
setApply(true);
|
80
|
super.performApply();
|
81
|
setApply(false);
|
82
|
}
|
83
|
|
84
|
protected Composite createComposite(Composite composite) {
|
85
|
Composite activateComp = new Composite(composite, SWT.NULL);
|
86
|
GridLayout layout = new GridLayout();
|
87
|
layout.numColumns = 2;
|
88
|
|
89
|
activateComp.setLayout(layout);
|
90
|
GridData gridData = new GridData(GridData.FILL_HORIZONTAL);
|
91
|
|
92
|
activateComp.setLayoutData(gridData);
|
93
|
|
94
|
return activateComp;
|
95
|
}
|
96
|
|
97
|
|
98
|
protected GridData createTextGridData() {
|
99
|
GridData sepGrid = new GridData(GridData.FILL_HORIZONTAL);
|
100
|
sepGrid.horizontalSpan = 2;
|
101
|
return sepGrid;
|
102
|
}
|
103
|
|
104
|
protected void getValues(){
|
105
|
|
106
|
}
|
107
|
|
108
|
|
109
|
protected Button createAllowOverrideButton(Composite activateComp) {
|
110
|
final Button allowOverrideCheckButton = new Button(activateComp, SWT.CHECK);
|
111
|
String overrideString;
|
112
|
if (isAdminPreference){
|
113
|
overrideString = Messages.GeneralPreference_allowOverride;
|
114
|
}else{
|
115
|
overrideString = Messages.GeneralPreference_override;
|
116
|
}
|
117
|
allowOverrideCheckButton.setText(overrideString);
|
118
|
GridData grid = new GridData();
|
119
|
grid.horizontalAlignment = SWT.END;
|
120
|
allowOverrideCheckButton.setLayoutData(grid);
|
121
|
return allowOverrideCheckButton;
|
122
|
}
|
123
|
|
124
|
public boolean isApply() {
|
125
|
return isApply;
|
126
|
}
|
127
|
|
128
|
public void setApply(boolean isApply) {
|
129
|
this.isApply = isApply;
|
130
|
if (this.getApplyButton() != null){
|
131
|
this.getApplyButton().setEnabled(this.isApply);
|
132
|
}
|
133
|
}
|
134
|
|
135
|
|
136
|
|
137
|
}
|