Revision 3be6ef3e
Added by Niels Hoffmann over 13 years ago
taxeditor-bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/BulkEditorMarkerPreferenceComposite.java | ||
---|---|---|
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 |
* @author p.ciardelli |
|
31 |
* @created 17.08.2009 |
|
32 |
* @version 1.0 |
|
33 |
*/ |
|
34 |
public class BulkEditorMarkerPreferenceComposite extends Composite { |
|
35 |
private static final Logger logger = Logger.getLogger(BulkEditorMarkerPreferenceComposite.class); |
|
36 |
|
|
37 |
private AbstractBulkEditorInput editorInput; |
|
38 |
|
|
39 |
Map<Button, MarkerType> markerTypeButtons = new HashMap<Button, MarkerType>(); |
|
40 |
|
|
41 |
/** |
|
42 |
* @param parent |
|
43 |
* @param style |
|
44 |
*/ |
|
45 |
public BulkEditorMarkerPreferenceComposite(AbstractBulkEditorInput editorInput, Composite parent, int style) { |
|
46 |
super(parent, style); |
|
47 |
this.editorInput = editorInput; |
|
48 |
createControl(); |
|
49 |
} |
|
50 |
|
|
51 |
/** |
|
52 |
* @param markerType |
|
53 |
* @return |
|
54 |
* |
|
55 |
*/ |
|
56 |
private boolean getEditMarkerPreference(MarkerType markerType) { |
|
57 |
return PreferencesUtil.getEditMarkerTypePreference(editorInput, markerType); |
|
58 |
} |
|
59 |
|
|
60 |
private void setEditMarkerPreference(MarkerType markerType, boolean edit) { |
|
61 |
PreferencesUtil.setEditMarkerTypePreference(editorInput, markerType, edit); |
|
62 |
} |
|
63 |
|
|
64 |
protected void createControl() { |
|
65 |
|
|
66 |
GridLayout gridLayout = new GridLayout(); |
|
67 |
gridLayout.numColumns = 3; |
|
68 |
gridLayout.marginHeight = 0; |
|
69 |
gridLayout.marginWidth = 12; |
|
70 |
setLayout(gridLayout); |
|
71 |
|
|
72 |
for (final MarkerType markerType : TermStore.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()); |
|
79 |
} |
|
80 |
}); |
|
81 |
button.setSelection(getEditMarkerPreference(markerType)); |
|
82 |
|
|
83 |
markerTypeButtons.put(button, markerType); |
|
84 |
} |
|
85 |
} |
|
86 |
} |
|
87 |
} |
|
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 |
} |
Also available in: Unified diff
performed javacscript:fix and worked on documentation