2 * Copyright (C) 2007 EDIT
3 * European Distributed Institute of Taxonomy
4 * http://www.e-taxonomy.eu
6 * The contents of this file are subject to the Mozilla Public License Version 1.1
7 * See LICENSE.TXT at the top of this package for the full license terms.
10 package eu
.etaxonomy
.taxeditor
.editor
.view
.concept
;
12 import java
.util
.HashMap
;
15 import org
.eclipse
.jface
.viewers
.IStructuredContentProvider
;
16 import org
.eclipse
.jface
.viewers
.Viewer
;
18 import eu
.etaxonomy
.cdm
.model
.taxon
.Taxon
;
19 import eu
.etaxonomy
.cdm
.model
.taxon
.TaxonRelationship
;
20 import eu
.etaxonomy
.cdm
.model
.taxon
.TaxonRelationshipType
;
21 import eu
.etaxonomy
.taxeditor
.editor
.TaxonEditorInput
;
25 * @created Jan 24, 2011
28 public class ConceptContentProvider
implements IStructuredContentProvider
{
31 public void dispose() {
36 public void inputChanged(Viewer viewer
, Object oldInput
, Object newInput
) {
40 public Object
[] getElements(Object inputElement
) {
42 if(inputElement
instanceof TaxonEditorInput
){
43 taxon
= ((TaxonEditorInput
) inputElement
).getTaxon();
45 else if(inputElement
instanceof Taxon
){
46 taxon
= (Taxon
) inputElement
;
49 Map
<TaxonRelationship
, Taxon
> taxonToTaxonRelationsMap
= new HashMap
<>();
51 for (TaxonRelationship relationship
: taxon
.getTaxonRelations()) {
52 if (! relationship
.getType().equals(TaxonRelationshipType
.MISAPPLIED_NAME_FOR()) ||
53 relationship
.getType().equals(TaxonRelationshipType
.TAXONOMICALLY_INCLUDED_IN())) {
54 taxonToTaxonRelationsMap
.put(relationship
, taxon
);
57 return taxonToTaxonRelationsMap
.entrySet().toArray();