From 23eb8de6354d1b3c50ae15492b9d65d7a71a05d0 Mon Sep 17 00:00:00 2001 From: "n.hoffmann" Date: Thu, 25 Jun 2009 17:49:29 +0000 Subject: [PATCH] Changed calls to retrieve term vocabularies to preferred term mechanism where applicable. --- .../description/CommonNameComposite.java | 3 +-- .../description/DistributionDialog.java | 15 +++---------- .../editor/description/LanguageDialog.java | 7 +++--- .../editor/labels/DefaultLabelStrategy.java | 6 ++--- .../AbstractDynamicConceptRelationMenu.java | 4 ++-- .../propertysheet/PropertySheetUtil.java | 22 ------------------- .../description/CommonNamePropertySource.java | 8 +++---- .../name/NonViralNamePropertySource.java | 7 ++---- .../wizard/ChooseRelationWizardPage.java | 5 +++-- .../tabbed/NamePropertySection.java | 5 ++++- .../wizard/ChooseSpecimenTypeWizardPage.java | 6 ++--- 11 files changed, 28 insertions(+), 60 deletions(-) diff --git a/taxeditor-editor/src/main/java/eu/etaxonomy/taxeditor/editor/description/CommonNameComposite.java b/taxeditor-editor/src/main/java/eu/etaxonomy/taxeditor/editor/description/CommonNameComposite.java index b774e764e..1310c5fd0 100644 --- a/taxeditor-editor/src/main/java/eu/etaxonomy/taxeditor/editor/description/CommonNameComposite.java +++ b/taxeditor-editor/src/main/java/eu/etaxonomy/taxeditor/editor/description/CommonNameComposite.java @@ -15,7 +15,6 @@ import org.eclipse.ui.views.properties.IPropertySource; import eu.etaxonomy.cdm.model.common.Language; import eu.etaxonomy.cdm.model.description.CommonTaxonName; -import eu.etaxonomy.taxeditor.model.LanguageUtil; import eu.etaxonomy.taxeditor.propertysheet.description.CommonNamePropertySource; /** @@ -44,7 +43,7 @@ public class CommonNameComposite extends DescriptionElementComposite { Language language = ((CommonTaxonName) element).getLanguage(); if (language != null) { - setNonEditableInfo(LanguageUtil.getDescription(language)); + setNonEditableInfo(language.getDescription()); } else { setNonEditableInfo("No language"); } diff --git a/taxeditor-editor/src/main/java/eu/etaxonomy/taxeditor/editor/description/DistributionDialog.java b/taxeditor-editor/src/main/java/eu/etaxonomy/taxeditor/editor/description/DistributionDialog.java index f7c1a8997..8073bc06d 100644 --- a/taxeditor-editor/src/main/java/eu/etaxonomy/taxeditor/editor/description/DistributionDialog.java +++ b/taxeditor-editor/src/main/java/eu/etaxonomy/taxeditor/editor/description/DistributionDialog.java @@ -35,6 +35,7 @@ import eu.etaxonomy.cdm.model.location.NamedArea; import eu.etaxonomy.cdm.model.reference.ReferenceBase; import eu.etaxonomy.taxeditor.editor.EditorUtil; import eu.etaxonomy.taxeditor.editor.reference.ReferenceSelectComposite; +import eu.etaxonomy.taxeditor.preference.PreferencesUtil; import eu.etaxonomy.taxeditor.store.CdmStore; /** @@ -357,18 +358,8 @@ public class DistributionDialog extends Dialog { /** * @return */ - private List> getPresenceAbsenceTerms() { - if (presenceAbsenceTerms == null) { - presenceAbsenceTerms = new ArrayList>(); - - for (PresenceAbsenceTermBase term : locationService.getPresenceTermVocabulary().getTermsOrderedByLabels(CdmStore.getDefaultLanguage())) { - presenceAbsenceTerms.add(term); - } - for (PresenceAbsenceTermBase term : locationService.getAbsenceTermVocabulary().getTermsOrderedByLabels(CdmStore.getDefaultLanguage())) { - presenceAbsenceTerms.add(term); - } - } - return presenceAbsenceTerms; + private List>> getPresenceAbsenceTerms() { + return PreferencesUtil.getPreferredPresenceAbsenceTerms(); } /** diff --git a/taxeditor-editor/src/main/java/eu/etaxonomy/taxeditor/editor/description/LanguageDialog.java b/taxeditor-editor/src/main/java/eu/etaxonomy/taxeditor/editor/description/LanguageDialog.java index 6c7328ee3..6e2513e48 100644 --- a/taxeditor-editor/src/main/java/eu/etaxonomy/taxeditor/editor/description/LanguageDialog.java +++ b/taxeditor-editor/src/main/java/eu/etaxonomy/taxeditor/editor/description/LanguageDialog.java @@ -31,8 +31,7 @@ import org.eclipse.swt.widgets.Shell; import eu.etaxonomy.cdm.model.common.Language; import eu.etaxonomy.taxeditor.editor.EditorUtil; -import eu.etaxonomy.taxeditor.model.LanguageUtil; -import eu.etaxonomy.taxeditor.store.CdmStore; +import eu.etaxonomy.taxeditor.store.VocabularyStore; /** * @author p.ciardelli @@ -140,9 +139,9 @@ public class LanguageDialog extends InputDialog { languages = new ArrayList(); int i = 0; int index = 0; - for (Language language : CdmStore.getLanguages()) { + for (Language language : VocabularyStore.getLanguages()) { - String description = LanguageUtil.getDescription(language); + String description = language.getDescription(); if (description == null) { logger.warn("No description for " + language + " - not added to language menu"); continue; diff --git a/taxeditor-editor/src/main/java/eu/etaxonomy/taxeditor/editor/labels/DefaultLabelStrategy.java b/taxeditor-editor/src/main/java/eu/etaxonomy/taxeditor/editor/labels/DefaultLabelStrategy.java index e572aaecf..c347d6499 100644 --- a/taxeditor-editor/src/main/java/eu/etaxonomy/taxeditor/editor/labels/DefaultLabelStrategy.java +++ b/taxeditor-editor/src/main/java/eu/etaxonomy/taxeditor/editor/labels/DefaultLabelStrategy.java @@ -10,7 +10,7 @@ import org.eclipse.swt.graphics.Image; import eu.etaxonomy.cdm.model.name.NameRelationship; import eu.etaxonomy.cdm.model.name.NameRelationshipType; import eu.etaxonomy.taxeditor.model.ImageResources; -import eu.etaxonomy.taxeditor.store.CdmStore; +import eu.etaxonomy.taxeditor.store.VocabularyStore; /** * @author p.ciardelli @@ -23,7 +23,7 @@ public class DefaultLabelStrategy implements ILabelImageStrategy { */ public String getNameRelationTypeLabel(NameRelationshipType type) { SortedSet vocab = - CdmStore.getDefault().getNameRelationshipTypes(); + VocabularyStore.getNameRelationshipTypes(); for (NameRelationshipType type1 : vocab) { if (type1.equals(type)) { @@ -39,7 +39,7 @@ public class DefaultLabelStrategy implements ILabelImageStrategy { public String getNameRelationTypeInverseLabel(NameRelationshipType type) { SortedSet vocab = - CdmStore.getDefault().getNameRelationshipTypes(); + VocabularyStore.getNameRelationshipTypes(); for (NameRelationshipType type1 : vocab) { if (type1.equals(type)) { diff --git a/taxeditor-editor/src/main/java/eu/etaxonomy/taxeditor/editor/name/handler/AbstractDynamicConceptRelationMenu.java b/taxeditor-editor/src/main/java/eu/etaxonomy/taxeditor/editor/name/handler/AbstractDynamicConceptRelationMenu.java index fc2bf2441..d85f918b6 100644 --- a/taxeditor-editor/src/main/java/eu/etaxonomy/taxeditor/editor/name/handler/AbstractDynamicConceptRelationMenu.java +++ b/taxeditor-editor/src/main/java/eu/etaxonomy/taxeditor/editor/name/handler/AbstractDynamicConceptRelationMenu.java @@ -14,7 +14,7 @@ import org.eclipse.ui.handlers.IHandlerService; import eu.etaxonomy.cdm.model.taxon.TaxonRelationshipType; import eu.etaxonomy.taxeditor.editor.internal.TaxeditorEditorPlugin; -import eu.etaxonomy.taxeditor.store.CdmStore; +import eu.etaxonomy.taxeditor.store.VocabularyStore; /** * @@ -33,7 +33,7 @@ public abstract class AbstractDynamicConceptRelationMenu extends ContributionIte public void fill(Menu menu, int index){ final IHandlerService handlerService = (IHandlerService) TaxeditorEditorPlugin.getDefault().getWorkbench().getService(IHandlerService.class); - for(final TaxonRelationshipType type : CdmStore.getDefault().getConceptRelationshipTypes()){ + for(final TaxonRelationshipType type : VocabularyStore.getConceptRelationshipTypes()){ MenuItem menuItem = new MenuItem(menu, -1); menuItem.setText(type.getLabel()); menuItem.setData(type); diff --git a/taxeditor-editor/src/main/java/eu/etaxonomy/taxeditor/propertysheet/PropertySheetUtil.java b/taxeditor-editor/src/main/java/eu/etaxonomy/taxeditor/propertysheet/PropertySheetUtil.java index 09584c155..54469dddf 100644 --- a/taxeditor-editor/src/main/java/eu/etaxonomy/taxeditor/propertysheet/PropertySheetUtil.java +++ b/taxeditor-editor/src/main/java/eu/etaxonomy/taxeditor/propertysheet/PropertySheetUtil.java @@ -9,8 +9,6 @@ package eu.etaxonomy.taxeditor.propertysheet; -import java.util.SortedSet; - import org.apache.log4j.Logger; import org.eclipse.swt.graphics.Color; import org.eclipse.swt.widgets.Tree; @@ -23,9 +21,7 @@ import org.eclipse.ui.IWorkbenchPage; import org.eclipse.ui.views.properties.PropertySheet; import org.eclipse.ui.views.properties.PropertySheetPage; -import eu.etaxonomy.cdm.model.name.NameRelationshipType; import eu.etaxonomy.taxeditor.editor.internal.TaxeditorEditorPlugin; -import eu.etaxonomy.taxeditor.store.CdmStore; /** * @author n.hoffmann @@ -193,24 +189,6 @@ public class PropertySheetUtil { } } - /** - * Get the name out of the session's name relations vocabulary, not directly - * from the object. - * - * @param type - * @return - */ - public static String getNameRelationLabelType(NameRelationshipType type) { - SortedSet vocab = - CdmStore.getDefault().getNameRelationshipTypes(); - for (NameRelationshipType type1 : vocab) { - if (type1.equals(type)) { - return type1.getLabel(); - } - } - return ""; - } - /*************************************************************************** * PROPERTY SHEET **************************************************************************/ diff --git a/taxeditor-editor/src/main/java/eu/etaxonomy/taxeditor/propertysheet/description/CommonNamePropertySource.java b/taxeditor-editor/src/main/java/eu/etaxonomy/taxeditor/propertysheet/description/CommonNamePropertySource.java index 08e81f60a..f6340c8f3 100644 --- a/taxeditor-editor/src/main/java/eu/etaxonomy/taxeditor/propertysheet/description/CommonNamePropertySource.java +++ b/taxeditor-editor/src/main/java/eu/etaxonomy/taxeditor/propertysheet/description/CommonNamePropertySource.java @@ -10,6 +10,7 @@ package eu.etaxonomy.taxeditor.propertysheet.description; +import java.util.ArrayList; import java.util.List; import org.apache.log4j.Logger; @@ -17,8 +18,7 @@ import org.eclipse.ui.views.properties.ComboBoxPropertyDescriptor; import eu.etaxonomy.cdm.model.common.Language; import eu.etaxonomy.cdm.model.description.CommonTaxonName; -import eu.etaxonomy.taxeditor.model.LanguageUtil; -import eu.etaxonomy.taxeditor.store.CdmStore; +import eu.etaxonomy.taxeditor.store.VocabularyStore; /** * @author p.ciardelli @@ -64,12 +64,12 @@ public class CommonNamePropertySource extends DescriptionElementPropertySource { */ private String[] getLanguageStringArray() { if (languages == null) { - languages = CdmStore.getLanguages(); + languages = new ArrayList(VocabularyStore.getLanguages()); int i = 0; languageStrings = new String[languages.size()]; for (Language language : languages) { - languageStrings[i] = LanguageUtil.getDescription(language); + languageStrings[i] = language.getDescription(); if (language.equals(commonName.getLanguage())) { selectedLanguageIndex = i; } diff --git a/taxeditor-editor/src/main/java/eu/etaxonomy/taxeditor/propertysheet/name/NonViralNamePropertySource.java b/taxeditor-editor/src/main/java/eu/etaxonomy/taxeditor/propertysheet/name/NonViralNamePropertySource.java index e0be8cb46..a5184b169 100644 --- a/taxeditor-editor/src/main/java/eu/etaxonomy/taxeditor/propertysheet/name/NonViralNamePropertySource.java +++ b/taxeditor-editor/src/main/java/eu/etaxonomy/taxeditor/propertysheet/name/NonViralNamePropertySource.java @@ -25,7 +25,6 @@ import org.eclipse.ui.views.properties.TextPropertyDescriptor; import eu.etaxonomy.cdm.common.CdmUtils; import eu.etaxonomy.cdm.model.common.IIdentifiableEntity; -import eu.etaxonomy.cdm.model.common.TermVocabulary; import eu.etaxonomy.cdm.model.name.NomenclaturalStatus; import eu.etaxonomy.cdm.model.name.NomenclaturalStatusType; import eu.etaxonomy.cdm.model.name.NonViralName; @@ -39,7 +38,6 @@ import eu.etaxonomy.taxeditor.propertysheet.ICdmBasePropertySource; import eu.etaxonomy.taxeditor.propertysheet.MarkersPropertySource; import eu.etaxonomy.taxeditor.propertysheet.reference.NomenclaturalReferencePropertySource; import eu.etaxonomy.taxeditor.propertysheet.reference.ReferencePropertySource; -import eu.etaxonomy.taxeditor.store.CdmStore; /** * @author p.ciardelli @@ -135,15 +133,14 @@ public class NonViralNamePropertySource implements ICdmBasePropertySource { // *********************************************************** // NOMENCLATURAL STATUS // *********************************************************** -// static TermVocabulary nomStatusVocabulary = -// TaxEditorPlugin.getDefault().getNomStatusVocabulary(); + NomenclaturalStatusType[] nomStatusTypes = null; String[] P_NOMSTATUS_MENU = null; private void populateNomStatusTypes() { // Get terms from nom status vocabulary List nomStatusTypesList = new ArrayList(); - Set statusVocab = CdmStore.getNomenclaturalStatusTypes(); + List statusVocab = PreferencesUtil.getPreferredNomenclaturalStatusTypes(); // If there is no status vocabulary, init type and status w empty arrays and return if (statusVocab == null) { diff --git a/taxeditor-editor/src/main/java/eu/etaxonomy/taxeditor/propertysheet/namerelations/wizard/ChooseRelationWizardPage.java b/taxeditor-editor/src/main/java/eu/etaxonomy/taxeditor/propertysheet/namerelations/wizard/ChooseRelationWizardPage.java index f5ae2891a..844fb2cc7 100644 --- a/taxeditor-editor/src/main/java/eu/etaxonomy/taxeditor/propertysheet/namerelations/wizard/ChooseRelationWizardPage.java +++ b/taxeditor-editor/src/main/java/eu/etaxonomy/taxeditor/propertysheet/namerelations/wizard/ChooseRelationWizardPage.java @@ -37,7 +37,8 @@ import eu.etaxonomy.taxeditor.editor.labels.LabelImageProvider; import eu.etaxonomy.taxeditor.editor.name.NameSelectComposite; import eu.etaxonomy.taxeditor.editor.reference.ReferenceSelectComposite; import eu.etaxonomy.taxeditor.model.NameUtil; -import eu.etaxonomy.taxeditor.store.CdmStore; +import eu.etaxonomy.taxeditor.preference.PreferencesUtil; +import eu.etaxonomy.taxeditor.store.VocabularyStore; /** * An all-in-one relation wizard page where the user chooses a related name, a @@ -132,7 +133,7 @@ public class ChooseRelationWizardPage extends WizardPage { typeCombo = new Combo(container, SWT.BORDER); typeCombo.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false)); for (NameRelationshipType relationType : - CdmStore.getDefault().getNameRelationshipTypes()) { + PreferencesUtil.getPreferredNameRelationshipTypes()) { relationTypes.add(relationType); String label = labelProvider.getNameRelationTypeLabel(relationType); diff --git a/taxeditor-editor/src/main/java/eu/etaxonomy/taxeditor/propertysheet/tabbed/NamePropertySection.java b/taxeditor-editor/src/main/java/eu/etaxonomy/taxeditor/propertysheet/tabbed/NamePropertySection.java index 5fed3ff4a..b74d93de8 100644 --- a/taxeditor-editor/src/main/java/eu/etaxonomy/taxeditor/propertysheet/tabbed/NamePropertySection.java +++ b/taxeditor-editor/src/main/java/eu/etaxonomy/taxeditor/propertysheet/tabbed/NamePropertySection.java @@ -10,6 +10,8 @@ package eu.etaxonomy.taxeditor.propertysheet.tabbed; +import java.util.Properties; + import org.apache.log4j.Logger; import org.eclipse.swt.SWT; import org.eclipse.swt.custom.CCombo; @@ -26,6 +28,7 @@ import eu.etaxonomy.cdm.model.name.NomenclaturalStatusType; import eu.etaxonomy.cdm.model.name.Rank; import eu.etaxonomy.taxeditor.preference.PreferencesUtil; import eu.etaxonomy.taxeditor.store.CdmStore; +import eu.etaxonomy.taxeditor.store.VocabularyStore; /** * @author n.hoffmann @@ -117,7 +120,7 @@ public class NamePropertySection extends AbstractNamePropertySection { nomenclaturalStatusCombo = getWidgetFactory().createCCombo(composite); nomenclaturalStatusCombo.setLayoutData(comboLayout); - for(NomenclaturalStatusType nomenclaturalStatusType : CdmStore.getNomenclaturalStatusTypes()){ + for(NomenclaturalStatusType nomenclaturalStatusType : PreferencesUtil.getPreferredNomenclaturalStatusTypes()){ nomenclaturalStatusCombo.add(nomenclaturalStatusType.getLabel(CdmStore.getDefaultLanguage())); } diff --git a/taxeditor-editor/src/main/java/eu/etaxonomy/taxeditor/propertysheet/type/wizard/ChooseSpecimenTypeWizardPage.java b/taxeditor-editor/src/main/java/eu/etaxonomy/taxeditor/propertysheet/type/wizard/ChooseSpecimenTypeWizardPage.java index bf6fe55b4..0d9646d33 100644 --- a/taxeditor-editor/src/main/java/eu/etaxonomy/taxeditor/propertysheet/type/wizard/ChooseSpecimenTypeWizardPage.java +++ b/taxeditor-editor/src/main/java/eu/etaxonomy/taxeditor/propertysheet/type/wizard/ChooseSpecimenTypeWizardPage.java @@ -34,6 +34,7 @@ import eu.etaxonomy.cdm.model.occurrence.Specimen; import eu.etaxonomy.cdm.model.reference.ReferenceBase; import eu.etaxonomy.taxeditor.editor.reference.ReferenceSelectComposite; import eu.etaxonomy.taxeditor.store.CdmStore; +import eu.etaxonomy.taxeditor.store.VocabularyStore; /** * @author p.ciardelli @@ -85,7 +86,7 @@ public class ChooseSpecimenTypeWizardPage extends WizardPage { // Create designation type status dropdown statusCombo = new Combo(container, SWT.BORDER); statusCombo.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false)); - typeStatusArray = new SpecimenTypeDesignationStatus[CdmStore.getDefault().getSpecimenTypeDesignationStatus().size()]; + typeStatusArray = new SpecimenTypeDesignationStatus[VocabularyStore.getSpecimenTypeDesignationStatus().size()]; int i = 0; int selectedIndex = -1; @@ -95,8 +96,7 @@ public class ChooseSpecimenTypeWizardPage extends WizardPage { SpecimenTypeDesignationStatus.class); } - for (Object typeStatusObject : - CdmStore.getDefault().getSpecimenTypeDesignationStatus()) { + for (Object typeStatusObject : VocabularyStore.getSpecimenTypeDesignationStatus()) { SpecimenTypeDesignationStatus typeStatus = CdmBase.deproxy(typeStatusObject, SpecimenTypeDesignationStatus.class); -- 2.34.1