3 * Copyright (C) 2007 EDIT
4 * European Distributed Institute of Taxonomy
5 * http://www.e-taxonomy.eu
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.
11 package eu
.etaxonomy
.taxeditor
.bulkeditor
;
13 import java
.util
.HashMap
;
16 import org
.apache
.log4j
.Logger
;
17 import org
.eclipse
.swt
.SWT
;
18 import org
.eclipse
.swt
.events
.SelectionAdapter
;
19 import org
.eclipse
.swt
.events
.SelectionEvent
;
20 import org
.eclipse
.swt
.layout
.GridLayout
;
21 import org
.eclipse
.swt
.widgets
.Button
;
22 import org
.eclipse
.swt
.widgets
.Composite
;
24 import eu
.etaxonomy
.cdm
.model
.common
.MarkerType
;
25 import eu
.etaxonomy
.taxeditor
.bulkeditor
.input
.BulkEditorInput
;
26 import eu
.etaxonomy
.taxeditor
.preference
.PreferencesUtil
;
27 import eu
.etaxonomy
.taxeditor
.store
.VocabularyStore
;
34 public class BulkEditorMarkerPreferenceComposite
extends Composite
{
35 private static final Logger logger
= Logger
.getLogger(BulkEditorMarkerPreferenceComposite
.class);
37 private BulkEditorInput editorInput
;
39 Map
<Button
, MarkerType
> markerTypeButtons
= new HashMap
<Button
, MarkerType
>();
45 public BulkEditorMarkerPreferenceComposite(BulkEditorInput editorInput
, Composite parent
, int style
) {
47 this.editorInput
= editorInput
;
56 private boolean getEditMarkerPreference(MarkerType markerType
) {
57 return PreferencesUtil
.getEditMarkerTypePreference(editorInput
, markerType
);
60 private void setEditMarkerPreference(MarkerType markerType
, boolean edit
) {
61 PreferencesUtil
.setEditMarkerTypePreference(editorInput
, markerType
, edit
);
64 protected void createControl() {
66 GridLayout gridLayout
= new GridLayout();
67 gridLayout
.numColumns
= 3;
68 gridLayout
.marginHeight
= 0;
69 gridLayout
.marginWidth
= 12;
70 setLayout(gridLayout
);
72 for (final MarkerType markerType
: VocabularyStore
.getNonTechnicalMarkerTypes()) {
73 if (editorInput
.isMarkerTypeEditingEnabled(markerType
)) {
74 final Button button
= new Button(this, SWT
.CHECK
);
75 button
.setText("Edit " + markerType
.getLabel() + " markers");
76 button
.addSelectionListener(new SelectionAdapter() {
77 public void widgetSelected(SelectionEvent e
) {
78 setEditMarkerPreference(markerType
, button
.getSelection());
81 button
.setSelection(getEditMarkerPreference(markerType
));
83 markerTypeButtons
.put(button
, markerType
);