1 |
1 |
package eu.etaxonomy.taxeditor.ui.section.userecords;
|
2 |
2 |
|
3 |
3 |
import java.util.ArrayList;
|
|
4 |
import java.util.Iterator;
|
4 |
5 |
import java.util.List;
|
5 |
6 |
import java.util.Map;
|
6 |
7 |
import java.util.Set;
|
... | ... | |
75 |
76 |
protected void createControls(ICdmFormElement formElement,
|
76 |
77 |
CategoricalData entity, int style) {
|
77 |
78 |
|
78 |
|
// State state = State.NewInstance("Tato", "Toto", "Titi");
|
79 |
|
// checkbox_orderRelevant = formFactory.createCheckbox(formElement,
|
80 |
|
// "Order Relevant", entity.getOrderRelevant(), style);
|
81 |
79 |
combo_UseCategory = formFactory.createTermComboElement(State.class, this, "Use Category", null, style);
|
82 |
80 |
combo_UseCategory.addSelectionListener(this);
|
83 |
81 |
combo_UseSubCategory = formFactory.createTermComboElement(State.class, this, "Use SubCategory", null, style);
|
... | ... | |
95 |
93 |
List<State> termsSubCategory = setUseCategoryComboTerms(TermStore.getTerms(State.class, null, false), combo_UseCategory.getSelection());
|
96 |
94 |
|
97 |
95 |
if (termsSubCategory != null) {
|
98 |
|
|
99 |
96 |
combo_UseSubCategory.setTerms(termsSubCategory);
|
100 |
97 |
combo_UseSubCategory.setSelection(stateSelection("Use SubCategory"));
|
101 |
98 |
combo_UseSubCategory.setEnabled(true);
|
... | ... | |
133 |
130 |
if(GetVocabularyType(modifier, comboCategory)) {
|
134 |
131 |
return modifier;
|
135 |
132 |
}
|
136 |
|
|
137 |
|
|
138 |
|
/*if (modifier.getMarkers() != null) {
|
139 |
|
for (Marker marker : modifier.getMarkers()) {
|
140 |
|
if(marker.getMarkerType().getTitleCache().equals(comboCategory)) {
|
141 |
|
return modifier;
|
142 |
|
}
|
143 |
|
/*else {
|
144 |
|
return null;
|
145 |
|
}
|
146 |
|
}
|
147 |
|
}*/
|
148 |
|
/*else {
|
149 |
|
return null;
|
150 |
|
}*/
|
151 |
|
|
152 |
133 |
}
|
153 |
134 |
} else {
|
154 |
135 |
return null;
|
... | ... | |
596 |
577 |
StateData stateData = StateData
|
597 |
578 |
.NewInstance(combo_UseCategory.getSelection());
|
598 |
579 |
stateData.setState(combo_UseCategory.getSelection());
|
599 |
|
//stateData.addModifyingText("Use Category", CdmStore.getDefaultLanguage());
|
600 |
|
//LanguageString languageString = LanguageString.NewInstance("Use Category", CdmStore.getDefaultLanguage());
|
601 |
|
//IService object = (IService) CdmStore.getCurrentApplicationConfiguration().getBean(IService.class.getName());
|
602 |
|
//object.save(languageString);
|
603 |
580 |
stateData.putModifyingText(CdmStore.getDefaultLanguage(), "Use Category");
|
604 |
581 |
getEntity().addState(stateData);
|
605 |
582 |
}
|
|
583 |
|
606 |
584 |
combo_UseSubCategory.setEnabled(true);
|
607 |
585 |
|
608 |
586 |
}
|
|
587 |
else {
|
|
588 |
if (!getEntity().getStates().isEmpty()) {
|
|
589 |
Iterator<StateData> itr = getEntity().getStates().iterator();
|
|
590 |
while(itr.hasNext()) {
|
|
591 |
StateData stateToRemove = itr.next();
|
|
592 |
itr.remove();
|
|
593 |
}
|
|
594 |
List<State> termsSubCategory = new ArrayList<State>();
|
|
595 |
State emptyState = State.NewInstance();
|
|
596 |
termsSubCategory.add(emptyState);
|
|
597 |
combo_UseSubCategory.setTerms(termsSubCategory);
|
|
598 |
combo_UseSubCategory.setEnabled(false);
|
|
599 |
}
|
|
600 |
}
|
609 |
601 |
}
|
|
602 |
|
610 |
603 |
if (eventSource == combo_UseSubCategory) {
|
611 |
604 |
if (combo_UseSubCategory.getSelection() != null) {
|
612 |
605 |
boolean isChanged = false;
|
... | ... | |
660 |
653 |
getEntity().addState(stateData);
|
661 |
654 |
}
|
662 |
655 |
|
|
656 |
} else {
|
|
657 |
if (!getEntity().getStates().isEmpty()) {
|
|
658 |
for (StateData existingStateData : getEntity().getStates()) {
|
|
659 |
Map<Language, LanguageString> modifyingText = existingStateData
|
|
660 |
.getModifyingText();
|
|
661 |
|
|
662 |
if (modifyingText.get(CdmStore.getDefaultLanguage()) != null) {
|
|
663 |
if (modifyingText.get(CdmStore.getDefaultLanguage()).getText() == "Use SubCategory") {
|
|
664 |
getEntity().removeState(existingStateData);
|
|
665 |
}
|
|
666 |
}
|
|
667 |
}
|
|
668 |
}
|
663 |
669 |
}
|
664 |
670 |
}
|
665 |
671 |
if (eventSource == combo_PlantPart) {
|
... | ... | |
719 |
725 |
|
720 |
726 |
//getEntity().addModifier(combo_PlantPart.getSelection());
|
721 |
727 |
}
|
|
728 |
} else {
|
|
729 |
Set<Modifier> modifiers = getEntity().getModifiers();
|
|
730 |
if(!modifiers.isEmpty()) {
|
|
731 |
for (Modifier modifier : modifiers) {
|
|
732 |
if(GetVocabularyType(modifier, "Plant Part")) {
|
|
733 |
getEntity().removeModifier(modifier);
|
|
734 |
|
|
735 |
}
|
|
736 |
}
|
|
737 |
}
|
|
738 |
|
722 |
739 |
}
|
723 |
740 |
}
|
724 |
741 |
if (eventSource == combo_Country) {
|
... | ... | |
775 |
792 |
getEntity().addModifier(country);
|
776 |
793 |
//getEntity().addModifier(combo_Country.getSelection());
|
777 |
794 |
}
|
|
795 |
} else {
|
|
796 |
Set<Modifier> modifiers = getEntity().getModifiers();
|
|
797 |
if(!modifiers.isEmpty()) {
|
|
798 |
for (Modifier modifier : modifiers) {
|
|
799 |
if(GetVocabularyType(modifier, "Country")) {
|
|
800 |
getEntity().removeModifier(modifier);
|
|
801 |
|
|
802 |
}
|
|
803 |
}
|
|
804 |
}
|
|
805 |
|
778 |
806 |
}
|
779 |
807 |
}
|
780 |
808 |
if (eventSource == combo_HumanGroup) {
|
... | ... | |
831 |
859 |
getEntity().addModifier(humanGroup);
|
832 |
860 |
//getEntity().addModifier(combo_HumanGroup.getSelection());
|
833 |
861 |
}
|
|
862 |
combo_EthnicGroup.setEnabled(true);
|
|
863 |
} else {
|
|
864 |
Set<Modifier> modifiers = getEntity().getModifiers();
|
|
865 |
if(!modifiers.isEmpty()) {
|
|
866 |
Iterator<Modifier> itr = modifiers.iterator();
|
|
867 |
while (itr.hasNext()) {
|
|
868 |
Modifier currentMod = itr.next();
|
|
869 |
if(GetVocabularyType(currentMod, "Human Group") || GetVocabularyType(currentMod, "Ethnic Group")) {
|
|
870 |
itr.remove();
|
|
871 |
}
|
|
872 |
}
|
|
873 |
|
|
874 |
|
|
875 |
/*for (Modifier modifier : modifiers) {
|
|
876 |
if(GetVocabularyType(modifier, "Human Group")) {
|
|
877 |
getEntity().removeModifier(modifier);
|
|
878 |
|
|
879 |
}
|
|
880 |
if(GetVocabularyType(modifier, "Ethnic Group")) {
|
|
881 |
getEntity().removeModifier(modifier);
|
|
882 |
|
|
883 |
}
|
|
884 |
}*/
|
|
885 |
}
|
|
886 |
List<Modifier> emptyListToResetComboBox = new ArrayList<Modifier>();
|
|
887 |
Modifier emptyMod = Modifier.NewInstance();
|
|
888 |
emptyListToResetComboBox.add(emptyMod);
|
|
889 |
combo_EthnicGroup.setTerms(emptyListToResetComboBox);
|
|
890 |
combo_EthnicGroup.setEnabled(false);
|
|
891 |
|
834 |
892 |
}
|
835 |
|
combo_EthnicGroup.setEnabled(true);
|
836 |
893 |
}
|
837 |
894 |
if (eventSource == combo_EthnicGroup) {
|
838 |
895 |
if (combo_EthnicGroup.getSelection() != null) {
|
... | ... | |
888 |
945 |
getEntity().addModifier(ethnicGroup);
|
889 |
946 |
//getEntity().addModifier(combo_EthnicGroup.getSelection());
|
890 |
947 |
}
|
|
948 |
} else {
|
|
949 |
Set<Modifier> modifiers = getEntity().getModifiers();
|
|
950 |
if(!modifiers.isEmpty()) {
|
|
951 |
for (Modifier modifier : modifiers) {
|
|
952 |
if(GetVocabularyType(modifier, "Ethnic Group")) {
|
|
953 |
getEntity().removeModifier(modifier);
|
|
954 |
|
|
955 |
}
|
|
956 |
|
|
957 |
}
|
|
958 |
}
|
|
959 |
|
891 |
960 |
}
|
892 |
961 |
}
|
893 |
962 |
}
|
AT: commiting latest changes to the Palm Use data extension