smaller changes in preferences
[taxeditor.git] / eu.etaxonomy.taxeditor.store / src / main / java / eu / etaxonomy / taxeditor / preference / menu / CdmPreferencePage.java
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 activateComp.setLayout(layout);
89 GridData gridData = new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_FILL);
90
91 activateComp.setLayoutData(gridData);
92 return activateComp;
93 }
94
95
96 protected GridData createTextGridData() {
97 GridData sepGrid = new GridData(GridData.FILL_HORIZONTAL);
98 sepGrid.horizontalSpan = 2;
99 return sepGrid;
100 }
101
102 protected void getValues(){
103
104 }
105
106
107 protected Button createAllowOverrideButton(Composite activateComp) {
108 final Button allowOverrideCheckButton = new Button(activateComp, SWT.CHECK);
109 String overrideString;
110 if (isAdminPreference){
111 overrideString = Messages.GeneralPreference_allowOverride;
112 }else{
113 overrideString = Messages.GeneralPreference_override;
114 }
115 allowOverrideCheckButton.setText(overrideString);
116 GridData grid = new GridData();
117 grid.horizontalAlignment = SWT.END;
118 allowOverrideCheckButton.setLayoutData(grid);
119 return allowOverrideCheckButton;
120 }
121
122 public boolean isApply() {
123 return isApply;
124 }
125
126 public void setApply(boolean isApply) {
127 this.isApply = isApply;
128 if (this.getApplyButton() != null){
129 this.getApplyButton().setEnabled(this.isApply);
130 }
131 }
132
133
134
135 }