Project

General

Profile

Revision 1245cdd8

ID1245cdd8eeb5fd795770e4fef35050b211dad0f7
Parent 7029881a
Child de5b7791

Added by Patrick Plitzner over 2 years ago

ref #7095 Change taxon column cell text depending on tree/list view

View differences:

eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/workingSet/matrix/CharacterMatrix.java
201 201

  
202 202
    private DefaultBodyLayerStack bodyLayer;
203 203

  
204
    private boolean isTreeView = true;
205

  
204 206

  
205 207
    public CharacterMatrix(Composite parent, CharacterMatrixPart part) {
206 208
        super(parent, SWT.NONE);
......
475 477
    }
476 478

  
477 479
    private void toggleTreeFlat(boolean isTree, Button btnToggleFlat, Button btnToggleTree, Button btnCollapseAll, Button btnExpandAll, Button btnFreezeSuppInfo) {
480
        isTreeView = isTree;
478 481
        createLayers(isTree);
479 482
        btnToggleFlat.setEnabled(isTree);
480 483
        btnToggleTree.setEnabled(!isTree);
......
485 488
        freezeSupplementalColumns(btnFreezeSuppInfo.getSelection());
486 489
    }
487 490

  
491
    public boolean isTreeView() {
492
        return isTreeView;
493
    }
494

  
488 495
    public void createTable(boolean treeView){
489 496
        /**
490 497
         * layers
......
759 766
                //add display converter for string representation
760 767
                configRegistry.registerConfigAttribute(
761 768
                        CellConfigAttributes.DISPLAY_CONVERTER,
762
                        new SupplementalInfoDisplayConverter(),
769
                        new SupplementalInfoDisplayConverter(CharacterMatrix.this),
763 770
                        DisplayMode.NORMAL,
764 771
                        TAXON_COLUMN);
765 772
                configRegistry.registerConfigAttribute(
......
769 776
                        TAXON_COLUMN);
770 777
                configRegistry.registerConfigAttribute(
771 778
                        CellConfigAttributes.DISPLAY_CONVERTER,
772
                        new SupplementalInfoDisplayConverter(),
779
                        new SupplementalInfoDisplayConverter(CharacterMatrix.this),
773 780
                        DisplayMode.NORMAL,
774 781
                        COLLECTOR_COLUMN);
775 782
                configRegistry.registerConfigAttribute(
......
779 786
                        COLLECTOR_COLUMN);
780 787
                configRegistry.registerConfigAttribute(
781 788
                        CellConfigAttributes.DISPLAY_CONVERTER,
782
                        new SupplementalInfoDisplayConverter(),
789
                        new SupplementalInfoDisplayConverter(CharacterMatrix.this),
783 790
                        DisplayMode.NORMAL,
784 791
                        IDENTIFIER_COLUMN);
785 792
                configRegistry.registerConfigAttribute(
......
789 796
                        IDENTIFIER_COLUMN);
790 797
                configRegistry.registerConfigAttribute(
791 798
                        CellConfigAttributes.DISPLAY_CONVERTER,
792
                        new SupplementalInfoDisplayConverter(),
799
                        new SupplementalInfoDisplayConverter(CharacterMatrix.this),
793 800
                        DisplayMode.NORMAL,
794 801
                        COUNTRY_COLUMN);
795 802
                configRegistry.registerConfigAttribute(
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/workingSet/matrix/RowWrapper.java
58 58
        if(specimen!=null){
59 59
            Collection<TaxonBase<?>> associatedTaxa = occurrenceService.listAssociatedTaxa(specimen, null, null, null, null);
60 60
            if(associatedTaxa!=null){
61
                //FIXME: what about multiple associated taxa
61 62
                associatedTaxon = (Taxon) associatedTaxa.iterator().next();
62 63
            }
63 64
            Collection<FieldUnit> fieldUnits = occurrenceService.getFieldUnits(specimen.getUuid());
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/workingSet/matrix/supplementalInfo/SupplementalInfoDisplayConverter.java
8 8
*/
9 9
package eu.etaxonomy.taxeditor.editor.workingSet.matrix.supplementalInfo;
10 10

  
11
import java.util.Collection;
12

  
13 11
import org.eclipse.nebula.widgets.nattable.data.convert.DisplayConverter;
14 12

  
15 13
import eu.etaxonomy.cdm.hibernate.HibernateProxyHelper;
......
17 15
import eu.etaxonomy.cdm.model.location.NamedArea;
18 16
import eu.etaxonomy.cdm.model.occurrence.FieldUnit;
19 17
import eu.etaxonomy.cdm.model.occurrence.GatheringEvent;
20
import eu.etaxonomy.cdm.model.taxon.TaxonBase;
18
import eu.etaxonomy.cdm.model.taxon.Taxon;
21 19
import eu.etaxonomy.cdm.model.taxon.TaxonNode;
20
import eu.etaxonomy.taxeditor.editor.workingSet.matrix.CharacterMatrix;
22 21

  
23 22
/**
24 23
 * Converts the supplemental information (taxon and specimen data)
......
30 29
 */
31 30
public class SupplementalInfoDisplayConverter extends DisplayConverter{
32 31

  
32
    private CharacterMatrix matrix;
33

  
34
    public SupplementalInfoDisplayConverter(CharacterMatrix matrix) {
35
        this.matrix= matrix;
36
    }
37

  
33 38
    /**
34 39
     * {@inheritDoc}
35 40
     */
......
38 43
        String displayValue = "";
39 44
        if(canonicalValue instanceof TaxonNode){
40 45
            TaxonNode node = (TaxonNode)canonicalValue;
41
            displayValue = node.getTaxon().getName().getNameCache();
46
            displayValue = node.getTaxon().getName().getTitleCache();
47
        }
48
        else if(canonicalValue instanceof Taxon){
49
            if(matrix.isTreeView()){
50
                return "---";
51
            }
52
            else {
53
                Taxon taxon = (Taxon)canonicalValue;
54
                displayValue = taxon.getName().getTitleCache();
55
            }
42 56
        }
43 57
        else if(HibernateProxyHelper.isInstanceOf(canonicalValue, FieldUnit.class)){
44 58
            FieldUnit fieldUnit = HibernateProxyHelper.deproxy(canonicalValue, FieldUnit.class);
......
57 71
        else if(HibernateProxyHelper.isInstanceOf(canonicalValue, NamedArea.class)){
58 72
            displayValue = HibernateProxyHelper.deproxy(canonicalValue, NamedArea.class).getLabel();
59 73
        }
60
        else if(canonicalValue instanceof Collection){
61
            String separator = ", ";
62
            for(Object object:((Collection<?>) canonicalValue)){
63
                if(object instanceof TaxonBase && ((TaxonBase) object).getName()!=null){
64
                    displayValue += ((TaxonBase) object).getName()+separator;
65
                }
66
            }
67
            displayValue = displayValue.substring(0, displayValue.length()-separator.length());
68
        }
69 74

  
70 75
        if(displayValue.isEmpty() && canonicalValue!=null){
71 76
            return canonicalValue.toString();

Also available in: Unified diff

Add picture from clipboard (Maximum size: 40 MB)