Revision 1cc08dc4
ref #7674 Disable cell editor for aggregated taxon descriptions
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/descriptiveDataSet/matrix/CellEditorDataConversionConfiguration.java | ||
---|---|---|
78 | 78 |
EditConfigAttributes.CELL_EDITABLE_RULE, |
79 | 79 |
IEditableRule.ALWAYS_EDITABLE, |
80 | 80 |
DisplayMode.EDIT, |
81 |
CharacterMatrixConfigLabelAccumulator.CATEGORICAL |
|
81 |
CharacterMatrixConfigLabelAccumulator.CATEGORICAL_EDITABLE
|
|
82 | 82 |
); |
83 | 83 |
//add display converter for string representation |
84 | 84 |
configRegistry.registerConfigAttribute( |
... | ... | |
91 | 91 |
configRegistry.registerConfigAttribute(EditConfigAttributes.CELL_EDITOR, |
92 | 92 |
new CategoricalDataCellEditor(matrix, new CategoricalComboBoxDataProvider(matrix)), |
93 | 93 |
DisplayMode.EDIT, |
94 |
CharacterMatrixConfigLabelAccumulator.CATEGORICAL |
|
94 |
CharacterMatrixConfigLabelAccumulator.CATEGORICAL_EDITABLE
|
|
95 | 95 |
); |
96 | 96 |
|
97 | 97 |
|
... | ... | |
103 | 103 |
EditConfigAttributes.CELL_EDITABLE_RULE, |
104 | 104 |
IEditableRule.ALWAYS_EDITABLE, |
105 | 105 |
DisplayMode.EDIT, |
106 |
CharacterMatrixConfigLabelAccumulator.QUANTITATIVE |
|
106 |
CharacterMatrixConfigLabelAccumulator.QUANTITATIVE_EDITABLE
|
|
107 | 107 |
); |
108 | 108 |
//add display converter for string representation |
109 | 109 |
configRegistry.registerConfigAttribute( |
110 | 110 |
CellConfigAttributes.DISPLAY_CONVERTER, |
111 | 111 |
new QuantitativeDataEditModeDisplayConverter(), |
112 | 112 |
DisplayMode.EDIT, |
113 |
CharacterMatrixConfigLabelAccumulator.QUANTITATIVE); |
|
113 |
CharacterMatrixConfigLabelAccumulator.QUANTITATIVE_EDITABLE);
|
|
114 | 114 |
configRegistry.registerConfigAttribute( |
115 | 115 |
CellConfigAttributes.DISPLAY_CONVERTER, |
116 | 116 |
new QuantitativeDataNormalModeDisplayConverter(), |
... | ... | |
122 | 122 |
EditConfigAttributes.OPEN_IN_DIALOG, |
123 | 123 |
Boolean.TRUE, |
124 | 124 |
DisplayMode.EDIT, |
125 |
CharacterMatrixConfigLabelAccumulator.QUANTITATIVE); |
|
125 |
CharacterMatrixConfigLabelAccumulator.QUANTITATIVE_EDITABLE);
|
|
126 | 126 |
//register quantitative editor |
127 | 127 |
configRegistry.registerConfigAttribute( |
128 | 128 |
EditConfigAttributes.CELL_EDITOR, |
129 | 129 |
new QuantitativeDataDialogEditor(matrix), |
130 | 130 |
DisplayMode.EDIT, |
131 |
CharacterMatrixConfigLabelAccumulator.QUANTITATIVE); |
|
131 |
CharacterMatrixConfigLabelAccumulator.QUANTITATIVE_EDITABLE);
|
|
132 | 132 |
// configure custom dialog settings |
133 | 133 |
Map<String, Object> editDialogSettings = new HashMap<>(); |
134 | 134 |
editDialogSettings.put(ICellEditDialog.DIALOG_SHELL_TITLE, "Quantitative Data"); |
... | ... | |
146 | 146 |
EditConfigAttributes.EDIT_DIALOG_SETTINGS, |
147 | 147 |
editDialogSettings, |
148 | 148 |
DisplayMode.EDIT, |
149 |
CharacterMatrixConfigLabelAccumulator.QUANTITATIVE); |
|
149 |
CharacterMatrixConfigLabelAccumulator.QUANTITATIVE_EDITABLE);
|
|
150 | 150 |
} |
151 | 151 |
|
152 | 152 |
} |
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/descriptiveDataSet/matrix/CharacterMatrixConfigLabelAccumulator.java | ||
---|---|---|
12 | 12 |
import org.eclipse.nebula.widgets.nattable.layer.cell.IConfigLabelAccumulator; |
13 | 13 |
|
14 | 14 |
import eu.etaxonomy.cdm.api.service.dto.TaxonRowWrapperDTO; |
15 |
import eu.etaxonomy.cdm.model.common.MarkerType; |
|
16 | 15 |
import eu.etaxonomy.cdm.model.description.Feature; |
17 |
import eu.etaxonomy.cdm.model.description.TaxonDescription; |
|
18 | 16 |
import eu.etaxonomy.cdm.model.taxon.TaxonNode; |
19 | 17 |
|
20 | 18 |
/** |
... | ... | |
26 | 24 |
|
27 | 25 |
public static final String QUANTITATIVE = "QUANTITATIVE"; |
28 | 26 |
public static final String CATEGORICAL = "CATEGORICAL"; |
27 |
public static final String CATEGORICAL_EDITABLE = CATEGORICAL+"_EDITABLE"; |
|
28 |
public static final String QUANTITATIVE_EDITABLE = QUANTITATIVE+"_EDITABLE"; |
|
29 | 29 |
|
30 | 30 |
private CharacterMatrix matrix; |
31 | 31 |
|
... | ... | |
36 | 36 |
|
37 | 37 |
@Override |
38 | 38 |
public void accumulateConfigLabels(LabelStack configLabels, int columnPosition, int rowPosition) { |
39 |
boolean isEditable = true; |
|
40 |
|
|
39 | 41 |
Object rowObject = matrix.getBodyDataProvider().getRowObject(rowPosition); |
40 | 42 |
if(rowObject instanceof TaxonNode){ |
41 | 43 |
configLabels.addLabel(CharacterMatrix.LABEL_TAXON_ROW); |
42 | 44 |
} |
43 | 45 |
else if(rowObject instanceof TaxonRowWrapperDTO){ |
44 |
TaxonDescription taxonDescription = ((TaxonRowWrapperDTO) rowObject).getDescription(); |
|
45 |
boolean isComputed = taxonDescription.getMarkers().stream() |
|
46 |
.anyMatch(marker->marker.getMarkerType().equals(MarkerType.COMPUTED())); |
|
47 |
if(isComputed){ |
|
46 |
if(MatrixUtility.isEntityComputed(((TaxonRowWrapperDTO) rowObject).getDescription())){ |
|
48 | 47 |
configLabels.addLabel(CharacterMatrix.LABEL_TAXON_AGGREGATED_DESCRIPTION); |
48 |
isEditable = false; |
|
49 | 49 |
} |
50 | 50 |
else{ |
51 | 51 |
configLabels.addLabel(CharacterMatrix.LABEL_TAXON_DESCRIPTION); |
... | ... | |
69 | 69 |
configLabels.addLabel(MatrixUtility.getProperty(feature)); |
70 | 70 |
if(feature.isSupportsCategoricalData()){ |
71 | 71 |
configLabels.addLabel(CATEGORICAL); |
72 |
if(isEditable){ |
|
73 |
configLabels.addLabel(CATEGORICAL_EDITABLE); |
|
74 |
} |
|
72 | 75 |
} |
73 | 76 |
else if(feature.isSupportsQuantitativeData()){ |
74 | 77 |
configLabels.addLabel(QUANTITATIVE); |
78 |
if(isEditable){ |
|
79 |
configLabels.addLabel(QUANTITATIVE_EDITABLE); |
|
80 |
} |
|
75 | 81 |
} |
76 | 82 |
} |
77 | 83 |
} |
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/descriptiveDataSet/matrix/MatrixUtility.java | ||
---|---|---|
11 | 11 |
import java.util.Set; |
12 | 12 |
import java.util.stream.Collectors; |
13 | 13 |
|
14 |
import eu.etaxonomy.cdm.model.common.AnnotatableEntity; |
|
15 |
import eu.etaxonomy.cdm.model.common.MarkerType; |
|
14 | 16 |
import eu.etaxonomy.cdm.model.description.DescriptiveDataSet; |
15 | 17 |
import eu.etaxonomy.cdm.model.description.Feature; |
16 | 18 |
import eu.etaxonomy.cdm.model.description.QuantitativeData; |
... | ... | |
67 | 69 |
+(max==null?"":"("+max.toString()+")"); //$NON-NLS-1$ |
68 | 70 |
} |
69 | 71 |
|
72 |
/** |
|
73 |
* Checks if the given entity has any marker of type |
|
74 |
* {@link MarkerType#COMPUTED()} |
|
75 |
* |
|
76 |
* @param entity |
|
77 |
* the entity to check |
|
78 |
* @return <code>true</code> of a computed marker was found, |
|
79 |
* <code>false</code> otherwise |
|
80 |
*/ |
|
81 |
public static boolean isEntityComputed(AnnotatableEntity entity){ |
|
82 |
return entity.getMarkers().stream() |
|
83 |
.anyMatch(marker->marker.getMarkerType().equals(MarkerType.COMPUTED())); |
|
84 |
} |
|
85 |
|
|
70 | 86 |
|
71 | 87 |
public static Classification getClassificationForDescriptiveDataSet(DescriptiveDataSet descriptiveDataSet){ |
72 | 88 |
Set<TaxonNode> taxonSubtreeFilter = descriptiveDataSet.getTaxonSubtreeFilter(); |
Also available in: Unified diff