Project

General

Profile

Revision 368703af

ID368703afa28e4175eb754f39f5a0f04a441fa7a6
Parent 43d417f5
Child e28f6b05

Added by Patrick Plitzner almost 4 years ago

ref #7095 sort tree hierarchy via taxon names

View differences:

eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/workingSet/matrix/CharacterMatrix.java
95 95
import org.eclipse.nebula.widgets.nattable.tree.ITreeRowModel;
96 96
import org.eclipse.nebula.widgets.nattable.tree.TreeLayer;
97 97
import org.eclipse.nebula.widgets.nattable.ui.menu.AbstractHeaderMenuConfiguration;
98
import org.eclipse.nebula.widgets.nattable.ui.menu.DebugMenuConfiguration;
99 98
import org.eclipse.nebula.widgets.nattable.ui.menu.PopupMenuBuilder;
100 99
import org.eclipse.nebula.widgets.nattable.viewport.ViewportLayer;
101 100
import org.eclipse.swt.SWT;
......
114 113
import eu.etaxonomy.cdm.api.conversation.ConversationHolder;
115 114
import eu.etaxonomy.cdm.api.conversation.IConversationEnabled;
116 115
import eu.etaxonomy.cdm.api.service.IWorkingSetService;
117
import eu.etaxonomy.cdm.hibernate.HibernateProxyHelper;
118 116
import eu.etaxonomy.cdm.model.common.TermVocabulary;
119 117
import eu.etaxonomy.cdm.model.description.DescriptionBase;
120 118
import eu.etaxonomy.cdm.model.description.DescriptionElementBase;
......
912 910
    * Using a String directly as the tree item has the possible disadvantage of
913 911
    * haven non-unique items in the tree within subtrees.
914 912
    */
915
    private class DescriptionTreeFormat implements TreeList.Format<RowWrapper> {
913
    private class DescriptionTreeFormat implements TreeList.Format<Object> {
916 914

  
917 915
        private Map parentMapping = new HashMap<>();
918 916

  
......
926 924
         * for the path.
927 925
         */
928 926
        @Override
929
        public void getPath(List path, RowWrapper element) {
930
            //TODO: check for multiple taxon nodes in multiple classifications
931
            Taxon taxon = (Taxon) element.getAssociatedTaxa().iterator().next();
932
            Set<TaxonNode> taxonNodes = taxon.getTaxonNodes();
933
            if(taxonNodes!=null){
934
                TaxonNode node = taxonNodes.iterator().next();
935
                TaxonNode parent = HibernateProxyHelper.deproxy(node.getParent(), TaxonNode.class);
936
                while(parent!=null){
937
                    path.add(parent);
938
                    parent = HibernateProxyHelper.deproxy(parent.getParent(), TaxonNode.class);
927
        public void getPath(List path, Object element) {
928
            if(element instanceof RowWrapper){
929
                //TODO: check for multiple taxon nodes in multiple classifications
930
                Taxon taxon = (Taxon) ((RowWrapper) element).getAssociatedTaxa().iterator().next();
931
                Set<TaxonNode> taxonNodes = taxon.getTaxonNodes();
932
                if(taxonNodes!=null){
933
                    TaxonNode node = taxonNodes.iterator().next();
934
                    addPathRecursive(path, node);
935
//                    Object rowWrapperParentNode = parentMapping.get(node);
936
//                    if(rowWrapperParentNode!=null){
937
//                        path.add(rowWrapperParentNode);
938
//                    }
939
//                    else{
940
//                        TaxonNode parentNode = HibernateProxyHelper.deproxy(node.getParent(), TaxonNode.class);
941
//                        while(parentNode!=null){
942
//                            path.add(parentNode);
943
//                            parentMapping.put(node, parentNode);
944
//                            if(parentNode instanceof TaxonNode){
945
//                                if(parentMapping.get(parentNode)!=null){
946
//                                    path.add(parentMapping).get(parentNode);
947
//                                }
948
//                                else{
949
//                                    parentNode = HibernateProxyHelper.deproxy(parentNode.getParent(), TaxonNode.class);
950
//                                }
951
//                            }
952
//                        }
953
//                    }
939 954
                }
940 955
            }
941 956
            path.add(element);
942 957
        }
943 958

  
959
        private void addPathRecursive(List path, TaxonNode node){
960
            if(node.getParent()!=null){
961
                addPathRecursive(path, node.getParent());
962
                path.add(node);
963
            }
964
        }
965

  
944 966
        /**
945 967
         * Simply always return true.
946 968
         *
......
948 970
         *         false if it is always a leaf node.
949 971
         */
950 972
        @Override
951
        public boolean allowsChildren(RowWrapper element) {
973
        public boolean allowsChildren(Object element) {
952 974
            return true;
953 975
        }
954 976

  
......
960 982
         * alphabetical order.
961 983
         */
962 984
        @Override
963
        public Comparator<RowWrapper> getComparator(int depth) {
964
            return new Comparator<RowWrapper>() {
985
        public Comparator<Object> getComparator(int depth) {
986
            return new Comparator<Object>() {
965 987

  
966 988
                @Override
967
                public int compare(RowWrapper o1, RowWrapper o2) {
968
                    return o1.getSpecimenDescription().getId()-(o2.getSpecimenDescription().getId());
989
                public int compare(Object o1, Object o2) {
990
//                    if(o1 instanceof RowWrapper && o2 instanceof RowWrapper){
991
//                        return ((RowWrapper) o1).getSpecimenDescription().getId()-(((RowWrapper) o2).getSpecimenDescription().getId());
992
//                    }
993
//                    else
994
                        if(o1 instanceof TaxonNode && o2 instanceof TaxonNode){
995
                        return ((TaxonNode) o1).getTaxon().getName().getNameCache().compareTo(((TaxonNode) o2).getTaxon().getName().getNameCache());
996
                    }
997
                    return 0;
969 998
                }
970 999

  
971 1000
            };
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/workingSet/matrix/supplementalInfo/SupplementalInfoDisplayConverter.java
17 17
import eu.etaxonomy.cdm.model.occurrence.FieldUnit;
18 18
import eu.etaxonomy.cdm.model.occurrence.GatheringEvent;
19 19
import eu.etaxonomy.cdm.model.taxon.TaxonBase;
20
import eu.etaxonomy.cdm.model.taxon.TaxonNode;
20 21

  
21 22
/**
22 23
 * @author pplitzner
......
31 32
    @Override
32 33
    public Object canonicalToDisplayValue(Object canonicalValue) {
33 34
        String displayValue = "";
34
        if(canonicalValue instanceof FieldUnit){
35
        if(canonicalValue instanceof TaxonNode){
36
            TaxonNode node = (TaxonNode)canonicalValue;
37
            displayValue = node.getTaxon().getName().getNameCache();
38
        }
39
        else if(canonicalValue instanceof FieldUnit){
35 40
            FieldUnit fieldUnit = (FieldUnit)canonicalValue;
36 41
            GatheringEvent gatheringEvent = fieldUnit.getGatheringEvent();
37 42
            if(gatheringEvent!=null){

Also available in: Unified diff

Add picture from clipboard (Maximum size: 40 MB)