Project

General

Profile

Download (1.51 KB) Statistics
| Branch: | Tag: | Revision:
1
/**
2
* Copyright (C) 2007 EDIT
3
* European Distributed Institute of Taxonomy
4
* http://www.e-taxonomy.eu
5
*
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.
8
*/
9
package eu.etaxonomy.taxeditor.editor.view.concept;
10

    
11
import java.util.HashMap;
12
import java.util.Map;
13

    
14
import org.eclipse.jface.viewers.IStructuredContentProvider;
15
import org.eclipse.jface.viewers.Viewer;
16

    
17
import eu.etaxonomy.cdm.model.taxon.Taxon;
18
import eu.etaxonomy.cdm.model.taxon.TaxonRelationship;
19
import eu.etaxonomy.cdm.model.taxon.TaxonRelationshipType;
20

    
21
/**
22
 * @author n.hoffmann
23
 * @created Jan 24, 2011
24
 */
25
public class ConceptContentProvider implements IStructuredContentProvider {
26

    
27
	@Override
28
	public void dispose() {
29

    
30
	}
31

    
32
	@Override
33
	public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
34
	}
35

    
36
	@Override
37
	public Object[] getElements(Object inputElement) {
38
		Taxon taxon = null;
39
		if(inputElement instanceof Taxon){
40
			taxon = (Taxon) inputElement;
41
		}
42
		if(taxon!=null){
43
			Map<TaxonRelationship, Taxon> taxonToTaxonRelationsMap = new HashMap<>();
44

    
45
			for (TaxonRelationship relationship : taxon.getTaxonRelations()) {
46
				if (! relationship.getType().equals(TaxonRelationshipType.MISAPPLIED_NAME_FOR()) ||
47
						 relationship.getType().equals(TaxonRelationshipType.TAXONOMICALLY_INCLUDED_IN())) {
48
					taxonToTaxonRelationsMap.put(relationship, taxon);
49
				}
50
			}
51
			return taxonToTaxonRelationsMap.entrySet().toArray();
52
		}
53
		return new Object[0];
54
	}
55
}
(1-1/2)