// $Id$
/**
* Copyright (C) 2007 EDIT
-* European Distributed Institute of Taxonomy
+* European Distributed Institute of Taxonomy
* http://www.e-taxonomy.eu
-*
+*
* The contents of this file are subject to the Mozilla Public License Version 1.1
* See LICENSE.TXT at the top of this package for the full license terms.
*/
package eu.etaxonomy.taxeditor.bulkeditor.preference;
-import java.util.HashMap;
-import java.util.Map;
-
-import org.eclipse.jface.preference.PreferencePage;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
+import org.eclipse.jface.preference.BooleanFieldEditor;
+import org.eclipse.jface.preference.FieldEditorPreferencePage;
import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.IWorkbenchPreferencePage;
import eu.etaxonomy.cdm.model.common.MarkerType;
+import eu.etaxonomy.taxeditor.model.MessagingUtils;
+import eu.etaxonomy.taxeditor.preference.IPreferenceKeys;
import eu.etaxonomy.taxeditor.preference.PreferencesUtil;
+import eu.etaxonomy.taxeditor.store.CdmStore;
import eu.etaxonomy.taxeditor.store.TermStore;
/**
- * <p>BulkEditorMarkerPreferenceComposite class.</p>
- *
* @author p.ciardelli
* @created 17.08.2009
* @version 1.0
*/
-public class BulkEditorMarkerPreferencePage extends PreferencePage implements IWorkbenchPreferencePage {
+public class BulkEditorMarkerPreferencePage extends FieldEditorPreferencePage implements IWorkbenchPreferencePage {
- private Map<MarkerType, Boolean> markerTypeEditingMap = new HashMap<MarkerType, Boolean>();
- /* (non-Javadoc)
- * @see org.eclipse.ui.IWorkbenchPreferencePage#init(org.eclipse.ui.IWorkbench)
- */
@Override
public void init(IWorkbench workbench) {
setPreferenceStore(PreferencesUtil.getPreferenceStore());
- markerTypeEditingMap = PreferencesUtil.getEditMarkerTypePreferences();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.preference.PreferencePage#createContents(org.eclipse.swt.widgets.Composite)
- */
- @Override
- protected Control createContents(Composite parent) {
- Composite container = new Composite(parent, SWT.NULL);
- container.setLayout(new GridLayout());
-
- for (final MarkerType markerType : TermStore.getNonTechnicalMarkerTypes()) {
- final Button button = new Button(container, SWT.CHECK);
- button.setText(String.format("Edit '%s' markers", markerType.getLabel()));
-
- button.addSelectionListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- markerTypeEditingMap.put(markerType, button.getSelection());
- }
- });
-
- boolean edit = markerTypeEditingMap.get(markerType) == null ? true : markerTypeEditingMap.get(markerType);
-
- button.setSelection(edit);
+ if(!CdmStore.isActive()) {
+ MessagingUtils.noDataSourceWarningDialog(null);
}
-
- return container;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.preference.PreferencePage#performOk()
- */
- @Override
- public boolean performOk() {
- PreferencesUtil.setEditMarkerTypePreferences(markerTypeEditingMap);
-
- return super.performOk();
}
+
+ @Override
+ protected void createFieldEditors() {
+ if(CdmStore.isActive()){
+ for (final MarkerType markerType : TermStore.getTerms(MarkerType.class)) {
+ addField(new BooleanFieldEditor(IPreferenceKeys.EDIT_MARKER_TYPE_PREFIX
+ + markerType.getClass().getName() + markerType.getLabel(), String.format("Edit '%s' markers",
+ markerType.getLabel()), getFieldEditorParent()));
+ }
+ }
+
+ }
}