2 * Copyright (C) 2015 EDIT
3 * European Distributed Institute of Taxonomy
4 * http://www.e-taxonomy.eu
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.
9 package eu
.etaxonomy
.taxeditor
.preference
.menu
;
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
;
19 import eu
.etaxonomy
.taxeditor
.l10n
.Messages
;
20 import eu
.etaxonomy
.taxeditor
.preference
.IE4PreferencePage
;
21 import eu
.etaxonomy
.taxeditor
.preference
.PreferencesUtil
;
28 public abstract class CdmPreferencePage
extends PreferencePage
implements IE4PreferencePage
{
30 private boolean isApply
= false;
32 protected boolean isAdminPreference
;
35 public CdmPreferencePage() {
39 public CdmPreferencePage(String title
) {
43 public CdmPreferencePage(String title
, ImageDescriptor image
) {
52 setPreferenceStore(PreferencesUtil
.getPreferenceStore());
56 public void createControl(Composite parent
){
57 super.createControl(parent
);
58 if (getApplyButton() != null){
59 this.getApplyButton().setEnabled(false);
65 public boolean performOk() {
67 return super.performOk();
72 public boolean performCancel() {
74 return super.performCancel();
78 public void performApply() {
84 protected Composite
createComposite(Composite composite
) {
85 Composite activateComp
= new Composite(composite
, SWT
.NULL
);
86 GridLayout layout
= new GridLayout();
87 layout
.numColumns
= 2;
89 activateComp
.setLayout(layout
);
90 GridData gridData
= new GridData(GridData
.FILL_HORIZONTAL
);
92 activateComp
.setLayoutData(gridData
);
98 protected GridData
createTextGridData() {
99 GridData sepGrid
= new GridData(GridData
.FILL_HORIZONTAL
);
100 sepGrid
.horizontalSpan
= 2;
104 protected void getValues(){
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
;
115 overrideString
= Messages
.GeneralPreference_override
;
117 allowOverrideCheckButton
.setText(overrideString
);
118 GridData grid
= new GridData();
119 grid
.horizontalAlignment
= SWT
.END
;
120 allowOverrideCheckButton
.setLayoutData(grid
);
121 return allowOverrideCheckButton
;
124 public boolean isApply() {
128 public void setApply(boolean isApply
) {
129 this.isApply
= isApply
;
130 if (this.getApplyButton() != null){
131 this.getApplyButton().setEnabled(this.isApply
);