Revision d00b84de
Added by Patrick Plitzner over 10 years ago
- added icons for derivate views
- enhanced DerivateViewEditorInput handling
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/derivate/DerivateContentProvider.java | ||
---|---|---|
28 | 28 |
|
29 | 29 |
@Override |
30 | 30 |
public Object[] getElements(Object inputElement) { |
31 |
FieldUnit fieldUnit = null;
|
|
31 |
SpecimenOrObservationBase<?> specimen = null;
|
|
32 | 32 |
if(inputElement instanceof DerivateViewEditorInput){ |
33 |
fieldUnit = ((DerivateViewEditorInput) inputElement).getFieldUnit();
|
|
33 |
inputElement = ((DerivateViewEditorInput) inputElement).getDerivate();
|
|
34 | 34 |
} |
35 |
|
|
35 | 36 |
// return the parent FieldUnit if element is a DerivedUnit |
36 |
else if(inputElement instanceof DerivedUnit){
|
|
37 |
fieldUnit = EditorUtil.getFieldUnit((DerivedUnit)inputElement);
|
|
37 |
if(inputElement instanceof DerivedUnit){ |
|
38 |
specimen = EditorUtil.getFieldUnit((DerivedUnit)inputElement);
|
|
38 | 39 |
} |
39 | 40 |
else if(inputElement instanceof FieldUnit){ |
40 |
fieldUnit = (FieldUnit) inputElement; |
|
41 |
// fieldUnit.getTitleCache(); |
|
41 |
specimen = (FieldUnit) inputElement; |
|
42 | 42 |
} |
43 |
if(fieldUnit!=null){
|
|
44 |
return Collections.singleton(fieldUnit).toArray();
|
|
43 |
if(specimen!=null){
|
|
44 |
return Collections.singleton(specimen).toArray();
|
|
45 | 45 |
} |
46 | 46 |
else { |
47 | 47 |
return Collections.EMPTY_LIST.toArray(); |
... | ... | |
51 | 51 |
@Override |
52 | 52 |
public Object[] getChildren(Object parentElement) { |
53 | 53 |
if(parentElement instanceof DerivateViewEditorInput){ |
54 |
parentElement = ((DerivateViewEditorInput) parentElement).getFieldUnit();
|
|
54 |
parentElement = ((DerivateViewEditorInput) parentElement).getDerivate();
|
|
55 | 55 |
} |
56 |
|
|
56 | 57 |
if(parentElement instanceof SpecimenOrObservationBase){ |
57 | 58 |
return getDerivates((SpecimenOrObservationBase) parentElement).toArray(); |
58 | 59 |
} |
... | ... | |
62 | 63 |
@Override |
63 | 64 |
public Object getParent(Object element) { |
64 | 65 |
if(element instanceof DerivateViewEditorInput){ |
65 |
element = ((DerivateViewEditorInput) element).getFieldUnit();
|
|
66 |
element = ((DerivateViewEditorInput) element).getDerivate();
|
|
66 | 67 |
} |
67 |
if(element instanceof DerivedUnit){ |
|
68 |
|
|
69 |
if(element instanceof FieldUnit){ |
|
70 |
return element; |
|
71 |
} |
|
72 |
else if(element instanceof DerivedUnit){ |
|
68 | 73 |
DerivedUnit derivedUnit = (DerivedUnit)element; |
69 | 74 |
return derivedUnit.getOriginalUnit(); |
70 | 75 |
} |
... | ... | |
74 | 79 |
@Override |
75 | 80 |
public boolean hasChildren(Object element) { |
76 | 81 |
if(element instanceof DerivateViewEditorInput){ |
77 |
element = ((DerivateViewEditorInput) element).getFieldUnit();
|
|
82 |
element = ((DerivateViewEditorInput) element).getDerivate();
|
|
78 | 83 |
} |
84 |
|
|
79 | 85 |
if(element instanceof SpecimenOrObservationBase){ |
80 | 86 |
SpecimenOrObservationBase specimenOrObservation = (SpecimenOrObservationBase)element; |
81 | 87 |
for(DerivationEvent event:(Set<DerivationEvent>)specimenOrObservation.getDerivationEvents()){ |
Also available in: Unified diff