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.navigation.navigator;
|
12
|
|
13
|
import org.apache.log4j.Logger;
|
14
|
import org.eclipse.jface.viewers.ITreeContentProvider;
|
15
|
import org.eclipse.jface.viewers.Viewer;
|
16
|
|
17
|
import eu.etaxonomy.cdm.api.service.IClassificationService;
|
18
|
import eu.etaxonomy.cdm.api.service.ITaxonNodeService;
|
19
|
import eu.etaxonomy.cdm.model.taxon.Classification;
|
20
|
import eu.etaxonomy.cdm.model.taxon.TaxonNode;
|
21
|
import eu.etaxonomy.taxeditor.store.CdmStore;
|
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
|
Classification classification = (Classification) parentElement;
|
43
|
classification = CdmStore.getService(IClassificationService.class).load(classification.getUuid());
|
44
|
|
45
|
return classification.getChildNodes().toArray();
|
46
|
|
47
|
// classification.getChildNodes();
|
48
|
// List<String> propertyPaths = null;
|
49
|
//
|
50
|
// CdmStore.getService(ITaxonNodeService.class).loadChildNodesOfTaxonNode(taxonNode, propertyPaths);
|
51
|
// return ((Classification) parentElement).getChildNodes().toArray();
|
52
|
}
|
53
|
|
54
|
|
55
|
return new Object[0];
|
56
|
}
|
57
|
|
58
|
/* (non-Javadoc)
|
59
|
* @see org.eclipse.jface.viewers.ITreeContentProvider#getParent(java.lang.Object)
|
60
|
*/
|
61
|
/** {@inheritDoc} */
|
62
|
public Object getParent(Object element) {
|
63
|
return null;
|
64
|
}
|
65
|
|
66
|
/* (non-Javadoc)
|
67
|
* @see org.eclipse.jface.viewers.ITreeContentProvider#hasChildren(java.lang.Object)
|
68
|
*/
|
69
|
/** {@inheritDoc} */
|
70
|
public boolean hasChildren(Object element) {
|
71
|
return this.getChildren(element).length > 0;
|
72
|
}
|
73
|
|
74
|
/* (non-Javadoc)
|
75
|
* @see org.eclipse.jface.viewers.IStructuredContentProvider#getElements(java.lang.Object)
|
76
|
*/
|
77
|
/** {@inheritDoc} */
|
78
|
public Object[] getElements(Object inputElement) {
|
79
|
return this.getChildren(inputElement);
|
80
|
}
|
81
|
|
82
|
/* (non-Javadoc)
|
83
|
* @see org.eclipse.jface.viewers.IContentProvider#dispose()
|
84
|
*/
|
85
|
/**
|
86
|
* <p>dispose</p>
|
87
|
*/
|
88
|
public void dispose() {
|
89
|
}
|
90
|
|
91
|
/* (non-Javadoc)
|
92
|
* @see org.eclipse.jface.viewers.IContentProvider#inputChanged(org.eclipse.jface.viewers.Viewer, java.lang.Object, java.lang.Object)
|
93
|
*/
|
94
|
/** {@inheritDoc} */
|
95
|
public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
|
96
|
}
|
97
|
}
|