import java.util.Map;\r
import java.util.Set;\r
\r
-import org.apache.log4j.Logger;\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.DefinedTerm;\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.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.campanula.compatibility.ICdmFormElement;\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
* @created mar 13, 2012\r
- * @version 1.0\r
*/\r
public class UseRecordDetailElement extends\r
AbstractCdmDetailElement<CategoricalData> implements SelectionListener {\r
\r
@SuppressWarnings("unused")\r
- private static final Logger logger = Logger.getLogger(UseRecordDetailElement.class);\r
+ private static final Logger logger = LogManager.getLogger();\r
\r
private TermComboElement<State> combo_UseCategory;\r
private TermComboElement<State> combo_UseSubCategory;\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(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
+ 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
} else {\r
combo_EthnicGroup.setEnabled(false);\r
}\r
-\r
}\r
\r
/**\r
* Returns the select modifier\r
- * @param comboCategory\r
- * @return\r
*/\r
private DefinedTerm modifierSelection(String comboCategory) {\r
if(!getEntity().getModifiers().isEmpty()) {\r
return null;\r
}\r
return null;\r
-\r
}\r
\r
/**\r
* Returns the selected state\r
- * @param comboCategory\r
- * @return\r
*/\r
private State stateSelection(String comboCategory) {\r
if (!getEntity().getStateData().isEmpty()) {\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
return null;\r
}\r
return null;\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<DefinedTerm> setModifierComboTerms(List<DefinedTerm> listOfTerms, String modType) {\r
List<DefinedTerm> termsToAdd = new ArrayList<DefinedTerm>();\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
for (State term : listOfTerms) {\r
}\r
}\r
}\r
-\r
}\r
-\r
else {\r
return null;\r
}\r
\r
/**\r
* This function sets the EthnicGroup combo term\r
- * @param listOfTerms\r
- * @param selectedHumangroup\r
- * @return\r
*/\r
private List<DefinedTerm> setEthnicGroupComboTerms(List<DefinedTerm> listOfTerms,\r
DefinedTerm selectedHumangroup) {\r
return termsToAdd;\r
}\r
\r
-\r
- /** {@inheritDoc} */\r
@Override\r
public void handleEvent(Object eventSource) {\r
if (eventSource == combo_UseCategory) {\r
}\r
}\r
\r
-\r
if (isChanged == false) {\r
StateData stateData = StateData\r
.NewInstance(combo_UseCategory.getSelection());\r
}\r
\r
combo_UseSubCategory.setEnabled(true);\r
-\r
}\r
else {\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
stateData.putModifyingText(CdmStore.getDefaultLanguage(), UsageTermCollection.useSubCategoryVocabularyLabel);\r
getEntity().addStateData(stateData);\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
DefinedTerm plantPart = combo_PlantPart.getSelection();\r
getEntity().addModifier(plantPart);\r
}\r
}\r
}\r
-\r
}\r
}\r
if (eventSource == combo_Country) {\r
if(GetVocabularyType(modifier, UsageTermCollection.countryLabel)) {\r
itrExistingModifiers.remove();\r
}\r
-\r
}\r
DefinedTerm country = combo_Country.getSelection();\r
getEntity().addModifier(country);\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<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
if(isHumanGroupChanged){\r
DefinedTerm humanGroup = combo_HumanGroup.getSelection();\r
}\r
}\r
List<DefinedTerm> emptyListToResetComboBox = new ArrayList<DefinedTerm>();\r
- \r
+\r
// DefinedTerm emptyMod = DefinedTerm.NewInstance();\r
DefinedTerm emptyMod = null;\r
\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(GetVocabularyType(modifier, combo_HumanGroup.getSelection().getTitleCache())) {\r
itrExistingModifiers.remove();\r
}\r
-\r
}\r
DefinedTerm ethnicGroup = combo_EthnicGroup.getSelection();\r
getEntity().addModifier(ethnicGroup);\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(DefinedTerm term, String vocabularyExpected) {\r
if ((term.getPartOf() != null) && (term.getPartOf().getTitleCache().equals(vocabularyExpected))) {\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
}\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
+}