Project

General

Profile

« Previous | Next » 

Revision be252334

Added by Patrick Plitzner over 6 years ago

ref #7095 package restructuring

View differences:

eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/workingSet/matrix/CategoricalDataCellEditor.java
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 java.util.List;
12

  
13
import org.eclipse.nebula.widgets.nattable.edit.editor.IComboBoxDataProvider;
14
import org.eclipse.nebula.widgets.nattable.filterrow.combobox.FilterRowComboBoxCellEditor;
15

  
16
import eu.etaxonomy.cdm.model.description.CategoricalData;
17
import eu.etaxonomy.cdm.model.description.State;
18

  
19
/**
20
 * @author pplitzner
21
 * @since Dec 7, 2017
22
 *
23
 */
24
public class CategoricalDataCellEditor extends FilterRowComboBoxCellEditor{
25

  
26
    public CategoricalDataCellEditor(IComboBoxDataProvider dataProvider, int maxVisibleItems) {
27
        super(dataProvider, maxVisibleItems);
28
    }
29

  
30
    @Override
31
    public void setCanonicalValue(Object canonicalValue) {
32
        if (canonicalValue instanceof CategoricalData) {
33
            CategoricalData data = (CategoricalData)canonicalValue;
34
            List<State> states = data.getStatesOnly();
35
            String[] result = new String[states.size()];
36
            for (int i = 0; i < states.size(); i++) {
37
                result[i] = (String) this.displayConverter.canonicalToDisplayValue(
38
                        this.layerCell, this.configRegistry, states.get(i));
39
            }
40
            setEditorValue(result);
41
        }
42
    }
43

  
44
}
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/workingSet/matrix/CategoricalDataDisplayConverter.java
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.convert.DisplayConverter;
12

  
13
import eu.etaxonomy.cdm.model.description.CategoricalData;
14
import eu.etaxonomy.cdm.model.description.State;
15
import eu.etaxonomy.taxeditor.model.DescriptionHelper;
16

  
17
/**
18
 * @author pplitzner
19
 * @since Dec 1, 2017
20
 *
21
 */
22
public class CategoricalDataDisplayConverter extends DisplayConverter {
23

  
24
    /**
25
     * {@inheritDoc}
26
     */
27
    @Override
28
    public Object canonicalToDisplayValue(Object canonicalValue) {
29
        if(canonicalValue instanceof CategoricalData){
30
            return DescriptionHelper.getLabel(canonicalValue);
31
        }
32
        else if(canonicalValue instanceof State){
33
            return ((State) canonicalValue).getLabel();
34
        }
35
        return canonicalValue.toString();
36
    }
37

  
38
    /**
39
     * {@inheritDoc}
40
     */
41
    @Override
42
    public Object displayToCanonicalValue(Object displayValue) {
43
        return null;
44
    }
45

  
46
}
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/workingSet/matrix/CharacterMatrix.java
82 82
import eu.etaxonomy.cdm.model.description.State;
83 83
import eu.etaxonomy.cdm.model.description.WorkingSet;
84 84
import eu.etaxonomy.cdm.persistence.hibernate.CdmDataChangeMap;
85
import eu.etaxonomy.taxeditor.editor.workingSet.matrix.categorical.CategoricalDataCellEditor;
86
import eu.etaxonomy.taxeditor.editor.workingSet.matrix.categorical.CategoricalDataDisplayConverter;
87
import eu.etaxonomy.taxeditor.editor.workingSet.matrix.quantitative.QuantitativeDataCellEditor;
88
import eu.etaxonomy.taxeditor.editor.workingSet.matrix.quantitative.QuantitativeDataDisplayConverter;
85 89
import eu.etaxonomy.taxeditor.model.IDirtyMarkable;
86 90
import eu.etaxonomy.taxeditor.model.IPartContentHasDetails;
87 91
import eu.etaxonomy.taxeditor.store.CdmStore;
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/workingSet/matrix/QuantitativeDataCellEditor.java
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.edit.editor.AbstractCellEditor;
12
import org.eclipse.swt.SWT;
13
import org.eclipse.swt.widgets.Composite;
14
import org.eclipse.swt.widgets.Control;
15

  
16
import eu.etaxonomy.cdm.model.description.CategoricalData;
17
import eu.etaxonomy.taxeditor.editor.workingSet.matrix.quantitative.QuantitativeDataComposite;
18

  
19
/**
20
 * @author pplitzner
21
 * @since Dec 7, 2017
22
 *
23
 */
