Project

General

Profile

Download (22.6 KB) Statistics
| Branch: | Tag: | Revision:
1
/**
2
 * Copyright (C) 2017 EDIT
3
 * European Distributed Institute of Taxonomy
4
 * http://www.e-taxonomy.eu
5
 *
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.
8
 */
9
package eu.etaxonomy.taxeditor.editor.descriptiveDataSet.matrix;
10

    
11
import java.io.File;
12
import java.util.ArrayList;
13
import java.util.Collection;
14
import java.util.HashMap;
15
import java.util.List;
16
import java.util.Map;
17
import java.util.Properties;
18
import java.util.Set;
19
import java.util.UUID;
20
import java.util.stream.Collectors;
21

    
22
import org.apache.commons.collections4.map.LinkedMap;
23
import org.eclipse.core.runtime.ICoreRunnable;
24
import org.eclipse.core.runtime.IProgressMonitor;
25
import org.eclipse.core.runtime.jobs.Job;
26
import org.eclipse.jface.layout.GridDataFactory;
27
import org.eclipse.jface.viewers.ComboViewer;
28
import org.eclipse.nebula.widgets.nattable.NatTable;
29
import org.eclipse.nebula.widgets.nattable.config.ConfigRegistry;
30
import org.eclipse.nebula.widgets.nattable.config.DefaultNatTableStyleConfiguration;
31
import org.eclipse.nebula.widgets.nattable.coordinate.PositionCoordinate;
32
import org.eclipse.nebula.widgets.nattable.data.IDataProvider;
33
import org.eclipse.nebula.widgets.nattable.data.ListDataProvider;
34
import org.eclipse.nebula.widgets.nattable.export.command.ExportCommandHandler;
35
import org.eclipse.nebula.widgets.nattable.extension.glazedlists.GlazedListsEventLayer;
36
import org.eclipse.nebula.widgets.nattable.extension.glazedlists.GlazedListsSortModel;
37
import org.eclipse.nebula.widgets.nattable.extension.glazedlists.tree.GlazedListTreeData;
38
import org.eclipse.nebula.widgets.nattable.extension.glazedlists.tree.GlazedListTreeRowModel;
39
import org.eclipse.nebula.widgets.nattable.freeze.CompositeFreezeLayer;
40
import org.eclipse.nebula.widgets.nattable.freeze.FreezeHelper;
41
import org.eclipse.nebula.widgets.nattable.freeze.FreezeLayer;
42
import org.eclipse.nebula.widgets.nattable.grid.GridRegion;
43
import org.eclipse.nebula.widgets.nattable.grid.data.DefaultColumnHeaderDataProvider;
44
import org.eclipse.nebula.widgets.nattable.grid.data.DefaultCornerDataProvider;
45
import org.eclipse.nebula.widgets.nattable.grid.data.DefaultRowHeaderDataProvider;
46
import org.eclipse.nebula.widgets.nattable.grid.data.FixedSummaryRowHeaderLayer;
47
import org.eclipse.nebula.widgets.nattable.grid.layer.ColumnHeaderLayer;
48
import org.eclipse.nebula.widgets.nattable.grid.layer.CornerLayer;
49
import org.eclipse.nebula.widgets.nattable.grid.layer.DefaultRowHeaderDataLayer;
50
import org.eclipse.nebula.widgets.nattable.grid.layer.GridLayer;
51
import org.eclipse.nebula.widgets.nattable.layer.AbstractLayer;
52
import org.eclipse.nebula.widgets.nattable.layer.CompositeLayer;
53
import org.eclipse.nebula.widgets.nattable.layer.DataLayer;
54
import org.eclipse.nebula.widgets.nattable.layer.ILayer;
55
import org.eclipse.nebula.widgets.nattable.layer.cell.ColumnOverrideLabelAccumulator;
56
import org.eclipse.nebula.widgets.nattable.layer.stack.DefaultBodyLayerStack;
57
import org.eclipse.nebula.widgets.nattable.selection.SelectionLayer;
58
import org.eclipse.nebula.widgets.nattable.sort.SortHeaderLayer;
59
import org.eclipse.nebula.widgets.nattable.sort.config.SingleClickSortConfiguration;
60
import org.eclipse.nebula.widgets.nattable.style.HorizontalAlignmentEnum;
61
import org.eclipse.nebula.widgets.nattable.style.theme.ModernNatTableThemeConfiguration;
62
import org.eclipse.nebula.widgets.nattable.summaryrow.FixedSummaryRowLayer;
63
import org.eclipse.nebula.widgets.nattable.summaryrow.SummaryRowLayer;
64
import org.eclipse.nebula.widgets.nattable.tree.ITreeRowModel;
65
import org.eclipse.nebula.widgets.nattable.tree.TreeLayer;
66
import org.eclipse.nebula.widgets.nattable.util.GUIHelper;
67
import org.eclipse.nebula.widgets.nattable.viewport.ViewportLayer;
68
import org.eclipse.swt.SWT;
69
import org.eclipse.swt.layout.GridData;
70
import org.eclipse.swt.layout.GridLayout;
71
import org.eclipse.swt.widgets.Button;
72
import org.eclipse.swt.widgets.Composite;
73

    
74
import ca.odell.glazedlists.BasicEventList;
75
import ca.odell.glazedlists.EventList;
76
import ca.odell.glazedlists.SortedList;
77
import ca.odell.glazedlists.TreeList;
78
import eu.etaxonomy.cdm.api.application.CdmApplicationState;
79
import eu.etaxonomy.cdm.api.service.IDescriptiveDataSetService;
80
import eu.etaxonomy.cdm.api.service.IProgressMonitorService;
81
import eu.etaxonomy.cdm.api.service.dto.RowWrapperDTO;
82
import eu.etaxonomy.cdm.common.monitor.IRemotingProgressMonitor;
83
import eu.etaxonomy.cdm.model.description.DescriptiveDataSet;
84
import eu.etaxonomy.cdm.model.description.Feature;
85
import eu.etaxonomy.cdm.model.description.FeatureNode;
86
import eu.etaxonomy.cdm.model.description.FeatureTree;
87
import eu.etaxonomy.cdm.model.description.MeasurementUnit;
88
import eu.etaxonomy.cdm.model.description.SpecimenDescription;
89
import eu.etaxonomy.cdm.model.description.State;
90
import eu.etaxonomy.cdm.persistence.dto.SpecimenNodeWrapper;
91
import eu.etaxonomy.taxeditor.editor.l10n.Messages;
92
import eu.etaxonomy.taxeditor.model.MessagingUtils;
93
import eu.etaxonomy.taxeditor.store.CdmStore;
94
import eu.etaxonomy.taxeditor.workbench.WorkbenchUtility;
95

    
96
/**
97
 * Character matrix editor for editing specimen/taxon descriptions in a table
98
 * @author pplitzner
99
 * @since Nov 26, 2017
100
 *
101
 */
