3 * Copyright (C) 2007 EDIT
4 * European Distributed Institute of Taxonomy
5 * http://www.e-taxonomy.eu
7 * The contents of this file are subject to the Mozilla Public License Version 1.1
8 * See LICENSE.TXT at the top of this package for the full license terms.
11 package eu
.etaxonomy
.taxeditor
.editor
.view
.concept
;
13 import java
.util
.HashMap
;
16 import org
.eclipse
.jface
.viewers
.IStructuredContentProvider
;
17 import org
.eclipse
.jface
.viewers
.Viewer
;
19 import eu
.etaxonomy
.cdm
.model
.taxon
.Taxon
;
20 import eu
.etaxonomy
.cdm
.model
.taxon
.TaxonRelationship
;
21 import eu
.etaxonomy
.cdm
.model
.taxon
.TaxonRelationshipType
;
22 import eu
.etaxonomy
.taxeditor
.editor
.TaxonEditorInput
;
26 * @created Jan 24, 2011
29 public class ConceptContentProvider
implements IStructuredContentProvider
{
32 public void dispose() {
37 public void inputChanged(Viewer viewer
, Object oldInput
, Object newInput
) {
41 public Object
[] getElements(Object inputElement
) {
43 if(inputElement
instanceof TaxonEditorInput
){
44 taxon
= ((TaxonEditorInput
) inputElement
).getTaxon();
46 else if(inputElement
instanceof Taxon
){
47 taxon
= (Taxon
) inputElement
;
50 Map
<TaxonRelationship
, Taxon
> taxonToTaxonRelationsMap
= new HashMap
<>();
52 for (TaxonRelationship relationship
: taxon
.getTaxonRelations()) {
53 if (! relationship
.getType().equals(TaxonRelationshipType
.MISAPPLIED_NAME_FOR()) ||
54 relationship
.getType().equals(TaxonRelationshipType
.TAXONOMICALLY_INCLUDED_IN())) {
55 taxonToTaxonRelationsMap
.put(relationship
, taxon
);
58 return taxonToTaxonRelationsMap
.entrySet().toArray();