/**\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
+\r
import org.apache.log4j.Logger;\r
import org.eclipse.swt.events.SelectionEvent;\r
import org.eclipse.swt.events.SelectionListener;\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.common.TermType;\r
import eu.etaxonomy.cdm.model.description.CategoricalData;\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.taxeditor.store.CdmStore;\r
import eu.etaxonomy.taxeditor.store.TermStore;\r
+import eu.etaxonomy.taxeditor.store.UsageTermCollection;\r
import eu.etaxonomy.taxeditor.ui.combo.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
/**\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 = Logger.getLogger(UseRecordDetailElement.class);\r
\r
private TermComboElement<State> combo_UseCategory;\r
private TermComboElement<State> combo_UseSubCategory;\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(DefinedTerm.class, this, UsageTermCollection.plantPartLabel, null, style);\r
- combo_HumanGroup = formFactory.createTermComboElement(DefinedTerm.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(DefinedTerm.class, this, UsageTermCollection.ethnicGroupLabel, null, style);\r
- combo_Country = formFactory.createTermComboElement(DefinedTerm.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
+\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
+\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
+\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
+\r
List<DefinedTerm> ethnicGroupToAdd = setEthnicGroupComboTerms(TermStore.getTerms(DefinedTerm.class, null, false), combo_HumanGroup.getSelection());\r
if (ethnicGroupToAdd != null) {\r
combo_EthnicGroup.setTerms(ethnicGroupToAdd);\r
return null;\r
}\r
return null;\r
- \r
+\r
}\r
- \r
+\r
/**\r
* Returns the selected state\r
* @param comboCategory\r
return statedata.getState();\r
}\r
}\r
- } \r
+ }\r
}\r
}\r
else {\r
return null;\r
}\r
return null;\r
- \r
+\r
}\r
- \r
+\r
/**\r
* This function sets the combo terms (Besides EthnicGroup\r
* @param listOfTerms\r
termsToAdd.add(term);\r
}\r
}\r
- \r
+\r
return termsToAdd;\r
}\r
- \r
+\r
\r
/**\r
* This function sets the Use Category combo term\r
List<State> termsToAdd = new ArrayList<State>();\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
State selectedUseCategory) {\r
List<State> termsToAdd = new ArrayList<State>();\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().getStateData().isEmpty()) {\r
termsToAdd.add(term);\r
}\r
}\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
List<DefinedTerm> termsToAdd = new ArrayList<DefinedTerm>();\r
if (combo_HumanGroup.getSelection() != null) {\r
for (DefinedTerm term : listOfTerms) {\r
- \r
+\r
if ((term.getPartOf() != null) && (term.getPartOf().getTitleCache().equals(selectedHumangroup.getTitleCache()))) {\r
termsToAdd.add(term);\r
}\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
+\r
/** {@inheritDoc} */\r
@Override\r
public void handleEvent(Object eventSource) {\r
if(!useCategoryStateDataCheck.getState().getTitleCache().equals(combo_UseCategory.getSelection().getTitleCache())) {\r
isUseCategoryChanged = true;\r
}\r
- \r
+\r
}\r
}\r
ListIterator<StateData> itrExistingStates = getEntity().getStateData().listIterator();\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
+\r
if (isChanged == false) {\r
StateData stateData = StateData\r
.NewInstance(combo_UseCategory.getSelection());\r
stateData.putModifyingText(CdmStore.getDefaultLanguage(), UsageTermCollection.useCategoryVocabularyLabel);\r
getEntity().addStateData(stateData);\r
}\r
- \r
+\r
combo_UseSubCategory.setEnabled(true);\r
- \r
+\r
}\r
else {\r
if (!getEntity().getStateData().isEmpty()) {\r
}\r
}\r
}\r
- \r
+\r
if (eventSource == combo_UseSubCategory) {\r
if (combo_UseSubCategory.getSelection() != null) {\r
boolean isChanged = false;\r
}\r
}\r
}\r
- \r
+\r
if (isChanged == false){\r
StateData stateData = StateData\r
.NewInstance(combo_UseSubCategory.getSelection());\r
stateData.putModifyingText(CdmStore.getDefaultLanguage(), UsageTermCollection.useSubCategoryVocabularyLabel);\r
getEntity().addStateData(stateData);\r
}\r
- \r
+\r
} else {\r
if (!getEntity().getStateData().isEmpty()) {\r
Iterator<StateData> itrStateData = getEntity().getStateData().iterator();\r
if(GetVocabularyType(modifier, UsageTermCollection.plantPartLabel)) {\r
itrExistingModifiers.remove();\r
}\r
- \r
- } \r
+\r
+ }\r
DefinedTerm plantPart = combo_PlantPart.getSelection();\r
getEntity().addModifier(plantPart);\r
} else {\r
}\r
}\r
}\r
- \r
+\r
}\r
}\r
if (eventSource == combo_Country) {\r
if(GetVocabularyType(modifier, UsageTermCollection.countryLabel)) {\r
itrExistingModifiers.remove();\r
}\r
- \r
+\r
}\r
DefinedTerm country = combo_Country.getSelection();\r
getEntity().addModifier(country);\r
if(modToCheck.equals(combo_HumanGroup.getSelection()) && (GetVocabularyType(modToCheck, UsageTermCollection.humanGroupLabel))) {\r
isHumanGroupChanged = false;\r
}\r
- \r
- \r
+\r
+\r
}\r
Iterator<DefinedTerm> itrExistingModifiers = getEntity().getModifiers().iterator();\r
while (itrExistingModifiers.hasNext()) {\r
if((GetVocabularyType(modifier, UsageTermCollection.humanGroupLabel) || GetVocabularyType(modifier, UsageTermCollection.ethnicGroupLabel)) && isHumanGroupChanged) {\r
itrExistingModifiers.remove();\r
}\r
- \r
- } \r
+\r
+ }\r
if(isHumanGroupChanged){\r
DefinedTerm humanGroup = combo_HumanGroup.getSelection();\r
getEntity().addModifier(humanGroup);\r
}\r
}\r
List<DefinedTerm> emptyListToResetComboBox = new ArrayList<DefinedTerm>();\r
- //FIXME:3.3MC----\r
- //DefinedTerm emptyMod = DefinedTerm.NewInstance();\r
+\r
+// DefinedTerm emptyMod = DefinedTerm.NewInstance();\r
DefinedTerm emptyMod = null;\r
- //FIXME:3.3MC----\r
- \r
- \r
+\r
+\r
emptyListToResetComboBox.add(emptyMod);\r
combo_EthnicGroup.setTerms(emptyListToResetComboBox);\r
combo_EthnicGroup.setEnabled(false);\r
- \r
+\r
}\r
}\r
if (eventSource == combo_EthnicGroup) {\r
if(GetVocabularyType(modifier, combo_HumanGroup.getSelection().getTitleCache())) {\r
itrExistingModifiers.remove();\r
}\r
- \r
- } \r
+\r
+ }\r
DefinedTerm ethnicGroup = combo_EthnicGroup.getSelection();\r
getEntity().addModifier(ethnicGroup);\r
} else {\r
Set<DefinedTerm> modifiers = getEntity().getModifiers();\r
if(!modifiers.isEmpty()) {\r
- \r
+\r
Iterator<DefinedTerm> itr = modifiers.iterator();\r
while (itr.hasNext()) {\r
DefinedTerm currentMod = itr.next();\r
itr.remove();\r
}\r
}\r
- \r
+\r
}\r
}\r
}\r
}\r
- \r
- \r
+\r
+\r
\r
/**\r
* This function Checks the vocabulary type\r
}\r
return false;\r
}\r
- \r
- \r
+\r
+\r
\r
/** {@inheritDoc} */\r
@Override\r
State selectedUseCategory = combo_UseCategory.getSelection();\r
if (selectedUseCategory != null) {\r
combo_UseSubCategory.setTerms(setUseCategoryComboTerms(TermStore.getTerms(State.class, null, false),selectedUseCategory));\r
- \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
}\r
}\r
- \r
+\r
}\r
}\r
}\r