1 package eu
.etaxonomy
.taxeditor
.ui
.section
.userecords
;
3 import java
.util
.ArrayList
;
9 import org
.apache
.log4j
.Logger
;
10 import org
.eclipse
.swt
.events
.SelectionEvent
;
11 import org
.eclipse
.swt
.events
.SelectionListener
;
12 import org
.eclipse
.ui
.forms
.widgets
.Section
;
14 import eu
.etaxonomy
.cdm
.api
.service
.IService
;
15 import eu
.etaxonomy
.cdm
.api
.service
.IVocabularyService
;
16 import eu
.etaxonomy
.cdm
.model
.common
.DefinedTermBase
;
17 import eu
.etaxonomy
.cdm
.model
.common
.Language
;
18 import eu
.etaxonomy
.cdm
.model
.common
.LanguageString
;
19 import eu
.etaxonomy
.cdm
.model
.common
.Marker
;
20 import eu
.etaxonomy
.cdm
.model
.common
.MarkerType
;
21 import eu
.etaxonomy
.cdm
.model
.common
.TermVocabulary
;
22 import eu
.etaxonomy
.cdm
.model
.description
.CategoricalData
;
23 import eu
.etaxonomy
.cdm
.model
.description
.DescriptionElementBase
;
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
.cdm
.remote
.controller
.VocabularyController
;
28 import eu
.etaxonomy
.taxeditor
.store
.CdmStore
;
29 import eu
.etaxonomy
.taxeditor
.store
.TermManager
;
30 import eu
.etaxonomy
.taxeditor
.store
.TermStore
;
31 import eu
.etaxonomy
.taxeditor
.ui
.combo
.TermComboElement
;
32 import eu
.etaxonomy
.taxeditor
.ui
.element
.CdmFormFactory
;
33 import eu
.etaxonomy
.taxeditor
.ui
.element
.CheckboxElement
;
34 import eu
.etaxonomy
.taxeditor
.ui
.element
.ICdmFormElement
;
35 import eu
.etaxonomy
.taxeditor
.ui
.element
.CdmFormFactory
.EntityDetailType
;
36 import eu
.etaxonomy
.taxeditor
.ui
.section
.AbstractCdmDetailElement
;
37 import eu
.etaxonomy
.taxeditor
.ui
.section
.description
.DescriptionElementDetailElement
;
38 import eu
.etaxonomy
.taxeditor
.ui
.section
.description
.StateDataSection
;
39 import eu
.etaxonomy
.taxeditor
.ui
.section
.description
.detail
.AbstractDetailedDescriptionDetailElement
;
41 //public class UseRecordDetailElement extends AbstractDetailedDescriptionDetailElement<CategoricalData> {
42 public class UseRecordDetailElement
extends
43 AbstractCdmDetailElement
<CategoricalData
> implements SelectionListener
{
45 private static final Logger logger
= Logger
46 .getLogger(DescriptionElementDetailElement
.class);
48 // private CheckboxElement checkbox_orderRelevant;
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 // private AbstractDetailedDescriptionDetailElement detailElement;
58 * public UseRecordDetailElement(CdmFormFactory formFactory, ICdmFormElement
59 * formElement, CategoricalData entity, int style) { super(formFactory,
60 * formElement, entity, style); }
63 * public UseRecordDetailElement(CdmFormFactory formFactory, ICdmFormElement
64 * formElement, int style) {
66 public UseRecordDetailElement(CdmFormFactory formFactory
,
67 ICdmFormElement formElement
) {
68 super(formFactory
, formElement
);
73 protected void createControls(ICdmFormElement formElement
,
74 CategoricalData entity
, int style
) {
76 // State state = State.NewInstance("Tato", "Toto", "Titi");
77 // checkbox_orderRelevant = formFactory.createCheckbox(formElement,
78 // "Order Relevant", entity.getOrderRelevant(), style);
79 combo_UseCategory
= formFactory
.createTermComboElement(State
.class, this, "Use Category", null, style
);
80 combo_UseCategory
.addSelectionListener(this);
81 combo_UseSubCategory
= formFactory
.createTermComboElement(State
.class, this, "Use SubCategory", null, style
);
82 combo_Country
= formFactory
.createTermComboElement(Modifier
.class, this, "Country", null, style
);
83 combo_PlantPart
= formFactory
.createTermComboElement(Modifier
.class, this, "Plant Part", null, style
);
84 combo_HumanGroup
= formFactory
.createTermComboElement(Modifier
.class, this, "Human Group", null, style
);
85 combo_HumanGroup
.addSelectionListener(this);
86 combo_EthnicGroup
= formFactory
.createTermComboElement(Modifier
.class, this, "Ethnic Group", null, style
);
89 List
<State
> termsUseCategory
= setUseCategoryComboTerms(TermStore
.getTerms(State
.class, null, false));
90 combo_UseCategory
.setTerms(termsUseCategory
);
91 combo_UseCategory
.setSelection(stateSelection("Use Category"));
93 List
<State
> termsSubCategory
= setUseCategoryComboTerms(TermStore
.getTerms(State
.class, null, false), combo_UseCategory
.getSelection());
95 if (termsSubCategory
!= null) {
97 combo_UseSubCategory
.setTerms(termsSubCategory
);
98 combo_UseSubCategory
.setSelection(stateSelection("Use SubCategory"));
99 combo_UseSubCategory
.setEnabled(true);
102 combo_UseSubCategory
.setEnabled(false);
105 List
<Modifier
> plantPartsToAdd
= setModifierComboTerms(TermStore
.getTerms(Modifier
.class, null, false), "Plant Part");
106 combo_PlantPart
.setTerms(plantPartsToAdd
);
107 combo_PlantPart
.setSelection(modifierSelection("Plant Part"));
109 List
<Modifier
> countriesToAdd
= setModifierComboTerms(TermStore
.getTerms(Modifier
.class, null, false), "Country");
110 combo_Country
.setTerms(countriesToAdd
);
111 combo_Country
.setSelection(modifierSelection("Country"));
113 List
<Modifier
> humanGroupToAdd
= setModifierComboTerms(TermStore
.getTerms(Modifier
.class, null, false), "Human Group");
114 combo_HumanGroup
.setTerms(humanGroupToAdd
);
115 combo_HumanGroup
.setSelection(modifierSelection("Human Group"));
117 List
<Modifier
> ethnicGroupToAdd
= setEthnicGroupComboTerms(TermStore
.getTerms(Modifier
.class, null, false), combo_HumanGroup
.getSelection());
118 if (ethnicGroupToAdd
!= null) {
119 combo_EthnicGroup
.setTerms(ethnicGroupToAdd
);
120 combo_EthnicGroup
.setSelection(modifierSelection("Ethnic Group"));
121 combo_EthnicGroup
.setEnabled(true);
123 combo_EthnicGroup
.setEnabled(false);
128 private Modifier
modifierSelection(String comboCategory
) {
129 if(!getEntity().getModifiers().isEmpty()) {
130 for (Modifier modifier
: getEntity().getModifiers()) {
131 if (modifier
.getMarkers() != null) {
132 for (Marker marker
: modifier
.getMarkers()) {
133 if(marker
.getMarkerType().getTitleCache().equals(comboCategory
)) {
153 private State
stateSelection(String comboCategory
) {
154 if (!getEntity().getStates().isEmpty()) {
155 for (StateData statedata
: getEntity().getStates()) {
156 if (statedata
.getModifyingText().get(CdmStore
.getDefaultLanguage()) != null) {
157 if(statedata
.getModifyingText().get(CdmStore
.getDefaultLanguage()).getText() == comboCategory
) {
158 if(statedata
.getState() !=null) {
159 return statedata
.getState();
172 private List
<Modifier
> setModifierComboTerms(List
<Modifier
> listOfTerms
, String modType
) {
173 List
<Modifier
> termsToAdd
= new ArrayList
<Modifier
>();
174 for (Modifier term
: listOfTerms
) {
176 if ((term
.getPartOf() != null) && (term
.getPartOf().getTitleCache().equals(modType
))) {
177 termsToAdd
.add(term
);
179 else if ((term
.getVocabulary() != null) && (term
.getVocabulary().getTitleCache().equals(modType
))) {
180 termsToAdd
.add(term
);
187 private Modifier
plantPartSelection() {
188 /*if(!getEntity().getModifiers().isEmpty()) {
189 for (Modifier modifier : getEntity().getModifiers()) {
190 if (modifier.getMarkers() != null) {
191 for (Marker marker : modifier.getMarkers()) {
192 if(marker.getMarkerType().getTitleCache().equals("Plant Part")) {
209 //for testing purposes
211 Modifier modiftoreturn
= Modifier
.NewInstance();
212 if (!getEntity().getModifiers().isEmpty()) {
213 for (Modifier modifier
: getEntity().getModifiers()){
215 modiftoreturn
= modifier
;
219 return modiftoreturn
;
225 private Modifier
countrySelection() {
226 /*if(!getEntity().getModifiers().isEmpty()) {
227 for (Modifier modifier : getEntity().getModifiers()) {
228 if (modifier.getMarkers() != null) {
229 for (Marker marker : modifier.getMarkers()) {
230 if(marker.getMarkerType().getTitleCache().equals("Country")) {
247 //for testing purposes
249 Modifier modiftoreturn
= Modifier
.NewInstance();
250 if (!getEntity().getModifiers().isEmpty()) {
251 for (Modifier modifier
: getEntity().getModifiers()){
253 modiftoreturn
= modifier
;
257 return modiftoreturn
;
262 private Modifier
humanGroupSelection() {
263 /*if(!getEntity().getModifiers().isEmpty()) {
264 for (Modifier modifier : getEntity().getModifiers()) {
265 if (modifier.getMarkers() != null) {
266 for (Marker marker : modifier.getMarkers()) {
267 if(marker.getMarkerType().getTitleCache().equals("Human Group")) {
284 //for testing purposes
286 Modifier modiftoreturn
= Modifier
.NewInstance();
287 if (!getEntity().getModifiers().isEmpty()) {
288 for (Modifier modifier
: getEntity().getModifiers()){
289 if (countMods
== 2) {
290 modiftoreturn
= modifier
;
294 return modiftoreturn
;
299 private Modifier
ethnicGroupSelection() {
300 /*if(!getEntity().getModifiers().isEmpty()) {
301 for (Modifier modifier : getEntity().getModifiers()) {
302 if (modifier.getMarkers() != null) {
303 for (Marker marker : modifier.getMarkers()) {
304 if(marker.getMarkerType().getTitleCache().equals("Human Group")) {
321 //for testing purposes
323 Modifier modiftoreturn
= Modifier
.NewInstance();
324 if (!getEntity().getModifiers().isEmpty()) {
325 for (Modifier modifier
: getEntity().getModifiers()){
326 if (countMods
== 3) {
327 modiftoreturn
= modifier
;
331 return modiftoreturn
;
336 private State
useCategorySelection() {
337 /*if (!getEntity().getStates().isEmpty()) {
338 for (StateData statedata : getEntity().getStates()) {
339 if (statedata.getModifyingText().get(CdmStore.getDefaultLanguage()) != null) {
340 if(statedata.getModifyingText().get(CdmStore.getDefaultLanguage()).getText() == "Use Category") {
341 if(statedata.getState() !=null) {
342 return statedata.getState();
352 //for testing purposes
354 for (StateData state
: getEntity().getStates()) {
355 if (countStates
== 0) {
356 return state
.getState();
365 private State
useSubCategorySelection() {
366 /*if (!getEntity().getStates().isEmpty() && combo_UseCategory.getSelection() != null) {
367 for (StateData statedata : getEntity().getStates()) {
368 if (stateData.getModifyingText().get(CdmStore.getDefaultLanguage()) != null) {
369 if(statedata.getModifyingText().get(CdmStore.getDefaultLanguage()).getText() == "Use SubCategory") {
370 if(statedata.getState() !=null) {
371 return statedata.getState();
382 //for testing purposes
384 for (StateData state
: getEntity().getStates()) {
385 if ((countStates
== 1)) {
386 return state
.getState();
397 private List
<Modifier
> setPlantPartsComboTerms(List
<Modifier
> listOfTerms
) {
398 List
<Modifier
> termsToAdd
= new ArrayList
<Modifier
>();
399 for (Modifier term
: listOfTerms
) {
401 if ((term
.getPartOf() != null) && (term
.getPartOf().getTitleCache().equals("Plant Part"))) {
402 termsToAdd
.add(term
);
404 else if ((term
.getVocabulary() != null) && (term
.getVocabulary().getTitleCache().equals("Plant Part"))) {
405 termsToAdd
.add(term
);
412 private List
<Modifier
> setCountryComboTerms(List
<Modifier
> listOfTerms
) {
413 List
<Modifier
> termsToAdd
= new ArrayList
<Modifier
>();
414 for (Modifier term
: listOfTerms
) {
416 if ((term
.getPartOf() != null) && (term
.getPartOf().getTitleCache().equals("Country"))) {
417 termsToAdd
.add(term
);
419 else if ((term
.getVocabulary() != null) && (term
.getVocabulary().getTitleCache().equals("Country"))) {
420 termsToAdd
.add(term
);
428 private List
<State
> setUseCategoryComboTerms(List
<State
> listOfTerms
) {
429 List
<State
> termsToAdd
= new ArrayList
<State
>();
430 for (State term
: listOfTerms
) {
432 if ((term
.getPartOf() != null) && (term
.getPartOf().getTitleCache().equals("Use Category"))) {
433 termsToAdd
.add(term
);
435 else if ((term
.getVocabulary() !=null) && (term
.getPartOf() == null) && (term
.getVocabulary().getTitleCache().equals("Use Category"))) {
436 termsToAdd
.add(term
);
443 private List
<State
> setUseCategoryComboTerms(List
<State
> listOfTerms
,
444 State selectedUseCategory
) {
445 List
<State
> termsToAdd
= new ArrayList
<State
>();
446 if (combo_UseCategory
.getSelection() != null) {
448 for (State term
: listOfTerms
) {
449 if ((term
.getPartOf() != null) && (term
.getPartOf().getTitleCache().equals(selectedUseCategory
.getTitleCache()))) {
450 termsToAdd
.add(term
);
452 else if ((term
.getVocabulary() !=null) && (term
.getVocabulary().getTitleCache().equals(selectedUseCategory
.getTitleCache()))) {
453 termsToAdd
.add(term
);
458 else if (!getEntity().getStates().isEmpty()) {
459 for (StateData stateData
: getEntity().getStates()) {
460 if (stateData
.getModifyingText().get(CdmStore
.getDefaultLanguage()) != null) {
461 if ((stateData
.getState() != null) && (stateData
.getModifyingText().get(CdmStore
.getDefaultLanguage()).getText() == "Use Category")) {
462 for (State term
: listOfTerms
) {
463 if ((term
.getPartOf() != null) && (term
.getPartOf().getTitleCache().equals(stateData
.getState().getTitleCache()))) {
464 termsToAdd
.add(term
);
465 } else if ((term
.getVocabulary() != null) && (term
.getVocabulary().getTitleCache().equals(stateData
.getState().getTitleCache()))) {
466 termsToAdd
.add(term
);
483 private List
<Modifier
> setEthnicGroupComboTerms(List
<Modifier
> listOfTerms
,
484 Modifier selectedHumangroup
) {
485 List
<Modifier
> termsToAdd
= new ArrayList
<Modifier
>();
486 if (combo_HumanGroup
.getSelection() != null) {
487 for (Modifier term
: listOfTerms
) {
489 if ((term
.getPartOf() != null) && (term
.getPartOf().getTitleCache().equals(selectedHumangroup
.getTitleCache()))) {
490 termsToAdd
.add(term
);
492 else if ((term
.getVocabulary() != null) && (term
.getVocabulary().getTitleCache().equals(selectedHumangroup
.getTitleCache()))) {
493 termsToAdd
.add(term
);
497 else if (!getEntity().getModifiers().isEmpty()) {
498 for (Modifier modifier
: getEntity().getModifiers()) {
499 if (modifier
.getMarkers() != null) {
500 for (Marker marker
: modifier
.getMarkers()) {
501 if(marker
.getMarkerType().getTitleCache().equals("Human Group")) {
502 for (Modifier term
: listOfTerms
) {
503 if ((term
.getPartOf() != null) && (term
.getPartOf().getTitleCache().equals(modifier
.getTitleCache()))) {
504 termsToAdd
.add(modifier
);
505 } else if ((term
.getVocabulary() != null) && (term
.getVocabulary().getTitleCache().equals(modifier
.getTitleCache()))) {
506 termsToAdd
.add(modifier
);
522 private List
<Modifier
> setHumanGroupComboTerms(List
<Modifier
> listOfTerms
) {
523 List
<Modifier
> termsToAdd
= new ArrayList
<Modifier
>();
524 for (Modifier term
: listOfTerms
) {
526 if ((term
.getPartOf() != null) && (term
.getPartOf().getTitleCache().equals("Human Group"))) {
527 termsToAdd
.add(term
);
529 else if ((term
.getVocabulary() != null) && (term
.getPartOf() == null) && (term
.getVocabulary().getTitleCache().equals("Human Group"))) {
530 termsToAdd
.add(term
);
540 public void handleEvent(Object eventSource
) {
542 * if(eventSource == checkbox_orderRelevant){
543 * getEntity().setOrderRelevant(checkbox_orderRelevant.getSelection());
546 if (eventSource
== combo_UseCategory
) {
547 if (combo_UseCategory
.getSelection() != null) {
548 boolean isChanged
= false;
549 if (!getEntity().getStates().isEmpty()) {
550 for (StateData existingStateData
: getEntity().getStates()) {
551 Map
<Language
, LanguageString
> modifyingText
= existingStateData
554 if (modifyingText
.get(CdmStore
.getDefaultLanguage()) != null) {
555 if (modifyingText
.get(CdmStore
.getDefaultLanguage())
556 .getText() == "Use Category") {
557 getEntity().removeState(existingStateData
);
558 StateData stateData
= StateData
.NewInstance(combo_UseCategory
.getSelection());
559 stateData
.setState(combo_UseCategory
.getSelection());
560 //stateData.addModifyingText("Use Category", CdmStore.getDefaultLanguage());
561 stateData
.putModifyingText(CdmStore
.getDefaultLanguage(),"Use Category");
562 getEntity().addState(stateData
);
566 StateData stateData = StateData
567 .NewInstance(combo_UseCategory.getSelection());
568 stateData.setState(combo_UseCategory.getSelection());
569 //stateData.addModifyingText("Use Category", CdmStore.getDefaultLanguage());
570 stateData.putModifyingText(CdmStore.getDefaultLanguage(),"Use Category");
571 getEntity().addState(stateData);
575 StateData stateData = StateData
576 .NewInstance(combo_UseCategory.getSelection());
577 stateData.setState(combo_UseCategory.getSelection());
578 //stateData.addModifyingText("Use Category", CdmStore.getDefaultLanguage());
579 stateData.putModifyingText(CdmStore.getDefaultLanguage(), "Use Category");
580 getEntity().addState(stateData);
587 if (isChanged
== false) {
588 StateData stateData
= StateData
589 .NewInstance(combo_UseCategory
.getSelection());
590 stateData
.setState(combo_UseCategory
.getSelection());
591 //stateData.addModifyingText("Use Category", CdmStore.getDefaultLanguage());
592 //LanguageString languageString = LanguageString.NewInstance("Use Category", CdmStore.getDefaultLanguage());
593 //IService object = (IService) CdmStore.getCurrentApplicationConfiguration().getBean(IService.class.getName());
594 //object.save(languageString);
595 stateData
.putModifyingText(CdmStore
.getDefaultLanguage(), "Use Category");
596 getEntity().addState(stateData
);
598 combo_UseSubCategory
.setEnabled(true);
602 if (eventSource
== combo_UseSubCategory
) {
603 if (combo_UseSubCategory
.getSelection() != null) {
604 boolean isChanged
= false;
605 if (!getEntity().getStates().isEmpty()) {
606 for (StateData existingStateData
: getEntity().getStates()) {
607 Map
<Language
, LanguageString
> modifyingText
= existingStateData
610 if (modifyingText
.get(CdmStore
.getDefaultLanguage()) != null) {
611 if (modifyingText
.get(CdmStore
.getDefaultLanguage())
612 .getText() == "Use SubCategory") {
613 getEntity().removeState(existingStateData
);
614 StateData stateData
= StateData
.NewInstance(combo_UseSubCategory
.getSelection());
615 stateData
.setState(combo_UseSubCategory
.getSelection());
616 //stateData.addModifyingText("Use SubCategory", CdmStore.getDefaultLanguage());
617 stateData
.putModifyingText(CdmStore
.getDefaultLanguage(),"Use SubCategory");
618 getEntity().addState(stateData
);
622 StateData stateData = StateData
623 .NewInstance(combo_UseSubCategory.getSelection());
624 stateData.setState(combo_UseSubCategory.getSelection());
625 //stateData.addModifyingText("Use SubCategory", CdmStore.getDefaultLanguage());
626 stateData.putModifyingText(CdmStore.getDefaultLanguage(),"Use SubCategory");
627 getEntity().addState(stateData);
631 StateData stateData = StateData
632 .NewInstance(combo_UseSubCategory.getSelection());
633 stateData.setState(combo_UseSubCategory.getSelection());
634 //stateData.addModifyingText("Use SubCategory", CdmStore.getDefaultLanguage());
635 stateData.putModifyingText(CdmStore.getDefaultLanguage(), "Use SubCategory");
636 getEntity().addState(stateData);
642 if (isChanged
== false){
643 StateData stateData
= StateData
644 .NewInstance(combo_UseSubCategory
.getSelection());
645 stateData
.setState(combo_UseSubCategory
.getSelection());
646 //stateData.addModifyingText("Use SubCategory", CdmStore.getDefaultLanguage());
647 //LanguageString languageString = LanguageString.NewInstance("Use SubCategory", CdmStore.getDefaultLanguage());
648 //IService object = (IService) CdmStore.getCurrentApplicationConfiguration().getBean(IService.class.getName());
649 //object.save(languageString);
650 //stateData.putModifyingText(languageString);
651 stateData
.putModifyingText(CdmStore
.getDefaultLanguage(), "Use SubCategory");
652 getEntity().addState(stateData
);
657 if (eventSource
== combo_PlantPart
) {
658 if (combo_PlantPart
.getSelection() != null) {
659 boolean isChanged
= false;
660 MarkerType markerType
= MarkerType
.NewInstance("Plant Part", "Plant Part", null);
661 Set
<Modifier
> modifiers
= getEntity().getModifiers();
662 if(!modifiers
.isEmpty()) {
663 for (Modifier modifier
: modifiers
) {
664 if (modifier
.getMarkers() != null) {
665 for (Marker marker
: modifier
.getMarkers()) {
666 if (marker
.getMarkerType().getTitleCache().equals("Plant Part")) {
667 getEntity().removeModifier(modifier
);
668 Modifier plantPart
= combo_PlantPart
.getSelection();
669 plantPart
.addMarker(marker
);
670 getEntity().addModifier(plantPart
);
672 //getEntity().addModifier(combo_PlantPart.getSelection());
676 Marker markerPlantPart = Marker.NewInstance(markerType, false);
677 Modifier plantPart = combo_PlantPart.getSelection();
678 plantPart.addMarker(markerPlantPart);
679 getEntity().addModifier(plantPart);
680 //getEntity().addModifier(combo_PlantPart.getSelection());
688 //MarkerType markerType = MarkerType.NewInstance("Plant Part", "Plant Part", null);
689 Marker marker = Marker.NewInstance(markerType, false);
690 Modifier plantPart = combo_PlantPart.getSelection();
691 plantPart.addMarker(marker);
692 getEntity().addModifier(plantPart);
693 //getEntity().addModifier(combo_PlantPart.getSelection());
698 if(isChanged
== false) {
699 //MarkerType markerType = MarkerType.NewInstance("Plant Part", "Plant Part", null);
700 Marker marker
= Marker
.NewInstance(markerType
, false);
701 Modifier plantPart
= combo_PlantPart
.getSelection();
702 plantPart
.addMarker(marker
);
703 getEntity().addModifier(plantPart
);
704 //getEntity().addModifier(combo_PlantPart.getSelection());
708 if (eventSource
== combo_Country
) {
709 if (combo_Country
.getSelection() != null) {
710 boolean isChanged
= false;
711 MarkerType markerType
= MarkerType
.NewInstance("Country", "Country", null);
712 Set
<Modifier
> modifiers
= getEntity().getModifiers();
713 if(!modifiers
.isEmpty()) {
714 for (Modifier modifier
: modifiers
) {
715 if (modifier
.getMarkers() != null) {
716 for (Marker marker
: modifier
.getMarkers()) {
717 if (marker
.getMarkerType().getTitleCache().equals("Country")) {
718 getEntity().removeModifier(modifier
);
719 Modifier country
= combo_Country
.getSelection();
720 country
.addMarker(marker
);
721 getEntity().addModifier(country
);
723 //getEntity().addModifier(combo_Country.getSelection());
727 Marker markerCountry = Marker.NewInstance(markerType, false);
728 Modifier country = combo_Country.getSelection();
729 country.addMarker(markerCountry);
730 getEntity().addModifier(country);
731 //getEntity().addModifier(combo_Country.getSelection());
739 //MarkerType markerType = MarkerType.NewInstance("Country", "Country", null);
740 Marker marker = Marker.NewInstance(markerType, false);
741 Modifier country = combo_Country.getSelection();
742 country.addMarker(marker);
743 getEntity().addModifier(country);
744 //getEntity().addModifier(combo_Country.getSelection());
749 if (isChanged
== false) {
750 //MarkerType markerType = MarkerType.NewInstance("Country", "Country", null);
751 Marker marker
= Marker
.NewInstance(markerType
, false);
752 Modifier country
= combo_Country
.getSelection();
753 country
.addMarker(marker
);
754 getEntity().addModifier(country
);
755 //getEntity().addModifier(combo_Country.getSelection());
759 if (eventSource
== combo_HumanGroup
) {
760 if (combo_HumanGroup
.getSelection() != null) {
761 boolean isChanged
= false;
762 MarkerType markerType
= MarkerType
.NewInstance("Human Group", "Human Group", null);
763 Set
<Modifier
> modifiers
= getEntity().getModifiers();
764 if(!modifiers
.isEmpty()) {
765 for (Modifier modifier
: modifiers
) {
766 if (modifier
.getMarkers() != null) {
767 for (Marker marker
: modifier
.getMarkers()) {
768 if (marker
.getMarkerType().getTitleCache().equals("Human Group")) {
769 getEntity().removeModifier(modifier
);
770 Modifier humanGroup
= combo_HumanGroup
.getSelection();
771 humanGroup
.addMarker(marker
);
772 getEntity().addModifier(humanGroup
);
774 //getEntity().addModifier(combo_HumanGroup.getSelection());
778 Marker markerHumanGroup = Marker.NewInstance(markerType, false);
779 Modifier humanGroup = combo_HumanGroup.getSelection();
780 humanGroup.addMarker(markerHumanGroup);
781 getEntity().addModifier(humanGroup);
782 //getEntity().addModifier(combo_HumanGroup.getSelection());
790 //MarkerType markerType = MarkerType.NewInstance("Human Group", "Human Group", null);
791 Marker marker = Marker.NewInstance(markerType, false);
792 Modifier humanGroup = combo_HumanGroup.getSelection();
793 humanGroup.addMarker(marker);
794 getEntity().addModifier(humanGroup);
795 //getEntity().addModifier(combo_HumanGroup.getSelection());
800 if(isChanged
== false){
801 //MarkerType markerType = MarkerType.NewInstance("Human Group", "Human Group", null);
802 Marker marker
= Marker
.NewInstance(markerType
, false);
803 Modifier humanGroup
= combo_HumanGroup
.getSelection();
804 humanGroup
.addMarker(marker
);
805 getEntity().addModifier(humanGroup
);
806 //getEntity().addModifier(combo_HumanGroup.getSelection());
809 combo_EthnicGroup
.setEnabled(true);
811 if (eventSource
== combo_EthnicGroup
) {
812 if (combo_EthnicGroup
.getSelection() != null) {
813 boolean isChanged
= false;
814 MarkerType markerType
= MarkerType
.NewInstance("Ethnic Group", "Ethnic Group", null);
815 Set
<Modifier
> modifiers
= getEntity().getModifiers();
816 if(!modifiers
.isEmpty()) {
817 for (Modifier modifier
: modifiers
) {
818 if (modifier
.getMarkers() != null) {
819 for (Marker marker
: modifier
.getMarkers()) {
820 if (marker
.getMarkerType().getTitleCache().equals("Ethnic Group")) {
821 getEntity().removeModifier(modifier
);
822 Modifier ethnicGroup
= combo_EthnicGroup
.getSelection();
823 ethnicGroup
.addMarker(marker
);
824 getEntity().addModifier(ethnicGroup
);
826 //getEntity().addModifier(combo_EthnicGroup.getSelection());
830 Marker markerEthnicGroup = Marker.NewInstance(markerType, false);
831 Modifier ethnicGroup = combo_EthnicGroup.getSelection();
832 ethnicGroup.addMarker(markerEthnicGroup);
833 getEntity().addModifier(ethnicGroup);
834 //getEntity().addModifier(combo_EthnicGroup.getSelection());
842 //MarkerType markerType = MarkerType.NewInstance("Ethnic Group", "Ethnic Group", null);
843 Marker marker = Marker.NewInstance(markerType, false);
844 Modifier ethnicGroup = combo_EthnicGroup.getSelection();
845 ethnicGroup.addMarker(marker);
846 getEntity().addModifier(ethnicGroup);
847 //getEntity().addModifier(combo_EthnicGroup.getSelection());
852 if(isChanged
== false) {
853 //MarkerType markerType = MarkerType.NewInstance("Ethnic Group", "Ethnic Group", null);
854 Marker marker
= Marker
.NewInstance(markerType
, false);
855 Modifier ethnicGroup
= combo_EthnicGroup
.getSelection();
856 ethnicGroup
.addMarker(marker
);
857 getEntity().addModifier(ethnicGroup
);
858 //getEntity().addModifier(combo_EthnicGroup.getSelection());
868 public void setEntity(CategoricalData entity
) {
869 // section_stateData.setEntity(entity);
870 super.setEntity(entity
);
874 public void widgetSelected(SelectionEvent e
) {
875 Object eventSource
= e
.getSource();
876 //This is causing an error on purpose fix the if statement below
879 //if(eventSource == combo_UseCategory.getControls()) {
880 for (Object object
: combo_UseCategory
.getControls()) {
881 if (object
== eventSource
) {
882 State selectedUseCategory
= combo_UseCategory
.getSelection();
883 if (selectedUseCategory
!= null) {
884 if (!getEntity().getStates().isEmpty()) {
885 for (StateData existingStateData
: getEntity().getStates()) {
886 Map
<Language
, LanguageString
> modifyingText
= existingStateData
889 if (modifyingText
.get(CdmStore
.getDefaultLanguage()) != null) {
890 if (modifyingText
.get(CdmStore
.getDefaultLanguage())
891 .getText() == "Use SubCategory") {
892 getEntity().removeState(existingStateData
);
893 combo_UseSubCategory
.setSelected(false);
894 combo_UseSubCategory
.getSelection();
900 List
<State
> newSubCategories
= setUseCategoryComboTerms(TermStore
.getTerms(State
.class, null, false),selectedUseCategory
);
901 combo_UseSubCategory
.setTerms(newSubCategories
);
902 State emptyState
= State
.NewInstance();
903 combo_UseSubCategory
.setSelection(emptyState
);
904 combo_UseSubCategory
.setSelection(newSubCategories
.get(0));
905 combo_UseSubCategory
.setSelection(null);
907 combo_UseSubCategory
.setTerms(newSubCategories
);
912 for (Object object
: combo_HumanGroup
.getControls()) {
913 if (object
== eventSource
) {
914 Modifier selectedHumanGroup
= combo_HumanGroup
.getSelection();
915 if (selectedHumanGroup
!= null) {
916 combo_EthnicGroup
.setTerms(setEthnicGroupComboTerms(TermStore
.getTerms(Modifier
.class, null, false), selectedHumanGroup
));
921 State selectedUseCategory = combo_UseCategory.getSelection();
922 if (selectedUseCategory != null) {
923 combo_UseSubCategory.setTerms(setUseCategoryComboTerms(TermStore.getTerms(State.class, null, false),selectedUseCategory));
927 if (eventSource == combo_HumanGroup) {
928 Modifier selectedHumanGroup = combo_HumanGroup.getSelection();
929 if (selectedHumanGroup != null) {
930 combo_EthnicGroup.setTerms(setEthnicGroupComboTerms(TermStore.getTerms(Modifier.class, null, false), selectedHumanGroup));
938 public void widgetDefaultSelected(SelectionEvent e
) {
939 // TODO Auto-generated method stub