1
|
// $Id$
|
2
|
/**
|
3
|
* Copyright (C) 2007 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
|
|
11
|
package eu.etaxonomy.taxeditor.bulkeditor;
|
12
|
|
13
|
import java.util.HashMap;
|
14
|
import java.util.Map;
|
15
|
|
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;
|
23
|
|
24
|
import eu.etaxonomy.cdm.model.common.MarkerType;
|
25
|
import eu.etaxonomy.taxeditor.bulkeditor.input.AbstractBulkEditorInput;
|
26
|
import eu.etaxonomy.taxeditor.preference.PreferencesUtil;
|
27
|
import eu.etaxonomy.taxeditor.store.TermStore;
|
28
|
|
29
|
/**
|
30
|
* <p>BulkEditorMarkerPreferenceComposite class.</p>
|
31
|
*
|
32
|
* @author p.ciardelli
|
33
|
* @created 17.08.2009
|
34
|
* @version 1.0
|
35
|
*/
|
36
|
public class BulkEditorMarkerPreferenceComposite extends Composite {
|
37
|
private static final Logger logger = Logger.getLogger(BulkEditorMarkerPreferenceComposite.class);
|
38
|
|
39
|
private AbstractBulkEditorInput editorInput;
|
40
|
|
41
|
Map<Button, MarkerType> markerTypeButtons = new HashMap<Button, MarkerType>();
|
42
|
|
43
|
/**
|
44
|
* <p>Constructor for BulkEditorMarkerPreferenceComposite.</p>
|
45
|
*
|
46
|
* @param parent a {@link org.eclipse.swt.widgets.Composite} object.
|
47
|
* @param style a int.
|
48
|
* @param editorInput a {@link eu.etaxonomy.taxeditor.bulkeditor.input.AbstractBulkEditorInput} object.
|
49
|
*/
|
50
|
public BulkEditorMarkerPreferenceComposite(AbstractBulkEditorInput editorInput, Composite parent, int style) {
|
51
|
super(parent, style);
|
52
|
this.editorInput = editorInput;
|
53
|
createControl();
|
54
|
}
|
55
|
|
56
|
/**
|
57
|
* @param markerType
|
58
|
* @return
|
59
|
*
|
60
|
*/
|
61
|
private boolean getEditMarkerPreference(MarkerType markerType) {
|
62
|
return PreferencesUtil.getEditMarkerTypePreference(editorInput, markerType);
|
63
|
}
|
64
|
|
65
|
private void setEditMarkerPreference(MarkerType markerType, boolean edit) {
|
66
|
PreferencesUtil.setEditMarkerTypePreference(editorInput, markerType, edit);
|
67
|
}
|
68
|
|
69
|
/**
|
70
|
* <p>createControl</p>
|
71
|
*/
|
72
|
protected void createControl() {
|
73
|
|
74
|
GridLayout gridLayout = new GridLayout();
|
75
|
gridLayout.numColumns = 3;
|
76
|
gridLayout.marginHeight = 0;
|
77
|
gridLayout.marginWidth = 12;
|
78
|
setLayout(gridLayout);
|
79
|
|
80
|
for (final MarkerType markerType : TermStore.getNonTechnicalMarkerTypes()) {
|
81
|
if (editorInput.isMarkerTypeEditingEnabled(markerType)) {
|
82
|
final Button button = new Button(this, SWT.CHECK);
|
83
|
button.setText("Edit " + markerType.getLabel() + " markers");
|
84
|
button.addSelectionListener(new SelectionAdapter() {
|
85
|
public void widgetSelected(SelectionEvent e) {
|
86
|
setEditMarkerPreference(markerType, button.getSelection());
|
87
|
}
|
88
|
});
|
89
|
button.setSelection(getEditMarkerPreference(markerType));
|
90
|
|
91
|
markerTypeButtons.put(button, markerType);
|
92
|
}
|
93
|
}
|
94
|
}
|
95
|
}
|