Project

General

Profile

« Previous | Next » 

Revision d657d3eb

Added by Patrick Plitzner over 5 years ago

ref #7095 Disable cell editors for taxon node rows

View differences:

eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/workingSet/matrix/categorical/CategoricalDataCellEditor.java
67 67
     */
68 68
    @Override
69 69
    protected Control activateCell(Composite parent, Object originalCanonicalValue) {
70
        Control editorControl = super.activateCell(parent, originalCanonicalValue);
71
        ((NatCombo)editorControl).addSelectionListener(new SelectionListener() {
72
            @Override
73
            public void widgetSelected(SelectionEvent e) {
74
                matrix.setDirty();
75
            }
76
            @Override
77
            public void widgetDefaultSelected(SelectionEvent e) {
78
            }
79
        });
80
        return editorControl;
70
        if(matrix.getBodyDataProvider().getRowObject(this.getRowIndex()) instanceof RowWrapper){
71
            Control editorControl = super.activateCell(parent, originalCanonicalValue);
72
            ((NatCombo)editorControl).addSelectionListener(new SelectionListener() {
73
                @Override
74
                public void widgetSelected(SelectionEvent e) {
75
                    matrix.setDirty();
76
                }
77
                @Override
78
                public void widgetDefaultSelected(SelectionEvent e) {
79
                }
80
            });
81
            return editorControl;
82
        }
83
        return null;
81 84
    }
82 85

  
83 86
}
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/workingSet/matrix/quantitative/QuantitativeDataCellEditor.java
130 130
     */
131 131
    @Override
132 132
    protected Control activateCell(Composite parent, Object originalCanonicalValue) {
133
        this.editorControl = createEditorControl(parent);
134
        if(originalCanonicalValue==null){
135
            Object rowObject = matrix.getBodyDataProvider().getRowObject(this.getRowIndex());
136
            if(rowObject instanceof RowWrapper){
133
        Object rowObject = matrix.getBodyDataProvider().getRowObject(this.getRowIndex());
134
        if(rowObject instanceof RowWrapper){
135
            this.editorControl = createEditorControl(parent);
136
            if(originalCanonicalValue==null){
137 137
                QuantitativeData data = QuantitativeData.NewInstance(feature);
138 138
                ((RowWrapper) rowObject).getSpecimenDescription().addElement(data);
139 139
                originalCanonicalValue = data;
140 140
            }
141
        }
142
        this.setEditorValue(originalCanonicalValue);
143

  
144
        if(originalCanonicalValue instanceof QuantitativeData){
145
            QuantitativeData quantitativeData = (QuantitativeData)originalCanonicalValue;
146
            Set<StatisticalMeasure> statisticalValues = quantitativeData.getFeature().getRecommendedStatisticalMeasures();
147
            //Fill text controls with actual values and add modify listeners for editing
148
            for (StatisticalMeasure value : statisticalValues) {
149
                Text text = measureToTextMap.get(value);
150
                text.addModifyListener(e->{
151
                    quantitativeData.setSpecificStatisticalValue(Float.parseFloat(text.getText()), null, value);
152
                    dirty = true;
153
                });
154

  
155
                Float specificStatisticalValue = quantitativeData.getSpecificStatisticalValue(value);
156
                if(specificStatisticalValue!=null){
157
                    Listener[] listeners = text.getListeners(SWT.Modify);
158
                    for (Listener listener : listeners) {
159
                        text.removeListener(SWT.Modify, listener);
160
                    }
161
                    text.setText(Float.toString(specificStatisticalValue));
162
                    for (Listener listener : listeners) {
163
                        text.addListener(SWT.Modify, listener);
141
            this.setEditorValue(originalCanonicalValue);
142

  
143
            if(originalCanonicalValue instanceof QuantitativeData){
144
                QuantitativeData quantitativeData = (QuantitativeData)originalCanonicalValue;
145
                Set<StatisticalMeasure> statisticalValues = quantitativeData.getFeature().getRecommendedStatisticalMeasures();
146
                //Fill text controls with actual values and add modify listeners for editing
147
                for (StatisticalMeasure value : statisticalValues) {
148
                    Text text = measureToTextMap.get(value);
149
                    text.addModifyListener(e->{
150
                        quantitativeData.setSpecificStatisticalValue(Float.parseFloat(text.getText()), null, value);
151
                        dirty = true;
152
                    });
153

  
154
                    Float specificStatisticalValue = quantitativeData.getSpecificStatisticalValue(value);
155
                    if(specificStatisticalValue!=null){
156
                        Listener[] listeners = text.getListeners(SWT.Modify);
157
                        for (Listener listener : listeners) {
158
                            text.removeListener(SWT.Modify, listener);
159
                        }
160
                        text.setText(Float.toString(specificStatisticalValue));
161
                        for (Listener listener : listeners) {
162
                            text.addListener(SWT.Modify, listener);
163
                        }
164 164
                    }
165 165
                }
166 166
            }

Also available in: Unified diff