Revision 8707c0a4
Added by Patrick Plitzner over 6 years ago
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/workingSet/matrix/CharacterMatrix.java | ||
---|---|---|
285 | 285 |
new QuantitativeDataDisplayConverter(), |
286 | 286 |
DisplayMode.NORMAL, |
287 | 287 |
getProperty(feature)); |
288 |
//register quantitative editor |
|
289 |
configRegistry.registerConfigAttribute( |
|
290 |
EditConfigAttributes.CELL_EDITOR, |
|
291 |
new QuantitativeDataCellEditor(), |
|
292 |
DisplayMode.EDIT, |
|
293 |
getProperty(feature)); |
|
288 | 294 |
} |
289 | 295 |
else if(feature.isSupportsCategoricalData()){ |
290 | 296 |
//add display converter for string representation |
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/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 |
} |
Also available in: Unified diff
ref #7095 Implement prototypical quantitative data cell editor