Merge branch 'release/4.7.0'
[taxeditor.git] / eu.etaxonomy.taxeditor.store / src / main / java / eu / etaxonomy / taxeditor / databaseAdmin / wizard / NameDetailsViewComposite.java
1 /**
2 * Copyright (C) 2017 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.databaseAdmin.wizard;
10
11 import org.eclipse.jface.preference.IPreferenceStore;
12 import org.eclipse.swt.SWT;
13 import org.eclipse.swt.events.SelectionAdapter;
14 import org.eclipse.swt.events.SelectionEvent;
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.preference.IPreferenceKeys;
20 import eu.etaxonomy.taxeditor.preference.NameDetailsConfigurator;
21 import eu.etaxonomy.taxeditor.preference.PreferencesUtil;
22
23 /**
24 * @author k.luther
25 * @date 22.02.2017
26 *
27 */
28 public class NameDetailsViewComposite extends Composite {
29
30 NameDetailsConfigurator config;
31 boolean isSimpleDetailsViewActivated;
32 boolean isShowTaxon;
33 boolean isShowLSID;
34 boolean isShowNomenclaturalCode;
35 boolean isShowNameCache;
36 boolean isShowAppendedPhrase;
37 boolean isShowRank;
38 boolean isShowEpithets;
39 boolean isShowAuthorshipCache;
40 boolean isShowAuthorship;
41 boolean isShowNomenclaturalRef;
42 boolean isShowNomenclaturalStatus;
43 boolean isShowProtologue;
44 boolean isShowTypeDesignation;
45 boolean isShowNameRelationship;
46 Composite child;
47
48 public NameDetailsViewComposite(Composite parent, int style, NameDetailsConfigurator config){
49
50 super(parent, style);
51 // TabItem tbtmNameDetailsConfiguration = new TabItem(tabFolder, SWT.NONE);
52 // Composite c2 = new Composite(tabFolder, SWT.BORDER);
53 // c2.setLayout(new GridLayout(1, true));
54 // tbtmNameDetailsConfiguration.setControl(c2);
55 // composite.setLayout(new GridLayout(1, true));
56 this.config = config;
57
58 // Composite composite = new Composite(parent, SWT.NULL);
59 this.setLayout(new GridLayout());
60
61 isSimpleDetailsViewActivated= PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.SHOW_SIMPLE_NAME_DETAILS_SECTION);
62 final Button activateCheckButton = new Button(this, SWT.CHECK);
63 activateCheckButton.setText("Show only a simple name details view");
64 activateCheckButton.setSelection(isSimpleDetailsViewActivated);
65 activateCheckButton.addSelectionListener(new SelectionAdapter(){
66 @Override
67 public void widgetSelected(SelectionEvent e) {
68 isSimpleDetailsViewActivated = activateCheckButton.getSelection();
69 //
70 if(isSimpleDetailsViewActivated){
71 child.setVisible(true);
72 child.setEnabled(true);
73 }else{
74 child.setVisible(false);
75 child.setEnabled(false);
76 }
77 }
78 });
79
80 child = new Composite(this, SWT.NULL);
81 child.setLayout(new GridLayout());
82 child.setVisible(isSimpleDetailsViewActivated);
83
84 final Button showTaxon = new Button(child, SWT.CHECK);
85 isShowTaxon = PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.SHOW_SIMPLE_NAME_DETAILS_TAXON);
86 showTaxon.setText("Show taxon of the name");
87 showTaxon.setSelection(isShowTaxon);
88 showTaxon.addSelectionListener(new SelectionAdapter(){
89 @Override
90 public void widgetSelected(SelectionEvent e) {
91 isShowTaxon = showTaxon.getSelection();
92
93 }
94 });
95
96 final Button showLsid = new Button(child, SWT.CHECK);
97 isShowLSID = PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_LSID);
98 showLsid.setText("Show Lsid of the name");
99 showLsid.setSelection(isShowLSID);
100 showLsid.addSelectionListener(new SelectionAdapter(){
101 @Override
102 public void widgetSelected(SelectionEvent e) {
103 isShowLSID = showLsid.getSelection();
104
105 }
106 });
107
108 final Button showNomenclaturalCode = new Button(child, SWT.CHECK);
109 isShowNomenclaturalCode = PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_NOMENCLATURAL_CODE);
110 showNomenclaturalCode.setText("Show the nomenclatural code");
111 showNomenclaturalCode.setSelection(isShowNomenclaturalCode);
112 showNomenclaturalCode.addSelectionListener(new SelectionAdapter(){
113 @Override
114 public void widgetSelected(SelectionEvent e) {
115 isShowNomenclaturalCode = showNomenclaturalCode.getSelection();
116
117 }
118 });
119
120 final Button showNameCache = new Button(child, SWT.CHECK);
121 isShowNameCache= PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_NAMECACHE);
122 showNameCache.setText("Show nameCache of the name (only the scientific name without the author and year)");
123 showNameCache.setSelection(isShowNomenclaturalCode);
124 showNameCache.addSelectionListener(new SelectionAdapter(){
125 @Override
126 public void widgetSelected(SelectionEvent e) {
127 isShowNameCache = showNameCache.getSelection();
128
129 }
130 });
131 final Button showAppendedPhrase = new Button(child, SWT.CHECK);
132 isShowAppendedPhrase= PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_APPENDED_PHRASE);
133 showAppendedPhrase.setText("Show appended phrase");
134 showAppendedPhrase.setSelection(isShowAppendedPhrase);
135 showAppendedPhrase.addSelectionListener(new SelectionAdapter(){
136 @Override
137 public void widgetSelected(SelectionEvent e) {
138 isShowAppendedPhrase = showAppendedPhrase.getSelection();
139
140 }
141 });
142
143 final Button showRank = new Button(child, SWT.CHECK);
144 isShowRank = PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_RANK);
145 showRank.setText("Show rank of the name");
146 showRank.setSelection(isShowRank);
147 showRank.addSelectionListener(new SelectionAdapter(){
148 @Override
149 public void widgetSelected(SelectionEvent e) {
150 isShowRank = showRank.getSelection();
151
152 }
153 });
154 final Button showEpithets = new Button(child, SWT.CHECK);
155 isShowEpithets = PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_ATOMISED_EPITHETS);
156 showEpithets.setText("Show atomised epithets");
157 showEpithets.setSelection(isShowEpithets);
158 showEpithets.addSelectionListener(new SelectionAdapter(){
159 @Override
160 public void widgetSelected(SelectionEvent e) {
161 isShowEpithets = showEpithets.getSelection();
162
163 }
164 });
165 final Button showAuthorshipCache = new Button(child, SWT.CHECK);
166 isShowAuthorshipCache= PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_AUTHORSHIP_CACHE);
167 showAuthorshipCache.setText("Show authorship cache");
168 showAuthorshipCache.setSelection(isShowAuthorshipCache);
169 showAuthorshipCache.addSelectionListener(new SelectionAdapter(){
170 @Override
171 public void widgetSelected(SelectionEvent e) {
172 isShowAuthorshipCache = showAuthorshipCache.getSelection();
173
174 }
175 });
176
177 final Button showAuthorship = new Button(child, SWT.CHECK);
178 isShowAuthorship = PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_AUTHORSHIP);
179 showAuthorship.setText("Show authorship section");
180 showAuthorship.setSelection(isShowAuthorship);
181 showAuthorship.addSelectionListener(new SelectionAdapter(){
182 @Override
183 public void widgetSelected(SelectionEvent e) {
184 isShowAuthorship = showAuthorship.getSelection();
185
186 }
187 });
188
189 final Button showNomenclaturalRef = new Button(child, SWT.CHECK);
190 isShowNomenclaturalRef = PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_NOMENCLATURAL_REFERENCE);
191 showNomenclaturalRef.setText("Show nomenclatural reference section");
192 showNomenclaturalRef.setSelection(isShowNomenclaturalRef);
193 showNomenclaturalRef.addSelectionListener(new SelectionAdapter(){
194 @Override
195 public void widgetSelected(SelectionEvent e) {
196 isShowNomenclaturalRef = showNomenclaturalRef.getSelection();
197
198 }
199 });
200
201 final Button showNomenclaturalStatus = new Button(child, SWT.CHECK);
202 isShowNomenclaturalStatus = PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_NOMENCLATURAL_STATUS);
203 showNomenclaturalStatus.setText("Show nomenclatural status section");
204 showNomenclaturalStatus.setSelection(isShowNomenclaturalStatus);
205 showNomenclaturalStatus.addSelectionListener(new SelectionAdapter(){
206 @Override
207 public void widgetSelected(SelectionEvent e) {
208 isShowNomenclaturalStatus = showNomenclaturalStatus.getSelection();
209
210 }
211 });
212
213 final Button showProtologue = new Button(child, SWT.CHECK);
214 isShowProtologue = PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_PROTOLOGUE);
215 showProtologue.setText("Show protologue section");
216 showProtologue.setSelection(isShowProtologue);
217 showProtologue.addSelectionListener(new SelectionAdapter(){
218 @Override
219 public void widgetSelected(SelectionEvent e) {
220 isShowProtologue = showProtologue.getSelection();
221
222 }
223 });
224
225 final Button showTypeDesignation = new Button(child, SWT.CHECK);
226 isShowTypeDesignation = PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_TYPE_DESIGNATION);
227 showTypeDesignation.setText("Show name type designation section");
228 showTypeDesignation.setSelection(isShowTypeDesignation);
229 showTypeDesignation.addSelectionListener(new SelectionAdapter(){
230 @Override
231 public void widgetSelected(SelectionEvent e) {
232 isShowTypeDesignation = showTypeDesignation.getSelection();
233
234 }
235 });
236
237
238 final Button showNameRelationship = new Button(child, SWT.CHECK);
239 isShowNameRelationship = PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_NAME_RELATIONSHIP);
240 showNameRelationship.setText("Show name relationship section");
241 showNameRelationship.setSelection(isShowNameRelationship);
242 showNameRelationship.addSelectionListener(new SelectionAdapter(){
243 @Override
244 public void widgetSelected(SelectionEvent e) {
245 isShowNameRelationship = showNameRelationship.getSelection();
246
247 }
248 });
249
250 if(isSimpleDetailsViewActivated){
251 child.setEnabled(true);
252 }else{
253 child.setEnabled(false);
254 }
255
256 }
257
258 /**
259 *
260 */
261 protected NameDetailsConfigurator createNameDetailsViewConfig() {
262 saveConfigToPrefernceStore();
263
264 config.setSimpleDetailsViewActivated(doGetPreferenceStore().getBoolean(IPreferenceKeys.SHOW_SIMPLE_NAME_DETAILS_SECTION));
265 config.setAppendedPhraseActivated(doGetPreferenceStore().getBoolean(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_APPENDED_PHRASE));
266 config.setAtomisedEpithetsActivated(doGetPreferenceStore().getBoolean(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_ATOMISED_EPITHETS));
267 config.setAuthorshipSectionActivated(doGetPreferenceStore().getBoolean(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_AUTHORSHIP));
268 config.setLSIDActivated(doGetPreferenceStore().getBoolean(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_LSID));
269 config.setNameCacheActivated(doGetPreferenceStore().getBoolean(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_CACHE));
270 config.setNameRelationsSectionActivated(doGetPreferenceStore().getBoolean(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_NAME_RELATIONSHIP));
271 config.setNomenclaturalCodeActived(doGetPreferenceStore().getBoolean(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_NOMENCLATURAL_CODE));
272 config.setNomenclaturalStatusSectionActivated(doGetPreferenceStore().getBoolean(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_NOMENCLATURAL_STATUS));
273 config.setNomenclaturalReferenceSectionActivated(doGetPreferenceStore().getBoolean(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_NOMENCLATURAL_REFERENCE));
274 config.setProtologueActivated(doGetPreferenceStore().getBoolean(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_PROTOLOGUE));
275 config.setRankActivated(doGetPreferenceStore().getBoolean(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_RANK));
276 config.setSimpleDetailsViewActivated(doGetPreferenceStore().getBoolean(IPreferenceKeys.SHOW_SIMPLE_NAME_DETAILS_SECTION));
277 config.setTaxonSectionActivated(doGetPreferenceStore().getBoolean(IPreferenceKeys.SHOW_SIMPLE_NAME_DETAILS_TAXON));
278 config.setTypeDesignationSectionActivated(doGetPreferenceStore().getBoolean(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_TYPE_DESIGNATION));
279 return config;
280 }
281
282 /**
283 *
284 */
285 private void saveConfigToPrefernceStore() {
286 PreferencesUtil.getPreferenceStore().setValue(IPreferenceKeys.SHOW_SIMPLE_NAME_DETAILS_SECTION,
287 isSimpleDetailsViewActivated);
288 PreferencesUtil.getPreferenceStore().setValue(IPreferenceKeys.SHOW_SIMPLE_NAME_DETAILS_TAXON, isShowTaxon);
289 PreferencesUtil.getPreferenceStore().setValue(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_LSID, isShowLSID);
290 PreferencesUtil.getPreferenceStore().setValue(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_NOMENCLATURAL_CODE,
291 isShowNomenclaturalCode);
292 PreferencesUtil.getPreferenceStore().setValue(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_NAMECACHE,
293 isShowNameCache);
294 PreferencesUtil.getPreferenceStore().setValue(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_APPENDED_PHRASE,
295 isShowAppendedPhrase);
296 PreferencesUtil.getPreferenceStore().setValue(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_RANK, isShowRank);
297 PreferencesUtil.getPreferenceStore().setValue(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_ATOMISED_EPITHETS,
298 isShowEpithets);
299 PreferencesUtil.getPreferenceStore().setValue(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_AUTHORSHIP_CACHE,
300 isShowAuthorshipCache);
301 PreferencesUtil.getPreferenceStore().setValue(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_AUTHORSHIP,
302 isShowAuthorship);
303 PreferencesUtil.getPreferenceStore().setValue(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_NOMENCLATURAL_REFERENCE,
304 isShowNomenclaturalRef);
305 PreferencesUtil.getPreferenceStore().setValue(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_NOMENCLATURAL_STATUS,
306 isShowNomenclaturalStatus);
307 PreferencesUtil.getPreferenceStore().setValue(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_PROTOLOGUE,
308 isShowProtologue);
309 PreferencesUtil.getPreferenceStore().setValue(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_TYPE_DESIGNATION,
310 isShowTypeDesignation);
311 PreferencesUtil.getPreferenceStore().setValue(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_NAME_RELATIONSHIP,
312 isShowNameRelationship);
313
314 }
315
316 protected IPreferenceStore doGetPreferenceStore() {
317 return PreferencesUtil.getPreferenceStore();
318 }
319
320 }