24
public class QuantitativeDataCellEditor extends AbstractCellEditor{
25

  
26
    private QuantitativeDataComposite editorControl;
27

  
28
    /**
29
     * {@inheritDoc}
30
     */
31
    @Override
32
    public Object getEditorValue() {
33
        System.out.println("getValue");
34
        return editorControl.getMin()+" "+editorControl.getAvg()+" "+editorControl.getMax();
35
    }
36

  
37
    /**
38
     * {@inheritDoc}
39
     */
40
    @Override
41
    public void setEditorValue(Object value) {
42
        if(value instanceof CategoricalData){
43
            System.out.println("setValue: "+value);
44
        }
45
    }
46

  
47
    /**
48
     * {@inheritDoc}
49
     */
50
    @Override
51
    public Control getEditorControl() {
52
        return editorControl;
53
    }
54

  
55
    /**
56
     * {@inheritDoc}
57
     */
58
    @Override
59
    public Control createEditorControl(Composite parent) {
60
        return new QuantitativeDataComposite(parent, SWT.NONE);
61
    }
62

  
63
    /**
64
     * {@inheritDoc}
65
     */
66
    @Override
67
    protected Control activateCell(Composite parent, Object originalCanonicalValue) {
68
        this.editorControl = (QuantitativeDataComposite) createEditorControl(parent);
69
        return editorControl;
70
    }
71

  
72

  
73
}
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/workingSet/matrix/QuantitativeDataDisplayConverter.java
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.convert.DisplayConverter;
12

  
13
import eu.etaxonomy.cdm.model.description.QuantitativeData;
14
import eu.etaxonomy.taxeditor.model.DescriptionHelper;
15

  
16
/**
17
 * @author pplitzner
18
 * @since Dec 1, 2017
19
 *
20
 */
21
public class QuantitativeDataDisplayConverter extends DisplayConverter {
22

  
23
    /**
24
     * {@inheritDoc}
25
     */
26
    @Override
27
    public Object canonicalToDisplayValue(Object canonicalValue) {
28
        if(canonicalValue instanceof QuantitativeData){
29
            return DescriptionHelper.getLabel(canonicalValue);
30
        }
31
        return canonicalValue.toString();
32
    }
33

  
34
    /**
35
     * {@inheritDoc}
36
     */
37
    @Override
38
    public Object displayToCanonicalValue(Object displayValue) {
39
        return null;
40
    }
41

  
42
}
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/workingSet/matrix/categorical/CategoricalDataCellEditor.java
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.categorical;
10

  
11
import java.util.List;
12

  
13
import org.eclipse.nebula.widgets.nattable.edit.editor.IComboBoxDataProvider;
14
import org.eclipse.nebula.widgets.nattable.filterrow.combobox.FilterRowComboBoxCellEditor;
15

  
16
import eu.etaxonomy.cdm.model.description.CategoricalData;
17
import eu.etaxonomy.cdm.model.description.State;
18

  
19
/**
20
 * @author pplitzner
21
 * @since Dec 7, 2017
22
 *
23
 */
24
public class CategoricalDataCellEditor extends FilterRowComboBoxCellEditor{
25

  
26
    public CategoricalDataCellEditor(IComboBoxDataProvider dataProvider, int maxVisibleItems) {
27
        super(dataProvider, maxVisibleItems);
28
    }
29

  
30
    @Override
31
    public void setCanonicalValue(Object canonicalValue) {
32
        if (canonicalValue instanceof CategoricalData) {
33
            CategoricalData data = (CategoricalData)canonicalValue;
34
            List<State> states = data.getStatesOnly();
35
            String[] result = new String[states.size()];
36
            for (int i = 0; i < states.size(); i++) {
37
                result[i] = (String) this.displayConverter.canonicalToDisplayValue(
38
                        this.layerCell, this.configRegistry, states.get(i));
39
            }
40
            setEditorValue(result);
41
        }
42
    }
43

  
44
}
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/workingSet/matrix/categorical/CategoricalDataDisplayConverter.java
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.categorical;
10

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

  
13
import eu.etaxonomy.cdm.model.description.CategoricalData;
14
import eu.etaxonomy.cdm.model.description.State;
15
import eu.etaxonomy.taxeditor.model.DescriptionHelper;
16

  
17
/**
18
 * @author pplitzner
19
 * @since Dec 1, 2017
20
 *
21
 */
