1
|
// $Id$
|
2
|
/**
|
3
|
* Copyright (C) 2007 EDIT
|
4
|
* European Distributed Institute of Taxonomy
|
5
|
* http://www.e-taxonomy.eu
|
6
|
*
|
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.
|
9
|
*/
|
10
|
|
11
|
package eu.etaxonomy.taxeditor.editor.view.concept;
|
12
|
|
13
|
import java.util.HashSet;
|
14
|
import java.util.Set;
|
15
|
|
16
|
import org.eclipse.jface.viewers.IStructuredContentProvider;
|
17
|
import org.eclipse.jface.viewers.Viewer;
|
18
|
|
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;
|
23
|
|
24
|
/**
|
25
|
* @author n.hoffmann
|
26
|
* @created Jan 24, 2011
|
27
|
* @version 1.0
|
28
|
*/
|
29
|
public class ConceptContentProvider implements IStructuredContentProvider {
|
30
|
|
31
|
/* (non-Javadoc)
|
32
|
* @see org.eclipse.jface.viewers.IContentProvider#dispose()
|
33
|
*/
|
34
|
@Override
|
35
|
public void dispose() {
|
36
|
// TODO Auto-generated method stub
|
37
|
|
38
|
}
|
39
|
|
40
|
/* (non-Javadoc)
|
41
|
* @see org.eclipse.jface.viewers.IContentProvider#inputChanged(org.eclipse.jface.viewers.Viewer, java.lang.Object, java.lang.Object)
|
42
|
*/
|
43
|
@Override
|
44
|
public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
|
45
|
// TODO Auto-generated method stub
|
46
|
|
47
|
}
|
48
|
|
49
|
/* (non-Javadoc)
|
50
|
* @see org.eclipse.jface.viewers.IStructuredContentProvider#getElements(java.lang.Object)
|
51
|
*/
|
52
|
@Override
|
53
|
public Object[] getElements(Object inputElement) {
|
54
|
if(inputElement instanceof TaxonEditorInput){
|
55
|
Taxon taxon = ((TaxonEditorInput) inputElement).getTaxon();
|
56
|
|
57
|
Set<TaxonRelationship> filteredTaxonRelations = new HashSet<TaxonRelationship>();
|
58
|
|
59
|
for (TaxonRelationship relationship : taxon.getTaxonRelations()) {
|
60
|
if (! relationship.getType().equals(TaxonRelationshipType.MISAPPLIED_NAME_FOR()) ||
|
61
|
relationship.getType().equals(TaxonRelationshipType.TAXONOMICALLY_INCLUDED_IN())) {
|
62
|
filteredTaxonRelations.add(relationship);
|
63
|
}
|
64
|
}
|
65
|
|
66
|
return filteredTaxonRelations.toArray();
|
67
|
}
|
68
|
return new Object[0];
|
69
|
}
|
70
|
|
71
|
}
|