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.navigation.navigator;
|
11
|
|
12
|
import java.util.ArrayList;
|
13
|
import java.util.List;
|
14
|
|
15
|
import org.apache.log4j.Logger;
|
16
|
import org.eclipse.jface.viewers.ITreeContentProvider;
|
17
|
import org.eclipse.jface.viewers.Viewer;
|
18
|
|
19
|
import eu.etaxonomy.cdm.model.common.ITreeNode;
|
20
|
import eu.etaxonomy.cdm.model.taxon.Classification;
|
21
|
import eu.etaxonomy.cdm.model.taxon.ITaxonTreeNode;
|
22
|
|
23
|
/**
|
24
|
* <p>ClassificationContentProvider class.</p>
|
25
|
*
|
26
|
* @author n.hoffmann
|
27
|
* @created 17.06.2009
|
28
|
* @version 1.0
|
29
|
*/
|
30
|
public class ClassificationContentProvider implements ITreeContentProvider {
|
31
|
private static final Logger logger = Logger
|
32
|
.getLogger(ClassificationContentProvider.class);
|
33
|
|
34
|
/* (non-Javadoc)
|
35
|
* @see org.eclipse.jface.viewers.ITreeContentProvider#getChildren(java.lang.Object)
|
36
|
*/
|
37
|
/** {@inheritDoc} */
|
38
|
public Object[] getChildren(Object parentElement) {
|
39
|
if (parentElement instanceof Root) {
|
40
|
return ((Root) parentElement).getParentBeans().toArray();
|
41
|
}else if(parentElement instanceof Classification){
|
42
|
return ((Classification) parentElement).getChildNodes().toArray();
|
43
|
}
|
44
|
|
45
|
|
46
|
return new Object[0];
|
47
|
}
|
48
|
|
49
|
/* (non-Javadoc)
|
50
|
* @see org.eclipse.jface.viewers.ITreeContentProvider#getParent(java.lang.Object)
|
51
|
*/
|
52
|
/** {@inheritDoc} */
|
53
|
public Object getParent(Object element) {
|
54
|
return null;
|
55
|
}
|
56
|
|
57
|
/* (non-Javadoc)
|
58
|
* @see org.eclipse.jface.viewers.ITreeContentProvider#hasChildren(java.lang.Object)
|
59
|
*/
|
60
|
/** {@inheritDoc} */
|
61
|
public boolean hasChildren(Object element) {
|
62
|
return this.getChildren(element).length > 0;
|
63
|
}
|
64
|
|
65
|
/* (non-Javadoc)
|
66
|
* @see org.eclipse.jface.viewers.IStructuredContentProvider#getElements(java.lang.Object)
|
67
|
*/
|
68
|
/** {@inheritDoc} */
|
69
|
public Object[] getElements(Object inputElement) {
|
70
|
return this.getChildren(inputElement);
|
71
|
}
|
72
|
|
73
|
/* (non-Javadoc)
|
74
|
* @see org.eclipse.jface.viewers.IContentProvider#dispose()
|
75
|
*/
|
76
|
/**
|
77
|
* <p>dispose</p>
|
78
|
*/
|
79
|
public void dispose() {
|
80
|
}
|
81
|
|
82
|
/* (non-Javadoc)
|
83
|
* @see org.eclipse.jface.viewers.IContentProvider#inputChanged(org.eclipse.jface.viewers.Viewer, java.lang.Object, java.lang.Object)
|
84
|
*/
|
85
|
/** {@inheritDoc} */
|
86
|
public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
|
87
|
}
|
88
|
}
|