Project

General

Profile

« Previous | Next » 

Revision f8da7861

Added by Patrick Plitzner about 6 years ago

ref #7095 Init description elements when activating cell editor

View differences:

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

  
188 188
    private Collection<SpecimenOrObservationBase> specimenCache = null;
189 189

  
190
    private ListDataProvider<RowWrapper> bodyDataProvider;
191

  
190 192
    @PostConstruct
191 193
    public void create(Composite parent) {
192 194
        if(CdmStore.isActive() && conversation==null){
......
225 227
         * data provider
226 228
         */
227 229
        SpecimenColumnPropertyAccessor columnPropertyAccessor = new SpecimenColumnPropertyAccessor(this);
228
        IDataProvider bodyDataProvider = new ListDataProvider<RowWrapper>(sortedList, columnPropertyAccessor);
230
        bodyDataProvider = new ListDataProvider<RowWrapper>(sortedList, columnPropertyAccessor);
229 231

  
230 232
        /**
231 233
         * BODY layer
......
708 710
            //register quantitative editor
709 711
            configRegistry.registerConfigAttribute(
710 712
                    EditConfigAttributes.CELL_EDITOR,
711
                    new QuantitativeDataCellEditor(feature.getRecommendedStatisticalMeasures(), this),
713
                    new QuantitativeDataCellEditor(feature, this),
712 714
                    DisplayMode.EDIT,
713 715
                    MatrixUtility.getProperty(feature));
714 716
        }
......
735 737
                    }
736 738
                    return states;
737 739
                }
738
            }, 5, this);
740
            }, 5, this, feature);
739 741
            //register editor
740 742
            configRegistry.registerConfigAttribute(EditConfigAttributes.CELL_EDITOR,
741 743
                    comboBoxCellEditor,
......
785 787
        this.specimenCache = specimenCache;
786 788
    }
787 789

  
790
    /**
791
     * @return the bodyDataProvider
792
     */
793
    public ListDataProvider<RowWrapper> getBodyDataProvider() {
794
        return bodyDataProvider;
795
    }
796

  
788 797
    @Persist
789 798
    @Override
790 799
    public void save(IProgressMonitor monitor) {
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/workingSet/matrix/categorical/CategoricalDataCellEditor.java
19 19
import org.eclipse.swt.widgets.Control;
20 20

  
21 21
import eu.etaxonomy.cdm.model.description.CategoricalData;
22
import eu.etaxonomy.cdm.model.description.Feature;
22 23
import eu.etaxonomy.cdm.model.description.State;
23 24
import eu.etaxonomy.taxeditor.editor.workingSet.matrix.CharacterMatrix;
25
import eu.etaxonomy.taxeditor.editor.workingSet.matrix.RowWrapper;
24 26

  
25 27
/**
26 28
 * @author pplitzner
......
30 32
public class CategoricalDataCellEditor extends FilterRowComboBoxCellEditor{
31 33

  
32 34
    private CharacterMatrix matrix;
35
    private Feature feature;
33 36

  
34
    public CategoricalDataCellEditor(IComboBoxDataProvider dataProvider, int maxVisibleItems, CharacterMatrix matrix) {
37
    public CategoricalDataCellEditor(IComboBoxDataProvider dataProvider, int maxVisibleItems, CharacterMatrix matrix, Feature feature) {
35 38
        super(dataProvider, maxVisibleItems);
36 39
        this.matrix = matrix;
40
        this.feature = feature;
37 41
    }
38 42

  
39 43
    @Override
40 44
    public void setCanonicalValue(Object canonicalValue) {
45
        if(canonicalValue==null){
46
            CategoricalData data = CategoricalData.NewInstance(feature);
47
            RowWrapper rowWrapper = matrix.getBodyDataProvider().getRowObject(this.getRowIndex());
48
            rowWrapper.getSpecimenDescription().addElement(data);
49
            canonicalValue = data;
50
        }
41 51
        if (canonicalValue instanceof CategoricalData) {
42 52
            CategoricalData data = (CategoricalData)canonicalValue;
43 53
            List<State> states = data.getStatesOnly();
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/workingSet/matrix/quantitative/QuantitativeDataCellEditor.java
24 24
import org.eclipse.swt.widgets.Listener;
25 25
import org.eclipse.swt.widgets.Text;
26 26

  
27
import eu.etaxonomy.cdm.model.description.Feature;
27 28
import eu.etaxonomy.cdm.model.description.QuantitativeData;
28 29
import eu.etaxonomy.cdm.model.description.StatisticalMeasure;
29 30
import eu.etaxonomy.taxeditor.editor.workingSet.matrix.CharacterMatrix;
31
import eu.etaxonomy.taxeditor.editor.workingSet.matrix.RowWrapper;
30 32

  
31 33
/**
32 34
 * @author pplitzner
......
37 39

  
38 40
    private Control editorControl;
39 41

  
40
    private Set<StatisticalMeasure> statisticalMeasures;
42
    private Feature feature;
41 43

  
42 44
    private Map<StatisticalMeasure, Text> measureToTextMap = new HashMap<>();
43 45

  
......
47 49

  
48 50
    private boolean dirty = false;
49 51

  
50
    public QuantitativeDataCellEditor(Set<StatisticalMeasure> statisticalMeasures, CharacterMatrix matrix) {
52
    public QuantitativeDataCellEditor(Feature feature, CharacterMatrix matrix) {
51 53
        super();
52 54
        this.matrix = matrix;
53
        this.statisticalMeasures = statisticalMeasures;
55
        this.feature = feature;
54 56
    }
55 57

  
56 58

  
......
86 88
        Composite composite = new Composite(parent, SWT.NONE);
87 89
        composite.setLayout(new FillLayout(SWT.HORIZONTAL));
88 90

  
89
        for (StatisticalMeasure measure: statisticalMeasures) {
91
        for (StatisticalMeasure measure: feature.getRecommendedStatisticalMeasures()) {
90 92
            Composite measureComposite = new Composite(composite, SWT.NONE);
91 93
            GridLayout layout = new GridLayout(2, false);
92 94
            layout.horizontalSpacing = 0;
......
129 131
    @Override
130 132
    protected Control activateCell(Composite parent, Object originalCanonicalValue) {
131 133
        this.editorControl = createEditorControl(parent);
134
        if(originalCanonicalValue==null){
135
            QuantitativeData data = QuantitativeData.NewInstance(feature);
136
            RowWrapper rowObject = matrix.getBodyDataProvider().getRowObject(this.getRowIndex());
137
            rowObject.getSpecimenDescription().addElement(data);
138
            originalCanonicalValue = data;
139
        }
132 140
        this.setEditorValue(originalCanonicalValue);
133 141

  
134 142
        if(originalCanonicalValue instanceof QuantitativeData){

Also available in: Unified diff