1 |
dedec018
|
Patrick Plitzner
|
// $Id$
|
2 |
|
|
/**
|
3 |
|
|
* Copyright (C) 2018 EDIT
|
4 |
|
|
* European Distributed Institute of Taxonomy
|
5 |
|
|
* http://www.e-taxonomy.eu
|
6 |
|
|
*
|
7 |
|
|
* The contents of this file are subject to the Mozilla Public License Version 1.1
|
8 |
|
|
* See LICENSE.TXT at the top of this package for the full license terms.
|
9 |
|
|
*/
|
10 |
|
|
package eu.etaxonomy.taxeditor.editor.descriptiveDataSet.matrix;
|
11 |
|
|
|
12 |
d12e0f5d
|
Patrick Plitzner
|
import java.util.HashMap;
|
13 |
|
|
import java.util.Map;
|
14 |
|
|
|
15 |
dedec018
|
Patrick Plitzner
|
import org.eclipse.nebula.widgets.nattable.config.AbstractRegistryConfiguration;
|
16 |
|
|
import org.eclipse.nebula.widgets.nattable.config.CellConfigAttributes;
|
17 |
|
|
import org.eclipse.nebula.widgets.nattable.config.IConfigRegistry;
|
18 |
|
|
import org.eclipse.nebula.widgets.nattable.config.IEditableRule;
|
19 |
|
|
import org.eclipse.nebula.widgets.nattable.edit.EditConfigAttributes;
|
20 |
d12e0f5d
|
Patrick Plitzner
|
import org.eclipse.nebula.widgets.nattable.edit.gui.ICellEditDialog;
|
21 |
dedec018
|
Patrick Plitzner
|
import org.eclipse.nebula.widgets.nattable.style.DisplayMode;
|
22 |
d12e0f5d
|
Patrick Plitzner
|
import org.eclipse.swt.graphics.Point;
|
23 |
dedec018
|
Patrick Plitzner
|
|
24 |
bd0b8f0e
|
Patrick Plitzner
|
import eu.etaxonomy.taxeditor.editor.descriptiveDataSet.matrix.categorical.CategoricalComboBoxDataProvider;
|
25 |
dedec018
|
Patrick Plitzner
|
import eu.etaxonomy.taxeditor.editor.descriptiveDataSet.matrix.categorical.CategoricalDataCellEditor;
|
26 |
|
|
import eu.etaxonomy.taxeditor.editor.descriptiveDataSet.matrix.categorical.CategoricalDataDisplayConverter;
|
27 |
d12e0f5d
|
Patrick Plitzner
|
import eu.etaxonomy.taxeditor.editor.descriptiveDataSet.matrix.quantitative.QuantitativeDataDialogEditor;
|
28 |
|
|
import eu.etaxonomy.taxeditor.editor.descriptiveDataSet.matrix.quantitative.QuantitativeDataEditModeDisplayConverter;
|
29 |
a42acd70
|
Patrick Plitzner
|
import eu.etaxonomy.taxeditor.editor.descriptiveDataSet.matrix.quantitative.QuantitativeDataNormalModeDisplayConverter;
|
30 |
dedec018
|
Patrick Plitzner
|
import eu.etaxonomy.taxeditor.editor.descriptiveDataSet.matrix.supplementalInfo.SupplementalInfoDisplayConverter;
|
31 |
|
|
|
32 |
|
|
/**
|
33 |
|
|
* @author pplitzner
|
34 |
|
|
* @date 09.07.2018
|
35 |
|
|
*
|
36 |
|
|
*/
|
37 |
d12e0f5d
|
Patrick Plitzner
|
final class CellEditorDataConversionConfiguration extends AbstractRegistryConfiguration {
|
38 |
dedec018
|
Patrick Plitzner
|
|
39 |
|
|
private CharacterMatrix matrix;
|
40 |
|
|
|
41 |
d12e0f5d
|
Patrick Plitzner
|
public CellEditorDataConversionConfiguration(CharacterMatrix matrix) {
|
42 |
dedec018
|
Patrick Plitzner
|
super();
|
43 |
|
|
this.matrix = matrix;
|
44 |
|
|
}
|
45 |
|
|
|
46 |
|
|
@Override
|
47 |
|
|
public void configureRegistry(IConfigRegistry configRegistry) {
|
48 |
|
|
|
49 |
|
|
//add display converter for string representation
|
50 |
|
|
configRegistry.registerConfigAttribute(
|
51 |
|
|
CellConfigAttributes.DISPLAY_CONVERTER,
|
52 |
|
|
new SupplementalInfoDisplayConverter(),
|
53 |
|
|
DisplayMode.NORMAL,
|
54 |
|
|
CharacterMatrix.TAXON_COLUMN);
|
55 |
|
|
configRegistry.registerConfigAttribute(
|
56 |
|
|
CellConfigAttributes.DISPLAY_CONVERTER,
|
57 |
|
|
new SupplementalInfoDisplayConverter(),
|
58 |
|
|
DisplayMode.NORMAL,
|
59 |
|
|
CharacterMatrix.COLLECTOR_COLUMN);
|
60 |
|
|
configRegistry.registerConfigAttribute(
|
61 |
|
|
CellConfigAttributes.DISPLAY_CONVERTER,
|
62 |
|
|
new SupplementalInfoDisplayConverter(),
|
63 |
|
|
DisplayMode.NORMAL,
|
64 |
|
|
CharacterMatrix.IDENTIFIER_COLUMN);
|
65 |
|
|
configRegistry.registerConfigAttribute(
|
66 |
|
|
CellConfigAttributes.DISPLAY_CONVERTER,
|
67 |
|
|
new SupplementalInfoDisplayConverter(),
|
68 |
|
|
DisplayMode.NORMAL,
|
69 |
|
|
CharacterMatrix.COUNTRY_COLUMN);
|
70 |
|
|
|
71 |
a42acd70
|
Patrick Plitzner
|
//---register cell editors---
|
72 |
|
|
|
73 |
7c3f1a46
|
Patrick Plitzner
|
/**
|
74 |
|
|
* categorical cell editor
|
75 |
|
|
*/
|
76 |
dedec018
|
Patrick Plitzner
|
//make cell editable
|
77 |
|
|
configRegistry.registerConfigAttribute(
|
78 |
|
|
EditConfigAttributes.CELL_EDITABLE_RULE,
|
79 |
|
|
IEditableRule.ALWAYS_EDITABLE,
|
80 |
|
|
DisplayMode.EDIT,
|
81 |
1cc08dc4
|
Patrick Plitzner
|
CharacterMatrixConfigLabelAccumulator.CATEGORICAL_EDITABLE
|
82 |
a42acd70
|
Patrick Plitzner
|
);
|
83 |
|
|
//add display converter for string representation
|
84 |
|
|
configRegistry.registerConfigAttribute(
|
85 |
|
|
CellConfigAttributes.DISPLAY_CONVERTER,
|
86 |
|
|
new CategoricalDataDisplayConverter(),
|
87 |
|
|
DisplayMode.NORMAL,
|
88 |
|
|
CharacterMatrixConfigLabelAccumulator.CATEGORICAL
|
89 |
dedec018
|
Patrick Plitzner
|
);
|
90 |
bd0b8f0e
|
Patrick Plitzner
|
//register categorical editor
|
91 |
|
|
configRegistry.registerConfigAttribute(EditConfigAttributes.CELL_EDITOR,
|
92 |
|
|
new CategoricalDataCellEditor(matrix, new CategoricalComboBoxDataProvider(matrix)),
|
93 |
|
|
DisplayMode.EDIT,
|
94 |
1cc08dc4
|
Patrick Plitzner
|
CharacterMatrixConfigLabelAccumulator.CATEGORICAL_EDITABLE
|
95 |
bd0b8f0e
|
Patrick Plitzner
|
);
|
96 |
d12e0f5d
|
Patrick Plitzner
|
|
97 |
dedec018
|
Patrick Plitzner
|
|
98 |
7c3f1a46
|
Patrick Plitzner
|
/**
|
99 |
|
|
* quantitative cell editor
|
100 |
|
|
*/
|
101 |
a42acd70
|
Patrick Plitzner
|
//make cell editable
|
102 |
|
|
configRegistry.registerConfigAttribute(
|
103 |
|
|
EditConfigAttributes.CELL_EDITABLE_RULE,
|
104 |
|
|
IEditableRule.ALWAYS_EDITABLE,
|
105 |
|
|
DisplayMode.EDIT,
|
106 |
1cc08dc4
|
Patrick Plitzner
|
CharacterMatrixConfigLabelAccumulator.QUANTITATIVE_EDITABLE
|
107 |
a42acd70
|
Patrick Plitzner
|
);
|
108 |
7c3f1a46
|
Patrick Plitzner
|
//add display converter for string representation
|
109 |
a42acd70
|
Patrick Plitzner
|
configRegistry.registerConfigAttribute(
|
110 |
|
|
CellConfigAttributes.DISPLAY_CONVERTER,
|
111 |
|
|
new QuantitativeDataEditModeDisplayConverter(),
|
112 |
|
|
DisplayMode.EDIT,
|
113 |
1cc08dc4
|
Patrick Plitzner
|
CharacterMatrixConfigLabelAccumulator.QUANTITATIVE_EDITABLE);
|
114 |
a42acd70
|
Patrick Plitzner
|
configRegistry.registerConfigAttribute(
|
115 |
|
|
CellConfigAttributes.DISPLAY_CONVERTER,
|
116 |
|
|
new QuantitativeDataNormalModeDisplayConverter(),
|
117 |
|
|
DisplayMode.NORMAL,
|
118 |
|
|
CharacterMatrixConfigLabelAccumulator.QUANTITATIVE);
|
119 |
7c3f1a46
|
Patrick Plitzner
|
|
120 |
|
|
//Open cell editor in dialog
|
121 |
a42acd70
|
Patrick Plitzner
|
configRegistry.registerConfigAttribute(
|
122 |
|
|
EditConfigAttributes.OPEN_IN_DIALOG,
|
123 |
|
|
Boolean.TRUE,
|
124 |
|
|
DisplayMode.EDIT,
|
125 |
1cc08dc4
|
Patrick Plitzner
|
CharacterMatrixConfigLabelAccumulator.QUANTITATIVE_EDITABLE);
|
126 |
a42acd70
|
Patrick Plitzner
|
//register quantitative editor
|
127 |
|
|
configRegistry.registerConfigAttribute(
|
128 |
|
|
EditConfigAttributes.CELL_EDITOR,
|
129 |
|
|
new QuantitativeDataDialogEditor(matrix),
|
130 |
|
|
DisplayMode.EDIT,
|
131 |
1cc08dc4
|
Patrick Plitzner
|
CharacterMatrixConfigLabelAccumulator.QUANTITATIVE_EDITABLE);
|
132 |
a42acd70
|
Patrick Plitzner
|
// configure custom dialog settings
|
133 |
|
|
Map<String, Object> editDialogSettings = new HashMap<>();
|
134 |
|
|
editDialogSettings.put(ICellEditDialog.DIALOG_SHELL_TITLE, "Quantitative Data");
|
135 |
|
|
editDialogSettings.put(ICellEditDialog.DIALOG_SHELL_RESIZABLE, Boolean.TRUE);
|
136 |
|
|
|
137 |
6e927caf
|
Patrick Plitzner
|
Point size = new Point(250, 300);
|
138 |
a42acd70
|
Patrick Plitzner
|
editDialogSettings.put(ICellEditDialog.DIALOG_SHELL_SIZE, size);
|
139 |
|
|
|
140 |
|
|
//FIXME: this is not displayed because the cell editor
|
141 |
|
|
//is already a dialog. Maybe the cell editor and the
|
142 |
|
|
//dialog can be merged
|
143 |
|
|
editDialogSettings.put(ICellEditDialog.DIALOG_MESSAGE, "Enter exact values:");
|
144 |
|
|
|
145 |
|
|
configRegistry.registerConfigAttribute(
|
146 |
|
|
EditConfigAttributes.EDIT_DIALOG_SETTINGS,
|
147 |
|
|
editDialogSettings,
|
148 |
|
|
DisplayMode.EDIT,
|
149 |
1cc08dc4
|
Patrick Plitzner
|
CharacterMatrixConfigLabelAccumulator.QUANTITATIVE_EDITABLE);
|
150 |
a42acd70
|
Patrick Plitzner
|
}
|
151 |
|
|
|
152 |
dedec018
|
Patrick Plitzner
|
}
|