3 * Copyright (C) 2018 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.
10 package eu
.etaxonomy
.taxeditor
.editor
.workingSet
.matrix
;
12 import java
.util
.Comparator
;
13 import java
.util
.List
;
15 import ca
.odell
.glazedlists
.TreeList
;
16 import eu
.etaxonomy
.cdm
.model
.description
.WorkingSet
;
17 import eu
.etaxonomy
.cdm
.model
.name
.Rank
;
18 import eu
.etaxonomy
.cdm
.model
.taxon
.Classification
;
19 import eu
.etaxonomy
.cdm
.model
.taxon
.TaxonNode
;
22 * The tree format defines how to build the hierarchy path for the
23 * taxon column in the character matrix
29 public class DescriptionTreeFormat
implements TreeList
.Format
<Object
> {
33 public DescriptionTreeFormat(WorkingSet workingSet
) {
34 this.maxRank
= workingSet
.getMaxRank();
38 public void getPath(List path
, Object element
) {
39 if(element
instanceof RowWrapper
){
40 //TODO: check for multiple taxon nodes in multiple classifications
41 TaxonNode taxonNode
= ((RowWrapper
) element
).getTaxonNode();
42 addPathRecursive(path
, taxonNode
);
47 private void addPathRecursive(List path
, TaxonNode node
){
48 if(node
.getParent()!=null
49 && node
.getTaxon()!=null
50 && node
.getTaxon().getName()!=null
51 && node
.getTaxon().getName().getRank()!=null){
52 Rank rank
= node
.getTaxon().getName().getRank();
53 if(maxRank
==null || maxRank
.equals(rank
)){
57 addPathRecursive(path
, node
.getParent());
63 public boolean allowsChildren(Object element
) {
64 if(element
instanceof TaxonNode
){
71 public Comparator
<Object
> getComparator(int depth
) {
72 return new MatrixRowComparator();