2 * Copyright (C) 2007 EDIT
3 * European Distributed Institute of Taxonomy
4 * http://www.e-taxonomy.eu
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.
10 package eu
.etaxonomy
.taxeditor
.navigation
.navigator
;
12 import java
.util
.List
;
14 import org
.apache
.log4j
.Logger
;
15 import org
.eclipse
.jface
.viewers
.ITreeContentProvider
;
16 import org
.eclipse
.jface
.viewers
.Viewer
;
18 import eu
.etaxonomy
.cdm
.hibernate
.HHH_9751_Util
;
19 import eu
.etaxonomy
.cdm
.hibernate
.HibernateProxyHelper
;
20 import eu
.etaxonomy
.cdm
.model
.taxon
.ITaxonTreeNode
;
21 import eu
.etaxonomy
.cdm
.model
.taxon
.TaxonNode
;
24 * <p>TaxonNodeContentProvider class.</p>
30 public class TaxonNodeContentProvider
implements ITreeContentProvider
{
31 private static final Logger logger
= Logger
32 .getLogger(TaxonNodeContentProvider
.class);
34 private static final Object
[] NO_CHILDREN
= new Object
[0];
38 public Object
[] getChildren(Object parentElement
) {
39 Object
[] children
= null;
41 if(parentElement
instanceof ITaxonTreeNode
){
42 ITaxonTreeNode treeNode
= (ITaxonTreeNode
) HibernateProxyHelper
.deproxy(parentElement
);
43 List
<TaxonNode
> childrenSet
= treeNode
.getChildNodes();
44 HHH_9751_Util
.removeAllNull(childrenSet
);
45 children
= childrenSet
.toArray();
49 return children
!= null ? children
: NO_CHILDREN
;
54 public Object
getParent(Object element
) {
55 if(element
instanceof TaxonNode
){
56 return ((TaxonNode
) element
).getParent();
63 public boolean hasChildren(Object element
) {
64 if(element
instanceof TaxonNode
){
65 return ((TaxonNode
) element
).getCountChildren() > 0;
67 return getChildren(element
).length
> 0;
72 public Object
[] getElements(Object inputElement
) {
73 return this.getChildren(inputElement
);
80 public void dispose() {
85 public void inputChanged(Viewer viewer
, Object oldInput
, Object newInput
) {