2 * Copyright (C) 2007 EDIT
3 * European Distributed Institute of Taxonomy
4 * http://www.e-taxonomy.eu
6 * The contents of this file are subject to the Mozilla Public License Version 1.1
7 * See LICENSE.TXT at the top of this package for the full license terms.
9 package eu
.etaxonomy
.taxeditor
.preference
;
11 import java
.util
.ArrayList
;
12 import java
.util
.List
;
14 import org
.eclipse
.jface
.wizard
.WizardDialog
;
15 import org
.eclipse
.swt
.SWT
;
16 import org
.eclipse
.swt
.events
.MouseAdapter
;
17 import org
.eclipse
.swt
.events
.MouseEvent
;
18 import org
.eclipse
.swt
.layout
.GridData
;
19 import org
.eclipse
.swt
.widgets
.Button
;
20 import org
.eclipse
.swt
.widgets
.Composite
;
21 import org
.eclipse
.ui
.IWorkbenchPreferencePage
;
23 import eu
.etaxonomy
.cdm
.model
.description
.Feature
;
24 import eu
.etaxonomy
.taxeditor
.preference
.wizards
.FeatureWizard
;
25 import eu
.etaxonomy
.taxeditor
.store
.CdmStore
;
26 import eu
.etaxonomy
.taxeditor
.store
.StoreUtil
;
34 public class FeatureMenuPreferences
extends AbstractMenuPreferences
implements
35 IWorkbenchPreferencePage
{
37 public static final String PLUGIN_ID
= "eu.etaxonomy.taxeditor.preferences.feature";
38 private Button newButton
;
39 private Button editButton
;
40 private Button removeButton
;
42 public FeatureMenuPreferences() {
43 super(CdmStore
.getFeatures(), PreferencesUtil
.getPreferredFeatures(), "Feature Preferences", "Choose which features you would like to use for descriptive elements.");
48 * @see org.eclipse.jface.preference.PreferencePage#performOk()
50 public boolean performOk() {
51 List
<Feature
> preferredFeatures
= new ArrayList
<Feature
>();
52 for (Object element
: getTableViewer().getCheckedElements()){
53 preferredFeatures
.add((Feature
) element
);
56 PreferencesUtil
.setPreferredFeatures(preferredFeatures
);
62 * @see eu.etaxonomy.taxeditor.preference.AbstractMenuPreferences#createButtons(org.eclipse.swt.widgets.Composite)
65 protected void createButtons(Composite buttonContainer
) {
66 newButton
= new Button(buttonContainer
, SWT
.PUSH
);
67 newButton
.setText("New");
68 newButton
.setLayoutData(new GridData(SWT
.FILL
));
69 newButton
.addMouseListener(new MouseAdapter(){
72 * @see org.eclipse.swt.events.MouseAdapter#mouseUp(org.eclipse.swt.events.MouseEvent)
75 public void mouseUp(MouseEvent e
) {
77 FeatureWizard wizard
= new FeatureWizard();
79 WizardDialog dialog
= new WizardDialog(StoreUtil
.getShell(), wizard
);
82 tableViewer
.setInput(CdmStore
.getFeatures());
87 editButton
= new Button(buttonContainer
, SWT
.PUSH
);
88 editButton
.setText("Edit");
89 editButton
.setLayoutData(new GridData(SWT
.FILL
));
90 editButton
.addMouseListener(new MouseAdapter(){
93 * @see org.eclipse.swt.events.MouseAdapter#mouseUp(org.eclipse.swt.events.MouseEvent)
96 public void mouseUp(MouseEvent e
) {
99 StoreUtil
.notImplementedMessage();
101 // editing a feature is somewhat more complicated, because basically one can only edit the representation.
102 // Feature feature = (Feature) ((StructuredSelection) tableViewer.getSelection()).getFirstElement();
104 // FeatureWizard wizard = new FeatureWizard(feature);
106 // WizardDialog dialog = new WizardDialog(StoreUtil.getShell(), wizard);
109 // tableViewer.setInput(CdmStore.getFeatures());
114 removeButton
= new Button(buttonContainer
, SWT
.PUSH
);
115 removeButton
.setText("Remove");
116 removeButton
.setLayoutData(new GridData(SWT
.FILL
));
117 removeButton
.addMouseListener(new MouseAdapter(){
120 * @see org.eclipse.swt.events.MouseAdapter#mouseUp(org.eclipse.swt.events.MouseEvent)
123 public void mouseUp(MouseEvent e
) {
125 StoreUtil
.notImplementedMessage();