Revision 90f25990
Added by Katja Luther over 3 years ago
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/element/CdmFormFactory.java | ||
---|---|---|
256 | 256 |
import eu.etaxonomy.taxeditor.ui.section.occurrence.DerivedUnitBaseDetailSection; |
257 | 257 |
import eu.etaxonomy.taxeditor.ui.section.occurrence.DerivedUnitGeneralDetailElement; |
258 | 258 |
import eu.etaxonomy.taxeditor.ui.section.occurrence.DerivedUnitGeneralDetailSection; |
259 |
import eu.etaxonomy.taxeditor.ui.section.occurrence.DerivedUnitMediaSection; |
|
259 | 260 |
import eu.etaxonomy.taxeditor.ui.section.occurrence.DeterminationDetailElement; |
260 | 261 |
import eu.etaxonomy.taxeditor.ui.section.occurrence.DeterminationDetailSection; |
261 | 262 |
import eu.etaxonomy.taxeditor.ui.section.occurrence.DeterminationEventDetailElement; |
... | ... | |
318 | 319 |
import eu.etaxonomy.taxeditor.ui.section.occurrence.media.MediaSpecimenGeneralDetailSection; |
319 | 320 |
import eu.etaxonomy.taxeditor.ui.section.reference.NomenclaturalReferenceDetailElement; |
320 | 321 |
import eu.etaxonomy.taxeditor.ui.section.reference.NomenclaturalReferenceDetailSection; |
322 |
import eu.etaxonomy.taxeditor.ui.section.reference.OriginalSourceAdvancedSection; |
|
321 | 323 |
import eu.etaxonomy.taxeditor.ui.section.reference.ReferenceDetailElement; |
322 | 324 |
import eu.etaxonomy.taxeditor.ui.section.reference.ReferenceDetailSection; |
325 |
import eu.etaxonomy.taxeditor.ui.section.reference.SingleSourceSection; |
|
323 | 326 |
import eu.etaxonomy.taxeditor.ui.section.supplemental.AnnotationElement; |
324 | 327 |
import eu.etaxonomy.taxeditor.ui.section.supplemental.AnnotationSection; |
325 | 328 |
import eu.etaxonomy.taxeditor.ui.section.supplemental.CdmBaseElement; |
... | ... | |
1742 | 1745 |
|
1743 | 1746 |
} |
1744 | 1747 |
|
1748 |
public DerivedUnitMediaSection createDerivedUnitMediaSection(ConversationHolder conversation, |
|
1749 |
ICdmFormElement parentElement, int style) { |
|
1750 |
DerivedUnitMediaSection section = new DerivedUnitMediaSection(this, conversation, parentElement, style); |
|
1751 |
parentElement.addElement(section); |
|
1752 |
adapt(section); |
|
1753 |
return section; |
|
1754 |
|
|
1755 |
} |
|
1756 |
|
|
1745 | 1757 |
/** |
1746 | 1758 |
* @param definedTermClass |
1747 | 1759 |
* @param formElement |
... | ... | |
1836 | 1848 |
return section; |
1837 | 1849 |
} |
1838 | 1850 |
|
1851 |
public OriginalSourceAdvancedSection createOriginalSourceAdvancedSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){ |
|
1852 |
OriginalSourceAdvancedSection section = new OriginalSourceAdvancedSection(this, conversation, parentElement, selectionProvider, style); |
|
1853 |
addAndAdaptSection(parentElement, section); |
|
1854 |
return section; |
|
1855 |
} |
|
1856 |
|
|
1857 |
public SingleSourceSection createSingleSourceSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){ |
|
1858 |
SingleSourceSection section = new SingleSourceSection(this, conversation, parentElement, selectionProvider, style); |
|
1859 |
addAndAdaptSection(parentElement, section); |
|
1860 |
return section; |
|
1861 |
} |
|
1862 |
|
|
1839 | 1863 |
public TaxonBaseDetailSection createTaxonBaseDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){ |
1840 | 1864 |
TaxonBaseDetailSection section = new TaxonBaseDetailSection(this, conversation, parentElement, selectionProvider, style); |
1841 | 1865 |
addAndAdaptSection(parentElement, section); |
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/AbstractCdmDetailElement.java | ||
---|---|---|
278 | 278 |
except.add(formElement); |
279 | 279 |
} |
280 | 280 |
} |
281 |
|
|
282 |
enabled = getEntity() != null && CdmStore.currentAuthentiationHasPermission(StoreUtil.getCdmEntity(getEntity()), requiredCrud); |
|
281 |
if (getEntity() != null){ |
|
282 |
enabled = CdmStore.currentAuthentiationHasPermission(StoreUtil.getCdmEntity(getEntity()), requiredCrud); |
|
283 |
}else{ |
|
284 |
enabled = true; |
|
285 |
} |
|
283 | 286 |
setEnabled(enabled, except); |
284 | 287 |
} |
285 | 288 |
|
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/AbstractCdmDetailSection.java | ||
---|---|---|
143 | 143 |
} |
144 | 144 |
if (detailElement != null) { |
145 | 145 |
detailElement.setEntity(entity); |
146 |
formFactory.adapt(detailElement); |
|
146 | 147 |
Collection<Object> except = new ArrayList<>(); |
147 | 148 |
for(ICdmFormElement formElement:detailElement.getElements()){ |
148 | 149 |
if(formElement instanceof IEnableableFormElement && !((IEnableableFormElement) formElement).isEnabled()){ |
149 | 150 |
except.add(formElement); |
150 | 151 |
} |
151 | 152 |
} |
153 |
if (entity != null){ |
|
154 |
boolean hasPermission = CdmStore.currentAuthentiationHasPermission(StoreUtil.getCdmEntity(entity), requiredCrud); |
|
155 |
detailElement.setEnabled(isEnabled() && hasPermission, except); |
|
156 |
}else{ |
|
157 |
detailElement.setEnabled(isEnabled() && true, except); |
|
158 |
} |
|
152 | 159 |
|
153 |
boolean hasPermission = CdmStore.currentAuthentiationHasPermission(StoreUtil.getCdmEntity(entity), requiredCrud); |
|
154 |
detailElement.setEnabled(isEnabled() && hasPermission, except); |
|
155 | 160 |
} |
156 | 161 |
super.setEntity(entity); |
157 | 162 |
setSectionTitle(); |
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/occurrence/DerivedUnitBaseDetailElement.java | ||
---|---|---|
56 | 56 |
|
57 | 57 |
private OriginalLabelDataElement textOriginalLabel; |
58 | 58 |
|
59 |
private DerivedUnitMediaSection mediaDetailElement; |
|
60 |
|
|
59 | 61 |
|
60 | 62 |
|
61 | 63 |
/** |
... | ... | |
116 | 118 |
textOriginalLabel = formFactory.createOriginalLabelDataElement(formElement); |
117 | 119 |
textOriginalLabel.setEntity(getEntity()); |
118 | 120 |
|
121 |
|
|
122 |
|
|
119 | 123 |
super.createControls(formElement, entity, style); |
120 | 124 |
|
121 | 125 |
section_source = formFactory.createSourceCollectionDetailSection(getConversationHolder(), formElement, StoreUtil.getSectionStyle(SourceCollectionDetailSection.class, entity.getClass().getCanonicalName())); |
122 | 126 |
section_source.setLayoutData(LayoutConstants.FILL_HORIZONTALLY(2, 1)); |
123 | 127 |
section_source.setEntity(entity); |
124 | 128 |
|
129 |
mediaDetailElement = formFactory.createDerivedUnitMediaSection(getConversationHolder(), formElement, StoreUtil.getSectionStyle(DerivedUnitMediaSection.class, entity.getClass().getCanonicalName())); |
|
130 |
mediaDetailElement.setLayoutData(LayoutConstants.FILL_HORIZONTALLY(2, 1)); |
|
131 |
mediaDetailElement.setEntity(getEntity()); |
|
132 |
|
|
133 |
|
|
125 | 134 |
|
126 | 135 |
} |
127 | 136 |
|
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/occurrence/DerivedUnitMediaSection.java | ||
---|---|---|
1 |
/** |
|
2 |
* Copyright (C) 2020 EDIT |
|
3 |
* European Distributed Institute of Taxonomy |
|
4 |
* http://www.e-taxonomy.eu |
|
5 |
* |
|
6 |
* The contents of this file are subject to the Mozilla Public License Version 1.1 |
|
7 |
* See LICENSE.TXT at the top of this package for the full license terms. |
|
8 |
*/ |
|
9 |
package eu.etaxonomy.taxeditor.ui.section.occurrence; |
|
10 |
|
|
11 |
import java.util.Collection; |
|
12 |
import java.util.Comparator; |
|
13 |
|
|
14 |
import eu.etaxonomy.cdm.api.conversation.ConversationHolder; |
|
15 |
import eu.etaxonomy.cdm.api.facade.DerivedUnitFacade; |
|
16 |
import eu.etaxonomy.cdm.model.media.Media; |
|
17 |
import eu.etaxonomy.taxeditor.ui.dialog.selection.MediaSelectionDialog; |
|
18 |
import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory; |
|
19 |
import eu.etaxonomy.taxeditor.ui.element.ICdmFormElement; |
|
20 |
import eu.etaxonomy.taxeditor.ui.section.AbstractEntityCollectionSection; |
|
21 |
import eu.etaxonomy.taxeditor.ui.section.DefaultCdmBaseComparator; |
|
22 |
|
|
23 |
/** |
|
24 |
* @author k.luther |
|
25 |
* @since Aug 4, 2020 |
|
26 |
*/ |
|
27 |
public class DerivedUnitMediaSection extends AbstractEntityCollectionSection<DerivedUnitFacade, Media> { |
|
28 |
|
|
29 |
public DerivedUnitMediaSection(CdmFormFactory cdmFormFactory, ConversationHolder conversation, ICdmFormElement parentElement, int style) { |
|
30 |
super(cdmFormFactory, conversation, parentElement, "Media", style); |
|
31 |
} |
|
32 |
|
|
33 |
@Override |
|
34 |
public Media createNewElement() { |
|
35 |
return Media.NewInstance(); |
|
36 |
} |
|
37 |
|
|
38 |
@Override |
|
39 |
public Collection<Media> getCollection(DerivedUnitFacade entity) { |
|
40 |
return entity.getDerivedUnitMedia(); |
|
41 |
} |
|
42 |
|
|
43 |
@Override |
|
44 |
public Comparator<Media> getComparator() { |
|
45 |
return new DefaultCdmBaseComparator<>(); |
|
46 |
} |
|
47 |
|
|
48 |
@Override |
|
49 |
public String getEmptyString() { |
|
50 |
return "No media yet."; |
|
51 |
} |
|
52 |
|
|
53 |
@Override |
|
54 |
protected String getTooltipString() { |
|
55 |
return "Create new media"; |
|
56 |
} |
|
57 |
|
|
58 |
@Override |
|
59 |
public void addElement(Media element) { |
|
60 |
getEntity().addDerivedUnitMedia(element); |
|
61 |
} |
|
62 |
|
|
63 |
@Override |
|
64 |
public void removeElement(Media element) { |
|
65 |
getEntity().removeDerivedUnitMedia(element); |
|
66 |
} |
|
67 |
|
|
68 |
@Override |
|
69 |
public Media addExisting() { |
|
70 |
return MediaSelectionDialog.select(getShell(), null); |
|
71 |
} |
|
72 |
|
|
73 |
@Override |
|
74 |
public boolean allowAddExisting() { |
|
75 |
return true; |
|
76 |
} |
|
77 |
|
|
78 |
} |
Also available in: Unified diff
ref #9065: add media section to derived unit details view