3 * Copyright (C) 2007 EDIT
4 * European Distributed Institute of Taxonomy
5 * http://www.e-taxonomy.eu
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.
11 package eu
.etaxonomy
.taxeditor
.navigation
.navigator
;
13 import java
.util
.ArrayList
;
14 import java
.util
.List
;
16 import org
.apache
.log4j
.Logger
;
17 import org
.eclipse
.jface
.viewers
.ITreeContentProvider
;
18 import org
.eclipse
.jface
.viewers
.Viewer
;
20 import eu
.etaxonomy
.cdm
.model
.taxon
.Synonym
;
21 import eu
.etaxonomy
.cdm
.model
.taxon
.Taxon
;
22 import eu
.etaxonomy
.cdm
.model
.taxon
.TaxonBase
;
23 import eu
.etaxonomy
.cdm
.model
.taxon
.TaxonNode
;
24 import eu
.etaxonomy
.taxeditor
.editor
.name
.IterableSynonymyList
;
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];
37 public Object
[] getChildren(Object parentElement
) {
38 Object
[] children
= null;
39 if (parentElement
instanceof Synonym
) {
40 children
= NO_CHILDREN
;
41 } else if (parentElement
instanceof TaxonNode
) {
42 List
<TaxonBase
> list
= new ArrayList
<TaxonBase
>();
44 Taxon taxon
= ((TaxonNode
) parentElement
).getTaxon();
46 for (TaxonBase taxonBase
: new IterableSynonymyList(taxon
)) {
47 if (taxonBase
instanceof Synonym
) {
51 children
= list
.toArray();
53 return children
!= null ? children
: NO_CHILDREN
;
56 public Object
getParent(Object element
) {
60 public boolean hasChildren(Object element
) {
61 return this.getChildren(element
).length
> 0;
64 public Object
[] getElements(Object inputElement
) {
65 return this.getChildren(inputElement
);
68 public void dispose() {
71 public void inputChanged(Viewer viewer
, Object oldInput
, Object newInput
) {