102
public class CharacterMatrix extends Composite {
103

    
104
    private static final String CHARACTER_MATRIX_STATE_PROPERTIES = "characterMatrixState.properties"; //$NON-NLS-1$
105

    
106
    static final int LEADING_COLUMN_COUNT = 4;
107
    static final String TAXON_COLUMN = "taxon_column"; //$NON-NLS-1$
108
    static final String COLLECTOR_COLUMN = "collector_column"; //$NON-NLS-1$
109
    static final String IDENTIFIER_COLUMN = "identifier_column"; //$NON-NLS-1$
110
    static final String COUNTRY_COLUMN = "country_column"; //$NON-NLS-1$
111

    
112
    static final String LABEL_TAXON_ROW = "TAXON_ROW"; //$NON-NLS-1$
113

    
114
    private DescriptiveDataSet descriptiveDataSet;
115

    
116
    private NatTable natTable;
117

    
118
    private Map<Integer, Feature> indexToFeatureMap = new HashMap<>();
119

    
120
    private Map<Feature, List<State>> categoricalFeatureToStateMap = new HashMap<>();
121

    
122
    private LinkedMap<String, String> propertyToLabelMap = new LinkedMap<>();
123

    
124
    private EventList<Object> descriptions;
125

    
126
    private Collection<SpecimenNodeWrapper> specimenCache = null;
127

    
128
    private ListDataProvider<Object> bodyDataProvider;
129

    
130
    private FreezeLayer freezeLayer;
131

    
132
    private ViewportLayer viewportLayer;
133

    
134
    private List<Feature> features;
135

    
136
    private CharacterMatrixPart part;
137

    
138
    private AbstractLayer topMostLayer;
139

    
140
    private FixedSummaryRowLayer summaryRowLayer;
141

    
142
    private ConfigRegistry configRegistry;
143

    
144
    private DefaultBodyLayerStack bodyLayer;
145

    
146
    private boolean isTreeView = true;
147

    
148
    private CharacterMatrixToolbar toolbar;
149

    
150

    
151
    public CharacterMatrix(Composite parent, CharacterMatrixPart part) {
152
        super(parent, SWT.NONE);
153
        this.part = part;
154
        this.setLayout(new GridLayout());
155

    
156
        createToolBar();
157

    
158
        natTable = new NatTable(this, false);
159

    
160
        createBottomToolbar();
161

    
162
    }
163

    
164
    private void createToolBar(){
165
        toolbar = new CharacterMatrixToolbar(this, SWT.NONE);
166
    }
167

    
168
    @SuppressWarnings("unused")
169
    private void createBottomToolbar() {
170
        new CharacterMatrixBottomToolbar(this, SWT.NONE);
171
    }
172

    
173

    
174
    private void applyStyles(){
175
        ModernNatTableThemeConfiguration configuration = new ModernNatTableThemeConfiguration();
176
        configuration.summaryRowHAlign = HorizontalAlignmentEnum.CENTER;
177
        // NOTE: Getting the colors and fonts from the GUIHelper ensures that
178
        // they are disposed properly (required by SWT)
179
        configuration.summaryRowBgColor = GUIHelper.getColor(255, 255, 153);
180
        configuration.cHeaderBgColor = GUIHelper.getColor(211, 211, 211);
181
        configuration.rHeaderBgColor = GUIHelper.getColor(211, 211, 211);
182
        natTable.addConfiguration(configuration);
183

    
184
    }
185

    
186
    void toggleTreeFlat(boolean isTree, Button btnToggleFlat, Button btnToggleTree, Button btnCollapseAll, Button btnExpandAll, Button btnFreezeSuppInfo) {
187
        isTreeView = isTree;
188
        createTable(isTree);
189
        btnToggleFlat.setEnabled(isTree);
190
        btnToggleTree.setEnabled(!isTree);
191
        btnCollapseAll.setEnabled(isTree);
192
        btnExpandAll.setEnabled(isTree);
193
    }
194

    
195
    public boolean isTreeView() {
196
        return isTreeView;
197
    }
198

    
199
    public void createTable(boolean treeView){
200
        /**
201
         * layers
202
         */
203
        createLayers(treeView);
204

    
205
        /**
206
         * configuration
207
         */
208
        configureNatTable(treeView, configRegistry, topMostLayer, summaryRowLayer);
209

    
210
        /**
211
         * handlers and listeners
212
         */
213
        registerHandlersAndListeners(topMostLayer);
214

    
215
        //grab all space
216
        GridDataFactory.fillDefaults().grab(true, true).applyTo(natTable);
217

    
218
        //update label to current data set
219
        toolbar.getWsLabel().setText(descriptiveDataSet.getLabel());
220
        toolbar.getWsLabel().setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
221
        toolbar.getWsLabel().getParent().layout();
222

    
223
        //initial freeze of supplemental columns
224
        freezeSupplementalColumns(true);
225

    
226
        this.layout();
227
    }
228

    
229
    private List<Feature> initFeatureList(FeatureNode node){
230
        List<Feature> features = new ArrayList<>();
231
        node.getChildNodes().forEach(childNode->
232
                {
233
                    features.add(childNode.getFeature());
234
                    features.addAll(initFeatureList(childNode));
235
                });
236
        return features;
237
    }
238

    
239
    public void initDescriptiveDataSet(DescriptiveDataSet descriptiveDataSet){
240
        this.descriptiveDataSet = descriptiveDataSet;
241
        //get features/columns stored in descriptive data set
242
        FeatureTree tree = descriptiveDataSet.getDescriptiveSystem();
243
        features = initFeatureList(tree.getRoot());
244

    
245
        //init state data for categorical features
246
        features.forEach(feature->
247
        {
248
            if(feature.isSupportsCategoricalData()){
249
                List<State> supportedStates = new ArrayList<>();
250
                feature.getSupportedCategoricalEnumerations().forEach(voc->supportedStates.addAll(voc.getTerms()));
251
                categoricalFeatureToStateMap.put(feature, supportedStates);
252
            }
253
        });
254
        descriptions = new BasicEventList<>();
255

    
256
    }
257

    
258
    private void createLayers(boolean treeView) {
259
        // use the SortedList constructor with 'null' for the Comparator
260
        // because the Comparator will be set by configuration
261
        SortedList<Object> sortedList = new SortedList<>(descriptions, new MatrixRowComparator());
262
        // wrap the SortedList with the TreeList
263
        TreeList<Object> treeList = new TreeList(sortedList, new DescriptionTreeFormat(descriptiveDataSet), TreeList.NODES_START_EXPANDED);
264
        /**
265
         * data provider
266
         */
267
        SpecimenColumnPropertyAccessor columnPropertyAccessor = new SpecimenColumnPropertyAccessor(this);
268
        bodyDataProvider = treeView?new ListDataProvider<>(treeList, columnPropertyAccessor):new ListDataProvider<>(sortedList, columnPropertyAccessor);
269

    
270
        configRegistry = new ConfigRegistry();
271

    
272

    
273
        /**
274
         * BODY layer
275
         *
276
         *
277

    
278
        CompositeLayer
279
         - (top) SummaryRowLayer
280
         - (bottom) ViewportLayer
281

    
282
             ^
283
        ViewportLayer
284

    
285
             ^
286
        TreeLayer (default visible)
287

    
288
             ^
289
        CompositeFreezeLayer
290
         - viewportLayer
291
         - selectionLayer
292
         - freezeLayer
293

    
294
             ^
295
        FreezeLayer
296

    
297
             ^
298
        SelectionLayer
299

    
300
             ^
301
        ColumnHideShowLayer
302

    
303
             ^
304
        ColumnReorderLayer
305

    
306
             ^
307
        DataLayer
308

    
309
         *
310

    
311
         */
312
        DataLayer bodyDataLayer = new DataLayer(bodyDataProvider);
313

    
314
        //register labels
315
        CharacterMatrixConfigLabelAccumulator labelAccumulator = new CharacterMatrixConfigLabelAccumulator(this);
316
        bodyDataLayer.setConfigLabelAccumulator(labelAccumulator);
317

    
318

    
319
        propertyToLabelMap.put(TAXON_COLUMN, Messages.CharacterMatrix_TAXON);
320
        propertyToLabelMap.put(COLLECTOR_COLUMN, Messages.CharacterMatrix_COLLECTOR_NO);
321
        propertyToLabelMap.put(IDENTIFIER_COLUMN, Messages.CharacterMatrix_IDENTIFIER);
322
        propertyToLabelMap.put(COUNTRY_COLUMN, Messages.CharacterMatrix_COUNTRY);
323
        for(int i=0;i<features.size();i++){
324
            Feature feature = features.get(i);
325
            initLabels(i, feature);
326
        }
327

    
328
        // layer for event handling of GlazedLists and PropertyChanges
329
        GlazedListsEventLayer eventLayer = new GlazedListsEventLayer<>(bodyDataLayer, treeList);
330
        GlazedListTreeData treeData = new GlazedListTreeData<>(treeList);
331
        ITreeRowModel treeRowModel = new GlazedListTreeRowModel<>(treeData);
332

    
333
        bodyLayer = new DefaultBodyLayerStack(
334
                eventLayer);
335
        viewportLayer = bodyLayer.getViewportLayer();
336
        final SelectionLayer selectionLayer = bodyLayer.getSelectionLayer();
337
        freezeLayer = new FreezeLayer(selectionLayer);
338
        final CompositeFreezeLayer compositeFreezeLayer = new CompositeFreezeLayer(
339
                freezeLayer, bodyLayer.getViewportLayer(), selectionLayer);
340
        TreeLayer treeLayer = new TreeLayer(compositeFreezeLayer, treeRowModel);
341

    
342
        topMostLayer = treeView?treeLayer:compositeFreezeLayer;
343

    
344
        summaryRowLayer = new FixedSummaryRowLayer(bodyDataLayer, topMostLayer, configRegistry, false);
345
        //regoster labels with summary prefix for summary layer
346
        ColumnOverrideLabelAccumulator summaryColumnLabelAccumulator =new ColumnOverrideLabelAccumulator(bodyDataLayer);
347
        summaryRowLayer.setConfigLabelAccumulator(summaryColumnLabelAccumulator);
348
        for(int i=0;i<features.size();i++){
349
            Feature feature = features.get(i);
350
            summaryColumnLabelAccumulator.registerColumnOverrides(
351
                    i+LEADING_COLUMN_COUNT,
352
                    SummaryRowLayer.DEFAULT_SUMMARY_COLUMN_CONFIG_LABEL_PREFIX+MatrixUtility.getProperty(feature));
353
        }
354
        // because the horizontal dependency is the ViewportLayer
355
        // we need to set the composite dependency to false
356
        summaryRowLayer.setHorizontalCompositeDependency(false);
357

    
358
        CompositeLayer composite = new CompositeLayer(1, 2);
359
        composite.setChildLayer("SUMMARY", summaryRowLayer, 0, 0); //$NON-NLS-1$
360
        composite.setChildLayer(GridRegion.BODY, topMostLayer, 0, 1);
361

    
362

    
363
        /**
364
         * column header layer
365
         */
366
        IDataProvider columnHeaderDataProvider = new DefaultColumnHeaderDataProvider(
367
                propertyToLabelMap.values().toArray(new String[] {}), propertyToLabelMap);
368
        DataLayer columnHeaderDataLayer = new DataLayer(columnHeaderDataProvider);
369
        ColumnHeaderLayer columnHeaderLayer = new ColumnHeaderLayer(columnHeaderDataLayer, topMostLayer, selectionLayer);
370

    
371
        // add the SortHeaderLayer to the column header layer stack
372
        // as we use GlazedLists, we use the GlazedListsSortModel which
373
        // delegates the sorting to the SortedList
374
        final SortHeaderLayer<SpecimenDescription> sortHeaderLayer = new SortHeaderLayer<>(
375
                columnHeaderLayer,
376
                new GlazedListsSortModel<>(
377
                        sortedList,
378
                        columnPropertyAccessor,
379
                        configRegistry,
380
                        columnHeaderDataLayer));
381

    
382

    
383
        /**
384
         * row header layer
385
         */
386
        IDataProvider rowHeaderDataProvider = new DefaultRowHeaderDataProvider(bodyDataProvider);
387
        DefaultRowHeaderDataLayer rowHeaderDataLayer = new DefaultRowHeaderDataLayer(rowHeaderDataProvider);
388
        FixedSummaryRowHeaderLayer fixedSummaryRowHeaderLayer = new FixedSummaryRowHeaderLayer(rowHeaderDataLayer,
389
                composite, selectionLayer);
390
        fixedSummaryRowHeaderLayer.setSummaryRowLabel("\u2211"); //$NON-NLS-1$
391

    
392

    
393
        /**
394
         * corner layer
395
         */
396
        ILayer cornerLayer = new CornerLayer(
397
                new DataLayer(new DefaultCornerDataProvider(columnHeaderDataProvider, rowHeaderDataProvider)),
398
                fixedSummaryRowHeaderLayer, sortHeaderLayer);
399

    
400

    
401
        /**
402
         * GRID layer (composition of all other layers)
403
         */
404
        GridLayer gridLayer = new GridLayer(composite, sortHeaderLayer, fixedSummaryRowHeaderLayer, cornerLayer);
405

    
406
        natTable.setLayer(gridLayer);
407

    
408
    }
409

    
410
    private void registerHandlersAndListeners(AbstractLayer topMostLayer) {
411
        // add the ExportCommandHandler to the ViewportLayer in order to make
412
        // exporting work
413
        topMostLayer.registerCommandHandler(new ExportCommandHandler(topMostLayer));
414

    
415
        //propagate single cell selection
416
        natTable.addLayerListener(new CellSelectionListener(part));
417

    
418
        //register handler for view configuration menu
419
        natTable.registerCommandHandler(toolbar.getDisplayPersistenceDialogCommandHandler());
420
    }
421

    
422
    private void configureNatTable(boolean treeView,
423
            ConfigRegistry configRegistry,
424
            AbstractLayer topMostLayer,
425
            FixedSummaryRowLayer summaryRowLayer) {
426
        /**
427
         * CONFIGURATION
428
         */
429
        natTable.setConfigRegistry(configRegistry);
430

    
431
        applyStyles();
432

    
433
        //add default configuration because autoconfigure is set to false in constructor
434
        natTable.addConfiguration(new DefaultNatTableStyleConfiguration());
435

    
436
        //FIXME: this is for DEBUG ONLY
437
        //        natTable.addConfiguration(new DebugMenuConfiguration(natTable));
438

    
439
        // override the default sort configuration and change the mouse bindings
440
        // to sort on a single click
441
        if(!treeView){
442
            natTable.addConfiguration(new SingleClickSortConfiguration());
443
        }
444

    
445
        natTable.addConfiguration(new CharacterMatrixLabelStyleConfiguration());
446

    
447
        // add the header menu configuration for adding the column header menu
448
        // with hide/show actions
449
        natTable.addConfiguration(new CharacterMatrixHeaderMenuConfiguration(natTable));
450

    
451
        // add custom configuration for data conversion and add column labels to viewport layer
452
        topMostLayer.addConfiguration(new DataConversionConfiguration(this));
453

    
454
        //register aggregation configuration
455
        summaryRowLayer.addConfiguration(new AggregationConfiguration(this));
456

    
457
        natTable.configure();
458
    }
459

    
460
    void freezeSupplementalColumns(boolean freeze){
461
        if(freeze){
462
            FreezeHelper.freeze(freezeLayer, viewportLayer,
463
                    new PositionCoordinate(viewportLayer, 0, 0),
464
                    new PositionCoordinate(viewportLayer, LEADING_COLUMN_COUNT-1, -1));
465
        }
466
        else{
467
            FreezeHelper.unfreeze(freezeLayer, viewportLayer);
468
        }
469
    }
470

    
471
    void selectStateItem(ComboViewer comboStates, String stateName){
472
        String[] items = comboStates.getCombo().getItems();
473
        for(int i=0;i<items.length;i++){
474
            if(items[i].equals(stateName)){
475
                comboStates.getCombo().select(i);
476
                break;
477
            }
478
        }
479
    }
480

    
481
    private void initLabels(int index, Feature feature) {
482
        indexToFeatureMap.put(index+LEADING_COLUMN_COUNT, feature);
483

    
484
        String featureLabel = feature.getLabel();
485
        String property = featureLabel;
486
        //show unit for quantitative data
487
        if(feature.isSupportsQuantitativeData()){
488
            Set<MeasurementUnit> recommendedMeasurementUnits = feature.getRecommendedMeasurementUnits();
489
            if(recommendedMeasurementUnits.size()>1){
490
                MessagingUtils.warningDialog(Messages.CharacterMatrix_INIT_PROBLEM, CharacterMatrix.class,
491
                        String.format(Messages.CharacterMatrix_INIT_PROBLEM_MESSAGE, feature.getLabel()));
492
            }
493
            if(recommendedMeasurementUnits.size()==1){
494
                MeasurementUnit unit = recommendedMeasurementUnits.iterator().next();
495
                featureLabel += " ["+unit.getIdInVocabulary()+"]"; //$NON-NLS-1$ //$NON-NLS-2$
496
            }
497
        }
498
        propertyToLabelMap.put(property, featureLabel);
499
    }
500

    
501
    public void loadDescriptions(DescriptiveDataSet descriptiveDataSet) {
502
        UUID monitorUuid = CdmStore.getService(IDescriptiveDataSetService.class).monitGetRowWrapper(descriptiveDataSet);
503
        IProgressMonitorService progressMonitorService = CdmApplicationState.getCurrentAppConfig().getProgressMonitorService();
504

    
505

    
506
        String jobLabel = "Load character data";
507
        Job job = Job.create(jobLabel, (ICoreRunnable) monitor -> {
508
            monitor.beginTask(jobLabel, IProgressMonitor.UNKNOWN);
509
            while(progressMonitorService.isMonitorThreadRunning(monitorUuid)){
510
                if(monitor.isCanceled()){
511
                    progressMonitorService.interrupt(monitorUuid);
512
                }
513
            }
514
            IRemotingProgressMonitor remotingMonitor = progressMonitorService.getRemotingMonitor(monitorUuid);
515
            Collection<RowWrapperDTO> wrappers = (Collection<RowWrapperDTO>) remotingMonitor.getResult();
516
            if(wrappers!=null){
517
                wrappers.forEach(wrapper->CharacterMatrix.this.descriptions.add(wrapper));
518
            }
519
            monitor.done();
520
        });
521
        job.schedule(1000);
522
    }
523

    
524
    public List<State> getSupportedStatesForCategoricalFeature(Feature feature){
525
        return categoricalFeatureToStateMap.get(feature);
526
    }
527

    
528
    public Map<Integer, Feature> getIndexToFeatureMap() {
529
        return indexToFeatureMap;
530
    }
531

    
532
    public LinkedMap<String, String> getPropertyToLabelMap() {
533
        return propertyToLabelMap;
534
    }
535

    
536
    public void setDirty() {
537
        part.setDirty();
538
    }
539

    
540
    public NatTable getNatTable() {
541
        return natTable;
542
    }
543

    
544
    public EventList<Object> getDescriptions() {
545
        return descriptions;
546
    }
547

    
548
    public DescriptiveDataSet getDescriptiveDataSet() {
549
        return descriptiveDataSet;
550
    }
551

    
552
    public Collection<SpecimenNodeWrapper> getSpecimenCache() {
553
        return specimenCache;
554
    }
555

    
556
    public void setSpecimenCache(Collection<SpecimenNodeWrapper> specimenCache) {
557
        this.specimenCache = specimenCache.stream()
558
                .filter(wrapper ->
559
        //map descriptions on a list of uuids of the described specimen
560
        !this.descriptions.stream()
561
        .map(o->((RowWrapperDTO)o).getSpecimen().getUuid())
562
        .collect(Collectors.toList())
563
        //an check if the specimen to add is already contained
564
        .contains(wrapper.getUuidAndTitleCache().getUuid())
565
        )
566
        .collect(Collectors.toList());
567
    }
568

    
569
    public Properties getNatTableState() {
570
        return toolbar.getNatTableState();
571
    }
572

    
573
    public ListDataProvider<Object> getBodyDataProvider() {
574
        return bodyDataProvider;
575
    }
576

    
577
    DefaultBodyLayerStack getBodyLayer() {
578
        return bodyLayer;
579
    }
580

    
581
    File getStatePropertiesFile() {
582
        return new File(WorkbenchUtility.getBaseLocation(), CHARACTER_MATRIX_STATE_PROPERTIES);
583
    }
584

    
585
    public List<Feature> getFeatures() {
586
        return features;
587
    }
588

    
589
}
(3-3/16)