Revision dedec018
Added by Patrick Plitzner about 5 years ago
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/descriptiveDataSet/matrix/CharacterMatrix.java | ||
---|---|---|
27 | 27 |
import org.eclipse.jface.viewers.ComboViewer; |
28 | 28 |
import org.eclipse.jface.viewers.StructuredSelection; |
29 | 29 |
import org.eclipse.nebula.widgets.nattable.NatTable; |
30 |
import org.eclipse.nebula.widgets.nattable.config.AbstractRegistryConfiguration; |
|
31 |
import org.eclipse.nebula.widgets.nattable.config.CellConfigAttributes; |
|
32 | 30 |
import org.eclipse.nebula.widgets.nattable.config.ConfigRegistry; |
33 | 31 |
import org.eclipse.nebula.widgets.nattable.config.DefaultNatTableStyleConfiguration; |
34 |
import org.eclipse.nebula.widgets.nattable.config.IConfigRegistry; |
|
35 |
import org.eclipse.nebula.widgets.nattable.config.IEditableRule; |
|
36 | 32 |
import org.eclipse.nebula.widgets.nattable.coordinate.PositionCoordinate; |
37 | 33 |
import org.eclipse.nebula.widgets.nattable.data.IDataProvider; |
38 | 34 |
import org.eclipse.nebula.widgets.nattable.data.ListDataProvider; |
39 |
import org.eclipse.nebula.widgets.nattable.edit.EditConfigAttributes; |
|
40 | 35 |
import org.eclipse.nebula.widgets.nattable.export.command.ExportCommandHandler; |
41 | 36 |
import org.eclipse.nebula.widgets.nattable.extension.glazedlists.GlazedListsEventLayer; |
42 | 37 |
import org.eclipse.nebula.widgets.nattable.extension.glazedlists.GlazedListsSortModel; |
... | ... | |
67 | 62 |
import org.eclipse.nebula.widgets.nattable.selection.event.CellSelectionEvent; |
68 | 63 |
import org.eclipse.nebula.widgets.nattable.sort.SortHeaderLayer; |
69 | 64 |
import org.eclipse.nebula.widgets.nattable.sort.config.SingleClickSortConfiguration; |
70 |
import org.eclipse.nebula.widgets.nattable.style.DisplayMode; |
|
71 | 65 |
import org.eclipse.nebula.widgets.nattable.style.HorizontalAlignmentEnum; |
72 | 66 |
import org.eclipse.nebula.widgets.nattable.style.theme.ModernNatTableThemeConfiguration; |
73 |
import org.eclipse.nebula.widgets.nattable.summaryrow.DefaultSummaryRowConfiguration; |
|
74 | 67 |
import org.eclipse.nebula.widgets.nattable.summaryrow.FixedSummaryRowLayer; |
75 |
import org.eclipse.nebula.widgets.nattable.summaryrow.ISummaryProvider; |
|
76 |
import org.eclipse.nebula.widgets.nattable.summaryrow.SummaryRowConfigAttributes; |
|
77 | 68 |
import org.eclipse.nebula.widgets.nattable.summaryrow.SummaryRowLayer; |
78 | 69 |
import org.eclipse.nebula.widgets.nattable.tree.ITreeRowModel; |
79 | 70 |
import org.eclipse.nebula.widgets.nattable.tree.TreeLayer; |
... | ... | |
104 | 95 |
import eu.etaxonomy.cdm.model.description.SpecimenDescription; |
105 | 96 |
import eu.etaxonomy.cdm.model.description.State; |
106 | 97 |
import eu.etaxonomy.cdm.persistence.dto.SpecimenNodeWrapper; |
107 |
import eu.etaxonomy.taxeditor.editor.descriptiveDataSet.matrix.categorical.CategoricalDataCellEditor; |
|
108 |
import eu.etaxonomy.taxeditor.editor.descriptiveDataSet.matrix.categorical.CategoricalDataDisplayConverter; |
|
109 |
import eu.etaxonomy.taxeditor.editor.descriptiveDataSet.matrix.quantitative.QuantitativeDataCellEditor; |
|
110 |
import eu.etaxonomy.taxeditor.editor.descriptiveDataSet.matrix.quantitative.QuantitativeDataDisplayConverter; |
|
111 |
import eu.etaxonomy.taxeditor.editor.descriptiveDataSet.matrix.supplementalInfo.SupplementalInfoDisplayConverter; |
|
112 | 98 |
import eu.etaxonomy.taxeditor.editor.l10n.Messages; |
113 | 99 |
import eu.etaxonomy.taxeditor.model.MessagingUtils; |
114 | 100 |
import eu.etaxonomy.taxeditor.store.CdmStore; |
... | ... | |
493 | 479 |
natTable.registerCommandHandler(toolbar.getDisplayPersistenceDialogCommandHandler()); |
494 | 480 |
} |
495 | 481 |
|
496 |
private void configureNatTable(boolean treeView, ConfigRegistry configRegistry, AbstractLayer topMostLayer, |
|
482 |
private void configureNatTable(boolean treeView, |
|
483 |
ConfigRegistry configRegistry, |
|
484 |
AbstractLayer topMostLayer, |
|
497 | 485 |
FixedSummaryRowLayer summaryRowLayer) { |
498 | 486 |
/** |
499 | 487 |
* CONFIGURATION |
... | ... | |
530 | 518 |
}); |
531 | 519 |
|
532 | 520 |
// add custom configuration for data conversion and add column labels to viewport layer |
533 |
topMostLayer.addConfiguration(new AbstractRegistryConfiguration() { |
|
534 |
@Override |
|
535 |
public void configureRegistry(IConfigRegistry configRegistry) { |
|
536 |
|
|
537 |
//add display converter for string representation |
|
538 |
configRegistry.registerConfigAttribute( |
|
539 |
CellConfigAttributes.DISPLAY_CONVERTER, |
|
540 |
new SupplementalInfoDisplayConverter(), |
|
541 |
DisplayMode.NORMAL, |
|
542 |
TAXON_COLUMN); |
|
543 |
configRegistry.registerConfigAttribute( |
|
544 |
CellConfigAttributes.DISPLAY_CONVERTER, |
|
545 |
new SupplementalInfoDisplayConverter(), |
|
546 |
DisplayMode.NORMAL, |
|
547 |
COLLECTOR_COLUMN); |
|
548 |
configRegistry.registerConfigAttribute( |
|
549 |
CellConfigAttributes.DISPLAY_CONVERTER, |
|
550 |
new SupplementalInfoDisplayConverter(), |
|
551 |
DisplayMode.NORMAL, |
|
552 |
IDENTIFIER_COLUMN); |
|
553 |
configRegistry.registerConfigAttribute( |
|
554 |
CellConfigAttributes.DISPLAY_CONVERTER, |
|
555 |
new SupplementalInfoDisplayConverter(), |
|
556 |
DisplayMode.NORMAL, |
|
557 |
COUNTRY_COLUMN); |
|
558 |
features.forEach(feature->registerColumnConfiguration(feature, configRegistry)); |
|
559 |
} |
|
560 |
|
|
561 |
}); |
|
521 |
topMostLayer.addConfiguration(new DataConversionConfiguration(this)); |
|
562 | 522 |
|
563 | 523 |
//no summary for the supplemental columns |
564 |
for(int i=0;i<LEADING_COLUMN_COUNT;i++){ |
|
565 |
int index = i; |
|
566 |
summaryRowLayer.addConfiguration(new DefaultSummaryRowConfiguration() { |
|
567 |
@Override |
|
568 |
public void addSummaryProviderConfig(IConfigRegistry configRegistry) { |
|
569 |
configRegistry.registerConfigAttribute( |
|
570 |
SummaryRowConfigAttributes.SUMMARY_PROVIDER, |
|
571 |
new ISummaryProvider() { |
|
572 |
|
|
573 |
@Override |
|
574 |
public Object summarize(int columnIndex) { |
|
575 |
return ""; |
|
576 |
} |
|
577 |
}, |
|
578 |
DisplayMode.NORMAL, |
|
579 |
SummaryRowLayer.DEFAULT_SUMMARY_COLUMN_CONFIG_LABEL_PREFIX+index); |
|
580 |
} |
|
581 |
}); |
|
582 |
} |
|
524 |
summaryRowLayer.addConfiguration(new SummaryRowConfiguration()); |
|
525 |
|
|
583 | 526 |
//register aggregation configuration for each feature |
584 | 527 |
features.forEach(feature->summaryRowLayer.addConfiguration(new AggregationConfiguration(bodyDataProvider, feature))); |
585 | 528 |
|
... | ... | |
627 | 570 |
propertyToLabelMap.put(property, featureLabel); |
628 | 571 |
} |
629 | 572 |
|
630 |
private void registerColumnConfiguration(Feature feature, IConfigRegistry configRegistry) { |
|
631 |
//make cell editable |
|
632 |
configRegistry.registerConfigAttribute( |
|
633 |
EditConfigAttributes.CELL_EDITABLE_RULE, |
|
634 |
IEditableRule.ALWAYS_EDITABLE, |
|
635 |
DisplayMode.EDIT, |
|
636 |
MatrixUtility.getProperty(feature) |
|
637 |
); |
|
638 |
if(feature.isSupportsQuantitativeData()){ |
|
639 |
//add display converter for string representation |
|
640 |
configRegistry.registerConfigAttribute( |
|
641 |
CellConfigAttributes.DISPLAY_CONVERTER, |
|
642 |
new QuantitativeDataDisplayConverter(), |
|
643 |
DisplayMode.NORMAL, |
|
644 |
MatrixUtility.getProperty(feature)); |
|
645 |
//register quantitative editor |
|
646 |
configRegistry.registerConfigAttribute( |
|
647 |
EditConfigAttributes.CELL_EDITOR, |
|
648 |
new QuantitativeDataCellEditor(feature, this), |
|
649 |
DisplayMode.EDIT, |
|
650 |
MatrixUtility.getProperty(feature)); |
|
651 |
} |
|
652 |
else if(feature.isSupportsCategoricalData()){ |
|
653 |
//add display converter for string representation |
|
654 |
configRegistry.registerConfigAttribute( |
|
655 |
CellConfigAttributes.DISPLAY_CONVERTER, |
|
656 |
new CategoricalDataDisplayConverter(), |
|
657 |
DisplayMode.NORMAL, |
|
658 |
MatrixUtility.getProperty(feature)); |
|
659 |
|
|
660 |
//add combo box cell editor |
|
661 |
//register editor |
|
662 |
configRegistry.registerConfigAttribute(EditConfigAttributes.CELL_EDITOR, |
|
663 |
new CategoricalDataCellEditor(getSupportedStatesForCategoricalFeature(feature), this, feature), |
|
664 |
DisplayMode.EDIT, |
|
665 |
MatrixUtility.getProperty(feature)); |
|
666 |
|
|
667 |
} |
|
668 |
|
|
669 |
} |
|
670 |
|
|
671 |
|
|
672 | 573 |
public void loadDescriptions(DescriptiveDataSet descriptiveDataSet) { |
673 | 574 |
UUID monitorUuid = CdmStore.getService(IDescriptiveDataSetService.class).monitGetRowWrapper(descriptiveDataSet); |
674 | 575 |
IProgressMonitorService progressMonitorService = CdmApplicationState.getCurrentAppConfig().getProgressMonitorService(); |
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/descriptiveDataSet/matrix/DataConversionConfiguration.java | ||
---|---|---|
1 |
// $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 |
import org.eclipse.nebula.widgets.nattable.config.AbstractRegistryConfiguration; |
|
13 |
import org.eclipse.nebula.widgets.nattable.config.CellConfigAttributes; |
|
14 |
import org.eclipse.nebula.widgets.nattable.config.IConfigRegistry; |
|
15 |
import org.eclipse.nebula.widgets.nattable.config.IEditableRule; |
|
16 |
import org.eclipse.nebula.widgets.nattable.edit.EditConfigAttributes; |
|
17 |
import org.eclipse.nebula.widgets.nattable.style.DisplayMode; |
|
18 |
|
|
19 |
import eu.etaxonomy.cdm.model.description.Feature; |
|
20 |
import eu.etaxonomy.taxeditor.editor.descriptiveDataSet.matrix.categorical.CategoricalDataCellEditor; |
|
21 |
import eu.etaxonomy.taxeditor.editor.descriptiveDataSet.matrix.categorical.CategoricalDataDisplayConverter; |
|
22 |
import eu.etaxonomy.taxeditor.editor.descriptiveDataSet.matrix.quantitative.QuantitativeDataCellEditor; |
|
23 |
import eu.etaxonomy.taxeditor.editor.descriptiveDataSet.matrix.quantitative.QuantitativeDataDisplayConverter; |
|
24 |
import eu.etaxonomy.taxeditor.editor.descriptiveDataSet.matrix.supplementalInfo.SupplementalInfoDisplayConverter; |
|
25 |
|
|
26 |
/** |
|
27 |
* @author pplitzner |
|
28 |
* @date 09.07.2018 |
|
29 |
* |
|
30 |
*/ |
|
31 |
final class DataConversionConfiguration extends AbstractRegistryConfiguration { |
|
32 |
|
|
33 |
private CharacterMatrix matrix; |
|
34 |
|
|
35 |
public DataConversionConfiguration(CharacterMatrix matrix) { |
|
36 |
super(); |
|
37 |
this.matrix = matrix; |
|
38 |
} |
|
39 |
|
|
40 |
@Override |
|
41 |
public void configureRegistry(IConfigRegistry configRegistry) { |
|
42 |
|
|
43 |
//add display converter for string representation |
|
44 |
configRegistry.registerConfigAttribute( |
|
45 |
CellConfigAttributes.DISPLAY_CONVERTER, |
|
46 |
new SupplementalInfoDisplayConverter(), |
|
47 |
DisplayMode.NORMAL, |
|
48 |
CharacterMatrix.TAXON_COLUMN); |
|
49 |
configRegistry.registerConfigAttribute( |
|
50 |
CellConfigAttributes.DISPLAY_CONVERTER, |
|
51 |
new SupplementalInfoDisplayConverter(), |
|
52 |
DisplayMode.NORMAL, |
|
53 |
CharacterMatrix.COLLECTOR_COLUMN); |
|
54 |
configRegistry.registerConfigAttribute( |
|
55 |
CellConfigAttributes.DISPLAY_CONVERTER, |
|
56 |
new SupplementalInfoDisplayConverter(), |
|
57 |
DisplayMode.NORMAL, |
|
58 |
CharacterMatrix.IDENTIFIER_COLUMN); |
|
59 |
configRegistry.registerConfigAttribute( |
|
60 |
CellConfigAttributes.DISPLAY_CONVERTER, |
|
61 |
new SupplementalInfoDisplayConverter(), |
|
62 |
DisplayMode.NORMAL, |
|
63 |
CharacterMatrix.COUNTRY_COLUMN); |
|
64 |
matrix.getFeatures().forEach(feature->registerColumnConfiguration(feature, configRegistry)); |
|
65 |
} |
|
66 |
|
|
67 |
private void registerColumnConfiguration(Feature feature, IConfigRegistry configRegistry) { |
|
68 |
//make cell editable |
|
69 |
configRegistry.registerConfigAttribute( |
|
70 |
EditConfigAttributes.CELL_EDITABLE_RULE, |
|
71 |
IEditableRule.ALWAYS_EDITABLE, |
|
72 |
DisplayMode.EDIT, |
|
73 |
MatrixUtility.getProperty(feature) |
|
74 |
); |
|
75 |
if(feature.isSupportsQuantitativeData()){ |
|
76 |
//add display converter for string representation |
|
77 |
configRegistry.registerConfigAttribute( |
|
78 |
CellConfigAttributes.DISPLAY_CONVERTER, |
|
79 |
new QuantitativeDataDisplayConverter(), |
|
80 |
DisplayMode.NORMAL, |
|
81 |
MatrixUtility.getProperty(feature)); |
|
82 |
//register quantitative editor |
|
83 |
configRegistry.registerConfigAttribute( |
|
84 |
EditConfigAttributes.CELL_EDITOR, |
|
85 |
new QuantitativeDataCellEditor(feature, matrix), |
|
86 |
DisplayMode.EDIT, |
|
87 |
MatrixUtility.getProperty(feature)); |
|
88 |
} |
|
89 |
else if(feature.isSupportsCategoricalData()){ |
|
90 |
//add display converter for string representation |
|
91 |
configRegistry.registerConfigAttribute( |
|
92 |
CellConfigAttributes.DISPLAY_CONVERTER, |
|
93 |
new CategoricalDataDisplayConverter(), |
|
94 |
DisplayMode.NORMAL, |
|
95 |
MatrixUtility.getProperty(feature)); |
|
96 |
|
|
97 |
//add combo box cell editor |
|
98 |
//register editor |
|
99 |
configRegistry.registerConfigAttribute(EditConfigAttributes.CELL_EDITOR, |
|
100 |
new CategoricalDataCellEditor(matrix.getSupportedStatesForCategoricalFeature(feature), matrix, feature), |
|
101 |
DisplayMode.EDIT, |
|
102 |
MatrixUtility.getProperty(feature)); |
|
103 |
|
|
104 |
} |
|
105 |
|
|
106 |
} |
|
107 |
} |
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/descriptiveDataSet/matrix/SummaryRowConfiguration.java | ||
---|---|---|
1 |
// $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 |
import org.eclipse.nebula.widgets.nattable.config.IConfigRegistry; |
|
13 |
import org.eclipse.nebula.widgets.nattable.style.DisplayMode; |
|
14 |
import org.eclipse.nebula.widgets.nattable.summaryrow.DefaultSummaryRowConfiguration; |
|
15 |
import org.eclipse.nebula.widgets.nattable.summaryrow.ISummaryProvider; |
|
16 |
import org.eclipse.nebula.widgets.nattable.summaryrow.SummaryRowConfigAttributes; |
|
17 |
import org.eclipse.nebula.widgets.nattable.summaryrow.SummaryRowLayer; |
|
18 |
|
|
19 |
/** |
|
20 |
* @author pplitzner |
|
21 |
* @date 09.07.2018 |
|
22 |
* |
|
23 |
*/ |
|
24 |
final class SummaryRowConfiguration extends DefaultSummaryRowConfiguration { |
|
25 |
|
|
26 |
public SummaryRowConfiguration() { |
|
27 |
super(); |
|
28 |
} |
|
29 |
|
|
30 |
|
|
31 |
@Override |
|
32 |
public void addSummaryProviderConfig(IConfigRegistry configRegistry) { |
|
33 |
for(int i=0;i<CharacterMatrix.LEADING_COLUMN_COUNT;i++){ |
|
34 |
int index = i; |
|
35 |
configRegistry.registerConfigAttribute( |
|
36 |
SummaryRowConfigAttributes.SUMMARY_PROVIDER, |
|
37 |
new ISummaryProvider() { |
|
38 |
|
|
39 |
@Override |
|
40 |
public Object summarize(int columnIndex) { |
|
41 |
return ""; |
|
42 |
} |
|
43 |
}, |
|
44 |
DisplayMode.NORMAL, |
|
45 |
SummaryRowLayer.DEFAULT_SUMMARY_COLUMN_CONFIG_LABEL_PREFIX+index); |
|
46 |
} |
|
47 |
} |
|
48 |
} |
Also available in: Unified diff
Refactor character matrix