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
|
|
10
|
package eu.etaxonomy.taxeditor.editor.view.concept;
|
11
|
|
12
|
import java.util.HashMap;
|
13
|
import java.util.Map;
|
14
|
|
15
|
import org.eclipse.jface.viewers.IStructuredContentProvider;
|
16
|
import org.eclipse.jface.viewers.Viewer;
|
17
|
|
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;
|
22
|
|
23
|
/**
|
24
|
* @author n.hoffmann
|
25
|
* @created Jan 24, 2011
|
26
|
* @version 1.0
|
27
|
*/
|
28
|
public class ConceptContentProvider implements IStructuredContentProvider {
|
29
|
|
30
|
@Override
|
31
|
public void dispose() {
|
32
|
|
33
|
}
|
34
|
|
35
|
@Override
|
36
|
public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
|
37
|
}
|
38
|
|
39
|
@Override
|
40
|
public Object[] getElements(Object inputElement) {
|
41
|
Taxon taxon = null;
|
42
|
if(inputElement instanceof TaxonEditorInput){
|
43
|
taxon = ((TaxonEditorInput) inputElement).getTaxon();
|
44
|
}
|
45
|
else if(inputElement instanceof Taxon){
|
46
|
taxon = (Taxon) inputElement;
|
47
|
}
|
48
|
if(taxon!=null){
|
49
|
Map<TaxonRelationship, Taxon> taxonToTaxonRelationsMap = new HashMap<>();
|
50
|
|
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);
|
55
|
}
|
56
|
}
|
57
|
return taxonToTaxonRelationsMap.entrySet().toArray();
|
58
|
}
|
59
|
return new Object[0];
|
60
|
}
|
61
|
|
62
|
}
|