cleanup
[taxeditor.git] / eu.etaxonomy.taxeditor.store / src / main / java / eu / etaxonomy / taxeditor / ui / section / userecords / UseRecordDetailElement.java
1 /**
2 * Copyright (C) 2011 EDIT
3 * European Distributed Institute of Taxonomy
4 * http://www.e-taxonomy.eu
5 *
6 * The contents of this file are subject to the Mozilla Public License Version 1.1
7 * See LICENSE.TXT at the top of this package for the full license terms.
8 */
9 package eu.etaxonomy.taxeditor.ui.section.userecords;
10
11 import java.util.ArrayList;
12 import java.util.Iterator;
13 import java.util.List;
14 import java.util.ListIterator;
15 import java.util.Map;
16 import java.util.Set;
17
18 import org.apache.logging.log4j.LogManager;
19 import org.apache.logging.log4j.Logger;
20 import org.eclipse.swt.events.SelectionEvent;
21 import org.eclipse.swt.events.SelectionListener;
22
23 import eu.etaxonomy.cdm.model.term.DefinedTerm;
24 import eu.etaxonomy.cdm.model.common.Language;
25 import eu.etaxonomy.cdm.model.common.LanguageString;
26 import eu.etaxonomy.cdm.model.common.Marker;
27 import eu.etaxonomy.cdm.model.term.TermType;
28 import eu.etaxonomy.cdm.model.description.CategoricalData;
29 import eu.etaxonomy.cdm.model.description.State;
30 import eu.etaxonomy.cdm.model.description.StateData;
31 import eu.etaxonomy.taxeditor.store.CdmStore;
32 import eu.etaxonomy.taxeditor.store.TermStore;
33 import eu.etaxonomy.taxeditor.store.UsageTermCollection;
34 import eu.etaxonomy.taxeditor.ui.combo.term.TermComboElement;
35 import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;
36 import eu.etaxonomy.taxeditor.ui.element.ICdmFormElement;
37 import eu.etaxonomy.taxeditor.ui.section.AbstractCdmDetailElement;
38
39 /**
40 * The context manager mediates context start/stop and workbench shutdowns to all registered listeners.
41 *
42 * @author a.theys
43 * @created mar 13, 2012
44 */
45 public class UseRecordDetailElement extends
46 AbstractCdmDetailElement<CategoricalData> implements SelectionListener {
47
48 @SuppressWarnings("unused")
49 private static final Logger logger = LogManager.getLogger();
50
51 private TermComboElement<State> combo_UseCategory;
52 private TermComboElement<State> combo_UseSubCategory;
53 private TermComboElement<DefinedTerm> combo_PlantPart;
54 private TermComboElement<DefinedTerm> combo_Country;
55 private TermComboElement<DefinedTerm> combo_HumanGroup;
56 private TermComboElement<DefinedTerm> combo_EthnicGroup;
57
58 public UseRecordDetailElement(CdmFormFactory formFactory,
59 ICdmFormElement formElement) {
60 super(formFactory, formElement);
61 }
62
63 @Override
64 protected void createControls(ICdmFormElement formElement,
65 CategoricalData entity, int style) {
66
67 combo_UseCategory = formFactory.createDefinedTermComboElement(TermType.State, this, UsageTermCollection.useCategoryVocabularyLabel, null, style);
68 combo_UseCategory.addSelectionListener(this);
69 combo_UseSubCategory = formFactory.createDefinedTermComboElement(TermType.State, this, UsageTermCollection.useSubCategoryVocabularyLabel, null, style);
70 combo_PlantPart = formFactory.createDefinedTermComboElement(TermType.Modifier, this, UsageTermCollection.plantPartLabel, null, style);
71 combo_HumanGroup = formFactory.createDefinedTermComboElement(TermType.Modifier, this, UsageTermCollection.humanGroupLabel, null, style);
72 combo_HumanGroup.addSelectionListener(this);
73 combo_EthnicGroup = formFactory.createDefinedTermComboElement(TermType.Modifier, this, UsageTermCollection.ethnicGroupLabel, null, style);
74 combo_Country = formFactory.createDefinedTermComboElement(TermType.Modifier, this, UsageTermCollection.countryLabel, null, style);
75
76
77 List<State> termsUseCategory = setUseCategoryComboTerms(TermStore.getTerms(State.class, null, false));
78 combo_UseCategory.setTerms(termsUseCategory);
79 combo_UseCategory.setSelection(stateSelection(UsageTermCollection.useCategoryVocabularyLabel));
80
81 List<State> termsSubCategory = setUseCategoryComboTerms(TermStore.getTerms(State.class, null, false), combo_UseCategory.getSelection());
82
83 if (termsSubCategory != null) {
84 combo_UseSubCategory.setTerms(termsSubCategory);
85 combo_UseSubCategory.setSelection(stateSelection(UsageTermCollection.useSubCategoryVocabularyLabel));
86 combo_UseSubCategory.setEnabled(true);
87 }
88 else {
89 combo_UseSubCategory.setEnabled(false);
90 }
91
92 List<DefinedTerm> plantPartsToAdd = setModifierComboTerms(TermStore.getTerms(DefinedTerm.class, null, false), UsageTermCollection.plantPartLabel);
93 combo_PlantPart.setTerms(plantPartsToAdd);
94 combo_PlantPart.setSelection(modifierSelection(UsageTermCollection.plantPartLabel));
95
96 List<DefinedTerm> countriesToAdd = setModifierComboTerms(TermStore.getTerms(DefinedTerm.class, null, false), UsageTermCollection.countryLabel);
97 combo_Country.setTerms(countriesToAdd);
98 combo_Country.setSelection(modifierSelection(UsageTermCollection.countryLabel));
99
100 List<DefinedTerm> humanGroupToAdd = setModifierComboTerms(TermStore.getTerms(DefinedTerm.class, null, false), UsageTermCollection.humanGroupLabel);
101 combo_HumanGroup.setTerms(humanGroupToAdd);
102 combo_HumanGroup.setSelection(modifierSelection(UsageTermCollection.humanGroupLabel));
103
104 List<DefinedTerm> ethnicGroupToAdd = setEthnicGroupComboTerms(TermStore.getTerms(DefinedTerm.class, null, false), combo_HumanGroup.getSelection());
105 if (ethnicGroupToAdd != null) {
106 combo_EthnicGroup.setTerms(ethnicGroupToAdd);
107 combo_EthnicGroup.setSelection(modifierSelection(UsageTermCollection.ethnicGroupLabel));
108 combo_EthnicGroup.setEnabled(true);
109 } else {
110 combo_EthnicGroup.setEnabled(false);
111 }
112 }
113
114 /**
115 * Returns the select modifier
116 */
117 private DefinedTerm modifierSelection(String comboCategory) {
118 if(!getEntity().getModifiers().isEmpty()) {
119 for (DefinedTerm modifier : getEntity().getModifiers()) {
120 if(GetVocabularyType(modifier, comboCategory)) {
121 return modifier;
122 }
123 }
124 } else {
125 return null;
126 }
127 return null;
128 }
129
130 /**
131 * Returns the selected state
132 * @param comboCategory
133 */
134 private State stateSelection(String comboCategory) {
135 if (!getEntity().getStateData().isEmpty()) {
136 for (StateData statedata : getEntity().getStateData()) {
137 if (statedata.getModifyingText().get(CdmStore.getDefaultLanguage()) != null) {
138 String testString = statedata.getModifyingText().get(CdmStore.getDefaultLanguage()).getText();
139 if(testString.equals(comboCategory)) {
140 if(statedata.getState() !=null) {
141 return statedata.getState();
142 }
143 }
144 }
145 }
146 }
147 else {
148 return null;
149 }
150 return null;
151 }
152
153 /**
154 * This function sets the combo terms (Besides EthnicGroup
155 * @param listOfTerms
156 * @param modType
157 * @return
158 */
159 private List<DefinedTerm> setModifierComboTerms(List<DefinedTerm> listOfTerms, String modType) {
160 List<DefinedTerm> termsToAdd = new ArrayList<DefinedTerm>();
161 for (DefinedTerm term : listOfTerms) {
162
163 if ((term.getPartOf() != null) && (term.getPartOf().getTitleCache().equals(modType))) {
164 termsToAdd.add(term);
165 }
166 else if ((term.getVocabulary() != null) && (term.getPartOf() == null) && (term.getVocabulary().getTitleCache().equals(modType))) {
167 termsToAdd.add(term);
168 }
169 }
170
171 return termsToAdd;
172 }
173
174 /**
175 * This function sets the Use Category combo term
176 */
177 private List<State> setUseCategoryComboTerms(List<State> listOfTerms) {
178 List<State> termsToAdd = new ArrayList<State>();
179 for (State term : listOfTerms) {
180
181 if ((term.getPartOf() != null) && (term.getPartOf().getUuid().equals( UsageTermCollection.uuidUseCategoryVocabulary))) {
182 termsToAdd.add(term);
183 }
184 else if ((term.getVocabulary() !=null) && (term.getPartOf() == null) && (term.getVocabulary().getUuid().equals(UsageTermCollection.uuidUseCategoryVocabulary))) {
185 termsToAdd.add(term);
186 }
187 }
188 return termsToAdd;
189 }
190
191 /**
192 * This function sets the Use SubCategory combo term
193 */
194 private List<State> setUseCategoryComboTerms(List<State> listOfTerms,
195 State selectedUseCategory) {
196 List<State> termsToAdd = new ArrayList<State>();
197 if (combo_UseCategory.getSelection() != null) {
198
199 for (State term : listOfTerms) {
200 if ((term.getPartOf() != null) && (term.getPartOf().getTitleCache().equals(selectedUseCategory.getTitleCache()))) {
201 termsToAdd.add(term);
202 }
203 else if ((term.getVocabulary() !=null) && (term.getVocabulary().getTitleCache().equals(selectedUseCategory.getTitleCache()))) {
204 termsToAdd.add(term);
205 }
206
207 }
208 }
209 else if (!getEntity().getStateData().isEmpty()) {
210 for (StateData stateData : getEntity().getStateData()) {
211 if (stateData.getModifyingText().get(CdmStore.getDefaultLanguage()) != null) {
212 if ((stateData.getState() != null) && (stateData.getModifyingText().get(CdmStore.getDefaultLanguage()).getText() == UsageTermCollection.useCategoryVocabularyLabel)) {
213 for (State term : listOfTerms) {
214 if ((term.getPartOf() != null) && (term.getPartOf().getTitleCache().equals(stateData.getState().getTitleCache()))) {
215 termsToAdd.add(term);
216 } else if ((term.getVocabulary() != null) && (term.getVocabulary().getTitleCache().equals(stateData.getState().getTitleCache()))) {
217 termsToAdd.add(term);
218 }
219 }
220
221 }
222 }
223 }
224 }
225 else {
226 return null;
227 }
228
229 return termsToAdd;
230 }
231
232
233 /**
234 * This function sets the EthnicGroup combo term
235 * @param listOfTerms
236 * @param selectedHumangroup
237 * @return
238 */
239 private List<DefinedTerm> setEthnicGroupComboTerms(List<DefinedTerm> listOfTerms,
240 DefinedTerm selectedHumangroup) {
241 List<DefinedTerm> termsToAdd = new ArrayList<DefinedTerm>();
242 if (combo_HumanGroup.getSelection() != null) {
243 for (DefinedTerm term : listOfTerms) {
244
245 if ((term.getPartOf() != null) && (term.getPartOf().getTitleCache().equals(selectedHumangroup.getTitleCache()))) {
246 termsToAdd.add(term);
247 }
248 else if ((term.getVocabulary() != null) && (term.getVocabulary().getTitleCache().equals(selectedHumangroup.getTitleCache()))) {
249 termsToAdd.add(term);
250 }
251 }
252 }
253 else if (!getEntity().getModifiers().isEmpty()) {
254 for (DefinedTerm modifier : getEntity().getModifiers()) {
255 if (modifier.getMarkers() != null) {
256 for (Marker marker : modifier.getMarkers()) {
257 if(marker.getMarkerType().getTitleCache().equals(UsageTermCollection.humanGroupLabel)) {
258 for (DefinedTerm term : listOfTerms) {
259 if ((term.getPartOf() != null) && (term.getPartOf().getTitleCache().equals(modifier.getTitleCache()))) {
260 termsToAdd.add(modifier);
261 } else if ((term.getVocabulary() != null) && (term.getVocabulary().getTitleCache().equals(modifier.getTitleCache()))) {
262 termsToAdd.add(modifier);
263 }
264 }
265
266 }
267 }
268 }
269 }
270 } else {
271 return null;
272 }
273
274 return termsToAdd;
275 }
276
277
278 /** {@inheritDoc} */
279 @Override
280 public void handleEvent(Object eventSource) {
281 if (eventSource == combo_UseCategory) {
282 if (combo_UseCategory.getSelection() != null) {
283 boolean isChanged = false;
284 boolean isUseCategoryChanged = false;
285 if (!getEntity().getStateData().isEmpty()) {
286 for (StateData useCategoryStateDataCheck : getEntity().getStateData()) {
287 Map<Language, LanguageString> modText = useCategoryStateDataCheck.getModifyingText();
288 if(modText.get(CdmStore.getDefaultLanguage()) != null && modText.get(CdmStore.getDefaultLanguage()).getText().equals(UsageTermCollection.useCategoryVocabularyLabel)) {
289 if(!useCategoryStateDataCheck.getState().getTitleCache().equals(combo_UseCategory.getSelection().getTitleCache())) {
290 isUseCategoryChanged = true;
291 }
292
293 }
294 }
295 ListIterator<StateData> itrExistingStates = getEntity().getStateData().listIterator();
296 while(itrExistingStates.hasNext()) {
297 StateData existingStateData = itrExistingStates.next();
298 Map<Language, LanguageString> modifyingText = existingStateData
299 .getModifyingText();
300 if (modifyingText.get(CdmStore.getDefaultLanguage()) != null) {
301 if (modifyingText.get(CdmStore.getDefaultLanguage()).getText().equals(UsageTermCollection.useCategoryVocabularyLabel)) {
302 isChanged = true;
303 if(!existingStateData.getState().getTitleCache().equals(combo_UseCategory.getSelection().getTitleCache())) {
304 itrExistingStates.remove();
305 StateData stateData = StateData.NewInstance(combo_UseCategory.getSelection());
306 stateData.setState(combo_UseCategory.getSelection());
307 stateData.putModifyingText(CdmStore.getDefaultLanguage(),UsageTermCollection.useCategoryVocabularyLabel);
308 itrExistingStates.add(stateData);
309
310 }
311 } else if (modifyingText.get(CdmStore.getDefaultLanguage()).getText().equals(UsageTermCollection.useSubCategoryVocabularyLabel) && isUseCategoryChanged == true) {
312 itrExistingStates.remove();
313 }
314 }
315 }
316 }
317
318
319 if (isChanged == false) {
320 StateData stateData = StateData
321 .NewInstance(combo_UseCategory.getSelection());
322 stateData.setState(combo_UseCategory.getSelection());
323 stateData.putModifyingText(CdmStore.getDefaultLanguage(), UsageTermCollection.useCategoryVocabularyLabel);
324 getEntity().addStateData(stateData);
325 }
326
327 combo_UseSubCategory.setEnabled(true);
328
329 }
330 else {
331 if (!getEntity().getStateData().isEmpty()) {
332 Iterator<StateData> itr = getEntity().getStateData().iterator();
333 while(itr.hasNext()) {
334 itr.next();
335 itr.remove();
336 }
337 List<State> termsSubCategory = new ArrayList<State>();
338 State emptyState = State.NewInstance();
339 termsSubCategory.add(emptyState);
340 combo_UseSubCategory.setTerms(termsSubCategory);
341 combo_UseSubCategory.setEnabled(false);
342 }
343 }
344 }
345
346 if (eventSource == combo_UseSubCategory) {
347 if (combo_UseSubCategory.getSelection() != null) {
348 boolean isChanged = false;
349 if (!getEntity().getStateData().isEmpty()) {
350 ListIterator<StateData> itrExistingStates = getEntity().getStateData().listIterator();
351 while(itrExistingStates.hasNext()) {
352 StateData existingStateData = itrExistingStates.next();
353 Map<Language, LanguageString> modifyingText = existingStateData
354 .getModifyingText();
355 if (modifyingText.get(CdmStore.getDefaultLanguage()) != null) {
356 if (modifyingText.get(CdmStore.getDefaultLanguage()).getText().equals(UsageTermCollection.useSubCategoryVocabularyLabel)) {
357 isChanged = true;
358 if(!existingStateData.getState().getTitleCache().equals(combo_UseSubCategory.getSelection().getTitleCache())) {
359 itrExistingStates.remove();
360 StateData stateData = StateData.NewInstance(combo_UseSubCategory.getSelection());
361 stateData.setState(combo_UseSubCategory.getSelection());
362 stateData.putModifyingText(CdmStore.getDefaultLanguage(),UsageTermCollection.useSubCategoryVocabularyLabel);
363 itrExistingStates.add(stateData);
364 }
365 }
366 }
367 }
368 }
369
370 if (isChanged == false){
371 StateData stateData = StateData
372 .NewInstance(combo_UseSubCategory.getSelection());
373 stateData.setState(combo_UseSubCategory.getSelection());
374 stateData.putModifyingText(CdmStore.getDefaultLanguage(), UsageTermCollection.useSubCategoryVocabularyLabel);
375 getEntity().addStateData(stateData);
376 }
377
378 } else {
379 if (!getEntity().getStateData().isEmpty()) {
380 Iterator<StateData> itrStateData = getEntity().getStateData().iterator();
381 while(itrStateData.hasNext()) {
382 StateData existingStateData = itrStateData.next();
383 Map<Language, LanguageString> modifyingText = existingStateData
384 .getModifyingText();
385
386 if (modifyingText.get(CdmStore.getDefaultLanguage()) != null) {
387 if (modifyingText.get(CdmStore.getDefaultLanguage()).getText() == UsageTermCollection.useSubCategoryVocabularyLabel) {
388 itrStateData.remove();
389 }
390 }
391 }
392 }
393 }
394 }
395 if (eventSource == combo_PlantPart) {
396 if (combo_PlantPart.getSelection() != null) {
397 Iterator<DefinedTerm> itrExistingModifiers = getEntity().getModifiers().iterator();
398 while (itrExistingModifiers.hasNext()) {
399 DefinedTerm modifier = itrExistingModifiers.next();
400 if(GetVocabularyType(modifier, UsageTermCollection.plantPartLabel)) {
401 itrExistingModifiers.remove();
402 }
403
404 }
405 DefinedTerm plantPart = combo_PlantPart.getSelection();
406 getEntity().addModifier(plantPart);
407 } else {
408 Set<DefinedTerm> modifiers = getEntity().getModifiers();
409 if(!modifiers.isEmpty()) {
410 Iterator<DefinedTerm> itr = modifiers.iterator();
411 while (itr.hasNext()) {
412 DefinedTerm currentMod = itr.next();
413 if(GetVocabularyType(currentMod, UsageTermCollection.plantPartLabel)) {
414 itr.remove();
415 }
416 }
417 }
418
419 }
420 }
421 if (eventSource == combo_Country) {
422 if (combo_Country.getSelection() != null) {
423 Iterator<DefinedTerm> itrExistingModifiers = getEntity().getModifiers().iterator();
424 while (itrExistingModifiers.hasNext()) {
425 DefinedTerm modifier = itrExistingModifiers.next();
426 if(GetVocabularyType(modifier, UsageTermCollection.countryLabel)) {
427 itrExistingModifiers.remove();
428 }
429
430 }
431 DefinedTerm country = combo_Country.getSelection();
432 getEntity().addModifier(country);
433 } else {
434 Set<DefinedTerm> modifiers = getEntity().getModifiers();
435 if(!modifiers.isEmpty()) {
436 Iterator<DefinedTerm> itr = modifiers.iterator();
437 while (itr.hasNext()) {
438 DefinedTerm currentMod = itr.next();
439 if(GetVocabularyType(currentMod, UsageTermCollection.countryLabel)) {
440 itr.remove();
441 }
442 }
443 }
444 }
445 }
446 if (eventSource == combo_HumanGroup) {
447 if (combo_HumanGroup.getSelection() != null) {
448 boolean isHumanGroupChanged = true;
449 for (DefinedTerm modToCheck: getEntity().getModifiers()) {
450 if(modToCheck.equals(combo_HumanGroup.getSelection()) && (GetVocabularyType(modToCheck, UsageTermCollection.humanGroupLabel))) {
451 isHumanGroupChanged = false;
452 }
453
454
455 }
456 Iterator<DefinedTerm> itrExistingModifiers = getEntity().getModifiers().iterator();
457 while (itrExistingModifiers.hasNext()) {
458 DefinedTerm modifier = itrExistingModifiers.next();
459 if((GetVocabularyType(modifier, UsageTermCollection.humanGroupLabel) || GetVocabularyType(modifier, UsageTermCollection.ethnicGroupLabel)) && isHumanGroupChanged) {
460 itrExistingModifiers.remove();
461 }
462
463 }
464 if(isHumanGroupChanged){
465 DefinedTerm humanGroup = combo_HumanGroup.getSelection();
466 getEntity().addModifier(humanGroup);
467 }
468 combo_EthnicGroup.setEnabled(true);
469 } else {
470 Set<DefinedTerm> modifiers = getEntity().getModifiers();
471 if(!modifiers.isEmpty()) {
472 Iterator<DefinedTerm> itr = modifiers.iterator();
473 while (itr.hasNext()) {
474 DefinedTerm currentMod = itr.next();
475 if(GetVocabularyType(currentMod, UsageTermCollection.humanGroupLabel) || GetVocabularyType(currentMod, UsageTermCollection.ethnicGroupLabel)) {
476 itr.remove();
477 }
478 }
479 }
480 List<DefinedTerm> emptyListToResetComboBox = new ArrayList<DefinedTerm>();
481
482 // DefinedTerm emptyMod = DefinedTerm.NewInstance();
483 DefinedTerm emptyMod = null;
484
485
486 emptyListToResetComboBox.add(emptyMod);
487 combo_EthnicGroup.setTerms(emptyListToResetComboBox);
488 combo_EthnicGroup.setEnabled(false);
489
490 }
491 }
492 if (eventSource == combo_EthnicGroup) {
493 if (combo_EthnicGroup.getSelection() != null) {
494 Iterator<DefinedTerm> itrExistingModifiers = getEntity().getModifiers().iterator();
495 while (itrExistingModifiers.hasNext()) {
496 DefinedTerm modifier = itrExistingModifiers.next();
497 if(GetVocabularyType(modifier, combo_HumanGroup.getSelection().getTitleCache())) {
498 itrExistingModifiers.remove();
499 }
500
501 }
502 DefinedTerm ethnicGroup = combo_EthnicGroup.getSelection();
503 getEntity().addModifier(ethnicGroup);
504 } else {
505 Set<DefinedTerm> modifiers = getEntity().getModifiers();
506 if(!modifiers.isEmpty()) {
507
508 Iterator<DefinedTerm> itr = modifiers.iterator();
509 while (itr.hasNext()) {
510 DefinedTerm currentMod = itr.next();
511 if(GetVocabularyType(currentMod, UsageTermCollection.ethnicGroupLabel)) {
512 itr.remove();
513 }
514 }
515
516 }
517 }
518 }
519 }
520
521
522
523 /**
524 * This function Checks the vocabulary type
525 * @param term
526 * @param vocabularyExpected
527 * @return
528 */
529 private boolean GetVocabularyType(DefinedTerm term, String vocabularyExpected) {
530 if ((term.getPartOf() != null) && (term.getPartOf().getTitleCache().equals(vocabularyExpected))) {
531 return true;
532 }
533 else if ((term.getVocabulary() != null) && (term.getPartOf()==null) && (term.getVocabulary().getTitleCache().equals(vocabularyExpected))) {
534 return true;
535 }
536 else if ((vocabularyExpected.equals(UsageTermCollection.ethnicGroupLabel)) && ((term.getPartOf() != null))) {
537 return true;
538 }
539 return false;
540 }
541
542
543
544 /** {@inheritDoc} */
545 @Override
546 public void setEntity(CategoricalData entity) {
547 super.setEntity(entity);
548 }
549
550 /** {@inheritDoc} */
551 @Override
552 public void widgetSelected(SelectionEvent e) {
553 Object eventSource = e.getSource();
554 for (Object object: combo_UseCategory.getControls()) {
555 if (object == eventSource) {
556 State selectedUseCategory = combo_UseCategory.getSelection();
557 if (selectedUseCategory != null) {
558 combo_UseSubCategory.setTerms(setUseCategoryComboTerms(TermStore.getTerms(State.class, null, false),selectedUseCategory));
559
560 if (!getEntity().getStateData().isEmpty()) {
561 Iterator<StateData> itrExistingState = getEntity().getStateData().iterator();
562 while(itrExistingState.hasNext()) {
563 StateData existingStateData = itrExistingState.next();
564 Map<Language, LanguageString> modifyingText = existingStateData.getModifyingText();
565 if (modifyingText.get(CdmStore.getDefaultLanguage()) != null) {
566 if (modifyingText.get(CdmStore.getDefaultLanguage())
567 .getText().equals(UsageTermCollection.useSubCategoryVocabularyLabel)) {
568 combo_UseSubCategory.setSelection(stateSelection(UsageTermCollection.useSubCategoryVocabularyLabel));
569 }
570 }
571 }
572 }
573 }
574 }
575 }
576 for (Object object: combo_HumanGroup.getControls()) {
577 if (object == eventSource) {
578 DefinedTerm selectedHumanGroup = combo_HumanGroup.getSelection();
579 if (selectedHumanGroup != null) {
580 combo_EthnicGroup.setTerms(setEthnicGroupComboTerms(TermStore.getTerms(DefinedTerm.class, null, false), selectedHumanGroup));
581 if (!getEntity().getModifiers().isEmpty()) {
582 Iterator<DefinedTerm> iterModifiers = getEntity().getModifiers().iterator();
583 while (iterModifiers.hasNext()) {
584 DefinedTerm existingModifier = iterModifiers.next();
585 if(GetVocabularyType(existingModifier, UsageTermCollection.ethnicGroupLabel)) {
586 combo_EthnicGroup.setSelection(modifierSelection(UsageTermCollection.ethnicGroupLabel));
587 }
588 }
589 }
590
591 }
592 }
593 }
594 }
595
596 /** {@inheritDoc} */
597 @Override
598 public void widgetDefaultSelected(SelectionEvent e) {
599 // TODO Auto-generated method stub
600
601 }
602
603 }