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