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
.propertysheet
.tabbed
;
13 import java
.util
.Properties
;
15 import org
.apache
.log4j
.Logger
;
16 import org
.eclipse
.swt
.SWT
;
17 import org
.eclipse
.swt
.custom
.CCombo
;
18 import org
.eclipse
.swt
.custom
.CLabel
;
19 import org
.eclipse
.swt
.events
.ModifyEvent
;
20 import org
.eclipse
.swt
.events
.ModifyListener
;
21 import org
.eclipse
.swt
.layout
.GridData
;
22 import org
.eclipse
.swt
.widgets
.Composite
;
23 import org
.eclipse
.swt
.widgets
.Text
;
24 import org
.eclipse
.ui
.views
.properties
.tabbed
.TabbedPropertySheetPage
;
26 import eu
.etaxonomy
.cdm
.common
.CdmUtils
;
27 import eu
.etaxonomy
.cdm
.model
.name
.NomenclaturalStatusType
;
28 import eu
.etaxonomy
.cdm
.model
.name
.Rank
;
29 import eu
.etaxonomy
.taxeditor
.preference
.PreferencesUtil
;
30 import eu
.etaxonomy
.taxeditor
.store
.CdmStore
;
31 import eu
.etaxonomy
.taxeditor
.store
.VocabularyStore
;
38 public class NamePropertySection
extends AbstractNamePropertySection
{
39 private static final Logger logger
= Logger
40 .getLogger(NamePropertySection
.class);
43 private CCombo rankCombo
;
45 private Text uninomialText
;
46 private Text infragenericEpithetText
;
47 private Text specificEpithetText
;
48 private Text infraSpecificEpithetText
;
49 private Text appendedPhraseText
;
51 private CCombo nomenclaturalStatusCombo
;
53 protected ModifyListener listener
= new ModifyListener() {
55 public void modifyText(ModifyEvent arg0
) {
56 logger
.warn("element modified");
58 // FIXME this is a workaround because cache do not get generated on change of underlying data
59 // remove once this is fixed in library
60 name
.setAuthorshipCache(null,false);
61 name
.setNameCache(null, false);
66 name
.setGenusOrUninomial(uninomialText
.getText());
68 // TODO refresh the editor
69 //EditorUtil.getActiveEditorPage(Page.NAME).setDirty();
70 //EditorUtil.getActiveEditorPage(Page.NAME).redraw(false);
71 groupedComposite
.refresh();
77 public void createControls(Composite parent
, TabbedPropertySheetPage editorPropertySheetPage
){
78 super.createControls(parent
, editorPropertySheetPage
);
79 // super.createControls(parent, tabbedPropertySheetPage);
81 GridData textFieldLayout
= new GridData(SWT
.FILL
, SWT
.FILL
, true, true);
82 GridData comboLayout
= new GridData(SWT
.FILL
, SWT
.FILL
, true, false);
85 CLabel rankComboLabel
= getWidgetFactory().createCLabel(composite
, "Rank:");
86 rankCombo
= getWidgetFactory().createCCombo(composite
);
87 rankCombo
.setLayoutData(comboLayout
);
89 for (Rank rank
: PreferencesUtil
.getPreferredRanks()){
90 rankCombo
.add(rank
.getLabel(CdmStore
.getDefaultLanguage()));
94 CLabel uninomialLabel
= getWidgetFactory().createCLabel(composite
, "Uninomial");
95 uninomialText
= getWidgetFactory().createText(composite
, "");
96 uninomialText
.setLayoutData(textFieldLayout
);
98 // infrageneric epithet
99 CLabel infragenericEpithetLabel
= getWidgetFactory().createCLabel(composite
, "Infrageneric Epithet");
100 infragenericEpithetText
= getWidgetFactory().createText(composite
, "");
101 infragenericEpithetText
.setLayoutData(textFieldLayout
);
104 CLabel specificEpithetLabel
= getWidgetFactory().createCLabel(composite
, "Specific Epithet");
105 specificEpithetText
= getWidgetFactory().createText(composite
, "");
106 specificEpithetText
.setLayoutData(textFieldLayout
);
108 // infraspecific epithet
109 CLabel infraspecificEpithetLabel
= getWidgetFactory().createCLabel(composite
, "Infraspecific Epithet");
110 infraSpecificEpithetText
= getWidgetFactory().createText(composite
, "");
111 infraSpecificEpithetText
.setLayoutData(textFieldLayout
);
114 CLabel appendedPhraseLabel
= getWidgetFactory().createCLabel(composite
, "Appended Phrase");
115 appendedPhraseText
= getWidgetFactory().createText(composite
, "");
116 appendedPhraseText
.setLayoutData(textFieldLayout
);
118 // nomenclatural status
119 CLabel nomenclaturalStatusLabel
= getWidgetFactory().createCLabel(composite
, "Nomenclatural Status", SWT
.NO_BACKGROUND
);
120 nomenclaturalStatusCombo
= getWidgetFactory().createCCombo(composite
);
121 nomenclaturalStatusCombo
.setLayoutData(comboLayout
);
123 for(NomenclaturalStatusType nomenclaturalStatusType
: PreferencesUtil
.getPreferredNomenclaturalStatusTypes()){
124 nomenclaturalStatusCombo
.add(nomenclaturalStatusType
.getLabel(CdmStore
.getDefaultLanguage()));
130 * @see org.eclipse.ui.views.properties.tabbed.AbstractPropertySection#refresh()
133 public void refresh() {
136 section
.setText("Name");
138 cacheText
.removeModifyListener(listener
);
139 cacheText
.setText(CdmUtils
.Nz(name
.getNameCache()));
140 cacheText
.addModifyListener(listener
);
142 editCacheButton
.setSelection(name
.isProtectedNameCache());
144 uninomialText
.removeModifyListener(listener
);
145 uninomialText
.setText(CdmUtils
.Nz(name
.getGenusOrUninomial()));
146 uninomialText
.addModifyListener(listener
);
148 infragenericEpithetText
.setText(CdmUtils
.Nz(name
.getInfraGenericEpithet()));
149 specificEpithetText
.setText(CdmUtils
.Nz(name
.getSpecificEpithet()));
150 infraSpecificEpithetText
.setText(CdmUtils
.Nz(name
.getInfraSpecificEpithet()));
152 appendedPhraseText
.setText(CdmUtils
.Nz(name
.getAppendedPhrase()));
157 * @see eu.etaxonomy.taxeditor.propertysheet.tabbed.AbstractNamePropertySection#toggleCacheEditing()
160 protected void toggleCacheEditing() {
161 super.toggleCacheEditing();
163 if(name
.isProtectedNameCache()){
164 name
.setProtectedNameCache(false);
166 name
.setProtectedNameCache(true);