4 package eu
.etaxonomy
.taxeditor
.editor
.view
.concept
.graph
;
6 import java
.util
.HashMap
;
9 import org
.eclipse
.jface
.viewers
.Viewer
;
10 import org
.eclipse
.zest
.core
.viewers
.IGraphContentProvider
;
12 import eu
.etaxonomy
.cdm
.model
.taxon
.Taxon
;
13 import eu
.etaxonomy
.cdm
.model
.taxon
.TaxonRelationship
;
14 import eu
.etaxonomy
.cdm
.model
.taxon
.TaxonRelationshipType
;
15 import eu
.etaxonomy
.taxeditor
.editor
.e4
.TaxonEditorInputE4
;
21 public class ConceptGraphContentProvider
implements IGraphContentProvider
{
24 * @see org.eclipse.jface.viewers.IContentProvider#dispose()
27 public void dispose() {
28 // TODO Auto-generated method stub
33 * @see org.eclipse.jface.viewers.IContentProvider#inputChanged(org.eclipse.jface.viewers.Viewer, java.lang.Object, java.lang.Object)
36 public void inputChanged(Viewer viewer
, Object oldInput
, Object newInput
) {
37 // TODO Auto-generated method stub
42 * @see org.eclipse.zest.core.viewers.IGraphContentProvider#getSource(java.lang.Object)
45 public Object
getSource(Object taxonRelationship
) {
46 return ((TaxonRelationship
)taxonRelationship
).getFromTaxon();
50 * @see org.eclipse.zest.core.viewers.IGraphContentProvider#getDestination(java.lang.Object)
53 public Object
getDestination(Object taxonRelationship
) {
54 return ((TaxonRelationship
)taxonRelationship
).getToTaxon();
58 * @see org.eclipse.zest.core.viewers.IGraphContentProvider#getElements(java.lang.Object)
61 public Object
[] getElements(Object inputElement
) {
62 if(inputElement
instanceof TaxonEditorInputE4
){
63 Taxon taxon
= ((TaxonEditorInputE4
) inputElement
).getTaxon();
65 Map
<String
, TaxonRelationship
> filteredTaxonRelations
= new HashMap
<String
, TaxonRelationship
>();
66 getTaxonRelationshipsRecursive(filteredTaxonRelations
, taxon
);
68 return filteredTaxonRelations
.values().toArray();
73 private void getTaxonRelationshipsRecursive(Map
<String
, TaxonRelationship
> filteredTaxonRelations
, Taxon taxon
) {
74 // TODO extract method into new class TaxonHelper in
75 // eu.etaxonomy.taxeditor.model;
76 // see also ConceptContentProvider
77 for (TaxonRelationship relationship
: taxon
.getTaxonRelations()) {
79 if (!relationship
.getType().equals(TaxonRelationshipType
.MISAPPLIED_NAME_FOR())
80 && !relationship
.getType().equals(TaxonRelationshipType
.INVALID_DESIGNATION_FOR())
81 && !relationship
.getType().equals(TaxonRelationshipType
.TAXONOMICALLY_INCLUDED_IN())) {
83 if(!relationship
.getToTaxon().equals(taxon
)){
87 String key
= relationship
.getFromTaxon().getUuid().toString() + relationship
.getType().getUuid();
88 if(!filteredTaxonRelations
.containsKey(key
)) {
89 filteredTaxonRelations
.put(key
, relationship
);
90 Taxon toTaxon
= relationship
.getToTaxon();
92 getTaxonRelationshipsRecursive(filteredTaxonRelations
, toTaxon
);