Revision c42c7bec
Added by Patrick Plitzner over 6 years ago
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/workingSet/matrix/CharacterMatrix.java | ||
---|---|---|
293 | 293 |
//register quantitative editor |
294 | 294 |
configRegistry.registerConfigAttribute( |
295 | 295 |
EditConfigAttributes.CELL_EDITOR, |
296 |
new QuantitativeDataCellEditor(feature.getRecommendedStatisticalMeasures()), |
|
296 |
new QuantitativeDataCellEditor(feature.getRecommendedStatisticalMeasures(), this),
|
|
297 | 297 |
DisplayMode.EDIT, |
298 | 298 |
getProperty(feature)); |
299 | 299 |
} |
... | ... | |
320 | 320 |
} |
321 | 321 |
return states; |
322 | 322 |
} |
323 |
}, 5); |
|
323 |
}, 5, this);
|
|
324 | 324 |
//register editor |
325 | 325 |
configRegistry.registerConfigAttribute(EditConfigAttributes.CELL_EDITOR, |
326 | 326 |
comboBoxCellEditor, |
... | ... | |
350 | 350 |
return feature.getLabel(); |
351 | 351 |
} |
352 | 352 |
|
353 |
public void setDirty() { |
|
354 |
this.dirty.setDirty(true); |
|
355 |
} |
|
356 |
|
|
353 | 357 |
@Persist |
354 | 358 |
@Override |
355 | 359 |
public void save(IProgressMonitor monitor) { |
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/workingSet/matrix/categorical/CategoricalDataCellEditor.java | ||
---|---|---|
12 | 12 |
|
13 | 13 |
import org.eclipse.nebula.widgets.nattable.edit.editor.IComboBoxDataProvider; |
14 | 14 |
import org.eclipse.nebula.widgets.nattable.filterrow.combobox.FilterRowComboBoxCellEditor; |
15 |
import org.eclipse.nebula.widgets.nattable.widget.NatCombo; |
|
16 |
import org.eclipse.swt.events.SelectionEvent; |
|
17 |
import org.eclipse.swt.events.SelectionListener; |
|
18 |
import org.eclipse.swt.widgets.Composite; |
|
19 |
import org.eclipse.swt.widgets.Control; |
|
15 | 20 |
|
16 | 21 |
import eu.etaxonomy.cdm.model.description.CategoricalData; |
17 | 22 |
import eu.etaxonomy.cdm.model.description.State; |
23 |
import eu.etaxonomy.taxeditor.editor.workingSet.matrix.CharacterMatrix; |
|
18 | 24 |
|
19 | 25 |
/** |
20 | 26 |
* @author pplitzner |
... | ... | |
23 | 29 |
*/ |
24 | 30 |
public class CategoricalDataCellEditor extends FilterRowComboBoxCellEditor{ |
25 | 31 |
|
26 |
public CategoricalDataCellEditor(IComboBoxDataProvider dataProvider, int maxVisibleItems) { |
|
32 |
private CharacterMatrix matrix; |
|
33 |
|
|
34 |
public CategoricalDataCellEditor(IComboBoxDataProvider dataProvider, int maxVisibleItems, CharacterMatrix matrix) { |
|
27 | 35 |
super(dataProvider, maxVisibleItems); |
36 |
this.matrix = matrix; |
|
28 | 37 |
} |
29 | 38 |
|
30 | 39 |
@Override |
... | ... | |
41 | 50 |
} |
42 | 51 |
} |
43 | 52 |
|
53 |
/** |
|
54 |
* {@inheritDoc} |
|
55 |
*/ |
|
56 |
@Override |
|
57 |
protected Control activateCell(Composite parent, Object originalCanonicalValue) { |
|
58 |
Control editorControl = super.activateCell(parent, originalCanonicalValue); |
|
59 |
((NatCombo)editorControl).addSelectionListener(new SelectionListener() { |
|
60 |
@Override |
|
61 |
public void widgetSelected(SelectionEvent e) { |
|
62 |
matrix.setDirty(); |
|
63 |
} |
|
64 |
@Override |
|
65 |
public void widgetDefaultSelected(SelectionEvent e) { |
|
66 |
} |
|
67 |
}); |
|
68 |
return editorControl; |
|
69 |
} |
|
70 |
|
|
44 | 71 |
} |
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/workingSet/matrix/quantitative/QuantitativeDataCellEditor.java | ||
---|---|---|
13 | 13 |
import java.util.Set; |
14 | 14 |
|
15 | 15 |
import org.eclipse.nebula.widgets.nattable.edit.editor.AbstractCellEditor; |
16 |
import org.eclipse.nebula.widgets.nattable.selection.SelectionLayer.MoveDirectionEnum; |
|
16 | 17 |
import org.eclipse.swt.SWT; |
17 | 18 |
import org.eclipse.swt.layout.FillLayout; |
18 | 19 |
import org.eclipse.swt.layout.GridData; |
... | ... | |
20 | 21 |
import org.eclipse.swt.widgets.Composite; |
21 | 22 |
import org.eclipse.swt.widgets.Control; |
22 | 23 |
import org.eclipse.swt.widgets.Label; |
24 |
import org.eclipse.swt.widgets.Listener; |
|
23 | 25 |
import org.eclipse.swt.widgets.Text; |
24 | 26 |
|
25 |
import eu.etaxonomy.cdm.model.description.CategoricalData;
|
|
27 |
import eu.etaxonomy.cdm.model.description.QuantitativeData;
|
|
26 | 28 |
import eu.etaxonomy.cdm.model.description.StatisticalMeasure; |
29 |
import eu.etaxonomy.taxeditor.editor.workingSet.matrix.CharacterMatrix; |
|
27 | 30 |
|
28 | 31 |
/** |
29 | 32 |
* @author pplitzner |
... | ... | |
38 | 41 |
|
39 | 42 |
private Map<StatisticalMeasure, Text> measureToTextMap = new HashMap<>(); |
40 | 43 |
|
41 |
public QuantitativeDataCellEditor(Set<StatisticalMeasure> statisticalMeasures) { |
|
44 |
private Object editorValue; |
|
45 |
|
|
46 |
private CharacterMatrix matrix; |
|
47 |
|
|
48 |
private boolean dirty = false; |
|
49 |
|
|
50 |
public QuantitativeDataCellEditor(Set<StatisticalMeasure> statisticalMeasures, CharacterMatrix matrix) { |
|
42 | 51 |
super(); |
52 |
this.matrix = matrix; |
|
43 | 53 |
this.statisticalMeasures = statisticalMeasures; |
44 | 54 |
} |
45 | 55 |
|
56 |
|
|
46 | 57 |
/** |
47 | 58 |
* {@inheritDoc} |
48 | 59 |
*/ |
49 | 60 |
@Override |
50 | 61 |
public Object getEditorValue() { |
51 |
return null;
|
|
62 |
return this.editorValue;
|
|
52 | 63 |
} |
53 | 64 |
|
54 | 65 |
/** |
... | ... | |
56 | 67 |
*/ |
57 | 68 |
@Override |
58 | 69 |
public void setEditorValue(Object value) { |
59 |
if(value instanceof CategoricalData){ |
|
60 |
} |
|
70 |
this.editorValue = value; |
|
61 | 71 |
} |
62 | 72 |
|
63 | 73 |
/** |
... | ... | |
101 | 111 |
return composite; |
102 | 112 |
} |
103 | 113 |
|
114 |
/** |
|
115 |
* {@inheritDoc} |
|
116 |
*/ |
|
117 |
@Override |
|
118 |
public boolean commit(MoveDirectionEnum direction, boolean closeAfterCommit, boolean skipValidation) { |
|
119 |
if(dirty){ |
|
120 |
matrix.setDirty(); |
|
121 |
dirty = false; |
|
122 |
} |
|
123 |
return super.commit(direction, closeAfterCommit, skipValidation); |
|
124 |
} |
|
125 |
|
|
104 | 126 |
/** |
105 | 127 |
* {@inheritDoc} |
106 | 128 |
*/ |
107 | 129 |
@Override |
108 | 130 |
protected Control activateCell(Composite parent, Object originalCanonicalValue) { |
109 |
System.out.println(originalCanonicalValue); |
|
110 | 131 |
this.editorControl = createEditorControl(parent); |
132 |
this.setEditorValue(originalCanonicalValue); |
|
133 |
|
|
134 |
if(originalCanonicalValue instanceof QuantitativeData){ |
|
135 |
QuantitativeData quantitativeData = (QuantitativeData)originalCanonicalValue; |
|
136 |
Set<StatisticalMeasure> statisticalValues = quantitativeData.getFeature().getRecommendedStatisticalMeasures(); |
|
137 |
//Fill text controls with actual values and add modify listeners for editing |
|
138 |
for (StatisticalMeasure value : statisticalValues) { |
|
139 |
Text text = measureToTextMap.get(value); |
|
140 |
text.addModifyListener(e->{ |
|
141 |
quantitativeData.setSpecificStatisticalValue(Float.parseFloat(text.getText()), null, value); |
|
142 |
dirty = true; |
|
143 |
}); |
|
144 |
|
|
145 |
Float specificStatisticalValue = quantitativeData.getSpecificStatisticalValue(value); |
|
146 |
if(specificStatisticalValue!=null){ |
|
147 |
Listener[] listeners = text.getListeners(SWT.Modify); |
|
148 |
for (Listener listener : listeners) { |
|
149 |
text.removeListener(SWT.Modify, listener); |
|
150 |
} |
|
151 |
text.setText(Float.toString(specificStatisticalValue)); |
|
152 |
for (Listener listener : listeners) { |
|
153 |
text.addListener(SWT.Modify, listener); |
|
154 |
} |
|
155 |
} |
|
156 |
} |
|
157 |
} |
|
111 | 158 |
return this.editorControl; |
112 | 159 |
} |
113 | 160 |
|
114 |
|
|
115 | 161 |
} |
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/workingSet/matrix/quantitative/QuantitativeDataComposite.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.swt.SWT; |
|
12 |
import org.eclipse.swt.layout.FillLayout; |
|
13 |
import org.eclipse.swt.widgets.Composite; |
|
14 |
import org.eclipse.swt.widgets.Text; |
|
15 |
|
|
16 |
/** |
|
17 |
* @author pplitzner |
|
18 |
* @since Dec 11, 2017 |
|
19 |
* |
|
20 |
*/ |
|
21 |
public class QuantitativeDataComposite extends Composite { |
|
22 |
private Text min; |
|
23 |
private Text avg; |
|
24 |
private Text max; |
|
25 |
|
|
26 |
/** |
|
27 |
* Create the composite. |
|
28 |
* @param parent |
|
29 |
* @param style |
|
30 |
*/ |
|
31 |
public QuantitativeDataComposite(Composite parent, int style) { |
|
32 |
super(parent, style); |
|
33 |
setLayout(new FillLayout(SWT.HORIZONTAL)); |
|
34 |
|
|
35 |
min = new Text(this, SWT.NONE); |
|
36 |
|
|
37 |
avg = new Text(this, SWT.BORDER); |
|
38 |
|
|
39 |
max = new Text(this, SWT.BORDER); |
|
40 |
|
|
41 |
} |
|
42 |
|
|
43 |
@Override |
|
44 |
protected void checkSubclass() { |
|
45 |
// Disable the check that prevents subclassing of SWT components |
|
46 |
} |
|
47 |
|
|
48 |
public Text getMin() { |
|
49 |
return min; |
|
50 |
} |
|
51 |
public Text getAvg() { |
|
52 |
return avg; |
|
53 |
} |
|
54 |
public Text getMax() { |
|
55 |
return max; |
|
56 |
} |
|
57 |
} |
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/workingSet/matrix/quantitative/QuantitativeDataDisplayConverter.java | ||
---|---|---|
28 | 28 |
if(canonicalValue instanceof QuantitativeData){ |
29 | 29 |
return DescriptionHelper.getLabel(canonicalValue); |
30 | 30 |
} |
31 |
return canonicalValue.toString(); |
|
31 |
if(canonicalValue!=null){ |
|
32 |
return canonicalValue.toString(); |
|
33 |
} |
|
34 |
return null; |
|
32 | 35 |
} |
33 | 36 |
|
34 | 37 |
/** |
Also available in: Unified diff
ref #7095 Handle dirty state of character matrix when editing