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
.menu
;
11 import org
.eclipse
.core
.runtime
.IStatus
;
12 import org
.eclipse
.jface
.viewers
.StructuredSelection
;
13 import org
.eclipse
.jface
.wizard
.WizardDialog
;
14 import org
.eclipse
.swt
.events
.SelectionAdapter
;
15 import org
.eclipse
.swt
.events
.SelectionEvent
;
17 import eu
.etaxonomy
.cdm
.model
.description
.Feature
;
18 import eu
.etaxonomy
.taxeditor
.preference
.wizard
.VocabularyTermWizard
;
19 import eu
.etaxonomy
.taxeditor
.store
.StoreUtil
;
20 import eu
.etaxonomy
.taxeditor
.store
.TermStore
;
23 * <p>FeatureMenuPreferences class.</p>
30 public class FeatureMenuPreferences
extends AbstractMenuPreferences
<Feature
> {
32 /** Constant <code>PLUGIN_ID="eu.etaxonomy.taxeditor.preferences.feat"{trunked}</code> */
33 public static final String PLUGIN_ID
= "eu.etaxonomy.taxeditor.preferences.feature";
36 * <p>Constructor for FeatureMenuPreferences.</p>
38 public FeatureMenuPreferences() {
39 super(TermStore
.getFeatures(),
40 "Feature Preferences",
41 "Choose which features you would like to use for descriptive elements.",
46 * @see eu.etaxonomy.taxeditor.preference.AbstractMenuPreferences#addEditButtonListeners()
48 * TODO refactor into superclass
52 protected void addNewButtonListeners() {
53 newButton
.addSelectionListener(new SelectionAdapter(){
55 * @see org.eclipse.swt.events.SelectionAdapter#widgetSelected(org.eclipse.swt.events.SelectionEvent)
58 public void widgetSelected(SelectionEvent e
) {
59 super.widgetSelected(e
);
60 VocabularyTermWizard
<Feature
> wizard
= new VocabularyTermWizard
<Feature
>(Feature
.class);
62 WizardDialog dialog
= new WizardDialog(StoreUtil
.getShell(), wizard
);
63 if(dialog
.open() == IStatus
.OK
){
64 tableViewer
.setInput(TermStore
.getFeatures());
71 * @see eu.etaxonomy.taxeditor.preference.AbstractMenuPreferences#addEditButtonListeners()
75 protected void addEditButtonListeners() {
76 editButton
.addSelectionListener(new SelectionAdapter(){
78 * @see org.eclipse.swt.events.SelectionAdapter#widgetSelected(org.eclipse.swt.events.SelectionEvent)
81 public void widgetSelected(SelectionEvent e
) {
82 super.widgetSelected(e
);
83 Feature selection
= (Feature
) ((StructuredSelection
) tableViewer
.getSelection()).getFirstElement();
85 VocabularyTermWizard
<Feature
> wizard
= new VocabularyTermWizard
<Feature
>(Feature
.class, selection
);
87 WizardDialog dialog
= new WizardDialog(StoreUtil
.getShell(), wizard
);
91 tableViewer
.setInput(TermStore
.getFeatures());
92 tableViewer
.reveal(selection
);
98 * @see eu.etaxonomy.taxeditor.preference.menu.AbstractMenuPreferences#getTermClass()
102 protected Class
<Feature
> getTermClass() {
103 return Feature
.class;
107 * @see eu.etaxonomy.taxeditor.preference.AbstractMenuPreferences#addEditButtonListeners()
109 * TODO refactor into superclass
112 // protected void addDeleteButtonListeners() {
113 // removeButton.addMouseListener(new MouseAdapter(){
116 // * @see org.eclipse.swt.events.MouseAdapter#mouseUp(org.eclipse.swt.events.MouseEvent)
119 // public void mouseUp(MouseEvent e) {
122 // Feature selected = (Feature) ((StructuredSelection) tableViewer.getSelection()).getFirstElement();
124 // VocabularyStore.delete(selected);
127 // tableViewer.setInput(VocabularyStore.getFeatures());