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
.preference
;
13 import java
.util
.HashMap
;
16 import org
.eclipse
.jface
.preference
.PreferencePage
;
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 import org
.eclipse
.swt
.widgets
.Control
;
24 import org
.eclipse
.ui
.IWorkbench
;
25 import org
.eclipse
.ui
.IWorkbenchPreferencePage
;
27 import eu
.etaxonomy
.cdm
.model
.common
.MarkerType
;
28 import eu
.etaxonomy
.taxeditor
.model
.MessagingUtils
;
29 import eu
.etaxonomy
.taxeditor
.preference
.PreferencesUtil
;
30 import eu
.etaxonomy
.taxeditor
.store
.CdmStore
;
31 import eu
.etaxonomy
.taxeditor
.store
.TermStore
;
34 * <p>BulkEditorMarkerPreferenceComposite class.</p>
40 public class BulkEditorMarkerPreferencePage
extends PreferencePage
implements IWorkbenchPreferencePage
{
42 private Map
<MarkerType
, Boolean
> markerTypeEditingMap
= new HashMap
<MarkerType
, Boolean
>();
45 * @see org.eclipse.ui.IWorkbenchPreferencePage#init(org.eclipse.ui.IWorkbench)
48 public void init(IWorkbench workbench
) {
49 setPreferenceStore(PreferencesUtil
.getPreferenceStore());
50 if(!CdmStore
.isActive()) {
51 MessagingUtils
.noDataSourceWarningDialog(null);
53 markerTypeEditingMap
= PreferencesUtil
.getEditMarkerTypePreferences();
58 * @see org.eclipse.jface.preference.PreferencePage#createContents(org.eclipse.swt.widgets.Composite)
61 protected Control
createContents(Composite parent
) {
62 Composite container
= new Composite(parent
, SWT
.NULL
);
63 container
.setLayout(new GridLayout());
64 if(CdmStore
.isActive()){
65 for (final MarkerType markerType
: TermStore
.getTerms(MarkerType
.class)) {
66 final Button button
= new Button(container
, SWT
.CHECK
);
67 button
.setText(String
.format("Edit '%s' markers", markerType
.getLabel()));
69 button
.addSelectionListener(new SelectionAdapter() {
71 public void widgetSelected(SelectionEvent e
) {
72 markerTypeEditingMap
.put(markerType
, button
.getSelection());
76 boolean edit
= markerTypeEditingMap
.get(markerType
) == null ?
true : markerTypeEditingMap
.get(markerType
);
78 button
.setSelection(edit
);
85 * @see org.eclipse.jface.preference.PreferencePage#performOk()
88 public boolean performOk() {
89 PreferencesUtil
.setEditMarkerTypePreferences(markerTypeEditingMap
);
91 return super.performOk();