22
public class CategoricalDataDisplayConverter extends DisplayConverter {
23

  
24
    /**
25
     * {@inheritDoc}
26
     */
27
    @Override
28
    public Object canonicalToDisplayValue(Object canonicalValue) {
29
        if(canonicalValue instanceof CategoricalData){
30
            return DescriptionHelper.getLabel(canonicalValue);
31
        }
32
        else if(canonicalValue instanceof State){
33
            return ((State) canonicalValue).getLabel();
34
        }
35
        return canonicalValue.toString();
36
    }
37

  
38
    /**
39
     * {@inheritDoc}
40
     */
41
    @Override
42
    public Object displayToCanonicalValue(Object displayValue) {
43
        return null;
44
    }
45

  
46
}
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/workingSet/matrix/quantitative/QuantitativeDataCellEditor.java
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.quantitative;
10

  
11
import org.eclipse.nebula.widgets.nattable.edit.editor.AbstractCellEditor;
12
import org.eclipse.swt.SWT;
13
import org.eclipse.swt.widgets.Composite;
14
import org.eclipse.swt.widgets.Control;
15

  
16
import eu.etaxonomy.cdm.model.description.CategoricalData;
17

  
18
/**
19
 * @author pplitzner
20
 * @since Dec 7, 2017
21
 *
22
 */
23
public class QuantitativeDataCellEditor extends AbstractCellEditor{
24

  
25
    private QuantitativeDataComposite editorControl;
26

  
27
    /**
28
     * {@inheritDoc}
29
     */
30
    @Override
31
    public Object getEditorValue() {
32
        System.out.println("getValue");
33
        return editorControl.getMin()+" "+editorControl.getAvg()+" "+editorControl.getMax();
34
    }
35

  
36
    /**
37
     * {@inheritDoc}
38
     */
39
    @Override
40
    public void setEditorValue(Object value) {
41
        if(value instanceof CategoricalData){
42
            System.out.println("setValue: "+value);
43
        }
44
    }
45

  
46
    /**
47
     * {@inheritDoc}
48
     */
49
    @Override
50
    public Control getEditorControl() {
51
        return editorControl;
52
    }
53

  
54
    /**
55
     * {@inheritDoc}
56
     */
57
    @Override
58
    public Control createEditorControl(Composite parent) {
59
        return new QuantitativeDataComposite(parent, SWT.NONE);
60
    }
61

  
62
    /**
63
     * {@inheritDoc}
64
     */
65
    @Override
66
    protected Control activateCell(Composite parent, Object originalCanonicalValue) {
67
        this.editorControl = (QuantitativeDataComposite) createEditorControl(parent);
68
        return editorControl;
69
    }
70

  
71

  
72
}
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/workingSet/matrix/quantitative/QuantitativeDataDisplayConverter.java
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.quantitative;
10

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

  
13
import eu.etaxonomy.cdm.model.description.QuantitativeData;
14
import eu.etaxonomy.taxeditor.model.DescriptionHelper;
15

  
16
/**
17
 * @author pplitzner
18
 * @since Dec 1, 2017
19
 *
20
 */
21
public class QuantitativeDataDisplayConverter extends DisplayConverter {
22

  
23
    /**
24
     * {@inheritDoc}
25
     */
26
    @Override
27
    public Object canonicalToDisplayValue(Object canonicalValue) {
28
        if(canonicalValue instanceof QuantitativeData){
29
            return DescriptionHelper.getLabel(canonicalValue);
30
        }
31
        return canonicalValue.toString();
32
    }
33

  
34
    /**
35
     * {@inheritDoc}
36
     */
37
    @Override
38
    public Object displayToCanonicalValue(Object displayValue) {
39
        return null;
40
    }
41

  
42
}

Also available in: Unified diff