Revision 4faee5bc
Added by Katja Luther over 2 years ago
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/occurrence/FieldUnitFacadeGeneralDetailElement.java | ||
---|---|---|
8 | 8 |
*/ |
9 | 9 |
package eu.etaxonomy.taxeditor.ui.section.occurrence; |
10 | 10 |
|
11 |
import java.util.Collection; |
|
12 |
import java.util.HashSet; |
|
13 |
import java.util.Set; |
|
14 |
|
|
11 | 15 |
import eu.etaxonomy.cdm.api.facade.DerivedUnitFacade; |
12 | 16 |
import eu.etaxonomy.cdm.model.agent.AgentBase; |
17 |
import eu.etaxonomy.cdm.model.agent.Team; |
|
18 |
import eu.etaxonomy.cdm.model.common.CdmBase; |
|
13 | 19 |
import eu.etaxonomy.cdm.model.common.LanguageString; |
14 | 20 |
import eu.etaxonomy.cdm.model.location.NamedArea; |
15 | 21 |
import eu.etaxonomy.cdm.model.occurrence.SpecimenOrObservationType; |
16 | 22 |
import eu.etaxonomy.taxeditor.preference.PreferencesUtil; |
23 |
import eu.etaxonomy.taxeditor.store.CdmStore; |
|
17 | 24 |
import eu.etaxonomy.taxeditor.store.StoreUtil; |
18 | 25 |
import eu.etaxonomy.taxeditor.ui.combo.EnumComboElement; |
19 | 26 |
import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory; |
... | ... | |
47 | 54 |
private NumberWithLabelElement number_elevation; |
48 | 55 |
private TimePeriodElement element_date; |
49 | 56 |
private CollectorSelectionElement selection_collector; |
57 |
private CollectorSelectionElement selection_primary_collector; |
|
50 | 58 |
private TextWithLabelElement text_collectingNumber; |
51 | 59 |
private GatheringEventUnitElement element_elevation; |
52 | 60 |
private CheckboxElement checkIsPublish; |
... | ... | |
81 | 89 |
|
82 | 90 |
element_date = formFactory.createTimePeriodElement(formElement, "Date", entity.getGatheringPeriod(), style); |
83 | 91 |
selection_collector = formFactory.createCollectorSelectionElement(formElement, "Collector", entity.getCollector(), EntitySelectionElement.ALL, style); |
92 |
selection_primary_collector = formFactory |
|
93 |
.createCollectorSelectionElement( |
|
94 |
formElement, "Primary collector", |
|
95 |
entity.getCollector(), entity.getPrimaryCollector(), EntitySelectionElement.ALL, |
|
96 |
style); |
|
97 |
if (!(entity.getCollector() instanceof Team)){ |
|
98 |
selection_primary_collector.setEnabled(false); |
|
99 |
} |
|
84 | 100 |
text_collectingNumber = formFactory.createTextWithLabelElement(formElement, "Collecting number", |
85 | 101 |
entity.getFieldNumber(), style); |
86 | 102 |
checkIsPublish = formFactory.createCheckbox(formElement, "Publish", entity.innerFieldUnit().isPublish(), style); |
... | ... | |
104 | 120 |
getEntity().setGatheringPeriod(element_date.getTimePeriod()); |
105 | 121 |
} else if (eventSource == selection_collector) { |
106 | 122 |
getEntity().setCollector(selection_collector.getSelection()); |
123 |
|
|
124 |
if (getEntity().getCollector() instanceof Team){ |
|
125 |
selection_primary_collector.setCollectorTeam((Team)getEntity().getCollector()); |
|
126 |
}else{ |
|
127 |
selection_primary_collector.setEntity(null); |
|
128 |
} |
|
129 |
selection_primary_collector.setEnabled((getEntity().getCollector() instanceof Team)); |
|
130 |
|
|
131 |
} else if (eventSource == selection_primary_collector) { |
|
132 |
getEntity().setCollector(selection_primary_collector.getSelection()); |
|
107 | 133 |
} else if (eventSource == text_collectingNumber) { |
108 | 134 |
getEntity().setFieldNumber(text_collectingNumber.getText()); |
109 | 135 |
} else if (eventSource == combo_specorobstype) { |
... | ... | |
115 | 141 |
toggleableText_titleCache.setText(getEntity().getTitleCache()); |
116 | 142 |
|
117 | 143 |
} |
144 |
protected void updateControlStates(){ |
|
145 |
if (getEntity() != null ){ |
|
146 |
enabled = enabled && CdmStore.currentAuthentiationHasPermission(StoreUtil.getCdmEntity(getEntity()), requiredCrud); |
|
147 |
}else{ |
|
148 |
enabled = true; |
|
149 |
} |
|
150 |
Set<Object> except = new HashSet<>(); |
|
151 |
if (!selection_primary_collector.isEnabled() && enabled){ |
|
152 |
except.add(selection_primary_collector); |
|
153 |
} |
|
154 |
setEnabled(enabled, except); |
|
155 |
|
|
156 |
} |
|
157 |
|
|
118 | 158 |
} |
Also available in: Unified diff
ref #9894: add field primary collector and handle as described in ticket