Project

General

Profile

Download (1.97 KB) Statistics
| Branch: | Tag: | Revision:
1
/**
2
* Copyright (C) 2018 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.bulkeditor.e4;
10

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

    
13
import eu.etaxonomy.cdm.model.common.CdmBase;
14
import eu.etaxonomy.taxeditor.bulkeditor.input.AbstractBulkEditorInput;
15

    
16
/**
17
 * @author pplitzner
18
 * @since May 29, 2018
19
 *
20
 */
21
public class BulkEditorPropertyAccessor implements IColumnPropertyAccessor<CdmBase> {
22

    
23
        private AbstractBulkEditorInput input;
24

    
25

    
26
        public BulkEditorPropertyAccessor(AbstractBulkEditorInput<CdmBase> input) {
27
            super();
28
            this.input = input;
29
        }
30

    
31
        @Override
32
        public Object getDataValue(CdmBase rowObject, int columnIndex) {
33
            if(columnIndex==0){
34
                return input.getText(rowObject);
35
            }else if(columnIndex==1){
36
                return input.getTypeText(rowObject);
37
            }
38
            return null;
39
        }
40

    
41
        @Override
42
        public void setDataValue(CdmBase rowObject, int columnIndex, Object newValue) {
43
            //no editing allowed
44
        }
45

    
46
        @Override
47
        public int getColumnCount() {
48
            return 2;
49
        }
50

    
51
        @Override
52
        public String getColumnProperty(int columnIndex) {
53
            if(columnIndex==0){
54
                return input.getName();
55
            }else if(columnIndex==1){
56
                return BulkEditorE4Composite.TYPE_PROPERTY;
57
            }
58
            return null;
59
        }
60

    
61
        @Override
62
        public int getColumnIndex(String propertyName) {
63
            if(propertyName.equals(input.getName())){
64
                return 0;
65
            }
66
            else if(propertyName.equals(BulkEditorE4Composite.TYPE_PROPERTY)){
67
                return 1;
68
            }
69
            return 0;
70
        }
71
    }
(5-5/7)