3 * Copyright (C) 2018 EDIT
4 * European Distributed Institute of Taxonomy
5 * http://www.e-taxonomy.eu
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.
10 package eu
.etaxonomy
.taxeditor
.editor
.descriptiveDataSet
.matrix
;
12 import java
.util
.HashMap
;
15 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 import org
.eclipse
.nebula
.widgets
.nattable
.edit
.gui
.ICellEditDialog
;
21 import org
.eclipse
.nebula
.widgets
.nattable
.style
.DisplayMode
;
22 import org
.eclipse
.swt
.graphics
.Point
;
24 import eu
.etaxonomy
.taxeditor
.editor
.descriptiveDataSet
.matrix
.categorical
.CategoricalComboBoxDataProvider
;
25 import eu
.etaxonomy
.taxeditor
.editor
.descriptiveDataSet
.matrix
.categorical
.CategoricalDataCellEditor
;
26 import eu
.etaxonomy
.taxeditor
.editor
.descriptiveDataSet
.matrix
.categorical
.CategoricalDataDisplayConverter
;
27 import eu
.etaxonomy
.taxeditor
.editor
.descriptiveDataSet
.matrix
.quantitative
.QuantitativeDataDialogEditor
;
28 import eu
.etaxonomy
.taxeditor
.editor
.descriptiveDataSet
.matrix
.quantitative
.QuantitativeDataEditModeDisplayConverter
;
29 import eu
.etaxonomy
.taxeditor
.editor
.descriptiveDataSet
.matrix
.quantitative
.QuantitativeDataNormalModeDisplayConverter
;
30 import eu
.etaxonomy
.taxeditor
.editor
.descriptiveDataSet
.matrix
.supplementalInfo
.SupplementalInfoDisplayConverter
;
37 final class CellEditorDataConversionConfiguration
extends AbstractRegistryConfiguration
{
39 private CharacterMatrix matrix
;
41 public CellEditorDataConversionConfiguration(CharacterMatrix matrix
) {
47 public void configureRegistry(IConfigRegistry configRegistry
) {
49 //add display converter for string representation
50 configRegistry
.registerConfigAttribute(
51 CellConfigAttributes
.DISPLAY_CONVERTER
,
52 new SupplementalInfoDisplayConverter(),
54 CharacterMatrix
.TAXON_COLUMN
);
55 configRegistry
.registerConfigAttribute(
56 CellConfigAttributes
.DISPLAY_CONVERTER
,
57 new SupplementalInfoDisplayConverter(),
59 CharacterMatrix
.COLLECTOR_COLUMN
);
60 configRegistry
.registerConfigAttribute(
61 CellConfigAttributes
.DISPLAY_CONVERTER
,
62 new SupplementalInfoDisplayConverter(),
64 CharacterMatrix
.IDENTIFIER_COLUMN
);
65 configRegistry
.registerConfigAttribute(
66 CellConfigAttributes
.DISPLAY_CONVERTER
,
67 new SupplementalInfoDisplayConverter(),
69 CharacterMatrix
.COUNTRY_COLUMN
);
71 //---register cell editors---
74 * categorical cell editor
77 configRegistry
.registerConfigAttribute(
78 EditConfigAttributes
.CELL_EDITABLE_RULE
,
79 IEditableRule
.ALWAYS_EDITABLE
,
81 CharacterMatrixConfigLabelAccumulator
.CATEGORICAL
83 //add display converter for string representation
84 configRegistry
.registerConfigAttribute(
85 CellConfigAttributes
.DISPLAY_CONVERTER
,
86 new CategoricalDataDisplayConverter(),
88 CharacterMatrixConfigLabelAccumulator
.CATEGORICAL
90 //register categorical editor
91 configRegistry
.registerConfigAttribute(EditConfigAttributes
.CELL_EDITOR
,
92 new CategoricalDataCellEditor(matrix
, new CategoricalComboBoxDataProvider(matrix
)),
94 CharacterMatrixConfigLabelAccumulator
.CATEGORICAL
99 * quantitative cell editor
102 configRegistry
.registerConfigAttribute(
103 EditConfigAttributes
.CELL_EDITABLE_RULE
,
104 IEditableRule
.ALWAYS_EDITABLE
,
106 CharacterMatrixConfigLabelAccumulator
.QUANTITATIVE
108 //add display converter for string representation
109 configRegistry
.registerConfigAttribute(
110 CellConfigAttributes
.DISPLAY_CONVERTER
,
111 new QuantitativeDataEditModeDisplayConverter(),
113 CharacterMatrixConfigLabelAccumulator
.QUANTITATIVE
);
114 configRegistry
.registerConfigAttribute(
115 CellConfigAttributes
.DISPLAY_CONVERTER
,
116 new QuantitativeDataNormalModeDisplayConverter(),
118 CharacterMatrixConfigLabelAccumulator
.QUANTITATIVE
);
120 //Open cell editor in dialog
121 configRegistry
.registerConfigAttribute(
122 EditConfigAttributes
.OPEN_IN_DIALOG
,
125 CharacterMatrixConfigLabelAccumulator
.QUANTITATIVE
);
126 //register quantitative editor
127 configRegistry
.registerConfigAttribute(
128 EditConfigAttributes
.CELL_EDITOR
,
129 new QuantitativeDataDialogEditor(matrix
),
131 CharacterMatrixConfigLabelAccumulator
.QUANTITATIVE
);
132 // 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
);
137 Point size
= new Point(250, 300);
138 editDialogSettings
.put(ICellEditDialog
.DIALOG_SHELL_SIZE
, size
);
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:");
145 configRegistry
.registerConfigAttribute(
146 EditConfigAttributes
.EDIT_DIALOG_SETTINGS
,
149 CharacterMatrixConfigLabelAccumulator
.QUANTITATIVE
);