Revision d0ba58fc
Added by Patrick Plitzner over 9 years ago
- refactored DerivateViewEditorInput to use UUIDs instead of CDM entities
- added delete operation to DerivateView (currently only deleting leafs of the derivate tree is allowed)
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/derivate/DerivateContentProvider.java | ||
---|---|---|
10 | 10 |
import org.eclipse.jface.viewers.TreeNode; |
11 | 11 |
import org.eclipse.jface.viewers.Viewer; |
12 | 12 |
|
13 |
import eu.etaxonomy.cdm.api.service.IOccurrenceService; |
|
13 | 14 |
import eu.etaxonomy.cdm.model.molecular.DnaSample; |
14 | 15 |
import eu.etaxonomy.cdm.model.molecular.Sequence; |
15 | 16 |
import eu.etaxonomy.cdm.model.molecular.SingleRead; |
... | ... | |
17 | 18 |
import eu.etaxonomy.cdm.model.occurrence.DerivedUnit; |
18 | 19 |
import eu.etaxonomy.cdm.model.occurrence.SpecimenOrObservationBase; |
19 | 20 |
import eu.etaxonomy.cdm.model.occurrence.SpecimenOrObservationType; |
20 |
import eu.etaxonomy.taxeditor.editor.EditorUtil;
|
|
21 |
import eu.etaxonomy.taxeditor.store.CdmStore;
|
|
21 | 22 |
|
22 | 23 |
public class DerivateContentProvider implements ITreeContentProvider { |
23 | 24 |
|
... | ... | |
33 | 34 |
|
34 | 35 |
@Override |
35 | 36 |
public Object[] getElements(Object inputElement) { |
36 |
SpecimenOrObservationBase specimen = null;
|
|
37 |
SpecimenOrObservationBase<?> rootElement = null;
|
|
37 | 38 |
if(inputElement instanceof DerivateViewEditorInput){ |
38 |
specimen = ((DerivateViewEditorInput) inputElement).getDerivate();
|
|
39 |
rootElement = CdmStore.getService(IOccurrenceService.class).load(((DerivateViewEditorInput) inputElement).getRootElementUUID());
|
|
39 | 40 |
} |
40 | 41 |
|
41 |
specimen = EditorUtil.getTopMostDerivate(specimen); |
|
42 |
|
|
43 |
if(specimen!=null){ |
|
42 |
if(rootElement!=null){ |
|
44 | 43 |
//show topmost element in the derivate hierarchy if no field unit was found |
45 |
TreeNode node = new TreeNode(specimen);
|
|
44 |
TreeNode node = new TreeNode(rootElement);
|
|
46 | 45 |
return Collections.singleton(node).toArray(); |
47 | 46 |
} |
48 | 47 |
return null; |
... | ... | |
112 | 111 |
return !((Sequence)element).getSingleReads().isEmpty(); |
113 | 112 |
} |
114 | 113 |
else if(element instanceof SpecimenOrObservationBase){ |
115 |
SpecimenOrObservationBase specimenOrObservation = (SpecimenOrObservationBase)element;
|
|
116 |
for(DerivationEvent event:(Set<DerivationEvent>)specimenOrObservation.getDerivationEvents()){
|
|
114 |
SpecimenOrObservationBase<?> specimenOrObservation = (SpecimenOrObservationBase<?>)element;
|
|
115 |
for(DerivationEvent event:specimenOrObservation.getDerivationEvents()){ |
|
117 | 116 |
if(!event.getDerivatives().isEmpty()){ |
118 | 117 |
return true; |
119 | 118 |
} |
... | ... | |
122 | 121 |
return false; |
123 | 122 |
} |
124 | 123 |
|
125 |
private List<DerivedUnit> getDerivates(SpecimenOrObservationBase specimenOrObservation){ |
|
124 |
private List<DerivedUnit> getDerivates(SpecimenOrObservationBase<?> specimenOrObservation){
|
|
126 | 125 |
List<DerivedUnit> derivates = new ArrayList<DerivedUnit>(); |
127 |
for(DerivationEvent derivationEvent:(Set<DerivationEvent>)specimenOrObservation.getDerivationEvents()){
|
|
126 |
for(DerivationEvent derivationEvent:specimenOrObservation.getDerivationEvents()){ |
|
128 | 127 |
derivates.addAll(derivationEvent.getDerivatives()); |
129 | 128 |
} |
130 | 129 |
return derivates; |
Also available in: Unified diff