ca82b0e1920760826e2e799c498a8ad6b09f5dcc
[taxeditor.git] / eu.etaxonomy.taxeditor.store / src / main / java / eu / etaxonomy / taxeditor / preference / ChecklistEditorGeneralPreference.java
1 // $Id$
2 /**
3 * Copyright (C) 2014 EDIT
4 * European Distributed Institute of Taxonomy
5 * http://www.e-taxonomy.eu
6 *
7 * The contents of this file are subject to the Mozilla Public License Version 1.1
8 * See LICENSE.TXT at the top of this package for the full license terms.
9 */
10 package eu.etaxonomy.taxeditor.preference;
11
12 import org.eclipse.jface.preference.PreferencePage;
13 import org.eclipse.swt.SWT;
14 import org.eclipse.swt.custom.CLabel;
15 import org.eclipse.swt.events.SelectionAdapter;
16 import org.eclipse.swt.events.SelectionEvent;
17 import org.eclipse.swt.layout.GridLayout;
18 import org.eclipse.swt.widgets.Button;
19 import org.eclipse.swt.widgets.Composite;
20 import org.eclipse.swt.widgets.Control;
21 import org.eclipse.ui.IWorkbench;
22 import org.eclipse.ui.IWorkbenchPreferencePage;
23
24 import eu.etaxonomy.taxeditor.ui.element.CommandHandlerButton;
25
26 /**
27 * @author a.oppermann
28 * @date 21.07.2014
29 *
30 */
31 public class ChecklistEditorGeneralPreference extends PreferencePage implements IWorkbenchPreferencePage {
32
33 boolean isEditorActivated;
34 Composite child ;
35 /*
36 * (non-Javadoc)
37 *
38 * @see
39 * org.eclipse.jface.preference.FieldEditorPreferencePage#createFieldEditors
40 * ()
41 */
42 @Override
43 protected Control createContents(Composite parent) {
44
45 Composite composite = new Composite(parent, SWT.NULL);
46 composite.setLayout(new GridLayout());
47 isEditorActivated = PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.DISTRIBUTION_AREA_PREFRENCES_ACTIVE);
48 final Button activateCheckButton = new Button(composite, SWT.CHECK);
49 activateCheckButton.setText("Enable Checklist Editor");
50 activateCheckButton.setSelection(isEditorActivated);
51 activateCheckButton.addSelectionListener(new SelectionAdapter(){
52 @Override
53 public void widgetSelected(SelectionEvent e) {
54 isEditorActivated = activateCheckButton.getSelection();
55 PreferencesUtil.getPreferenceStore().setValue(IPreferenceKeys.DISTRIBUTION_AREA_PREFRENCES_ACTIVE, isEditorActivated);
56 if(isEditorActivated){
57 child.setVisible(true);
58 child.setEnabled(true);
59 }else{
60 child.setVisible(false);
61 child.setEnabled(false);
62 }
63
64 }
65 });
66
67 child = new Composite(composite, SWT.NULL);
68 child.setLayout(new GridLayout());
69 child.setVisible(isEditorActivated);
70 final CLabel label = new CLabel(child, SWT.NULL);
71 label.setText("Please open the wizard below, in order to \n" + "choose the areas for the Checklist Editor");
72 final CommandHandlerButton button_openFeatureTree = new CommandHandlerButton(child, SWT.PUSH,
73 "eu.etaxonomy.taxeditor.store.open.OpenDistributionEditorWizardHandler");
74
75 button_openFeatureTree.setText("Open Distribution Selection Wizard");
76 if(isEditorActivated){
77 child.setEnabled(true);
78 }else{
79 child.setEnabled(false);
80 }
81
82 return composite;
83 }
84
85 /*
86 * (non-Javadoc)
87 *
88 * @see
89 * org.eclipse.ui.IWorkbenchPreferencePage#init(org.eclipse.ui.IWorkbench)
90 */
91 @Override
92 public void init(IWorkbench workbench) {
93 }
94
95 }