4 package eu
.etaxonomy
.taxeditor
.editor
.view
.concept
.graph
;
7 import java
.util
.HashMap
;
10 import org
.eclipse
.jface
.viewers
.Viewer
;
11 import org
.eclipse
.zest
.core
.viewers
.IGraphContentProvider
;
15 import eu
.etaxonomy
.cdm
.model
.taxon
.Taxon
;
16 import eu
.etaxonomy
.cdm
.model
.taxon
.TaxonRelationship
;
17 import eu
.etaxonomy
.cdm
.model
.taxon
.TaxonRelationshipType
;
18 import eu
.etaxonomy
.taxeditor
.editor
.TaxonEditorInput
;
24 public class ConceptGraphContentProvider
implements IGraphContentProvider
{
27 * @see org.eclipse.jface.viewers.IContentProvider#dispose()
30 public void dispose() {
31 // TODO Auto-generated method stub
36 * @see org.eclipse.jface.viewers.IContentProvider#inputChanged(org.eclipse.jface.viewers.Viewer, java.lang.Object, java.lang.Object)
39 public void inputChanged(Viewer viewer
, Object oldInput
, Object newInput
) {
40 // TODO Auto-generated method stub
45 * @see org.eclipse.zest.core.viewers.IGraphContentProvider#getSource(java.lang.Object)
48 public Object
getSource(Object taxonRelationship
) {
49 return ((TaxonRelationship
)taxonRelationship
).getFromTaxon();
53 * @see org.eclipse.zest.core.viewers.IGraphContentProvider#getDestination(java.lang.Object)
56 public Object
getDestination(Object taxonRelationship
) {
57 return ((TaxonRelationship
)taxonRelationship
).getToTaxon();
61 * @see org.eclipse.zest.core.viewers.IGraphContentProvider#getElements(java.lang.Object)
64 public Object
[] getElements(Object inputElement
) {
65 if(inputElement
instanceof TaxonEditorInput
){
66 Taxon taxon
= ((TaxonEditorInput
) inputElement
).getTaxon();
68 Map
<String
, TaxonRelationship
> filteredTaxonRelations
= new HashMap
<String
, TaxonRelationship
>();
69 getTaxonRelationshipsRecursive(filteredTaxonRelations
, taxon
);
71 return filteredTaxonRelations
.values().toArray();
76 private void getTaxonRelationshipsRecursive(Map
<String
, TaxonRelationship
> filteredTaxonRelations
, Taxon taxon
) {
77 // TODO extract method into new class TaxonHelper in
78 // eu.etaxonomy.taxeditor.model;
79 // see also ConceptContentProvider
80 for (TaxonRelationship relationship
: taxon
.getTaxonRelations()) {
82 if (!relationship
.getType().equals(TaxonRelationshipType
.MISAPPLIED_NAME_FOR())
83 && !relationship
.getType().equals(TaxonRelationshipType
.INVALID_DESIGNATION_FOR())
84 && !relationship
.getType().equals(TaxonRelationshipType
.TAXONOMICALLY_INCLUDED_IN())) {
86 if(!relationship
.getToTaxon().equals(taxon
)){
90 String key
= relationship
.getFromTaxon().getUuid().toString() + relationship
.getType().getUuid();
91 if(!filteredTaxonRelations
.containsKey(key
)) {
92 filteredTaxonRelations
.put(key
, relationship
);
93 Taxon toTaxon
= relationship
.getToTaxon();
95 getTaxonRelationshipsRecursive(filteredTaxonRelations
, toTaxon
);