/**\r
* Copyright (C) 2011 EDIT\r
-* European Distributed Institute of Taxonomy \r
+* European Distributed Institute of Taxonomy\r
* http://www.e-taxonomy.eu\r
-* \r
+*\r
* The contents of this file are subject to the Mozilla Public License Version 1.1\r
* See LICENSE.TXT at the top of this package for the full license terms.\r
*/\r
import java.util.ListIterator;\r
import java.util.Map;\r
import java.util.Set;\r
-import org.apache.log4j.Logger;\r
+\r
+import org.apache.logging.log4j.LogManager;\r
+import org.apache.logging.log4j.Logger;\r
import org.eclipse.swt.events.SelectionEvent;\r
import org.eclipse.swt.events.SelectionListener;\r
+\r
+import eu.etaxonomy.cdm.model.common.CdmBase;\r
import eu.etaxonomy.cdm.model.common.Language;\r
import eu.etaxonomy.cdm.model.common.LanguageString;\r
import eu.etaxonomy.cdm.model.common.Marker;\r
import eu.etaxonomy.cdm.model.description.CategoricalData;\r
-import eu.etaxonomy.cdm.model.description.Modifier;\r
import eu.etaxonomy.cdm.model.description.State;\r
import eu.etaxonomy.cdm.model.description.StateData;\r
-import eu.etaxonomy.taxeditor.editor.UsageTermCollection;\r
+import eu.etaxonomy.cdm.model.term.DefinedTerm;\r
+import eu.etaxonomy.cdm.model.term.TermType;\r
import eu.etaxonomy.taxeditor.store.CdmStore;\r
import eu.etaxonomy.taxeditor.store.TermStore;\r
-import eu.etaxonomy.taxeditor.ui.combo.TermComboElement;\r
+import eu.etaxonomy.taxeditor.store.UsageTermCollection;\r
+import eu.etaxonomy.taxeditor.ui.combo.term.TermComboElement;\r
import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;\r
import eu.etaxonomy.taxeditor.ui.element.ICdmFormElement;\r
import eu.etaxonomy.taxeditor.ui.section.AbstractCdmDetailElement;\r
\r
- \r
/**\r
* The context manager mediates context start/stop and workbench shutdowns to all registered listeners.\r
*\r
- * @author a.theys \r
+ * @author a.theys\r
* @created mar 13, 2012\r
- * @version 1.0\r
*/\r
public class UseRecordDetailElement extends\r
AbstractCdmDetailElement<CategoricalData> implements SelectionListener {\r
\r
- private static final Logger logger = Logger\r
- .getLogger(UseRecordDetailElement.class);\r
+ @SuppressWarnings("unused")\r
+ private static final Logger logger = LogManager.getLogger();\r
\r
private TermComboElement<State> combo_UseCategory;\r
private TermComboElement<State> combo_UseSubCategory;\r
- private TermComboElement<Modifier> combo_PlantPart;\r
- private TermComboElement<Modifier> combo_Country;\r
- private TermComboElement<Modifier> combo_HumanGroup;\r
- private TermComboElement<Modifier> combo_EthnicGroup;\r
+ private TermComboElement<DefinedTerm> combo_PlantPart;\r
+ private TermComboElement<DefinedTerm> combo_Country;\r
+ private TermComboElement<DefinedTerm> combo_HumanGroup;\r
+ private TermComboElement<DefinedTerm> combo_EthnicGroup;\r
\r
public UseRecordDetailElement(CdmFormFactory formFactory,\r
ICdmFormElement formElement) {\r
super(formFactory, formElement);\r
}\r
\r
- /** {@inheritDoc} */\r
@Override\r
protected void createControls(ICdmFormElement formElement,\r
CategoricalData entity, int style) {\r
\r
- combo_UseCategory = formFactory.createTermComboElement(State.class, this, UsageTermCollection.useCategoryVocabularyLabel, null, style);\r
+ combo_UseCategory = formFactory.createDefinedTermComboElement(TermType.State, this, UsageTermCollection.useCategoryVocabularyLabel, null, style);\r
combo_UseCategory.addSelectionListener(this);\r
- combo_UseSubCategory = formFactory.createTermComboElement(State.class, this, UsageTermCollection.useSubCategoryVocabularyLabel, null, style);\r
- combo_PlantPart = formFactory.createTermComboElement(Modifier.class, this, UsageTermCollection.plantPartLabel, null, style);\r
- combo_HumanGroup = formFactory.createTermComboElement(Modifier.class, this, UsageTermCollection.humanGroupLabel, null, style);\r
+ combo_UseSubCategory = formFactory.createDefinedTermComboElement(TermType.State, this, UsageTermCollection.useSubCategoryVocabularyLabel, null, style);\r
+ combo_PlantPart = formFactory.createDefinedTermComboElement(TermType.Modifier, this, UsageTermCollection.plantPartLabel, null, style);\r
+ combo_HumanGroup = formFactory.createDefinedTermComboElement(TermType.Modifier, this, UsageTermCollection.humanGroupLabel, null, style);\r
combo_HumanGroup.addSelectionListener(this);\r
- combo_EthnicGroup = formFactory.createTermComboElement(Modifier.class, this, UsageTermCollection.ethnicGroupLabel, null, style);\r
- combo_Country = formFactory.createTermComboElement(Modifier.class, this, UsageTermCollection.countryLabel, null, style);\r
- \r
+ combo_EthnicGroup = formFactory.createDefinedTermComboElement(TermType.Modifier, this, UsageTermCollection.ethnicGroupLabel, null, style);\r
+ combo_Country = formFactory.createDefinedTermComboElement(TermType.Modifier, this, UsageTermCollection.countryLabel, null, style);\r
+\r
\r
List<State> termsUseCategory = setUseCategoryComboTerms(TermStore.getTerms(State.class, null, false));\r
combo_UseCategory.setTerms(termsUseCategory);\r
combo_UseCategory.setSelection(stateSelection(UsageTermCollection.useCategoryVocabularyLabel));\r
- \r
+\r
List<State> termsSubCategory = setUseCategoryComboTerms(TermStore.getTerms(State.class, null, false), combo_UseCategory.getSelection());\r
- \r
+\r
if (termsSubCategory != null) {\r
combo_UseSubCategory.setTerms(termsSubCategory);\r
combo_UseSubCategory.setSelection(stateSelection(UsageTermCollection.useSubCategoryVocabularyLabel));\r
else {\r
combo_UseSubCategory.setEnabled(false);\r
}\r
- \r
- List<Modifier> plantPartsToAdd = setModifierComboTerms(TermStore.getTerms(Modifier.class, null, false), UsageTermCollection.plantPartLabel);\r
+\r
+ List<DefinedTerm> plantPartsToAdd = setModifierComboTerms(TermStore.getTerms(DefinedTerm.class, null, false), UsageTermCollection.plantPartLabel);\r
combo_PlantPart.setTerms(plantPartsToAdd);\r
combo_PlantPart.setSelection(modifierSelection(UsageTermCollection.plantPartLabel));\r
- \r
- List<Modifier> countriesToAdd = setModifierComboTerms(TermStore.getTerms(Modifier.class, null, false), UsageTermCollection.countryLabel);\r
+\r
+ List<DefinedTerm> countriesToAdd = setModifierComboTerms(TermStore.getTerms(DefinedTerm.class, null, false), UsageTermCollection.countryLabel);\r
combo_Country.setTerms(countriesToAdd);\r
combo_Country.setSelection(modifierSelection(UsageTermCollection.countryLabel));\r
- \r
- List<Modifier> humanGroupToAdd = setModifierComboTerms(TermStore.getTerms(Modifier.class, null, false), UsageTermCollection.humanGroupLabel);\r
+\r
+ List<DefinedTerm> humanGroupToAdd = setModifierComboTerms(TermStore.getTerms(DefinedTerm.class, null, false), UsageTermCollection.humanGroupLabel);\r
combo_HumanGroup.setTerms(humanGroupToAdd);\r
combo_HumanGroup.setSelection(modifierSelection(UsageTermCollection.humanGroupLabel));\r
- \r
- List<Modifier> ethnicGroupToAdd = setEthnicGroupComboTerms(TermStore.getTerms(Modifier.class, null, false), combo_HumanGroup.getSelection());\r
+\r
+ List<DefinedTerm> ethnicGroupToAdd = setEthnicGroupComboTerms(TermStore.getTerms(DefinedTerm.class, null, false), combo_HumanGroup.getSelection());\r
if (ethnicGroupToAdd != null) {\r
combo_EthnicGroup.setTerms(ethnicGroupToAdd);\r
combo_EthnicGroup.setSelection(modifierSelection(UsageTermCollection.ethnicGroupLabel));\r
} else {\r
combo_EthnicGroup.setEnabled(false);\r
}\r
-\r
}\r
\r
/**\r
* Returns the select modifier\r
- * @param comboCategory\r
- * @return\r
*/\r
- private Modifier modifierSelection(String comboCategory) {\r
+ private DefinedTerm modifierSelection(String comboCategory) {\r
if(!getEntity().getModifiers().isEmpty()) {\r
- for (Modifier modifier : getEntity().getModifiers()) {\r
+ for (DefinedTerm modifier : getEntity().getModifiers()) {\r
if(GetVocabularyType(modifier, comboCategory)) {\r
return modifier;\r
}\r
return null;\r
}\r
return null;\r
- \r
}\r
- \r
+\r
/**\r
* Returns the selected state\r
- * @param comboCategory\r
- * @return\r
*/\r
private State stateSelection(String comboCategory) {\r
- if (!getEntity().getStates().isEmpty()) {\r
- for (StateData statedata : getEntity().getStates()) {\r
+ if (!getEntity().getStateData().isEmpty()) {\r
+ for (StateData statedata : getEntity().getStateData()) {\r
if (statedata.getModifyingText().get(CdmStore.getDefaultLanguage()) != null) {\r
String testString = statedata.getModifyingText().get(CdmStore.getDefaultLanguage()).getText();\r
if(testString.equals(comboCategory)) {\r
if(statedata.getState() !=null) {\r
- return statedata.getState();\r
+ return CdmBase.deproxy(statedata.getState(), State.class);\r
}\r
}\r
- } \r
+ }\r
}\r
}\r
else {\r
return null;\r
}\r
return null;\r
- \r
}\r
- \r
+\r
/**\r
* This function sets the combo terms (Besides EthnicGroup\r
- * @param listOfTerms\r
- * @param modType\r
- * @return\r
*/\r
- private List<Modifier> setModifierComboTerms(List<Modifier> listOfTerms, String modType) {\r
- List<Modifier> termsToAdd = new ArrayList<Modifier>();\r
- for (Modifier term : listOfTerms) {\r
+ private List<DefinedTerm> setModifierComboTerms(List<DefinedTerm> listOfTerms, String modType) {\r
+ List<DefinedTerm> termsToAdd = new ArrayList<DefinedTerm>();\r
+ for (DefinedTerm term : listOfTerms) {\r
\r
if ((term.getPartOf() != null) && (term.getPartOf().getTitleCache().equals(modType))) {\r
termsToAdd.add(term);\r
termsToAdd.add(term);\r
}\r
}\r
- \r
+\r
return termsToAdd;\r
}\r
- \r
\r
/**\r
* This function sets the Use Category combo term\r
- * @param listOfTerms\r
- * @return\r
*/\r
private List<State> setUseCategoryComboTerms(List<State> listOfTerms) {\r
- List<State> termsToAdd = new ArrayList<State>();\r
+ List<State> termsToAdd = new ArrayList<>();\r
for (State term : listOfTerms) {\r
-\r
- if ((term.getPartOf() != null) && (term.getPartOf().getTitleCache().equals(UsageTermCollection.useCategoryVocabularyLabel))) {\r
+ if ((term.getPartOf() != null) && (term.getPartOf().getUuid().equals( UsageTermCollection.uuidUseCategoryVocabulary))) {\r
termsToAdd.add(term);\r
}\r
- else if ((term.getVocabulary() !=null) && (term.getPartOf() == null) && (term.getVocabulary().getTitleCache().equals(UsageTermCollection.useCategoryVocabularyLabel))) {\r
+ else if ((term.getVocabulary() !=null) && (term.getPartOf() == null) && (term.getVocabulary().getUuid().equals(UsageTermCollection.uuidUseCategoryVocabulary))) {\r
termsToAdd.add(term);\r
}\r
}\r
return termsToAdd;\r
-\r
}\r
\r
/**\r
* This function sets the Use SubCategory combo term\r
- * @param listOfTerms\r
- * @param selectedUseCategory\r
- * @return\r
*/\r
private List<State> setUseCategoryComboTerms(List<State> listOfTerms,\r
State selectedUseCategory) {\r
- List<State> termsToAdd = new ArrayList<State>();\r
+\r
+ List<State> termsToAdd = new ArrayList<>();\r
if (combo_UseCategory.getSelection() != null) {\r
- \r
+\r
for (State term : listOfTerms) {\r
if ((term.getPartOf() != null) && (term.getPartOf().getTitleCache().equals(selectedUseCategory.getTitleCache()))) {\r
termsToAdd.add(term);\r
else if ((term.getVocabulary() !=null) && (term.getVocabulary().getTitleCache().equals(selectedUseCategory.getTitleCache()))) {\r
termsToAdd.add(term);\r
}\r
- \r
+\r
}\r
}\r
- else if (!getEntity().getStates().isEmpty()) {\r
- for (StateData stateData : getEntity().getStates()) {\r
+ else if (!getEntity().getStateData().isEmpty()) {\r
+ for (StateData stateData : getEntity().getStateData()) {\r
if (stateData.getModifyingText().get(CdmStore.getDefaultLanguage()) != null) {\r
if ((stateData.getState() != null) && (stateData.getModifyingText().get(CdmStore.getDefaultLanguage()).getText() == UsageTermCollection.useCategoryVocabularyLabel)) {\r
for (State term : listOfTerms) {\r
termsToAdd.add(term);\r
}\r
}\r
- \r
+\r
}\r
}\r
}\r
- \r
}\r
- \r
else {\r
return null;\r
}\r
\r
return termsToAdd;\r
}\r
- \r
- \r
+\r
+\r
/**\r
* This function sets the EthnicGroup combo term\r
- * @param listOfTerms\r
- * @param selectedHumangroup\r
- * @return\r
*/\r
- private List<Modifier> setEthnicGroupComboTerms(List<Modifier> listOfTerms,\r
- Modifier selectedHumangroup) {\r
- List<Modifier> termsToAdd = new ArrayList<Modifier>();\r
+ private List<DefinedTerm> setEthnicGroupComboTerms(List<DefinedTerm> listOfTerms,\r
+ DefinedTerm selectedHumangroup) {\r
+ List<DefinedTerm> termsToAdd = new ArrayList<DefinedTerm>();\r
if (combo_HumanGroup.getSelection() != null) {\r
- for (Modifier term : listOfTerms) {\r
- \r
+ for (DefinedTerm term : listOfTerms) {\r
+\r
if ((term.getPartOf() != null) && (term.getPartOf().getTitleCache().equals(selectedHumangroup.getTitleCache()))) {\r
termsToAdd.add(term);\r
}\r
}\r
}\r
else if (!getEntity().getModifiers().isEmpty()) {\r
- for (Modifier modifier : getEntity().getModifiers()) {\r
+ for (DefinedTerm modifier : getEntity().getModifiers()) {\r
if (modifier.getMarkers() != null) {\r
for (Marker marker : modifier.getMarkers()) {\r
if(marker.getMarkerType().getTitleCache().equals(UsageTermCollection.humanGroupLabel)) {\r
- for (Modifier term : listOfTerms) {\r
+ for (DefinedTerm term : listOfTerms) {\r
if ((term.getPartOf() != null) && (term.getPartOf().getTitleCache().equals(modifier.getTitleCache()))) {\r
termsToAdd.add(modifier);\r
} else if ((term.getVocabulary() != null) && (term.getVocabulary().getTitleCache().equals(modifier.getTitleCache()))) {\r
termsToAdd.add(modifier);\r
}\r
}\r
- \r
+\r
}\r
}\r
}\r
} else {\r
return null;\r
}\r
- \r
+\r
return termsToAdd;\r
}\r
\r
- \r
- /** {@inheritDoc} */\r
@Override\r
public void handleEvent(Object eventSource) {\r
if (eventSource == combo_UseCategory) {\r
if (combo_UseCategory.getSelection() != null) {\r
boolean isChanged = false;\r
boolean isUseCategoryChanged = false;\r
- if (!getEntity().getStates().isEmpty()) {\r
- for (StateData useCategoryStateDataCheck : getEntity().getStates()) {\r
+ if (!getEntity().getStateData().isEmpty()) {\r
+ for (StateData useCategoryStateDataCheck : getEntity().getStateData()) {\r
Map<Language, LanguageString> modText = useCategoryStateDataCheck.getModifyingText();\r
if(modText.get(CdmStore.getDefaultLanguage()) != null && modText.get(CdmStore.getDefaultLanguage()).getText().equals(UsageTermCollection.useCategoryVocabularyLabel)) {\r
if(!useCategoryStateDataCheck.getState().getTitleCache().equals(combo_UseCategory.getSelection().getTitleCache())) {\r
isUseCategoryChanged = true;\r
}\r
- \r
+\r
}\r
}\r
- ListIterator<StateData> itrExistingStates = getEntity().getStates().listIterator();\r
+ ListIterator<StateData> itrExistingStates = getEntity().getStateData().listIterator();\r
while(itrExistingStates.hasNext()) {\r
StateData existingStateData = itrExistingStates.next();\r
Map<Language, LanguageString> modifyingText = existingStateData\r
stateData.setState(combo_UseCategory.getSelection());\r
stateData.putModifyingText(CdmStore.getDefaultLanguage(),UsageTermCollection.useCategoryVocabularyLabel);\r
itrExistingStates.add(stateData);\r
- \r
+\r
}\r
} else if (modifyingText.get(CdmStore.getDefaultLanguage()).getText().equals(UsageTermCollection.useSubCategoryVocabularyLabel) && isUseCategoryChanged == true) {\r
itrExistingStates.remove();\r
}\r
}\r
}\r
- \r
- \r
+\r
if (isChanged == false) {\r
StateData stateData = StateData\r
.NewInstance(combo_UseCategory.getSelection());\r
stateData.setState(combo_UseCategory.getSelection());\r
stateData.putModifyingText(CdmStore.getDefaultLanguage(), UsageTermCollection.useCategoryVocabularyLabel);\r
- getEntity().addState(stateData);\r
+ getEntity().addStateData(stateData);\r
}\r
- \r
+\r
combo_UseSubCategory.setEnabled(true);\r
- \r
}\r
else {\r
- if (!getEntity().getStates().isEmpty()) {\r
- Iterator<StateData> itr = getEntity().getStates().iterator();\r
+ if (!getEntity().getStateData().isEmpty()) {\r
+ Iterator<StateData> itr = getEntity().getStateData().iterator();\r
while(itr.hasNext()) {\r
- StateData stateToRemove = itr.next();\r
+ itr.next();\r
itr.remove();\r
}\r
- List<State> termsSubCategory = new ArrayList<State>();\r
+ List<State> termsSubCategory = new ArrayList<>();\r
State emptyState = State.NewInstance();\r
termsSubCategory.add(emptyState);\r
combo_UseSubCategory.setTerms(termsSubCategory);\r
}\r
}\r
}\r
- \r
+\r
if (eventSource == combo_UseSubCategory) {\r
if (combo_UseSubCategory.getSelection() != null) {\r
boolean isChanged = false;\r
- if (!getEntity().getStates().isEmpty()) {\r
- ListIterator<StateData> itrExistingStates = getEntity().getStates().listIterator();\r
+ if (!getEntity().getStateData().isEmpty()) {\r
+ ListIterator<StateData> itrExistingStates = getEntity().getStateData().listIterator();\r
while(itrExistingStates.hasNext()) {\r
StateData existingStateData = itrExistingStates.next();\r
Map<Language, LanguageString> modifyingText = existingStateData\r
}\r
}\r
}\r
- \r
+\r
if (isChanged == false){\r
StateData stateData = StateData\r
.NewInstance(combo_UseSubCategory.getSelection());\r
stateData.setState(combo_UseSubCategory.getSelection());\r
stateData.putModifyingText(CdmStore.getDefaultLanguage(), UsageTermCollection.useSubCategoryVocabularyLabel);\r
- getEntity().addState(stateData);\r
+ getEntity().addStateData(stateData);\r
}\r
- \r
} else {\r
- if (!getEntity().getStates().isEmpty()) {\r
- Iterator<StateData> itrStateData = getEntity().getStates().iterator();\r
+ if (!getEntity().getStateData().isEmpty()) {\r
+ Iterator<StateData> itrStateData = getEntity().getStateData().iterator();\r
while(itrStateData.hasNext()) {\r
StateData existingStateData = itrStateData.next();\r
Map<Language, LanguageString> modifyingText = existingStateData\r
}\r
if (eventSource == combo_PlantPart) {\r
if (combo_PlantPart.getSelection() != null) {\r
- Iterator<Modifier> itrExistingModifiers = getEntity().getModifiers().iterator();\r
+ Iterator<DefinedTerm> itrExistingModifiers = getEntity().getModifiers().iterator();\r
while (itrExistingModifiers.hasNext()) {\r
- Modifier modifier = itrExistingModifiers.next();\r
+ DefinedTerm modifier = itrExistingModifiers.next();\r
if(GetVocabularyType(modifier, UsageTermCollection.plantPartLabel)) {\r
itrExistingModifiers.remove();\r
}\r
- \r
- } \r
- Modifier plantPart = combo_PlantPart.getSelection();\r
+ }\r
+ DefinedTerm plantPart = combo_PlantPart.getSelection();\r
getEntity().addModifier(plantPart);\r
} else {\r
- Set<Modifier> modifiers = getEntity().getModifiers();\r
+ Set<DefinedTerm> modifiers = getEntity().getModifiers();\r
if(!modifiers.isEmpty()) {\r
- Iterator<Modifier> itr = modifiers.iterator();\r
+ Iterator<DefinedTerm> itr = modifiers.iterator();\r
while (itr.hasNext()) {\r
- Modifier currentMod = itr.next();\r
+ DefinedTerm currentMod = itr.next();\r
if(GetVocabularyType(currentMod, UsageTermCollection.plantPartLabel)) {\r
itr.remove();\r
}\r
}\r
}\r
- \r
}\r
}\r
if (eventSource == combo_Country) {\r
if (combo_Country.getSelection() != null) {\r
- Iterator<Modifier> itrExistingModifiers = getEntity().getModifiers().iterator();\r
+ Iterator<DefinedTerm> itrExistingModifiers = getEntity().getModifiers().iterator();\r
while (itrExistingModifiers.hasNext()) {\r
- Modifier modifier = itrExistingModifiers.next();\r
+ DefinedTerm modifier = itrExistingModifiers.next();\r
if(GetVocabularyType(modifier, UsageTermCollection.countryLabel)) {\r
itrExistingModifiers.remove();\r
}\r
- \r
}\r
- Modifier country = combo_Country.getSelection();\r
+ DefinedTerm country = combo_Country.getSelection();\r
getEntity().addModifier(country);\r
} else {\r
- Set<Modifier> modifiers = getEntity().getModifiers();\r
+ Set<DefinedTerm> modifiers = getEntity().getModifiers();\r
if(!modifiers.isEmpty()) {\r
- Iterator<Modifier> itr = modifiers.iterator();\r
+ Iterator<DefinedTerm> itr = modifiers.iterator();\r
while (itr.hasNext()) {\r
- Modifier currentMod = itr.next();\r
+ DefinedTerm currentMod = itr.next();\r
if(GetVocabularyType(currentMod, UsageTermCollection.countryLabel)) {\r
itr.remove();\r
}\r
if (eventSource == combo_HumanGroup) {\r
if (combo_HumanGroup.getSelection() != null) {\r
boolean isHumanGroupChanged = true;\r
- for (Modifier modToCheck: getEntity().getModifiers()) {\r
+ for (DefinedTerm modToCheck: getEntity().getModifiers()) {\r
if(modToCheck.equals(combo_HumanGroup.getSelection()) && (GetVocabularyType(modToCheck, UsageTermCollection.humanGroupLabel))) {\r
isHumanGroupChanged = false;\r
+ }\r
}\r
- \r
- \r
- }\r
- Iterator<Modifier> itrExistingModifiers = getEntity().getModifiers().iterator();\r
+ Iterator<DefinedTerm> itrExistingModifiers = getEntity().getModifiers().iterator();\r
while (itrExistingModifiers.hasNext()) {\r
- Modifier modifier = itrExistingModifiers.next();\r
+ DefinedTerm modifier = itrExistingModifiers.next();\r
if((GetVocabularyType(modifier, UsageTermCollection.humanGroupLabel) || GetVocabularyType(modifier, UsageTermCollection.ethnicGroupLabel)) && isHumanGroupChanged) {\r
itrExistingModifiers.remove();\r
}\r
- \r
- } \r
+ }\r
if(isHumanGroupChanged){\r
- Modifier humanGroup = combo_HumanGroup.getSelection();\r
+ DefinedTerm humanGroup = combo_HumanGroup.getSelection();\r
getEntity().addModifier(humanGroup);\r
}\r
combo_EthnicGroup.setEnabled(true);\r
} else {\r
- Set<Modifier> modifiers = getEntity().getModifiers();\r
+ Set<DefinedTerm> modifiers = getEntity().getModifiers();\r
if(!modifiers.isEmpty()) {\r
- Iterator<Modifier> itr = modifiers.iterator();\r
+ Iterator<DefinedTerm> itr = modifiers.iterator();\r
while (itr.hasNext()) {\r
- Modifier currentMod = itr.next();\r
+ DefinedTerm currentMod = itr.next();\r
if(GetVocabularyType(currentMod, UsageTermCollection.humanGroupLabel) || GetVocabularyType(currentMod, UsageTermCollection.ethnicGroupLabel)) {\r
itr.remove();\r
}\r
}\r
}\r
- List<Modifier> emptyListToResetComboBox = new ArrayList<Modifier>();\r
- Modifier emptyMod = Modifier.NewInstance();\r
+ List<DefinedTerm> emptyListToResetComboBox = new ArrayList<DefinedTerm>();\r
+\r
+// DefinedTerm emptyMod = DefinedTerm.NewInstance();\r
+ DefinedTerm emptyMod = null;\r
+\r
emptyListToResetComboBox.add(emptyMod);\r
combo_EthnicGroup.setTerms(emptyListToResetComboBox);\r
combo_EthnicGroup.setEnabled(false);\r
- \r
}\r
}\r
if (eventSource == combo_EthnicGroup) {\r
if (combo_EthnicGroup.getSelection() != null) {\r
- Iterator<Modifier> itrExistingModifiers = getEntity().getModifiers().iterator();\r
+ Iterator<DefinedTerm> itrExistingModifiers = getEntity().getModifiers().iterator();\r
while (itrExistingModifiers.hasNext()) {\r
- Modifier modifier = itrExistingModifiers.next();\r
+ DefinedTerm modifier = itrExistingModifiers.next();\r
if(GetVocabularyType(modifier, combo_HumanGroup.getSelection().getTitleCache())) {\r
itrExistingModifiers.remove();\r
}\r
- \r
- } \r
- Modifier ethnicGroup = combo_EthnicGroup.getSelection();\r
+ }\r
+ DefinedTerm ethnicGroup = combo_EthnicGroup.getSelection();\r
getEntity().addModifier(ethnicGroup);\r
} else {\r
- Set<Modifier> modifiers = getEntity().getModifiers();\r
+ Set<DefinedTerm> modifiers = getEntity().getModifiers();\r
if(!modifiers.isEmpty()) {\r
- \r
- Iterator<Modifier> itr = modifiers.iterator();\r
+\r
+ Iterator<DefinedTerm> itr = modifiers.iterator();\r
while (itr.hasNext()) {\r
- Modifier currentMod = itr.next();\r
+ DefinedTerm currentMod = itr.next();\r
if(GetVocabularyType(currentMod, UsageTermCollection.ethnicGroupLabel)) {\r
itr.remove();\r
}\r
}\r
- \r
}\r
}\r
}\r
}\r
- \r
- \r
\r
/**\r
* This function Checks the vocabulary type\r
- * @param term\r
- * @param vocabularyExpected\r
- * @return\r
*/\r
- private boolean GetVocabularyType(Modifier term, String vocabularyExpected) {\r
+ private boolean GetVocabularyType(DefinedTerm term, String vocabularyExpected) {\r
if ((term.getPartOf() != null) && (term.getPartOf().getTitleCache().equals(vocabularyExpected))) {\r
return true;\r
}\r
else if ((term.getVocabulary() != null) && (term.getPartOf()==null) && (term.getVocabulary().getTitleCache().equals(vocabularyExpected))) {\r
return true;\r
}\r
- else if ((vocabularyExpected.equals(UsageTermCollection.ethnicGroupLabel)) && (term.getVocabulary() == null) && ((term.getPartOf() != null))) {\r
+ else if ((vocabularyExpected.equals(UsageTermCollection.ethnicGroupLabel)) && ((term.getPartOf() != null))) {\r
return true;\r
}\r
return false;\r
}\r
- \r
- \r
\r
- /** {@inheritDoc} */\r
@Override\r
public void setEntity(CategoricalData entity) {\r
super.setEntity(entity);\r
}\r
\r
- /** {@inheritDoc} */\r
@Override\r
public void widgetSelected(SelectionEvent e) {\r
Object eventSource = e.getSource();\r
State selectedUseCategory = combo_UseCategory.getSelection();\r
if (selectedUseCategory != null) {\r
combo_UseSubCategory.setTerms(setUseCategoryComboTerms(TermStore.getTerms(State.class, null, false),selectedUseCategory));\r
- \r
- if (!getEntity().getStates().isEmpty()) {\r
- Iterator<StateData> itrExistingState = getEntity().getStates().iterator();\r
+\r
+ if (!getEntity().getStateData().isEmpty()) {\r
+ Iterator<StateData> itrExistingState = getEntity().getStateData().iterator();\r
while(itrExistingState.hasNext()) {\r
- StateData existingStateData = (StateData) itrExistingState.next();\r
+ StateData existingStateData = itrExistingState.next();\r
Map<Language, LanguageString> modifyingText = existingStateData.getModifyingText();\r
if (modifyingText.get(CdmStore.getDefaultLanguage()) != null) {\r
if (modifyingText.get(CdmStore.getDefaultLanguage())\r
}\r
for (Object object: combo_HumanGroup.getControls()) {\r
if (object == eventSource) {\r
- Modifier selectedHumanGroup = combo_HumanGroup.getSelection();\r
+ DefinedTerm selectedHumanGroup = combo_HumanGroup.getSelection();\r
if (selectedHumanGroup != null) {\r
- combo_EthnicGroup.setTerms(setEthnicGroupComboTerms(TermStore.getTerms(Modifier.class, null, false), selectedHumanGroup));\r
+ combo_EthnicGroup.setTerms(setEthnicGroupComboTerms(TermStore.getTerms(DefinedTerm.class, null, false), selectedHumanGroup));\r
if (!getEntity().getModifiers().isEmpty()) {\r
- Iterator<Modifier> iterModifiers = getEntity().getModifiers().iterator();\r
+ Iterator<DefinedTerm> iterModifiers = getEntity().getModifiers().iterator();\r
while (iterModifiers.hasNext()) {\r
- Modifier existingModifier = iterModifiers.next();\r
+ DefinedTerm existingModifier = iterModifiers.next();\r
if(GetVocabularyType(existingModifier, UsageTermCollection.ethnicGroupLabel)) {\r
combo_EthnicGroup.setSelection(modifierSelection(UsageTermCollection.ethnicGroupLabel));\r
}\r
}\r
}\r
- \r
}\r
}\r
}\r
}\r
\r
- /** {@inheritDoc} */\r
@Override\r
public void widgetDefaultSelected(SelectionEvent e) {\r
// TODO Auto-generated method stub\r
+ }\r
+
\r
+ @Override\r
+ public void fillFields() {\r
+ // TODO \r
+ //combo_UseCategory;\r
+ //combo_UseSubCategory;\r
+ //combo_PlantPart;\r
+ //combo_Country;\r
+ //combo_HumanGroup;\r
+ //combo_EthnicGroup;\r
}\r
\r
-}\r
+}