8 |
8 |
*/
|
9 |
9 |
package eu.etaxonomy.taxeditor.editor.workingSet.matrix.quantitative;
|
10 |
10 |
|
|
11 |
import java.util.HashMap;
|
|
12 |
import java.util.Map;
|
|
13 |
import java.util.Set;
|
|
14 |
|
11 |
15 |
import org.eclipse.nebula.widgets.nattable.edit.editor.AbstractCellEditor;
|
12 |
16 |
import org.eclipse.swt.SWT;
|
|
17 |
import org.eclipse.swt.layout.FillLayout;
|
|
18 |
import org.eclipse.swt.layout.GridData;
|
|
19 |
import org.eclipse.swt.layout.GridLayout;
|
13 |
20 |
import org.eclipse.swt.widgets.Composite;
|
14 |
21 |
import org.eclipse.swt.widgets.Control;
|
|
22 |
import org.eclipse.swt.widgets.Label;
|
|
23 |
import org.eclipse.swt.widgets.Text;
|
15 |
24 |
|
16 |
25 |
import eu.etaxonomy.cdm.model.description.CategoricalData;
|
|
26 |
import eu.etaxonomy.cdm.model.description.StatisticalMeasure;
|
17 |
27 |
|
18 |
28 |
/**
|
19 |
29 |
* @author pplitzner
|
... | ... | |
22 |
32 |
*/
|
23 |
33 |
public class QuantitativeDataCellEditor extends AbstractCellEditor{
|
24 |
34 |
|
25 |
|
private QuantitativeDataComposite editorControl;
|
|
35 |
private Control editorControl;
|
|
36 |
|
|
37 |
private Set<StatisticalMeasure> statisticalMeasures;
|
|
38 |
|
|
39 |
private Map<StatisticalMeasure, Text> measureToTextMap = new HashMap<>();
|
|
40 |
|
|
41 |
public QuantitativeDataCellEditor(Set<StatisticalMeasure> statisticalMeasures) {
|
|
42 |
super();
|
|
43 |
this.statisticalMeasures = statisticalMeasures;
|
|
44 |
}
|
26 |
45 |
|
27 |
46 |
/**
|
28 |
47 |
* {@inheritDoc}
|
29 |
48 |
*/
|
30 |
49 |
@Override
|
31 |
50 |
public Object getEditorValue() {
|
32 |
|
System.out.println("getValue");
|
33 |
|
return editorControl.getMin()+" "+editorControl.getAvg()+" "+editorControl.getMax();
|
|
51 |
return null;
|
34 |
52 |
}
|
35 |
53 |
|
36 |
54 |
/**
|
... | ... | |
39 |
57 |
@Override
|
40 |
58 |
public void setEditorValue(Object value) {
|
41 |
59 |
if(value instanceof CategoricalData){
|
42 |
|
System.out.println("setValue: "+value);
|
43 |
60 |
}
|
44 |
61 |
}
|
45 |
62 |
|
... | ... | |
56 |
73 |
*/
|
57 |
74 |
@Override
|
58 |
75 |
public Control createEditorControl(Composite parent) {
|
59 |
|
return new QuantitativeDataComposite(parent, SWT.NONE);
|
|
76 |
Composite composite = new Composite(parent, SWT.NONE);
|
|
77 |
composite.setLayout(new FillLayout(SWT.HORIZONTAL));
|
|
78 |
|
|
79 |
for (StatisticalMeasure measure: statisticalMeasures) {
|
|
80 |
Composite measureComposite = new Composite(composite, SWT.NONE);
|
|
81 |
GridLayout layout = new GridLayout(2, false);
|
|
82 |
layout.horizontalSpacing = 0;
|
|
83 |
layout.marginBottom = 0;
|
|
84 |
layout.marginHeight = 0;
|
|
85 |
layout.marginLeft = 0;
|
|
86 |
layout.marginRight = 0;
|
|
87 |
layout.marginTop = 0;
|
|
88 |
layout.marginWidth = 0;
|
|
89 |
layout.verticalSpacing = 0;
|
|
90 |
measureComposite.setLayout(layout);
|
|
91 |
Label label = new Label(measureComposite, SWT.NONE);
|
|
92 |
GridData layoutData = new GridData(SWT.CENTER, SWT.TOP, false, false);
|
|
93 |
label.setLayoutData(layoutData);
|
|
94 |
label.setText(measure.getLabel().substring(0, 3));
|
|
95 |
|
|
96 |
Text text = new Text(measureComposite, SWT.NONE);
|
|
97 |
label.setLayoutData(new GridData(SWT.CENTER, SWT.TOP, false, false));
|
|
98 |
|
|
99 |
measureToTextMap.put(measure, text);
|
|
100 |
}
|
|
101 |
return composite;
|
60 |
102 |
}
|
61 |
103 |
|
62 |
104 |
/**
|
... | ... | |
64 |
106 |
*/
|
65 |
107 |
@Override
|
66 |
108 |
protected Control activateCell(Composite parent, Object originalCanonicalValue) {
|
67 |
|
this.editorControl = (QuantitativeDataComposite) createEditorControl(parent);
|
68 |
|
return editorControl;
|
|
109 |
System.out.println(originalCanonicalValue);
|
|
110 |
this.editorControl = createEditorControl(parent);
|
|
111 |
return this.editorControl;
|
69 |
112 |
}
|
70 |
113 |
|
71 |
114 |
|
ref #7095 Create quantitative cell editor following statistical measures