Revision 6d75492c
Added by Alex Theys over 10 years ago
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/uses/UsesLabelProvider.java | ||
---|---|---|
17 | 17 |
import eu.etaxonomy.cdm.model.description.CategoricalData; |
18 | 18 |
import eu.etaxonomy.cdm.model.description.DescriptionBase; |
19 | 19 |
import eu.etaxonomy.cdm.model.description.DescriptionElementBase; |
20 |
import eu.etaxonomy.cdm.model.description.State; |
|
21 |
import eu.etaxonomy.cdm.model.description.StateData; |
|
20 | 22 |
import eu.etaxonomy.cdm.model.description.TextData; |
21 | 23 |
import eu.etaxonomy.taxeditor.store.CdmStore; |
22 | 24 |
|
... | ... | |
43 | 45 |
} |
44 | 46 |
} |
45 | 47 |
else if (element instanceof CategoricalData) { |
46 |
TextData textData = categoricalDescriptionBuilder.build((CategoricalData) element, getLanguageList()); |
|
47 |
text = textData.getText(CdmStore.getDefaultLanguage()); |
|
48 |
//String text = ""; |
|
49 |
//TextData textData = categoricalDescriptionBuilder.build((CategoricalData) element, getLanguageList()); |
|
50 |
if (((CategoricalData) element).getStates() != null) { |
|
51 |
for (StateData statedata : ((CategoricalData) element).getStates()) { |
|
52 |
if(statedata.getState() != null) { |
|
53 |
text = text + statedata.getState().getTitleCache(); |
|
54 |
} |
|
55 |
else { |
|
56 |
text = "No data provided"; |
|
57 |
} |
|
58 |
} |
|
59 |
} |
|
60 |
if (((CategoricalData) element).getStatesOnly() != null) { |
|
61 |
for (State state : ((CategoricalData) element).getStatesOnly()) { |
|
62 |
if (state != null) { |
|
63 |
text = text + state.getTitleCache(); |
|
64 |
} |
|
65 |
else { |
|
66 |
text = "No data provided"; |
|
67 |
} |
|
68 |
} |
|
69 |
} |
|
70 |
|
|
71 |
//text = textData.getText(CdmStore.getDefaultLanguage()); |
|
48 | 72 |
if (text == null || text.length() == 0) { |
49 | 73 |
text = "No data provided"; |
50 | 74 |
} |
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/element/CdmFormFactory.java | ||
---|---|---|
250 | 250 |
import eu.etaxonomy.taxeditor.ui.section.user.GroupsByUserDetailSection; |
251 | 251 |
import eu.etaxonomy.taxeditor.ui.section.user.UserDetailElement; |
252 | 252 |
import eu.etaxonomy.taxeditor.ui.section.user.UserDetailSection; |
253 |
import eu.etaxonomy.taxeditor.ui.section.userecords.UseRecordDetailElement; |
|
254 |
import eu.etaxonomy.taxeditor.ui.section.userecords.UseRecordDetailSection; |
|
253 | 255 |
import eu.etaxonomy.taxeditor.ui.section.vocabulary.DefinedTermDetailElement; |
254 | 256 |
import eu.etaxonomy.taxeditor.ui.section.vocabulary.DefinedTermDetailSection; |
255 | 257 |
import eu.etaxonomy.taxeditor.ui.section.vocabulary.NamedAreaDetailSection; |
... | ... | |
1526 | 1528 |
REFERENCED_ENTITY, |
1527 | 1529 |
TERM_VOCABULARY, |
1528 | 1530 |
NAMED_AREA, |
1529 |
NAMED_AREA_LEVEL |
|
1531 |
NAMED_AREA_LEVEL, |
|
1532 |
USE_RECORD |
|
1530 | 1533 |
} |
1531 | 1534 |
|
1532 | 1535 |
public AbstractFormSection createDefinedTermDetailSection(Class definedTermClass, |
... | ... | |
1724 | 1727 |
section = new NamedAreaDetailSection(this, conversation, parentElement, |
1725 | 1728 |
selectionProvider, style); |
1726 | 1729 |
break; |
1730 |
case USE_RECORD: |
|
1731 |
section = new UseRecordDetailSection(this, conversation, parentElement, |
|
1732 |
selectionProvider, style); |
|
1733 |
break; |
|
1727 | 1734 |
} |
1735 |
|
|
1728 | 1736 |
|
1729 | 1737 |
if (section == null) { |
1730 | 1738 |
throw new RuntimeException( |
... | ... | |
1859 | 1867 |
case NAMED_AREA_LEVEL: |
1860 | 1868 |
element = new DefinedTermDetailElement<NamedAreaLevel>(this, parentElement); |
1861 | 1869 |
break; |
1870 |
case USE_RECORD: |
|
1871 |
//element = new UseRecordDetailElement(this, parentElement, style); |
|
1872 |
element = new UseRecordDetailElement(this, parentElement); |
|
1873 |
break; |
|
1862 | 1874 |
} |
1863 | 1875 |
|
1864 | 1876 |
if (element == null) { |
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 |
|
|
4 |
|
|
5 |
import java.util.ArrayList; |
|
6 |
import java.util.List; |
|
7 |
import java.util.UUID; |
|
8 |
|
|
3 | 9 |
import org.apache.log4j.Logger; |
10 |
import org.eclipse.swt.events.SelectionEvent; |
|
11 |
import org.eclipse.swt.events.SelectionListener; |
|
4 | 12 |
import org.eclipse.ui.forms.widgets.Section; |
5 | 13 |
|
14 |
import eu.etaxonomy.cdm.api.service.IVocabularyService; |
|
15 |
import eu.etaxonomy.cdm.model.common.DefinedTermBase; |
|
16 |
import eu.etaxonomy.cdm.model.common.Language; |
|
17 |
import eu.etaxonomy.cdm.model.common.LanguageString; |
|
18 |
import eu.etaxonomy.cdm.model.common.TermVocabulary; |
|
6 | 19 |
import eu.etaxonomy.cdm.model.description.CategoricalData; |
7 | 20 |
import eu.etaxonomy.cdm.model.description.DescriptionElementBase; |
8 | 21 |
import eu.etaxonomy.cdm.model.description.State; |
22 |
import eu.etaxonomy.taxeditor.store.CdmStore; |
|
23 |
import eu.etaxonomy.taxeditor.store.TermStore; |
|
9 | 24 |
import eu.etaxonomy.taxeditor.ui.combo.TermComboElement; |
10 |
import eu.etaxonomy.taxeditor.ui.forms.CdmFormFactory;
|
|
11 |
import eu.etaxonomy.taxeditor.ui.forms.CheckboxElement;
|
|
12 |
import eu.etaxonomy.taxeditor.ui.forms.ICdmFormElement;
|
|
13 |
import eu.etaxonomy.taxeditor.ui.forms.CdmFormFactory.EntityDetailType;
|
|
25 |
import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;
|
|
26 |
import eu.etaxonomy.taxeditor.ui.element.CheckboxElement;
|
|
27 |
import eu.etaxonomy.taxeditor.ui.element.ICdmFormElement;
|
|
28 |
import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory.EntityDetailType;
|
|
14 | 29 |
import eu.etaxonomy.taxeditor.ui.section.AbstractCdmDetailElement; |
15 | 30 |
import eu.etaxonomy.taxeditor.ui.section.description.DescriptionElementDetailElement; |
16 | 31 |
import eu.etaxonomy.taxeditor.ui.section.description.StateDataSection; |
17 | 32 |
import eu.etaxonomy.taxeditor.ui.section.description.detail.AbstractDetailedDescriptionDetailElement; |
18 | 33 |
|
19 | 34 |
//public class UseRecordDetailElement extends AbstractDetailedDescriptionDetailElement<CategoricalData> { |
20 |
public class UseRecordDetailElement extends AbstractCdmDetailElement<CategoricalData> { |
|
35 |
public class UseRecordDetailElement extends AbstractCdmDetailElement<CategoricalData> implements SelectionListener {
|
|
21 | 36 |
|
22 | 37 |
|
23 | 38 |
private static final Logger logger = Logger |
24 | 39 |
.getLogger(DescriptionElementDetailElement.class); |
25 | 40 |
|
26 |
private CheckboxElement checkbox_orderRelevant; |
|
27 |
private TermComboElement UseCategory_stateData;
|
|
28 |
private UseSubCategorySection UseSubCategory_stateData;
|
|
41 |
//private CheckboxElement checkbox_orderRelevant;
|
|
42 |
private TermComboElement<State> combo_UseCategory;
|
|
43 |
private TermComboElement<State> combo_UseSubCategory;
|
|
29 | 44 |
//private AbstractDetailedDescriptionDetailElement detailElement; |
30 | 45 |
|
31 | 46 |
/*public UseRecordDetailElement(CdmFormFactory formFactory, |
... | ... | |
45 | 60 |
CategoricalData entity, int style) { |
46 | 61 |
|
47 | 62 |
|
48 |
State state = State.NewInstance("Tato", "Toto", "Titi"); |
|
63 |
//State state = State.NewInstance("Tato", "Toto", "Titi");
|
|
49 | 64 |
//checkbox_orderRelevant = formFactory.createCheckbox(formElement, "Order Relevant", entity.getOrderRelevant(), style); |
50 |
UseCategory_stateData = formFactory.createTermComboElement(State.class, this, "Use Category", state , style); |
|
65 |
combo_UseCategory = formFactory.createTermComboElement(State.class, this, "Use Category", null , style); |
|
66 |
combo_UseCategory.addSelectionListener(this); |
|
67 |
combo_UseSubCategory = formFactory.createTermComboElement(State.class, this, "Use Sub Category", null , style); |
|
68 |
//List<State> listOfTerms = TermStore.getTerms(State.class,null , false); |
|
69 |
|
|
70 |
|
|
71 |
//UUID uuidUseCategory = UUID.fromString("2bb365af-ce6c-4196-a30b-e69b05099ed0"); |
|
72 |
//TermVocabulary termVoc = CdmStore.getService(IVocabularyService.class).find(uuidUseCategory); |
|
73 |
List<State> termsToAdd = setUseCategoryComboTerms(TermStore.getTerms(State.class,null , false)); |
|
74 |
//combo_UseCategory.setTerms(setUseCategoryComboTerms(listOfTerms)); |
|
75 |
combo_UseCategory.setTerms(termsToAdd); |
|
76 |
|
|
77 |
//getPreferredTerms(State.class)); |
|
78 |
//UseSubCategory_stateData = formFactory.createTermComboElement(State.class, this, "Use Sub Category", null , style); |
|
51 | 79 |
//createEntityDetailSection(EntityDetailType.USE_CAT, getConversationHolder(), formElement, Section.EXPANDED); |
52 |
UseSubCategory_stateData = (UseSubCategorySection) formFactory.createEntityDetailSection(EntityDetailType.USE_SUBCAT, getConversationHolder(), formElement,Section.EXPANDED); |
|
80 |
//UseSubCategory_stateData = (UseSubCategorySection) formFactory.createEntityDetailSection(EntityDetailType.USE_SUBCAT, getConversationHolder(), formElement,Section.EXPANDED);
|
|
53 | 81 |
//UseCategory_stateData.setEntity(entity); |
54 |
UseSubCategory_stateData.setEntity(entity); |
|
82 |
//UseSubCategory_stateData.setEntity(entity);
|
|
55 | 83 |
//UseCategory_stateData.setLayoutData(CdmFormFactory.FILL_HORIZONTALLY(2, 1)); |
56 |
UseSubCategory_stateData.setLayoutData(CdmFormFactory.FILL_HORIZONTALLY(2, 1)); |
|
84 |
//UseSubCategory_stateData.setLayoutData(CdmFormFactory.FILL_HORIZONTALLY(2, 1));
|
|
57 | 85 |
|
58 | 86 |
} |
59 | 87 |
|
60 | 88 |
|
89 |
private List<State> setUseCategoryComboTerms(List<State> listOfTerms) { |
|
90 |
List<State> termsToAdd = new ArrayList<State>(); |
|
91 |
for(State term : listOfTerms) { |
|
92 |
|
|
93 |
if ((term.getPartOf() != null) && (term.getPartOf().getTitleCache().equals("Use Category"))) { |
|
94 |
termsToAdd.add(term); |
|
95 |
} |
|
96 |
} |
|
97 |
return termsToAdd; |
|
98 |
|
|
99 |
} |
|
100 |
|
|
101 |
private List<State> setUseCategoryComboTerms(List<State> listOfTerms, |
|
102 |
State selectedUseCategory) { |
|
103 |
List<State> termsToAdd = new ArrayList<State>(); |
|
104 |
for(State term : listOfTerms) { |
|
105 |
if ((term.getPartOf() != null) && (term.getPartOf().getTitleCache().equals(selectedUseCategory.getTitleCache()))) { |
|
106 |
termsToAdd.add(term); |
|
107 |
} |
|
108 |
|
|
109 |
} |
|
110 |
|
|
111 |
// TODO Auto-generated method stub |
|
112 |
return termsToAdd; |
|
113 |
} |
|
114 |
|
|
61 | 115 |
/** {@inheritDoc} */ |
62 | 116 |
@Override |
63 | 117 |
public void handleEvent(Object eventSource) { |
64 |
if(eventSource == checkbox_orderRelevant){ |
|
118 |
/*if(eventSource == checkbox_orderRelevant){
|
|
65 | 119 |
getEntity().setOrderRelevant(checkbox_orderRelevant.getSelection()); |
120 |
}*/ |
|
121 |
if(eventSource == combo_UseCategory){ |
|
122 |
TermVocabulary<State> useCategoryVocabulary = TermVocabulary.NewInstance("Use category vocabulary", "use categories", null, null); |
|
123 |
State useCategory1 = State.NewInstance("My first use category", "use category 1", null); |
|
124 |
useCategoryVocabulary.addTerm(useCategory1); |
|
125 |
getEntity().addState(useCategory1); |
|
126 |
List<State> currentStates = new ArrayList<State>(); |
|
127 |
currentStates.add(combo_UseCategory.getSelection()); |
|
128 |
getEntity().setStatesOnly(currentStates); |
|
129 |
//getEntity().addState(combo_UseCategory.getSelection()); |
|
130 |
//.setOrderRelevant(combo_UseCategory.getSelection()); |
|
66 | 131 |
} |
67 | 132 |
} |
133 |
|
|
134 |
/** {@inheritDoc} */ |
|
135 |
@Override |
|
136 |
public void setEntity(CategoricalData entity) { |
|
137 |
// section_stateData.setEntity(entity); |
|
138 |
super.setEntity(entity); |
|
139 |
} |
|
140 |
|
|
141 |
@Override |
|
142 |
public void widgetSelected(SelectionEvent e) { |
|
143 |
State selectedUseCategory = combo_UseCategory.getSelection(); |
|
144 |
if (selectedUseCategory != null) { |
|
145 |
combo_UseSubCategory.setTerms(setUseCategoryComboTerms(TermStore.getTerms(State.class,null , false), selectedUseCategory)); |
|
146 |
/*selectedLanguageString = getMultilanguageText().get( |
|
147 |
selectedLanguage); |
|
148 |
|
|
149 |
element_languageString.setLanguageString(selectedLanguageString);*/ |
|
150 |
} |
|
151 |
|
|
152 |
} |
|
153 |
|
|
154 |
|
|
155 |
|
|
156 |
@Override |
|
157 |
public void widgetDefaultSelected(SelectionEvent e) { |
|
158 |
// TODO Auto-generated method stub |
|
159 |
|
|
160 |
} |
|
161 |
|
|
68 | 162 |
|
69 | 163 |
} |
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/userecords/UseRecordDetailSection.java | ||
---|---|---|
5 | 5 |
import eu.etaxonomy.cdm.api.conversation.ConversationHolder; |
6 | 6 |
import eu.etaxonomy.cdm.model.description.DescriptionElementBase; |
7 | 7 |
import eu.etaxonomy.taxeditor.store.CdmStore; |
8 |
import eu.etaxonomy.taxeditor.ui.forms.CdmFormFactory;
|
|
9 |
import eu.etaxonomy.taxeditor.ui.forms.CdmFormFactory.DetailType;
|
|
10 |
import eu.etaxonomy.taxeditor.ui.forms.ICdmFormElement;
|
|
8 |
import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;
|
|
9 |
import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory.DetailType;
|
|
10 |
import eu.etaxonomy.taxeditor.ui.element.ICdmFormElement;
|
|
11 | 11 |
import eu.etaxonomy.taxeditor.ui.section.AbstractCdmDetailSection; |
12 | 12 |
|
13 | 13 |
public class UseRecordDetailSection extends AbstractCdmDetailSection<DescriptionElementBase> { |
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/view/userecords/UseRecordsViewer.java | ||
---|---|---|
10 | 10 |
import eu.etaxonomy.cdm.model.description.DescriptionElementBase; |
11 | 11 |
import eu.etaxonomy.cdm.model.reference.Reference; |
12 | 12 |
import eu.etaxonomy.cdm.model.taxon.TaxonBase; |
13 |
import eu.etaxonomy.taxeditor.ui.forms.RootElement;
|
|
14 |
import eu.etaxonomy.taxeditor.ui.forms.CdmFormFactory.DetailType;
|
|
15 |
import eu.etaxonomy.taxeditor.ui.forms.CdmFormFactory.EntityDetailType;
|
|
13 |
import eu.etaxonomy.taxeditor.ui.element.RootElement;
|
|
14 |
import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory.DetailType;
|
|
15 |
import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory.EntityDetailType;
|
|
16 | 16 |
import eu.etaxonomy.taxeditor.ui.section.description.DescribedSpecimenSection; |
17 | 17 |
import eu.etaxonomy.taxeditor.ui.section.description.DescriptionDetailSection; |
18 | 18 |
import eu.etaxonomy.taxeditor.ui.section.description.DescriptionElementDetailSection; |
Also available in: Unified diff
AT: commiting latest changes to the Palm Use data extension