2 * Copyright (C) 2017 EDIT
3 * European Distributed Institute of Taxonomy
4 * http://www.e-taxonomy.eu
6 * The contents of this file are subject to the Mozilla Public License Version 1.1
7 * See LICENSE.TXT at the top of this package for the full license terms.
9 package eu
.etaxonomy
.taxeditor
.editor
.descriptiveDataSet
.matrix
;
12 import java
.util
.ArrayList
;
13 import java
.util
.Collection
;
14 import java
.util
.HashMap
;
15 import java
.util
.List
;
17 import java
.util
.Properties
;
19 import java
.util
.UUID
;
20 import java
.util
.stream
.Collectors
;
22 import javax
.inject
.Inject
;
24 import org
.apache
.commons
.collections4
.map
.LinkedMap
;
25 import org
.eclipse
.core
.runtime
.ICoreRunnable
;
26 import org
.eclipse
.core
.runtime
.IProgressMonitor
;
27 import org
.eclipse
.core
.runtime
.SubMonitor
;
28 import org
.eclipse
.core
.runtime
.jobs
.IJobChangeEvent
;
29 import org
.eclipse
.core
.runtime
.jobs
.Job
;
30 import org
.eclipse
.core
.runtime
.jobs
.JobChangeAdapter
;
31 import org
.eclipse
.e4
.ui
.di
.UISynchronize
;
32 import org
.eclipse
.jface
.layout
.GridDataFactory
;
33 import org
.eclipse
.jface
.viewers
.ComboViewer
;
34 import org
.eclipse
.nebula
.widgets
.nattable
.NatTable
;
35 import org
.eclipse
.nebula
.widgets
.nattable
.config
.ConfigRegistry
;
36 import org
.eclipse
.nebula
.widgets
.nattable
.config
.DefaultNatTableStyleConfiguration
;
37 import org
.eclipse
.nebula
.widgets
.nattable
.coordinate
.PositionCoordinate
;
38 import org
.eclipse
.nebula
.widgets
.nattable
.data
.IDataProvider
;
39 import org
.eclipse
.nebula
.widgets
.nattable
.data
.ListDataProvider
;
40 import org
.eclipse
.nebula
.widgets
.nattable
.export
.command
.ExportCommandHandler
;
41 import org
.eclipse
.nebula
.widgets
.nattable
.extension
.glazedlists
.GlazedListsEventLayer
;
42 import org
.eclipse
.nebula
.widgets
.nattable
.extension
.glazedlists
.GlazedListsSortModel
;
43 import org
.eclipse
.nebula
.widgets
.nattable
.extension
.glazedlists
.tree
.GlazedListTreeData
;
44 import org
.eclipse
.nebula
.widgets
.nattable
.extension
.glazedlists
.tree
.GlazedListTreeRowModel
;
45 import org
.eclipse
.nebula
.widgets
.nattable
.freeze
.CompositeFreezeLayer
;
46 import org
.eclipse
.nebula
.widgets
.nattable
.freeze
.FreezeHelper
;
47 import org
.eclipse
.nebula
.widgets
.nattable
.freeze
.FreezeLayer
;
48 import org
.eclipse
.nebula
.widgets
.nattable
.grid
.GridRegion
;
49 import org
.eclipse
.nebula
.widgets
.nattable
.grid
.command
.ClientAreaResizeCommand
;
50 import org
.eclipse
.nebula
.widgets
.nattable
.grid
.data
.DefaultColumnHeaderDataProvider
;
51 import org
.eclipse
.nebula
.widgets
.nattable
.grid
.data
.DefaultCornerDataProvider
;
52 import org
.eclipse
.nebula
.widgets
.nattable
.grid
.data
.DefaultRowHeaderDataProvider
;
53 import org
.eclipse
.nebula
.widgets
.nattable
.grid
.data
.FixedSummaryRowHeaderLayer
;
54 import org
.eclipse
.nebula
.widgets
.nattable
.grid
.layer
.ColumnHeaderLayer
;
55 import org
.eclipse
.nebula
.widgets
.nattable
.grid
.layer
.CornerLayer
;
56 import org
.eclipse
.nebula
.widgets
.nattable
.grid
.layer
.DefaultRowHeaderDataLayer
;
57 import org
.eclipse
.nebula
.widgets
.nattable
.grid
.layer
.GridLayer
;
58 import org
.eclipse
.nebula
.widgets
.nattable
.layer
.AbstractLayer
;
59 import org
.eclipse
.nebula
.widgets
.nattable
.layer
.CompositeLayer
;
60 import org
.eclipse
.nebula
.widgets
.nattable
.layer
.DataLayer
;
61 import org
.eclipse
.nebula
.widgets
.nattable
.layer
.ILayer
;
62 import org
.eclipse
.nebula
.widgets
.nattable
.layer
.cell
.ColumnOverrideLabelAccumulator
;
63 import org
.eclipse
.nebula
.widgets
.nattable
.layer
.stack
.DefaultBodyLayerStack
;
64 import org
.eclipse
.nebula
.widgets
.nattable
.selection
.SelectionLayer
;
65 import org
.eclipse
.nebula
.widgets
.nattable
.sort
.SortHeaderLayer
;
66 import org
.eclipse
.nebula
.widgets
.nattable
.sort
.config
.SingleClickSortConfiguration
;
67 import org
.eclipse
.nebula
.widgets
.nattable
.style
.HorizontalAlignmentEnum
;
68 import org
.eclipse
.nebula
.widgets
.nattable
.style
.theme
.ModernNatTableThemeConfiguration
;
69 import org
.eclipse
.nebula
.widgets
.nattable
.summaryrow
.FixedSummaryRowLayer
;
70 import org
.eclipse
.nebula
.widgets
.nattable
.summaryrow
.SummaryRowLayer
;
71 import org
.eclipse
.nebula
.widgets
.nattable
.tree
.ITreeRowModel
;
72 import org
.eclipse
.nebula
.widgets
.nattable
.tree
.TreeLayer
;
73 import org
.eclipse
.nebula
.widgets
.nattable
.util
.GUIHelper
;
74 import org
.eclipse
.swt
.SWT
;
75 import org
.eclipse
.swt
.layout
.GridData
;
76 import org
.eclipse
.swt
.layout
.GridLayout
;
77 import org
.eclipse
.swt
.widgets
.Button
;
78 import org
.eclipse
.swt
.widgets
.Composite
;
80 import ca
.odell
.glazedlists
.BasicEventList
;
81 import ca
.odell
.glazedlists
.EventList
;
82 import ca
.odell
.glazedlists
.SortedList
;
83 import ca
.odell
.glazedlists
.TreeList
;
84 import eu
.etaxonomy
.cdm
.api
.service
.IDescriptiveDataSetService
;
85 import eu
.etaxonomy
.cdm
.api
.service
.UpdateResult
;
86 import eu
.etaxonomy
.cdm
.api
.service
.dto
.RowWrapperDTO
;
87 import eu
.etaxonomy
.cdm
.api
.service
.dto
.SpecimenRowWrapperDTO
;
88 import eu
.etaxonomy
.cdm
.common
.monitor
.IRemotingProgressMonitor
;
89 import eu
.etaxonomy
.cdm
.model
.description
.DescriptionBase
;
90 import eu
.etaxonomy
.cdm
.model
.description
.DescriptiveDataSet
;
91 import eu
.etaxonomy
.cdm
.model
.description
.Feature
;
92 import eu
.etaxonomy
.cdm
.model
.description
.FeatureNode
;
93 import eu
.etaxonomy
.cdm
.model
.description
.FeatureTree
;
94 import eu
.etaxonomy
.cdm
.model
.description
.MeasurementUnit
;
95 import eu
.etaxonomy
.cdm
.model
.description
.State
;
96 import eu
.etaxonomy
.cdm
.persistence
.dto
.SpecimenNodeWrapper
;
97 import eu
.etaxonomy
.taxeditor
.editor
.internal
.TaxeditorEditorPlugin
;
98 import eu
.etaxonomy
.taxeditor
.editor
.l10n
.Messages
;
99 import eu
.etaxonomy
.taxeditor
.model
.MessagingUtils
;
100 import eu
.etaxonomy
.taxeditor
.store
.CdmStore
;
101 import eu
.etaxonomy
.taxeditor
.workbench
.WorkbenchUtility
;
104 * Character matrix editor for editing specimen/taxon descriptions in a table
106 * @since Nov 26, 2017
109 public class CharacterMatrix
extends Composite
{
111 private static final String CHARACTER_MATRIX_STATE_PROPERTIES
= "characterMatrixState.properties"; //$NON-NLS-1$
113 static final int LEADING_COLUMN_COUNT
= 4;
114 static final String TAXON_COLUMN
= "taxon_column"; //$NON-NLS-1$
115 static final String COLLECTOR_COLUMN
= "collector_column"; //$NON-NLS-1$
116 static final String IDENTIFIER_COLUMN
= "identifier_column"; //$NON-NLS-1$
117 static final String COUNTRY_COLUMN
= "country_column"; //$NON-NLS-1$
119 static final String LABEL_TAXON_ROW
= "TAXON_ROW"; //$NON-NLS-1$
120 static final String LABEL_TAXON_AGGREGATED_DESCRIPTION
= "TAXON_AGGREGATED_DESCRIPTION"; //$NON-NLS-1$
121 static final String LABEL_TAXON_DESCRIPTION
= "LABEL_TAXON_DESCRIPTION"; //$NON-NLS-1$
124 private UISynchronize sync
;
126 private DescriptiveDataSet descriptiveDataSet
;
128 private NatTable natTable
;
130 private Map
<Integer
, Feature
> indexToFeatureMap
= new HashMap
<>();
132 private Map
<Feature
, List
<State
>> categoricalFeatureToStateMap
= new HashMap
<>();
134 private LinkedMap
<String
, String
> propertyToLabelMap
= new LinkedMap
<>();
136 private EventList
<Object
> descriptions
;
138 private Collection
<SpecimenNodeWrapper
> specimenCache
= null;
140 private Map
<Feature
, CategoricalDataHistogram
> featureToHistogramMap
= new HashMap
<>();
142 private Map
<Feature
, QuantitativeDataStatistics
> featureToQuantDataStatisticsMap
= new HashMap
<>();
144 private ListDataProvider
<Object
> bodyDataProvider
;
146 private FreezeLayer freezeLayer
;
148 private List
<Feature
> features
;
150 private CharacterMatrixPart part
;
152 private AbstractLayer topMostLayer
;
154 private FixedSummaryRowLayer summaryRowLayer
;
156 private ConfigRegistry configRegistry
;
158 private DefaultBodyLayerStack bodyLayer
;
160 private boolean isTreeView
= true;
162 private CharacterMatrixToolbar toolbar
;
164 private boolean isShowTooltips
= true;
166 public CharacterMatrix(Composite parent
, CharacterMatrixPart part
) {
167 super(parent
, SWT
.NONE
);
169 this.setLayout(new GridLayout());
173 natTable
= new NatTable(this, false);
175 createBottomToolbar();
179 private void createToolBar(){
180 toolbar
= new CharacterMatrixToolbar(this, SWT
.NONE
);
183 @SuppressWarnings("unused")
184 private void createBottomToolbar() {
185 new CharacterMatrixBottomToolbar(this, SWT
.NONE
);
189 private void applyStyles(){
190 ModernNatTableThemeConfiguration configuration
= new ModernNatTableThemeConfiguration();
191 configuration
.summaryRowHAlign
= HorizontalAlignmentEnum
.CENTER
;
192 // NOTE: Getting the colors and fonts from the GUIHelper ensures that
193 // they are disposed properly (required by SWT)
194 configuration
.cHeaderBgColor
= GUIHelper
.getColor(211, 211, 211);
195 configuration
.rHeaderBgColor
= GUIHelper
.getColor(211, 211, 211);
196 natTable
.addConfiguration(configuration
);
200 void toggleTreeFlat(boolean isTree
, Button btnToggleFlat
, Button btnToggleTree
, Button btnCollapseAll
, Button btnExpandAll
, Button btnFreezeSuppInfo
) {
202 createTable(isTree
, freezeLayer
.isFrozen());
203 btnToggleFlat
.setEnabled(isTree
);
204 btnToggleTree
.setEnabled(!isTree
);
205 btnCollapseAll
.setEnabled(isTree
);
206 btnExpandAll
.setEnabled(isTree
);
209 public boolean isTreeView() {
213 public void createTable(boolean treeView
, boolean freezeSupplementalColumns
){
217 createLayers(treeView
);
222 configureNatTable(treeView
, configRegistry
, topMostLayer
, summaryRowLayer
);
225 * handlers and listeners
227 registerHandlersAndListeners(topMostLayer
);
230 GridDataFactory
.fillDefaults().grab(true, true).applyTo(natTable
);
232 //update label to current data set
233 toolbar
.getWsLabel().setText(descriptiveDataSet
.getLabel());
234 toolbar
.getWsLabel().setLayoutData(new GridData(SWT
.FILL
, SWT
.CENTER
, true, false));
235 toolbar
.getWsLabel().getParent().layout();
237 //initial freeze of supplemental columns
238 freezeSupplementalColumns(freezeSupplementalColumns
);
241 //add tooltip to table
242 new CategoricalChartTooltip(this);
243 new QuantitativeChartTooltip(this);
246 natTable
.doCommand(new ClientAreaResizeCommand(natTable
));
249 private List
<Feature
> initFeatureList(FeatureNode node
){
250 List
<Feature
> features
= new ArrayList
<>();
251 node
.getChildNodes().forEach(childNode
->
253 features
.add(childNode
.getFeature());
254 features
.addAll(initFeatureList(childNode
));
259 public void initDescriptiveDataSet(DescriptiveDataSet descriptiveDataSet
){
260 this.descriptiveDataSet
= descriptiveDataSet
;
261 //get features/columns stored in descriptive data set
262 FeatureTree tree
= descriptiveDataSet
.getDescriptiveSystem();
263 features
= initFeatureList(tree
.getRoot());
265 //init state data for categorical features
266 features
.forEach(feature
->
268 if(feature
.isSupportsCategoricalData()){
269 List
<State
> supportedStates
= new ArrayList
<>();
270 feature
.getSupportedCategoricalEnumerations().forEach(voc
->supportedStates
.addAll(voc
.getTerms()));
271 categoricalFeatureToStateMap
.put(feature
, supportedStates
);
274 descriptions
= new BasicEventList
<>();
278 private void createLayers(boolean treeView
) {
279 // use the SortedList constructor with 'null' for the Comparator
280 // because the Comparator will be set by configuration
281 SortedList
<Object
> sortedList
= new SortedList
<>(descriptions
, new MatrixRowComparator());
282 // wrap the SortedList with the TreeList
283 TreeList
<Object
> treeList
= new TreeList(sortedList
, new DescriptionTreeFormat(descriptiveDataSet
), TreeList
.NODES_START_EXPANDED
);
287 SpecimenColumnPropertyAccessor columnPropertyAccessor
= new SpecimenColumnPropertyAccessor(this);
288 bodyDataProvider
= treeView?
new ListDataProvider
<>(treeList
, columnPropertyAccessor
):new ListDataProvider
<>(sortedList
, columnPropertyAccessor
);
290 configRegistry
= new ConfigRegistry();
299 - (top) SummaryRowLayer
300 - (bottom) ViewportLayer
306 TreeLayer (default visible)
332 DataLayer bodyDataLayer
= new DataLayer(bodyDataProvider
);
335 CharacterMatrixConfigLabelAccumulator labelAccumulator
= new CharacterMatrixConfigLabelAccumulator(this);
336 bodyDataLayer
.setConfigLabelAccumulator(labelAccumulator
);
339 propertyToLabelMap
.put(TAXON_COLUMN
, Messages
.CharacterMatrix_TAXON
);
340 propertyToLabelMap
.put(COLLECTOR_COLUMN
, Messages
.CharacterMatrix_COLLECTOR_NO
);
341 propertyToLabelMap
.put(IDENTIFIER_COLUMN
, Messages
.CharacterMatrix_IDENTIFIER
);
342 propertyToLabelMap
.put(COUNTRY_COLUMN
, Messages
.CharacterMatrix_COUNTRY
);
343 for(int i
=0;i
<features
.size();i
++){
344 Feature feature
= features
.get(i
);
345 initLabels(i
, feature
);
348 // layer for event handling of GlazedLists and PropertyChanges
349 GlazedListsEventLayer eventLayer
= new GlazedListsEventLayer
<>(bodyDataLayer
, treeList
);
350 GlazedListTreeData treeData
= new GlazedListTreeData
<>(treeList
);
351 ITreeRowModel treeRowModel
= new GlazedListTreeRowModel
<>(treeData
);
353 bodyLayer
= new DefaultBodyLayerStack(eventLayer
);
354 final SelectionLayer selectionLayer
= bodyLayer
.getSelectionLayer();
355 freezeLayer
= new FreezeLayer(selectionLayer
);
356 final CompositeFreezeLayer compositeFreezeLayer
= new CompositeFreezeLayer(
357 freezeLayer
, bodyLayer
.getViewportLayer(), selectionLayer
);
358 TreeLayer treeLayer
= new TreeLayer(compositeFreezeLayer
, treeRowModel
);
360 topMostLayer
= treeView?treeLayer
:compositeFreezeLayer
;
362 summaryRowLayer
= new FixedSummaryRowLayer(bodyDataLayer
, topMostLayer
, configRegistry
, false);
363 //regoster labels with summary prefix for summary layer
364 ColumnOverrideLabelAccumulator summaryColumnLabelAccumulator
=new ColumnOverrideLabelAccumulator(bodyDataLayer
);
365 summaryRowLayer
.setConfigLabelAccumulator(summaryColumnLabelAccumulator
);
366 for(int i
=0;i
<features
.size();i
++){
367 Feature feature
= features
.get(i
);
368 summaryColumnLabelAccumulator
.registerColumnOverrides(
369 i
+LEADING_COLUMN_COUNT
,
370 SummaryRowLayer
.DEFAULT_SUMMARY_COLUMN_CONFIG_LABEL_PREFIX
+MatrixUtility
.getProperty(feature
));
372 // because the horizontal dependency is the ViewportLayer
373 // we need to set the composite dependency to false
374 summaryRowLayer
.setHorizontalCompositeDependency(false);
376 CompositeLayer composite
= new CompositeLayer(1, 2);
377 composite
.setChildLayer("SUMMARY", summaryRowLayer
, 0, 0); //$NON-NLS-1$
378 composite
.setChildLayer(GridRegion
.BODY
, topMostLayer
, 0, 1);
382 * column header layer
384 IDataProvider columnHeaderDataProvider
= new DefaultColumnHeaderDataProvider(
385 propertyToLabelMap
.values().toArray(new String
[] {}), propertyToLabelMap
);
386 DataLayer columnHeaderDataLayer
= new DataLayer(columnHeaderDataProvider
);
387 ColumnHeaderLayer columnHeaderLayer
= new ColumnHeaderLayer(columnHeaderDataLayer
, topMostLayer
, selectionLayer
);
389 // add the SortHeaderLayer to the column header layer stack
390 // as we use GlazedLists, we use the GlazedListsSortModel which
391 // delegates the sorting to the SortedList
392 final SortHeaderLayer
<DescriptionBase
> sortHeaderLayer
= new SortHeaderLayer
<>(
394 new GlazedListsSortModel
<>(
396 columnPropertyAccessor
,
398 columnHeaderDataLayer
));
404 IDataProvider rowHeaderDataProvider
= new DefaultRowHeaderDataProvider(bodyDataProvider
);
405 DefaultRowHeaderDataLayer rowHeaderDataLayer
= new DefaultRowHeaderDataLayer(rowHeaderDataProvider
);
406 FixedSummaryRowHeaderLayer fixedSummaryRowHeaderLayer
= new FixedSummaryRowHeaderLayer(rowHeaderDataLayer
,
407 composite
, selectionLayer
);
408 fixedSummaryRowHeaderLayer
.setSummaryRowLabel("\u2211"); //$NON-NLS-1$
414 ILayer cornerLayer
= new CornerLayer(
415 new DataLayer(new DefaultCornerDataProvider(columnHeaderDataProvider
, rowHeaderDataProvider
)),
416 fixedSummaryRowHeaderLayer
, sortHeaderLayer
);
420 * GRID layer (composition of all other layers)
422 GridLayer gridLayer
= new GridLayer(composite
, sortHeaderLayer
, fixedSummaryRowHeaderLayer
, cornerLayer
);
424 natTable
.setLayer(gridLayer
);
428 private void registerHandlersAndListeners(AbstractLayer topMostLayer
) {
429 // add the ExportCommandHandler to the ViewportLayer in order to make
431 topMostLayer
.registerCommandHandler(new ExportCommandHandler(topMostLayer
));
433 //propagate single cell selection
434 natTable
.addLayerListener(new CellSelectionListener(part
));
436 //register handler for view configuration menu
437 natTable
.registerCommandHandler(toolbar
.getDisplayPersistenceDialogCommandHandler());
440 private void configureNatTable(boolean treeView
,
441 ConfigRegistry configRegistry
,
442 AbstractLayer topMostLayer
,
443 FixedSummaryRowLayer summaryRowLayer
) {
447 natTable
.setConfigRegistry(configRegistry
);
451 //add default configuration because autoconfigure is set to false in constructor
452 natTable
.addConfiguration(new DefaultNatTableStyleConfiguration());
454 //FIXME: this is for DEBUG ONLY
455 // natTable.addConfiguration(new DebugMenuConfiguration(natTable));
457 // override the default sort configuration and change the mouse bindings
458 // to sort on a single click
460 natTable
.addConfiguration(new SingleClickSortConfiguration());
463 natTable
.addConfiguration(new CharacterMatrixLabelStyleConfiguration());
465 // add the header menu configuration for adding the column header menu
466 // with hide/show actions
467 natTable
.addConfiguration(new CharacterMatrixHeaderMenuConfiguration(natTable
));
469 // add custom configuration for data conversion and add column labels to viewport layer
470 topMostLayer
.addConfiguration(new CellEditorDataConversionConfiguration(this));
472 //register aggregation configuration
473 summaryRowLayer
.addConfiguration(new AggregationConfiguration(this));
475 natTable
.configure();
478 void freezeSupplementalColumns(boolean freeze
){
480 FreezeHelper
.freeze(freezeLayer
, bodyLayer
.getViewportLayer(),
481 new PositionCoordinate(bodyLayer
.getViewportLayer(), 0, 0),
482 new PositionCoordinate(bodyLayer
.getViewportLayer(), LEADING_COLUMN_COUNT
-1, -1));
485 FreezeHelper
.unfreeze(freezeLayer
, bodyLayer
.getViewportLayer());
489 void selectStateItem(ComboViewer comboStates
, String stateName
){
490 String
[] items
= comboStates
.getCombo().getItems();
491 for(int i
=0;i
<items
.length
;i
++){
492 if(items
[i
].equals(stateName
)){
493 comboStates
.getCombo().select(i
);
499 private void initLabels(int index
, Feature feature
) {
500 indexToFeatureMap
.put(index
+LEADING_COLUMN_COUNT
, feature
);
502 String featureLabel
= feature
.getLabel();
503 String property
= featureLabel
;
504 //show unit for quantitative data
505 if(feature
.isSupportsQuantitativeData()){
506 Set
<MeasurementUnit
> recommendedMeasurementUnits
= feature
.getRecommendedMeasurementUnits();
507 if(recommendedMeasurementUnits
.size()>1){
508 MessagingUtils
.warningDialog(Messages
.CharacterMatrix_INIT_PROBLEM
, CharacterMatrix
.class,
509 String
.format(Messages
.CharacterMatrix_INIT_PROBLEM_MESSAGE
, feature
.getLabel()));
511 if(recommendedMeasurementUnits
.size()==1){
512 MeasurementUnit unit
= recommendedMeasurementUnits
.iterator().next();
513 featureLabel
+= " ["+unit
.getIdInVocabulary()+"]"; //$NON-NLS-1$ //$NON-NLS-2$
516 propertyToLabelMap
.put(property
, featureLabel
);
519 public void loadDescriptions(DescriptiveDataSet descriptiveDataSet
) {
520 UUID monitorUuid
= CdmStore
.getService(IDescriptiveDataSetService
.class).monitGetRowWrapper(descriptiveDataSet
);
522 final Collection
<RowWrapperDTO
> wrappers
= new ArrayList
<>();
523 String jobLabel
= Messages
.CharacterMatrix_LOAD_CHARACTER_DATA
;
524 Job job
= Job
.create(jobLabel
, (ICoreRunnable
) monitor
-> {
525 SubMonitor subMonitor
= SubMonitor
.convert(monitor
);
526 subMonitor
.beginTask(jobLabel
, IProgressMonitor
.UNKNOWN
);
527 IRemotingProgressMonitor remotingMonitor
;
529 remotingMonitor
= CdmStore
.getProgressMonitorClientManager()
530 .pollMonitor(jobLabel
,
536 } catch (InterruptedException e
) {
537 MessagingUtils
.informationDialog(Messages
.CharacterMatrix_LOADING_FAILED_TITLE
,
538 Messages
.CharacterMatrix_LOADING_FAILED_MESSAGE
);
541 Object result
= remotingMonitor
.getResult();
542 if(result
instanceof Collection
){
543 wrappers
.addAll((Collection
<RowWrapperDTO
>) result
);
545 if(result
instanceof Exception
){
546 MessagingUtils
.errorDialog("Exception during description loading", this.getClass(), "An exception occured during loading", TaxeditorEditorPlugin
.PLUGIN_ID
, (Throwable
) result
, true);
548 else if(wrappers
.isEmpty()){
549 MessagingUtils
.informationDialog(Messages
.CharacterMatrix_NO_DESCRIPTION_TITLE
,
550 Messages
.CharacterMatrix_NO_DESCRIPTION_MESSAGE
);
554 job
.addJobChangeListener(new JobChangeAdapter(){
556 public void done(IJobChangeEvent event
) {
558 List
<RowWrapperDTO
> rowsWithoutTaxonNode
= wrappers
.stream().filter(row
->row
.getTaxonNode()==null).collect(Collectors
.toList());
559 if(!rowsWithoutTaxonNode
.isEmpty()){
560 String collect
= rowsWithoutTaxonNode
.stream().
561 map(row
->row
.getDescription().toString())
562 .collect(Collectors
.joining("\n\n - ")); //$NON-NLS-1$
563 MessagingUtils
.warningDialog(
564 Messages
.CharacterMatrix_NO_NODE_FOUND_TITLE
,
566 String
.format(Messages
.CharacterMatrix_NO_NODE_FOUND_MESSAGE
, collect
)
569 wrappers
.stream().filter(row
->row
.getTaxonNode()!=null).forEach(wrapper
->CharacterMatrix
.this.descriptions
.add(wrapper
));
577 private void loadingDone() {
578 this.part
.loadingDone();
581 public List
<State
> getSupportedStatesForCategoricalFeature(Feature feature
){
582 return categoricalFeatureToStateMap
.get(feature
);
585 public Map
<Integer
, Feature
> getIndexToFeatureMap() {
586 return indexToFeatureMap
;
589 public LinkedMap
<String
, String
> getPropertyToLabelMap() {
590 return propertyToLabelMap
;
593 public void setDirty() {
597 public NatTable
getNatTable() {
601 public EventList
<Object
> getDescriptions() {
605 public DescriptiveDataSet
getDescriptiveDataSet() {
606 return descriptiveDataSet
;
609 public Collection
<SpecimenNodeWrapper
> getSpecimenCache() {
610 return specimenCache
;
613 public void setSpecimenCache(Collection
<SpecimenNodeWrapper
> specimenCache
) {
614 this.specimenCache
= specimenCache
.stream()
616 //map descriptions on a list of uuids of the described specimen
617 !this.descriptions
.stream()
618 .filter(rowWrapper
->rowWrapper
instanceof SpecimenRowWrapperDTO
)
619 .map(specimenRowWrapper
->((SpecimenRowWrapperDTO
) specimenRowWrapper
).getSpecimen().getUuid())
620 .collect(Collectors
.toList())
621 //an check if the specimen to add is already contained
622 .contains(wrapper
.getUuidAndTitleCache().getUuid())
624 .collect(Collectors
.toList());
627 public Properties
getNatTableState() {
628 return toolbar
.getNatTableState();
631 public ListDataProvider
<Object
> getBodyDataProvider() {
632 return bodyDataProvider
;
635 DefaultBodyLayerStack
getBodyLayer() {
639 File
getStatePropertiesFile() {
640 return new File(WorkbenchUtility
.getBaseLocation(), CHARACTER_MATRIX_STATE_PROPERTIES
);
643 public List
<Feature
> getFeatures() {
647 public void addUpdateResult(UpdateResult result
){
648 part
.addUpdateResult(result
);
651 public Map
<Feature
, CategoricalDataHistogram
> getFeatureToHistogramMap() {
652 return featureToHistogramMap
;
655 public Map
<Feature
, QuantitativeDataStatistics
> getFeatureToQuantDataStatisticsMap() {
656 return featureToQuantDataStatisticsMap
;
659 public void toogleIsShowTooltips() {
660 this.isShowTooltips
= !this.isShowTooltips
;
663 public boolean isShowTooltips() {
664 return isShowTooltips
;