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
.ArrayList
;
13 import java
.util
.List
;
15 import org
.apache
.log4j
.Logger
;
16 import org
.eclipse
.jface
.viewers
.ITreeContentProvider
;
17 import org
.eclipse
.jface
.viewers
.Viewer
;
19 import eu
.etaxonomy
.cdm
.model
.taxon
.Synonym
;
20 import eu
.etaxonomy
.cdm
.model
.taxon
.Taxon
;
21 import eu
.etaxonomy
.cdm
.model
.taxon
.TaxonBase
;
22 import eu
.etaxonomy
.cdm
.model
.taxon
.TaxonNode
;
25 * <p>SynonymContentProvider class.</p>
31 public class SynonymContentProvider
implements ITreeContentProvider
{
32 private static final Logger logger
= Logger
33 .getLogger(SynonymContentProvider
.class);
35 private static final Object
[] NO_CHILDREN
= new Object
[0];
38 public Object
[] getChildren(Object parentElement
) {
39 Object
[] children
= null;
40 if (parentElement
instanceof Synonym
) {
41 children
= NO_CHILDREN
;
42 } else if (parentElement
instanceof TaxonNode
) {
43 List
<TaxonBase
> list
= new ArrayList
<TaxonBase
>();
45 Taxon taxon
= ((TaxonNode
) parentElement
).getTaxon();
47 for (TaxonBase taxonBase
: new IterableSynonymyList(taxon
)) {
48 if (taxonBase
instanceof Synonym
) {
52 children
= list
.toArray();
54 return children
!= null ? children
: NO_CHILDREN
;
58 public Object
getParent(Object element
) {
63 public boolean hasChildren(Object element
) {
64 return this.getChildren(element
).length
> 0;
68 public Object
[] getElements(Object inputElement
) {
69 return this.getChildren(inputElement
);
75 public void dispose() {
79 public void inputChanged(Viewer viewer
, Object oldInput
, Object newInput
) {