Project

General

Profile

Download (2.43 KB) Statistics
| Branch: | Tag: | Revision:
1
/**
2
* Copyright (C) 2017 EDIT
3
* European Distributed Institute of Taxonomy
4
* http://www.e-taxonomy.eu
5
*
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.
8
*/
9
package eu.etaxonomy.taxeditor.editor.workingSet.matrix;
10

    
11
import org.eclipse.nebula.widgets.nattable.data.IColumnPropertyAccessor;
12

    
13
import eu.etaxonomy.cdm.model.description.Feature;
14

    
15
/**
16
 * @author pplitzner
17
 * @since Nov 26, 2017
18
 *
19
 */
20
public class SpecimenColumnPropertyAccessor implements IColumnPropertyAccessor<Object>{
21

    
22
    private CharacterMatrix matrix;
23

    
24
    public SpecimenColumnPropertyAccessor(CharacterMatrix matrix) {
25
        this.matrix = matrix;
26
    }
27

    
28

    
29
    /**
30
     * {@inheritDoc}
31
     */
32
    @Override
33
    public Object getDataValue(Object rowObject, int columnIndex) {
34
        if(rowObject instanceof RowWrapper){
35
            RowWrapper rowWrapper = (RowWrapper)rowObject;
36
            switch (columnIndex) {
37
            case 0:
38
                return rowWrapper.getAssociatedTaxon();
39
            case 1:
40
                return rowWrapper.getFieldUnit();
41
            case 2:
42
                return rowWrapper.getIdentifier();
43
            case 3:
44
                return rowWrapper.getCountry();
45

    
46
            default:
47
                break;
48
            }
49
            Feature feature = matrix.getIndexToFeatureMap().get(columnIndex);
50
            return rowWrapper.getDataValueForFeature(feature);
51
        } else if (columnIndex == 0) {
52
            return rowObject;
53
        }
54
        return null;
55
    }
56

    
57
    /**
58
     * {@inheritDoc}
59
     */
60
    @Override
61
    public void setDataValue(Object rowObject, int columnIndex, Object newValue) {
62
        if(rowObject instanceof RowWrapper){
63
            RowWrapper rowWrapper = (RowWrapper)rowObject;
64
            Feature feature = matrix.getIndexToFeatureMap().get(columnIndex);
65
            rowWrapper.setDataValueForFeature(feature, newValue);
66
        }
67
    }
68

    
69
    /**
70
     * {@inheritDoc}
71
     */
72
    @Override
73
    public int getColumnCount() {
74
        return matrix.getPropertyToLabelMap().size();
75
    }
76

    
77
    /**
78
     * {@inheritDoc}
79
     */
80
    @Override
81
    public String getColumnProperty(int columnIndex) {
82
        return matrix.getPropertyToLabelMap().get(columnIndex);
83
    }
84

    
85
    /**
86
     * {@inheritDoc}
87
     */
88
    @Override
89
    public int getColumnIndex(String propertyName){
90
        return matrix.getPropertyToLabelMap().indexOf(propertyName);
91
    }
92

    
93
}
(9-9/11)