Revision a42acd70
Added by Patrick Plitzner over 5 years ago
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/descriptiveDataSet/matrix/CellEditorDataConversionConfiguration.java | ||
---|---|---|
25 | 25 |
import eu.etaxonomy.taxeditor.editor.descriptiveDataSet.matrix.categorical.CategoricalDataCellEditor; |
26 | 26 |
import eu.etaxonomy.taxeditor.editor.descriptiveDataSet.matrix.categorical.CategoricalDataDisplayConverter; |
27 | 27 |
import eu.etaxonomy.taxeditor.editor.descriptiveDataSet.matrix.quantitative.QuantitativeDataDialogEditor; |
28 |
import eu.etaxonomy.taxeditor.editor.descriptiveDataSet.matrix.quantitative.QuantitativeDataNormalModeDisplayConverter; |
|
29 | 28 |
import eu.etaxonomy.taxeditor.editor.descriptiveDataSet.matrix.quantitative.QuantitativeDataEditModeDisplayConverter; |
29 |
import eu.etaxonomy.taxeditor.editor.descriptiveDataSet.matrix.quantitative.QuantitativeDataNormalModeDisplayConverter; |
|
30 | 30 |
import eu.etaxonomy.taxeditor.editor.descriptiveDataSet.matrix.supplementalInfo.SupplementalInfoDisplayConverter; |
31 | 31 |
|
32 | 32 |
/** |
... | ... | |
67 | 67 |
new SupplementalInfoDisplayConverter(), |
68 | 68 |
DisplayMode.NORMAL, |
69 | 69 |
CharacterMatrix.COUNTRY_COLUMN); |
70 |
matrix.getFeatures().forEach(feature->registerColumnConfiguration(feature, configRegistry)); |
|
71 |
} |
|
72 | 70 |
|
73 |
private void registerColumnConfiguration(Feature feature, IConfigRegistry configRegistry) { |
|
71 |
//---register cell editors--- |
|
72 |
|
|
73 |
//categorical cell editor |
|
74 | 74 |
//make cell editable |
75 | 75 |
configRegistry.registerConfigAttribute( |
76 | 76 |
EditConfigAttributes.CELL_EDITABLE_RULE, |
77 | 77 |
IEditableRule.ALWAYS_EDITABLE, |
78 | 78 |
DisplayMode.EDIT, |
79 |
MatrixUtility.getProperty(feature) |
|
79 |
CharacterMatrixConfigLabelAccumulator.CATEGORICAL |
|
80 |
); |
|
81 |
//add display converter for string representation |
|
82 |
configRegistry.registerConfigAttribute( |
|
83 |
CellConfigAttributes.DISPLAY_CONVERTER, |
|
84 |
new CategoricalDataDisplayConverter(), |
|
85 |
DisplayMode.NORMAL, |
|
86 |
CharacterMatrixConfigLabelAccumulator.CATEGORICAL |
|
80 | 87 |
); |
81 |
if(feature.isSupportsQuantitativeData()){ |
|
82 |
//add display converter for string representation |
|
83 |
configRegistry.registerConfigAttribute( |
|
84 |
CellConfigAttributes.DISPLAY_CONVERTER, |
|
85 |
new QuantitativeDataEditModeDisplayConverter(), |
|
86 |
DisplayMode.EDIT, |
|
87 |
MatrixUtility.getProperty(feature)); |
|
88 |
configRegistry.registerConfigAttribute( |
|
89 |
CellConfigAttributes.DISPLAY_CONVERTER, |
|
90 |
new QuantitativeDataNormalModeDisplayConverter(), |
|
91 |
DisplayMode.NORMAL, |
|
92 |
MatrixUtility.getProperty(feature)); |
|
93 |
//Open cell editorin dialog |
|
94 |
configRegistry.registerConfigAttribute( |
|
95 |
EditConfigAttributes.OPEN_IN_DIALOG, |
|
96 |
Boolean.TRUE, |
|
97 |
DisplayMode.EDIT, |
|
98 |
MatrixUtility.getProperty(feature)); |
|
99 |
//register quantitative editor |
|
100 |
configRegistry.registerConfigAttribute( |
|
101 |
EditConfigAttributes.CELL_EDITOR, |
|
102 |
new QuantitativeDataDialogEditor(matrix), |
|
103 |
DisplayMode.EDIT, |
|
104 |
MatrixUtility.getProperty(feature)); |
|
105 |
// configure custom dialog settings |
|
106 |
Map<String, Object> editDialogSettings = new HashMap<>(); |
|
107 |
editDialogSettings.put(ICellEditDialog.DIALOG_SHELL_TITLE, "Quantitative Data"); |
|
108 |
editDialogSettings.put(ICellEditDialog.DIALOG_SHELL_RESIZABLE, Boolean.TRUE); |
|
109 |
|
|
110 |
Point size = new Point(230, 300); |
|
111 |
editDialogSettings.put(ICellEditDialog.DIALOG_SHELL_SIZE, size); |
|
112 |
|
|
113 |
// add custum message |
|
114 |
//FIXME: this is not displayed because the cell editor |
|
115 |
//is already a dialog. Maybe the cell editor and the |
|
116 |
//dialog can be merged |
|
117 |
editDialogSettings.put(ICellEditDialog.DIALOG_MESSAGE, "Enter exact values:"); |
|
118 |
|
|
119 |
configRegistry.registerConfigAttribute( |
|
120 |
EditConfigAttributes.EDIT_DIALOG_SETTINGS, |
|
121 |
editDialogSettings, |
|
122 |
DisplayMode.EDIT, |
|
123 |
MatrixUtility.getProperty(feature)); |
|
124 | 88 |
|
125 |
} |
|
126 |
else if(feature.isSupportsCategoricalData()){ |
|
127 |
//add display converter for string representation |
|
128 |
configRegistry.registerConfigAttribute( |
|
129 |
CellConfigAttributes.DISPLAY_CONVERTER, |
|
130 |
new CategoricalDataDisplayConverter(), |
|
131 |
DisplayMode.NORMAL, |
|
132 |
MatrixUtility.getProperty(feature)); |
|
133 | 89 |
|
90 |
//quantitative cell editor |
|
91 |
//make cell editable |
|
92 |
configRegistry.registerConfigAttribute( |
|
93 |
EditConfigAttributes.CELL_EDITABLE_RULE, |
|
94 |
IEditableRule.ALWAYS_EDITABLE, |
|
95 |
DisplayMode.EDIT, |
|
96 |
CharacterMatrixConfigLabelAccumulator.QUANTITATIVE |
|
97 |
); |
|
98 |
//add display converter for string representation |
|
99 |
configRegistry.registerConfigAttribute( |
|
100 |
CellConfigAttributes.DISPLAY_CONVERTER, |
|
101 |
new QuantitativeDataEditModeDisplayConverter(), |
|
102 |
DisplayMode.EDIT, |
|
103 |
CharacterMatrixConfigLabelAccumulator.QUANTITATIVE); |
|
104 |
configRegistry.registerConfigAttribute( |
|
105 |
CellConfigAttributes.DISPLAY_CONVERTER, |
|
106 |
new QuantitativeDataNormalModeDisplayConverter(), |
|
107 |
DisplayMode.NORMAL, |
|
108 |
CharacterMatrixConfigLabelAccumulator.QUANTITATIVE); |
|
109 |
//Open cell editorin dialog |
|
110 |
configRegistry.registerConfigAttribute( |
|
111 |
EditConfigAttributes.OPEN_IN_DIALOG, |
|
112 |
Boolean.TRUE, |
|
113 |
DisplayMode.EDIT, |
|
114 |
CharacterMatrixConfigLabelAccumulator.QUANTITATIVE); |
|
115 |
//register quantitative editor |
|
116 |
configRegistry.registerConfigAttribute( |
|
117 |
EditConfigAttributes.CELL_EDITOR, |
|
118 |
new QuantitativeDataDialogEditor(matrix), |
|
119 |
DisplayMode.EDIT, |
|
120 |
CharacterMatrixConfigLabelAccumulator.QUANTITATIVE); |
|
121 |
// configure custom dialog settings |
|
122 |
Map<String, Object> editDialogSettings = new HashMap<>(); |
|
123 |
editDialogSettings.put(ICellEditDialog.DIALOG_SHELL_TITLE, "Quantitative Data"); |
|
124 |
editDialogSettings.put(ICellEditDialog.DIALOG_SHELL_RESIZABLE, Boolean.TRUE); |
|
125 |
|
|
126 |
Point size = new Point(230, 300); |
|
127 |
editDialogSettings.put(ICellEditDialog.DIALOG_SHELL_SIZE, size); |
|
128 |
|
|
129 |
// add custum message |
|
130 |
//FIXME: this is not displayed because the cell editor |
|
131 |
//is already a dialog. Maybe the cell editor and the |
|
132 |
//dialog can be merged |
|
133 |
editDialogSettings.put(ICellEditDialog.DIALOG_MESSAGE, "Enter exact values:"); |
|
134 |
|
|
135 |
configRegistry.registerConfigAttribute( |
|
136 |
EditConfigAttributes.EDIT_DIALOG_SETTINGS, |
|
137 |
editDialogSettings, |
|
138 |
DisplayMode.EDIT, |
|
139 |
CharacterMatrixConfigLabelAccumulator.QUANTITATIVE); |
|
140 |
|
|
141 |
|
|
142 |
//TODO: this for loop can maybe be avoided |
|
143 |
matrix.getFeatures().forEach(feature->registerColumnConfiguration(feature, configRegistry)); |
|
144 |
} |
|
145 |
|
|
146 |
private void registerColumnConfiguration(Feature feature, IConfigRegistry configRegistry) { |
|
147 |
if(feature.isSupportsCategoricalData()){ |
|
134 | 148 |
//add combo box cell editor |
135 | 149 |
//register editor |
136 | 150 |
configRegistry.registerConfigAttribute(EditConfigAttributes.CELL_EDITOR, |
Also available in: Unified diff
ref #7575 Refactor label accumulation