X-Git-Url: https://dev.e-taxonomy.eu/gitweb/taxeditor.git/blobdiff_plain/25fdf883a77a6355273594553ead3ca17cf0fdca..49a64920d20e616c151ce11732b48f14bd183850:/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/userecords/UseRecordDetailElement.java diff --git a/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/userecords/UseRecordDetailElement.java b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/userecords/UseRecordDetailElement.java index 32d02813f..8f913790f 100644 --- a/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/userecords/UseRecordDetailElement.java +++ b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/userecords/UseRecordDetailElement.java @@ -17,11 +17,12 @@ import java.util.Set; import org.apache.log4j.Logger; import org.eclipse.swt.events.SelectionEvent; import org.eclipse.swt.events.SelectionListener; + +import eu.etaxonomy.cdm.model.common.DefinedTerm; import eu.etaxonomy.cdm.model.common.Language; import eu.etaxonomy.cdm.model.common.LanguageString; import eu.etaxonomy.cdm.model.common.Marker; import eu.etaxonomy.cdm.model.description.CategoricalData; -import eu.etaxonomy.cdm.model.description.Modifier; import eu.etaxonomy.cdm.model.description.State; import eu.etaxonomy.cdm.model.description.StateData; import eu.etaxonomy.taxeditor.editor.UsageTermCollection; @@ -48,10 +49,10 @@ public class UseRecordDetailElement extends private TermComboElement combo_UseCategory; private TermComboElement combo_UseSubCategory; - private TermComboElement combo_PlantPart; - private TermComboElement combo_Country; - private TermComboElement combo_HumanGroup; - private TermComboElement combo_EthnicGroup; + private TermComboElement combo_PlantPart; + private TermComboElement combo_Country; + private TermComboElement combo_HumanGroup; + private TermComboElement combo_EthnicGroup; public UseRecordDetailElement(CdmFormFactory formFactory, ICdmFormElement formElement) { @@ -66,11 +67,11 @@ public class UseRecordDetailElement extends combo_UseCategory = formFactory.createTermComboElement(State.class, this, UsageTermCollection.useCategoryVocabularyLabel, null, style); combo_UseCategory.addSelectionListener(this); combo_UseSubCategory = formFactory.createTermComboElement(State.class, this, UsageTermCollection.useSubCategoryVocabularyLabel, null, style); - combo_PlantPart = formFactory.createTermComboElement(Modifier.class, this, UsageTermCollection.plantPartLabel, null, style); - combo_HumanGroup = formFactory.createTermComboElement(Modifier.class, this, UsageTermCollection.humanGroupLabel, null, style); + combo_PlantPart = formFactory.createTermComboElement(DefinedTerm.class, this, UsageTermCollection.plantPartLabel, null, style); + combo_HumanGroup = formFactory.createTermComboElement(DefinedTerm.class, this, UsageTermCollection.humanGroupLabel, null, style); combo_HumanGroup.addSelectionListener(this); - combo_EthnicGroup = formFactory.createTermComboElement(Modifier.class, this, UsageTermCollection.ethnicGroupLabel, null, style); - combo_Country = formFactory.createTermComboElement(Modifier.class, this, UsageTermCollection.countryLabel, null, style); + combo_EthnicGroup = formFactory.createTermComboElement(DefinedTerm.class, this, UsageTermCollection.ethnicGroupLabel, null, style); + combo_Country = formFactory.createTermComboElement(DefinedTerm.class, this, UsageTermCollection.countryLabel, null, style); List termsUseCategory = setUseCategoryComboTerms(TermStore.getTerms(State.class, null, false)); @@ -88,19 +89,19 @@ public class UseRecordDetailElement extends combo_UseSubCategory.setEnabled(false); } - List plantPartsToAdd = setModifierComboTerms(TermStore.getTerms(Modifier.class, null, false), UsageTermCollection.plantPartLabel); + List plantPartsToAdd = setModifierComboTerms(TermStore.getTerms(DefinedTerm.class, null, false), UsageTermCollection.plantPartLabel); combo_PlantPart.setTerms(plantPartsToAdd); combo_PlantPart.setSelection(modifierSelection(UsageTermCollection.plantPartLabel)); - List countriesToAdd = setModifierComboTerms(TermStore.getTerms(Modifier.class, null, false), UsageTermCollection.countryLabel); + List countriesToAdd = setModifierComboTerms(TermStore.getTerms(DefinedTerm.class, null, false), UsageTermCollection.countryLabel); combo_Country.setTerms(countriesToAdd); combo_Country.setSelection(modifierSelection(UsageTermCollection.countryLabel)); - List humanGroupToAdd = setModifierComboTerms(TermStore.getTerms(Modifier.class, null, false), UsageTermCollection.humanGroupLabel); + List humanGroupToAdd = setModifierComboTerms(TermStore.getTerms(DefinedTerm.class, null, false), UsageTermCollection.humanGroupLabel); combo_HumanGroup.setTerms(humanGroupToAdd); combo_HumanGroup.setSelection(modifierSelection(UsageTermCollection.humanGroupLabel)); - List ethnicGroupToAdd = setEthnicGroupComboTerms(TermStore.getTerms(Modifier.class, null, false), combo_HumanGroup.getSelection()); + List ethnicGroupToAdd = setEthnicGroupComboTerms(TermStore.getTerms(DefinedTerm.class, null, false), combo_HumanGroup.getSelection()); if (ethnicGroupToAdd != null) { combo_EthnicGroup.setTerms(ethnicGroupToAdd); combo_EthnicGroup.setSelection(modifierSelection(UsageTermCollection.ethnicGroupLabel)); @@ -116,9 +117,9 @@ public class UseRecordDetailElement extends * @param comboCategory * @return */ - private Modifier modifierSelection(String comboCategory) { + private DefinedTerm modifierSelection(String comboCategory) { if(!getEntity().getModifiers().isEmpty()) { - for (Modifier modifier : getEntity().getModifiers()) { + for (DefinedTerm modifier : getEntity().getModifiers()) { if(GetVocabularyType(modifier, comboCategory)) { return modifier; } @@ -161,9 +162,9 @@ public class UseRecordDetailElement extends * @param modType * @return */ - private List setModifierComboTerms(List listOfTerms, String modType) { - List termsToAdd = new ArrayList(); - for (Modifier term : listOfTerms) { + private List setModifierComboTerms(List listOfTerms, String modType) { + List termsToAdd = new ArrayList(); + for (DefinedTerm term : listOfTerms) { if ((term.getPartOf() != null) && (term.getPartOf().getTitleCache().equals(modType))) { termsToAdd.add(term); @@ -250,11 +251,11 @@ public class UseRecordDetailElement extends * @param selectedHumangroup * @return */ - private List setEthnicGroupComboTerms(List listOfTerms, - Modifier selectedHumangroup) { - List termsToAdd = new ArrayList(); + private List setEthnicGroupComboTerms(List listOfTerms, + DefinedTerm selectedHumangroup) { + List termsToAdd = new ArrayList(); if (combo_HumanGroup.getSelection() != null) { - for (Modifier term : listOfTerms) { + for (DefinedTerm term : listOfTerms) { if ((term.getPartOf() != null) && (term.getPartOf().getTitleCache().equals(selectedHumangroup.getTitleCache()))) { termsToAdd.add(term); @@ -265,11 +266,11 @@ public class UseRecordDetailElement extends } } else if (!getEntity().getModifiers().isEmpty()) { - for (Modifier modifier : getEntity().getModifiers()) { + for (DefinedTerm modifier : getEntity().getModifiers()) { if (modifier.getMarkers() != null) { for (Marker marker : modifier.getMarkers()) { if(marker.getMarkerType().getTitleCache().equals(UsageTermCollection.humanGroupLabel)) { - for (Modifier term : listOfTerms) { + for (DefinedTerm term : listOfTerms) { if ((term.getPartOf() != null) && (term.getPartOf().getTitleCache().equals(modifier.getTitleCache()))) { termsToAdd.add(modifier); } else if ((term.getVocabulary() != null) && (term.getVocabulary().getTitleCache().equals(modifier.getTitleCache()))) { @@ -408,22 +409,22 @@ public class UseRecordDetailElement extends } if (eventSource == combo_PlantPart) { if (combo_PlantPart.getSelection() != null) { - Iterator itrExistingModifiers = getEntity().getModifiers().iterator(); + Iterator itrExistingModifiers = getEntity().getModifiers().iterator(); while (itrExistingModifiers.hasNext()) { - Modifier modifier = itrExistingModifiers.next(); + DefinedTerm modifier = itrExistingModifiers.next(); if(GetVocabularyType(modifier, UsageTermCollection.plantPartLabel)) { itrExistingModifiers.remove(); } } - Modifier plantPart = combo_PlantPart.getSelection(); + DefinedTerm plantPart = combo_PlantPart.getSelection(); getEntity().addModifier(plantPart); } else { - Set modifiers = getEntity().getModifiers(); + Set modifiers = getEntity().getModifiers(); if(!modifiers.isEmpty()) { - Iterator itr = modifiers.iterator(); + Iterator itr = modifiers.iterator(); while (itr.hasNext()) { - Modifier currentMod = itr.next(); + DefinedTerm currentMod = itr.next(); if(GetVocabularyType(currentMod, UsageTermCollection.plantPartLabel)) { itr.remove(); } @@ -434,22 +435,22 @@ public class UseRecordDetailElement extends } if (eventSource == combo_Country) { if (combo_Country.getSelection() != null) { - Iterator itrExistingModifiers = getEntity().getModifiers().iterator(); + Iterator itrExistingModifiers = getEntity().getModifiers().iterator(); while (itrExistingModifiers.hasNext()) { - Modifier modifier = itrExistingModifiers.next(); + DefinedTerm modifier = itrExistingModifiers.next(); if(GetVocabularyType(modifier, UsageTermCollection.countryLabel)) { itrExistingModifiers.remove(); } } - Modifier country = combo_Country.getSelection(); + DefinedTerm country = combo_Country.getSelection(); getEntity().addModifier(country); } else { - Set modifiers = getEntity().getModifiers(); + Set modifiers = getEntity().getModifiers(); if(!modifiers.isEmpty()) { - Iterator itr = modifiers.iterator(); + Iterator itr = modifiers.iterator(); while (itr.hasNext()) { - Modifier currentMod = itr.next(); + DefinedTerm currentMod = itr.next(); if(GetVocabularyType(currentMod, UsageTermCollection.countryLabel)) { itr.remove(); } @@ -460,39 +461,39 @@ public class UseRecordDetailElement extends if (eventSource == combo_HumanGroup) { if (combo_HumanGroup.getSelection() != null) { boolean isHumanGroupChanged = true; - for (Modifier modToCheck: getEntity().getModifiers()) { + for (DefinedTerm modToCheck: getEntity().getModifiers()) { if(modToCheck.equals(combo_HumanGroup.getSelection()) && (GetVocabularyType(modToCheck, UsageTermCollection.humanGroupLabel))) { isHumanGroupChanged = false; } } - Iterator itrExistingModifiers = getEntity().getModifiers().iterator(); + Iterator itrExistingModifiers = getEntity().getModifiers().iterator(); while (itrExistingModifiers.hasNext()) { - Modifier modifier = itrExistingModifiers.next(); + DefinedTerm modifier = itrExistingModifiers.next(); if((GetVocabularyType(modifier, UsageTermCollection.humanGroupLabel) || GetVocabularyType(modifier, UsageTermCollection.ethnicGroupLabel)) && isHumanGroupChanged) { itrExistingModifiers.remove(); } } if(isHumanGroupChanged){ - Modifier humanGroup = combo_HumanGroup.getSelection(); + DefinedTerm humanGroup = combo_HumanGroup.getSelection(); getEntity().addModifier(humanGroup); } combo_EthnicGroup.setEnabled(true); } else { - Set modifiers = getEntity().getModifiers(); + Set modifiers = getEntity().getModifiers(); if(!modifiers.isEmpty()) { - Iterator itr = modifiers.iterator(); + Iterator itr = modifiers.iterator(); while (itr.hasNext()) { - Modifier currentMod = itr.next(); + DefinedTerm currentMod = itr.next(); if(GetVocabularyType(currentMod, UsageTermCollection.humanGroupLabel) || GetVocabularyType(currentMod, UsageTermCollection.ethnicGroupLabel)) { itr.remove(); } } } - List emptyListToResetComboBox = new ArrayList(); - Modifier emptyMod = Modifier.NewInstance(); + List emptyListToResetComboBox = new ArrayList(); + DefinedTerm emptyMod = DefinedTerm.NewInstance(); emptyListToResetComboBox.add(emptyMod); combo_EthnicGroup.setTerms(emptyListToResetComboBox); combo_EthnicGroup.setEnabled(false); @@ -501,23 +502,23 @@ public class UseRecordDetailElement extends } if (eventSource == combo_EthnicGroup) { if (combo_EthnicGroup.getSelection() != null) { - Iterator itrExistingModifiers = getEntity().getModifiers().iterator(); + Iterator itrExistingModifiers = getEntity().getModifiers().iterator(); while (itrExistingModifiers.hasNext()) { - Modifier modifier = itrExistingModifiers.next(); + DefinedTerm modifier = itrExistingModifiers.next(); if(GetVocabularyType(modifier, combo_HumanGroup.getSelection().getTitleCache())) { itrExistingModifiers.remove(); } } - Modifier ethnicGroup = combo_EthnicGroup.getSelection(); + DefinedTerm ethnicGroup = combo_EthnicGroup.getSelection(); getEntity().addModifier(ethnicGroup); } else { - Set modifiers = getEntity().getModifiers(); + Set modifiers = getEntity().getModifiers(); if(!modifiers.isEmpty()) { - Iterator itr = modifiers.iterator(); + Iterator itr = modifiers.iterator(); while (itr.hasNext()) { - Modifier currentMod = itr.next(); + DefinedTerm currentMod = itr.next(); if(GetVocabularyType(currentMod, UsageTermCollection.ethnicGroupLabel)) { itr.remove(); } @@ -536,7 +537,7 @@ public class UseRecordDetailElement extends * @param vocabularyExpected * @return */ - private boolean GetVocabularyType(Modifier term, String vocabularyExpected) { + private boolean GetVocabularyType(DefinedTerm term, String vocabularyExpected) { if ((term.getPartOf() != null) && (term.getPartOf().getTitleCache().equals(vocabularyExpected))) { return true; } @@ -585,13 +586,13 @@ public class UseRecordDetailElement extends } for (Object object: combo_HumanGroup.getControls()) { if (object == eventSource) { - Modifier selectedHumanGroup = combo_HumanGroup.getSelection(); + DefinedTerm selectedHumanGroup = combo_HumanGroup.getSelection(); if (selectedHumanGroup != null) { - combo_EthnicGroup.setTerms(setEthnicGroupComboTerms(TermStore.getTerms(Modifier.class, null, false), selectedHumanGroup)); + combo_EthnicGroup.setTerms(setEthnicGroupComboTerms(TermStore.getTerms(DefinedTerm.class, null, false), selectedHumanGroup)); if (!getEntity().getModifiers().isEmpty()) { - Iterator iterModifiers = getEntity().getModifiers().iterator(); + Iterator iterModifiers = getEntity().getModifiers().iterator(); while (iterModifiers.hasNext()) { - Modifier existingModifier = iterModifiers.next(); + DefinedTerm existingModifier = iterModifiers.next(); if(GetVocabularyType(existingModifier, UsageTermCollection.ethnicGroupLabel)) { combo_EthnicGroup.setSelection(modifierSelection(UsageTermCollection.ethnicGroupLabel)); }