Project

General

Profile

« Previous | Next » 

Revision 05a68539

Added by Alex Theys over 11 years ago

AT: commiting latest changes to the Palm Use data extension

View differences:

eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/uses/UsesLabelProvider.java
50 50
			//TextData textData = categoricalDescriptionBuilder.build((CategoricalData) element, getLanguageList());
51 51
			if (!((CategoricalData) element).getStates().isEmpty()) {
52 52
				for (StateData statedata : ((CategoricalData) element).getStates()) {
53
					if(statedata.getState() != null) {
53
					if(statedata.getState() != null && statedata.getModifyingText().get(CdmStore.getDefaultLanguage()) !=null && statedata.getModifyingText().get(CdmStore.getDefaultLanguage()).getText().equals("Use Category")) {
54
						text = text + statedata.getState().getTitleCache() + "; ";
55
					}
56
				}
57
				for (StateData statedata : ((CategoricalData) element).getStates()) {
58
					if(statedata.getState() != null && statedata.getModifyingText().get(CdmStore.getDefaultLanguage()) !=null && statedata.getModifyingText().get(CdmStore.getDefaultLanguage()).getText().equals("Use SubCategory")) {
54 59
						text = text + statedata.getState().getTitleCache() + "; ";
55 60
					}
56
					/*else {
57
						text = "No data provided";
58
					}*/
59 61
				}
60 62
			}
61
			
62 63
			if (!((CategoricalData) element).getModifiers().isEmpty()) {
63
				for (Modifier modifier : ((CategoricalData) element).getModifiers()) {
64
					text = text + modifier.getTitleCache();
64
				for (Modifier modifier: ((CategoricalData) element).getModifiers()){
65
					if(GetVocabularyType(modifier, "Country")) {
66
						text = text +  modifier.getTitleCache()+ "; ";
67
					}
68
					
69
				}
70
				for (Modifier modifier: ((CategoricalData) element).getModifiers()){
71
					if(GetVocabularyType(modifier, "Plant Part")) {
72
						text = text +  modifier.getTitleCache()+ "; ";
73
					}
74
					
75
				}
76
				for (Modifier modifier: ((CategoricalData) element).getModifiers()){
77
					if(GetVocabularyType(modifier, "Human Group")) {
78
						text = text +  modifier.getTitleCache()+ "; ";
79
					}
80
					
81
				}
82
				for (Modifier modifier: ((CategoricalData) element).getModifiers()){
83
					if(GetVocabularyType(modifier, "Ethnic Group")) {
84
						text = text +  modifier.getTitleCache()+ "; ";
85
					}
86
					
65 87
				}
66 88
			}
67

  
68
			
69
			//text = textData.getText(CdmStore.getDefaultLanguage());
89
		
70 90
			if (text == null || text.length() == 0) {
71 91
				text = "No data provided";
72 92
			}
73 93
			return text;
74 94
		}
75
		/*else  if (element instanceof DescriptionElementBase) {
76
			Map useRecordText = ((DescriptionElementBase) element).getModifyingText();
77
			
78
			
79
			if (text == null || text.length() == 0) {
80
				text = "Use Record: No label provided";
81
			}
82
			text = useRecordText.toString();
83
			//text = "Something else";
84
		}*/
95

  
85 96
		else{
86 97
			text = "Use Record";
87 98
		}
......
89 100
		return  text;
90 101
	}
91 102

  
103
	
104
	private boolean GetVocabularyType(Modifier term, String vocabularyExpected) {
105
		if ((term.getPartOf() != null) && (term.getPartOf().getTitleCache().equals(vocabularyExpected))) {
106
			return true;
107
		}
108
		else if ((term.getVocabulary() != null) && (term.getVocabulary().getTitleCache().equals(vocabularyExpected))) {
109
			return true;
110
		}
111
		return false;
112
	}
92 113
	@Override
93 114
	public StyledString getStyledText(Object element) {
94 115
		return new StyledString(this.getText(element),
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/userecords/UseRecordDetailElement.java
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
	}

Also available in: Unified diff