Project

General

Profile

Revision 8e4eddeb

ID8e4eddebc332ba1bb47bef4bd76b222d69cddd07
Parent 952ef0ec
Child 0c523381

Added by Katja Luther about 2 years ago

build layers for distribution editor

View differences:

eu.etaxonomy.taxeditor.editor/fragment.e4xmi
310 310
        <children xsi:type="menu:HandledToolItem" xmi:id="_hnZYUPycEeeOqKfc2I-67A" elementId="eu.etaxonomy.taxeditor.editor.handledtoolitem.0" iconURI="platform:/plugin/eu.etaxonomy.taxeditor.store/icons/refresh.gif" tooltip="%handledtoolitem.tooltip.1" command="_4k-uYPycEeeOqKfc2I-67A"/>
311 311
      </toolbar>
312 312
    </elements>
313
    <elements xsi:type="basic:PartDescriptor" xmi:id="_KnkUEPemEeiZEKOlcMbiPw" elementId="eu.etaxonomy.taxeditor.editor.view.checklist.e4.DistributionEditorPart" label="Distribution Editor" allowMultiple="true" closeable="true" dirtyable="true" contributionURI="bundleclass://eu.etaxonomy.taxeditor.editor/eu.etaxonomy.taxeditor.editor.view.checklist.e4.DistributionEditorPart"/>
313 314
  </fragments>
314 315
  <fragments xsi:type="fragment:StringModelFragment" xmi:id="__mwtMDVpEee_b7RlBzTDRw" featurename="commands" parentElementId="xpath:/">
315 316
    <elements xsi:type="commands:Command" xmi:id="_BjF3ADVqEee_b7RlBzTDRw" elementId="eu.etaxonomy.taxeditor.editor.command.specimeneditor.create_field_unit" commandName="%command.commandname.1"/>
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/AppModelId.java
278 278
	public static final String PARTDESCRIPTOR_EU_ETAXONOMY_TAXEDITOR_EDITOR_KEY_POLYTOMOUS_E4_POLYTOMOUSKEYLISTEDITORE4 = "eu.etaxonomy.taxeditor.editor.key.polytomous.e4.PolytomousKeyListEditorE4";
279 279
	public static final String PARTDESCRIPTOR_EU_ETAXONOMY_TAXEDITOR_EDITOR_NAME_E4_TAXONNAMEEDITORE4 = "eu.etaxonomy.taxeditor.editor.name.e4.TaxonNameEditorE4";
280 280
	public static final String PARTDESCRIPTOR_EU_ETAXONOMY_TAXEDITOR_EDITOR_VIEW_CHECKLIST_E4_CHECKLISTEDITORE4 = "eu.etaxonomy.taxeditor.editor.view.checklist.e4.ChecklistEditorE4";
281
	public static final String PARTDESCRIPTOR_EU_ETAXONOMY_TAXEDITOR_EDITOR_VIEW_CHECKLIST_E4_DISTRIBUTIONEDITORPART = "eu.etaxonomy.taxeditor.editor.view.checklist.e4.DistributionEditorPart";
281 282
	public static final String PARTDESCRIPTOR_EU_ETAXONOMY_TAXEDITOR_EDITOR_VIEW_CONCEPT_E4_CONCEPTVIEWPARTE4 = "eu.etaxonomy.taxeditor.editor.view.concept.e4.ConceptViewPartE4";
282 283
	public static final String PARTDESCRIPTOR_EU_ETAXONOMY_TAXEDITOR_EDITOR_VIEW_CONCEPT_GRAPH_E4_CONCEPTGRAPHVIEWE4 = "eu.etaxonomy.taxeditor.editor.view.concept.graph.e4.ConceptGraphViewE4";
283 284
	public static final String PARTDESCRIPTOR_EU_ETAXONOMY_TAXEDITOR_EDITOR_VIEW_DERIVATE_DERIVATEVIEW = "eu.etaxonomy.taxeditor.editor.view.derivate.DerivateView";
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/EditorUtil.java
45 45
import eu.etaxonomy.taxeditor.editor.internal.TaxeditorEditorPlugin;
46 46
import eu.etaxonomy.taxeditor.editor.l10n.Messages;
47 47
import eu.etaxonomy.taxeditor.editor.name.e4.TaxonNameEditorE4;
48
import eu.etaxonomy.taxeditor.editor.view.checklist.e4.DistributionEditorPart;
48 49
import eu.etaxonomy.taxeditor.editor.view.derivate.DerivateView;
49 50
import eu.etaxonomy.taxeditor.editor.view.derivate.DerivateViewEditorInput;
50 51
import eu.etaxonomy.taxeditor.model.AbstractUtility;
......
84 85
        editor.init(descriptiveDataSetUuid, true);
85 86
    }
86 87

  
88
    public static void openDistributionEditor(UUID parentTaxonUuid, EModelService modelService, EPartService partService, MApplication application){
89
        Collection<MPart> parts = partService.getParts();
90
        String partId = AppModelId.PARTDESCRIPTOR_EU_ETAXONOMY_TAXEDITOR_EDITOR_VIEW_CHECKLIST_E4_DISTRIBUTIONEDITORPART;
91
        MPart part = showPart(partId, modelService, partService, application);
92
        DistributionEditorPart editor = (DistributionEditorPart) part.getObject();
93
        editor.init(parentTaxonUuid);
94
    }
95

  
96

  
87 97
    public static void openSpecimenEditor(DerivateViewEditorInput input, EModelService modelService, EPartService partService, MApplication application){
88 98
        String partId = AppModelId.PARTDESCRIPTOR_EU_ETAXONOMY_TAXEDITOR_EDITOR_VIEW_DERIVATE_DERIVATEVIEW;
89 99
        MPart part = showPart(partId, modelService, partService, application);
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/descriptiveDataSet/matrix/CharacterMatrix.java
178 178

  
179 179
    private DefaultBodyLayerStack bodyLayer;
180 180

  
181
    private boolean isTreeView = true;
181
    private boolean isTreeView = false;
182 182

  
183 183
    private CharacterMatrixToolbar toolbar;
184 184

  
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/checklist/e4/DistributionEditor.java
9 9
package eu.etaxonomy.taxeditor.editor.view.checklist.e4;
10 10

  
11 11
import java.util.ArrayList;
12
import java.util.Arrays;
12 13
import java.util.Collection;
13 14
import java.util.HashMap;
14 15
import java.util.HashSet;
15 16
import java.util.List;
16 17
import java.util.Map;
18
import java.util.Set;
19
import java.util.SortedSet;
20
import java.util.TreeSet;
21
import java.util.UUID;
17 22

  
18 23
import javax.inject.Inject;
19 24

  
......
23 28
import org.eclipse.jface.layout.GridDataFactory;
24 29
import org.eclipse.jface.wizard.WizardDialog;
25 30
import org.eclipse.nebula.widgets.nattable.NatTable;
26
import org.eclipse.nebula.widgets.nattable.config.AbstractUiBindingConfiguration;
27 31
import org.eclipse.nebula.widgets.nattable.config.ConfigRegistry;
28 32
import org.eclipse.nebula.widgets.nattable.config.DefaultNatTableStyleConfiguration;
29 33
import org.eclipse.nebula.widgets.nattable.data.IDataProvider;
30 34
import org.eclipse.nebula.widgets.nattable.data.IRowDataProvider;
31 35
import org.eclipse.nebula.widgets.nattable.data.ListDataProvider;
32
import org.eclipse.nebula.widgets.nattable.export.command.ExportCommandHandler;
33 36
import org.eclipse.nebula.widgets.nattable.extension.e4.selection.E4SelectionListener;
34
import org.eclipse.nebula.widgets.nattable.extension.glazedlists.GlazedListsEventLayer;
35
import org.eclipse.nebula.widgets.nattable.extension.glazedlists.GlazedListsSortModel;
36
import org.eclipse.nebula.widgets.nattable.freeze.CompositeFreezeLayer;
37 37
import org.eclipse.nebula.widgets.nattable.freeze.FreezeLayer;
38 38
import org.eclipse.nebula.widgets.nattable.grid.GridRegion;
39
import org.eclipse.nebula.widgets.nattable.grid.command.ClientAreaResizeCommand;
40 39
import org.eclipse.nebula.widgets.nattable.grid.data.DefaultColumnHeaderDataProvider;
41 40
import org.eclipse.nebula.widgets.nattable.grid.data.DefaultCornerDataProvider;
42 41
import org.eclipse.nebula.widgets.nattable.grid.data.DefaultRowHeaderDataProvider;
43
import org.eclipse.nebula.widgets.nattable.grid.data.FixedSummaryRowHeaderLayer;
44 42
import org.eclipse.nebula.widgets.nattable.grid.layer.ColumnHeaderLayer;
45 43
import org.eclipse.nebula.widgets.nattable.grid.layer.CornerLayer;
46
import org.eclipse.nebula.widgets.nattable.grid.layer.DefaultRowHeaderDataLayer;
47 44
import org.eclipse.nebula.widgets.nattable.grid.layer.GridLayer;
45
import org.eclipse.nebula.widgets.nattable.grid.layer.RowHeaderLayer;
48 46
import org.eclipse.nebula.widgets.nattable.layer.AbstractLayer;
49
import org.eclipse.nebula.widgets.nattable.layer.CompositeLayer;
50 47
import org.eclipse.nebula.widgets.nattable.layer.DataLayer;
51 48
import org.eclipse.nebula.widgets.nattable.layer.ILayer;
52
import org.eclipse.nebula.widgets.nattable.layer.cell.ColumnOverrideLabelAccumulator;
53
import org.eclipse.nebula.widgets.nattable.layer.stack.DefaultBodyLayerStack;
54 49
import org.eclipse.nebula.widgets.nattable.selection.SelectionLayer;
55
import org.eclipse.nebula.widgets.nattable.sort.SortHeaderLayer;
56 50
import org.eclipse.nebula.widgets.nattable.sort.config.SingleClickSortConfiguration;
57 51
import org.eclipse.nebula.widgets.nattable.style.HorizontalAlignmentEnum;
58 52
import org.eclipse.nebula.widgets.nattable.style.theme.ModernNatTableThemeConfiguration;
59
import org.eclipse.nebula.widgets.nattable.summaryrow.FixedSummaryRowLayer;
60
import org.eclipse.nebula.widgets.nattable.summaryrow.SummaryRowLayer;
61
import org.eclipse.nebula.widgets.nattable.ui.binding.UiBindingRegistry;
62
import org.eclipse.nebula.widgets.nattable.ui.matcher.MouseEventMatcher;
63
import org.eclipse.nebula.widgets.nattable.ui.menu.PopupMenuAction;
64
import org.eclipse.nebula.widgets.nattable.ui.menu.PopupMenuBuilder;
65 53
import org.eclipse.nebula.widgets.nattable.util.GUIHelper;
54
import org.eclipse.nebula.widgets.nattable.viewport.ViewportLayer;
66 55
import org.eclipse.swt.SWT;
67 56
import org.eclipse.swt.events.SelectionAdapter;
68 57
import org.eclipse.swt.events.SelectionEvent;
......
71 60
import org.eclipse.swt.widgets.Button;
72 61
import org.eclipse.swt.widgets.Composite;
73 62
import org.eclipse.swt.widgets.Label;
74
import org.eclipse.swt.widgets.Menu;
75 63
import org.eclipse.swt.widgets.Text;
76 64

  
65
import ca.odell.glazedlists.BasicEventList;
77 66
import ca.odell.glazedlists.EventList;
78 67
import ca.odell.glazedlists.SortedList;
68
import eu.etaxonomy.cdm.api.service.IVocabularyService;
79 69
import eu.etaxonomy.cdm.api.service.dto.TaxonDistributionDTO;
70
import eu.etaxonomy.cdm.model.common.DefinedTermBase;
71
import eu.etaxonomy.cdm.model.common.Language;
72
import eu.etaxonomy.cdm.model.common.OrderedTermBase;
73
import eu.etaxonomy.cdm.model.common.OrderedTermComparator;
74
import eu.etaxonomy.cdm.model.common.TermIdInVocabularyComparator;
75
import eu.etaxonomy.cdm.model.common.TermLanguageComparator;
76
import eu.etaxonomy.cdm.model.common.TermVocabulary;
80 77
import eu.etaxonomy.cdm.model.description.DescriptionElementBase;
81 78
import eu.etaxonomy.cdm.model.location.NamedArea;
79
import eu.etaxonomy.cdm.model.metadata.PreferencePredicate;
82 80
import eu.etaxonomy.cdm.model.reference.Reference;
83 81
import eu.etaxonomy.taxeditor.editor.EditorUtil;
84
import eu.etaxonomy.taxeditor.editor.descriptiveDataSet.matrix.CharacterMatrixLabelStyleConfiguration;
85 82
import eu.etaxonomy.taxeditor.editor.l10n.Messages;
86 83
import eu.etaxonomy.taxeditor.model.AbstractUtility;
84
import eu.etaxonomy.taxeditor.preference.PreferencesUtil;
87 85
import eu.etaxonomy.taxeditor.preference.Resources;
88 86
import eu.etaxonomy.taxeditor.preference.wizard.AvailableDistributionWizard;
87
import eu.etaxonomy.taxeditor.store.CdmStore;
89 88
import eu.etaxonomy.taxeditor.store.StoreUtil;
90 89
import eu.etaxonomy.taxeditor.ui.dialog.selection.ReferenceSelectionDialog;
91 90

  
......
125 124
    private Text searchText;
126 125

  
127 126
    EventList<TaxonDistributionDTO> taxonList;
128
    List<NamedArea> areas = new ArrayList();
127
    SortedSet<DefinedTermBase> areas;
129 128
    DistributionEditorPart part;
130
    private DefaultBodyLayerStack bodyLayer;
129
    private ViewportLayer bodyLayer;
131 130
    private FreezeLayer freezeLayer;
132 131
    private ConfigRegistry configRegistry;
133 132
    private AbstractLayer topMostLayer;
134 133

  
135
    private FixedSummaryRowLayer summaryRowLayer;
134
    private SelectionLayer selectionLayer;
135

  
136
 //  private FixedSummaryRowLayer summaryRowLayer;
136 137

  
137 138

  
138 139
    /**
......
145 146
        this.part = part;
146 147
        createTopComposite(parent);
147 148

  
149

  
150
       // natTable = new NatTable(parent, viewportLayer);
148 151
        natTable = new NatTable(this, false);
149 152

  
150
        createStatusBar(parent);
153
       // createStatusBar(parent);
151 154
    }
152 155

  
153 156
    public boolean isShowRank() {
......
196 199
        statusLabel.setLayoutData(gridData);
197 200

  
198 201
        statusLabelSourceReference = new Label(composite, SWT.RIGHT);
199
//        GridData sourceGrid = new GridData();
200
//        sourceGrid.horizontalAlignment = GridData.HORIZONTAL_ALIGN_END;
201
//        //sourceGrid.grabExcessHorizontalSpace = false;
202
//        sourceGrid.horizontalSpan = 1;
203
       statusLabelSourceReference.setLayoutData(gridData);
202

  
203
        statusLabelSourceReference.setLayoutData(gridData);
204 204

  
205 205
        if (defaultSource != null){
206 206
            statusLabelSourceReference.setText("Default Source Reference: " + defaultSource.getAbbrevTitle() != null? defaultSource.getAbbrevTitle() : defaultSource.getAbbrevTitleCache());
......
238 238
        // to sort on a single click
239 239

  
240 240
        natTable.addConfiguration(new SingleClickSortConfiguration());
241
        natTable.addConfiguration(new CharacterMatrixLabelStyleConfiguration());
241
   //     natTable.addConfiguration(new CharacterMatrixLabelStyleConfiguration());
242 242

  
243 243
        // add the header menu configuration for adding the column header menu
244 244
        // with hide/show actions
......
251 251
//        summaryRowLayer.addConfiguration(new AggregationConfiguration(this));
252 252

  
253 253
      //+++CONTEXT MENU+++
254
        menuService.registerContextMenu(natTable, "eu.etaxonomy.taxeditor.editor.popupmenu.charactermatrix"); //$NON-NLS-1$
255
        // get the menu registered by EMenuService
256
        final Menu e4Menu = natTable.getMenu();
257
        // remove the menu reference from NatTable instance
258
        natTable.setMenu(null);
259
        natTable.addConfiguration(
260
                new AbstractUiBindingConfiguration() {
261
            @Override
262
            public void configureUiBindings(
263
                    UiBindingRegistry uiBindingRegistry) {
264
                // add e4 menu to NatTable
265
                new PopupMenuBuilder(natTable, e4Menu)
266
                    .build();
267

  
268
                // register the UI binding for header, corner and body region
269
                uiBindingRegistry.registerMouseDownBinding(
270
                        new MouseEventMatcher(
271
                                SWT.NONE,
272
                                null,
273
                                MouseEventMatcher.RIGHT_BUTTON),
274
                        new PopupMenuAction(e4Menu));
275
            }
276
        });
254
//        menuService.registerContextMenu(natTable, "eu.etaxonomy.taxeditor.editor.popupmenu.charactermatrix"); //$NON-NLS-1$
255
//        // get the menu registered by EMenuService
256
//        final Menu e4Menu = natTable.getMenu();
257
//        // remove the menu reference from NatTable instance
258
//        natTable.setMenu(null);
259
//        natTable.addConfiguration(
260
//                new AbstractUiBindingConfiguration() {
261
//            @Override
262
//            public void configureUiBindings(
263
//                    UiBindingRegistry uiBindingRegistry) {
264
//                // add e4 menu to NatTable
265
//                new PopupMenuBuilder(natTable, e4Menu)
266
//                    .build();
267
//
268
//                // register the UI binding for header, corner and body region
269
//                uiBindingRegistry.registerMouseDownBinding(
270
//                        new MouseEventMatcher(
271
//                                SWT.NONE,
272
//                                null,
273
//                                MouseEventMatcher.RIGHT_BUTTON),
274
//                        new PopupMenuAction(e4Menu));
275
//            }
276
//        });
277 277

  
278 278
        natTable.configure();
279 279
    }
280 280

  
281
    public void createTable(boolean freezeSupplementalColumns){
281
    public void createTable(){
282 282
        /**
283 283
         * layers
284 284
         */
285

  
285 286
        createLayers();
286 287

  
287 288
        /**
......
307 308

  
308 309

  
309 310
        this.layout();
310
        natTable.doCommand(new ClientAreaResizeCommand(natTable));
311
      //  boolean ok = natTable.doCommand(new ClientAreaResizeCommand(natTable));
312
      //  System.out.println(ok);
311 313
    }
312 314

  
313 315

  
314 316
    private void createLayers() {
315 317

  
316 318
        SortedList sortedList = new SortedList(taxonList, new TaxonDistributionDtoComparator());
319
        DistributionColumnAccessor columnPropertyAccessor = new DistributionColumnAccessor(this);
317 320

  
318 321

  
319
        /**
320
         * data provider
321
         */
322
        DistributionColumnAccessor columnPropertyAccessor = new DistributionColumnAccessor(this);
323 322
        bodyDataProvider = new ListDataProvider(sortedList, columnPropertyAccessor);
324 323

  
325
        propertyToLabelMap.put(TAXON_COLUMN, Messages.CharacterMatrix_TAXON);
324
        propertyToLabelMap.put(TAXON_COLUMN, Messages.ChecklistEditor_TAXON);
326 325
        if (isShowRank){
327
            propertyToLabelMap.put(RANK_COLUMN, Messages.CharacterMatrix_COLLECTOR_NO);
326
            propertyToLabelMap.put(RANK_COLUMN, Messages.ChecklistEditor_RANK);
328 327
        }
329 328
        configRegistry = new ConfigRegistry();
330 329

  
331

  
332
        /**
333
         * BODY layer
334
         *
335
         *
336

  
337
        CompositeLayer
338
         - (top) SummaryRowLayer
339
         - (bottom) ViewportLayer
340

  
341
             ^
342
        ViewportLayer
343

  
344
             ^
345
        TreeLayer (default visible)
346

  
347
             ^
348
        CompositeFreezeLayer
349
         - viewportLayer
350
         - selectionLayer
351
         - freezeLayer
352

  
353
             ^
354
        FreezeLayer
355

  
356
             ^
357
        SelectionLayer
358

  
359
             ^
360
        ColumnHideShowLayer
361

  
362
             ^
363
        ColumnReorderLayer
364

  
365
             ^
366
        DataLayer
367

  
368
         *
369

  
370
         */
371
        DataLayer bodyDataLayer = new DataLayer(bodyDataProvider);
372

  
373
        //register labels
374
//        CharacterMatrixConfigLabelAccumulator labelAccumulator = new CharacterMatrixConfigLabelAccumulator(this);
375
//        bodyDataLayer.setConfigLabelAccumulator(labelAccumulator);
376

  
377

  
378
        propertyToLabelMap.put(TAXON_COLUMN, Messages.CharacterMatrix_TAXON);
379 330
        initLabels();
331
        // build up a layer stack consisting of DataLayer, SelectionLayer and
332
        // ViewportLayer
333
        DataLayer bodyDataLayer = new DataLayer(bodyDataProvider);
334
        selectionLayer = new SelectionLayer(bodyDataLayer);
335
        bodyLayer = new ViewportLayer(selectionLayer);
380 336

  
381

  
382
   //     layer for event handling of GlazedLists and PropertyChanges
383
        GlazedListsEventLayer eventLayer = new GlazedListsEventLayer<>(bodyDataLayer, taxonList);
384

  
385

  
386

  
387
        bodyLayer = new DefaultBodyLayerStack(eventLayer);
388
        final SelectionLayer selectionLayer = bodyLayer.getSelectionLayer();
389
        freezeLayer = new FreezeLayer(selectionLayer);
390
        final CompositeFreezeLayer compositeFreezeLayer = new CompositeFreezeLayer(
391
                freezeLayer, bodyLayer.getViewportLayer(), selectionLayer);
392

  
393

  
394
        topMostLayer = compositeFreezeLayer;
395

  
396
        summaryRowLayer = new FixedSummaryRowLayer(bodyDataLayer, topMostLayer, configRegistry, false);
397
        //register labels with summary prefix for summary layer
398
        ColumnOverrideLabelAccumulator summaryColumnLabelAccumulator =new ColumnOverrideLabelAccumulator(bodyDataLayer);
399
        summaryRowLayer.setConfigLabelAccumulator(summaryColumnLabelAccumulator);
400
        int n = 1;
401
        if (isShowRank){
402
            n++;
403
        }
404
        for(int i=0;i<areas.size();i++){
405
            NamedArea namedArea = areas.get(i);
406
            summaryColumnLabelAccumulator.registerColumnOverrides(
407
                    i+n,
408
                    SummaryRowLayer.DEFAULT_SUMMARY_COLUMN_CONFIG_LABEL_PREFIX+namedArea.getLabel());
409
        }
410
        // because the horizontal dependency is the ViewportLayer
411
        // we need to set the composite dependency to false
412
        summaryRowLayer.setHorizontalCompositeDependency(false);
413

  
414
        CompositeLayer composite = new CompositeLayer(1, 2);
415
        composite.setChildLayer("SUMMARY", summaryRowLayer, 0, 0); //$NON-NLS-1$
416
        composite.setChildLayer(GridRegion.BODY, topMostLayer, 0, 1);
337
        // as the selection mouse bindings are registered for the region label
338
        // GridRegion.BODY
339
        // we need to set that region label to the viewport so the selection via mouse
340
        // is working correctly
341
        bodyLayer.setRegionName(GridRegion.BODY);
417 342

  
418 343

  
419
        /**
420
         * column header layer
421
         */
422
        IDataProvider columnHeaderDataProvider = new DefaultColumnHeaderDataProvider(
423
                propertyToLabelMap.values().toArray(new String[] {}), propertyToLabelMap);
424
        DataLayer columnHeaderDataLayer = new DataLayer(columnHeaderDataProvider);
425
        ColumnHeaderLayer columnHeaderLayer = new ColumnHeaderLayer(columnHeaderDataLayer, topMostLayer, selectionLayer);
426

  
427
        // add the SortHeaderLayer to the column header layer stack
428
        // as we use GlazedLists, we use the GlazedListsSortModel which
429
        // delegates the sorting to the SortedList
430
        final SortHeaderLayer<TaxonDistributionDTO> sortHeaderLayer = new SortHeaderLayer<>(
431
                columnHeaderLayer,
432
                new GlazedListsSortModel<>(sortedList,
433
                        columnPropertyAccessor,
434
                        configRegistry,
435
                        columnHeaderDataLayer));
344
        IDataProvider columnHeaderDataProvider =
345
                new DefaultColumnHeaderDataProvider(propertyToLabelMap.values().toArray(new String[] {}), propertyToLabelMap);
346
            DataLayer columnHeaderDataLayer = new DataLayer(columnHeaderDataProvider);
347
            ILayer columnHeaderLayer = new ColumnHeaderLayer(
348
                columnHeaderDataLayer,
349
                bodyLayer,
350
                selectionLayer);
436 351

  
437 352

  
438
        /**
439
         * row header layer
440
         */
353
     // build the row header layer stack
441 354
        IDataProvider rowHeaderDataProvider = new DefaultRowHeaderDataProvider(bodyDataProvider);
442
        DefaultRowHeaderDataLayer rowHeaderDataLayer = new DefaultRowHeaderDataLayer(rowHeaderDataProvider);
443
        FixedSummaryRowHeaderLayer fixedSummaryRowHeaderLayer = new FixedSummaryRowHeaderLayer(rowHeaderDataLayer,
444
                composite, selectionLayer);
445
        fixedSummaryRowHeaderLayer.setSummaryRowLabel("\u2211"); //$NON-NLS-1$
446

  
447

  
448
        /**
449
         * corner layer
450
         */
451
        ILayer cornerLayer = new CornerLayer(
452
                new DataLayer(new DefaultCornerDataProvider(columnHeaderDataProvider, rowHeaderDataProvider)),
453
                fixedSummaryRowHeaderLayer, sortHeaderLayer);
355
        DataLayer rowHeaderDataLayer = new DataLayer(rowHeaderDataProvider, 40, 20);
356
        ILayer rowHeaderLayer = new RowHeaderLayer(
357
            rowHeaderDataLayer,
358
            bodyLayer,
359
            selectionLayer);
360

  
361

  
362

  
363
        IDataProvider cornerDataProvider =
364
                new DefaultCornerDataProvider(
365
                    columnHeaderDataProvider,
366
                    rowHeaderDataProvider);
367
            DataLayer cornerDataLayer = new DataLayer(cornerDataProvider);
368
            ILayer cornerLayer = new CornerLayer(
369
                cornerDataLayer,
370
                rowHeaderLayer,
371
                columnHeaderLayer);
372

  
373
            GridLayer gridLayer = new GridLayer(
374
                    bodyLayer,
375
                    columnHeaderLayer,
376
                    rowHeaderLayer,
377
                    cornerLayer);
454 378

  
379
        natTable.setLayer(gridLayer);
455 380

  
456
        /**
457
         * GRID layer (composition of all other layers)
458
         */
459
        GridLayer gridLayer = new GridLayer(composite, sortHeaderLayer, null, cornerLayer);
381
        topMostLayer = bodyLayer;
460 382

  
461
        natTable.setLayer(gridLayer);
462 383

  
463 384
    }
464 385

  
......
543 464

  
544 465
    }
545 466
    public void loadDistributions(List<TaxonDistributionDTO> taxonList) {
546
        this.taxonList.addAll(taxonList);
547

  
467
        if (this.taxonList == null){
468
            this.taxonList = new BasicEventList<>();
469
        }
470
       taxonList.stream().forEach(wrapper->DistributionEditor.this.taxonList.add(wrapper));
548 471
    }
549 472

  
473

  
474

  
550 475
    public Collection<DescriptionElementBase> getDistributions() {
551 476
        Collection<DescriptionElementBase> descElements = new HashSet();
552 477
//TODO: only for edited taxa
......
564 489
        if (isShowRank){
565 490
            index++;
566 491
        }
567
        for (NamedArea area: areas) {
568
            this.areaToColumnIndexMap.put(index++, area);
492

  
493
        loadNamedAreas();
494
        for (DefinedTermBase area: areas) {
495
            this.areaToColumnIndexMap.put(index++, (NamedArea)area);
569 496

  
570 497
            //TODO: adapt to preference
571 498
            String areaLabel = area.getLabel();
......
574 501
        }
575 502
    }
576 503

  
504
    private SortedSet<DefinedTermBase> loadNamedAreas() {
505
        //IPreferenceStore preferenceStore = PreferencesUtil.getPreferenceStore();
506

  
507
        String valuesAreas = PreferencesUtil.getStringValue(PreferencePredicate.AvailableDistributionAreaTerms.getKey());
508
        String values = PreferencesUtil.getStringValue(PreferencePredicate.AvailableDistributionAreaVocabularies.getKey());
509
        if (values != null && values != "") { //$NON-NLS-1$
510
            String[] split = values.split(";"); //$NON-NLS-1$
511
            List<String> listValue = Arrays.asList(split);
512
            List<DefinedTermBase> termlist = new ArrayList<DefinedTermBase>();
513
            Set<UUID> uuidList = new HashSet<UUID>();
514
            UUID uuid;
515
            for(String s : listValue){
516
                uuid = UUID.fromString(s);
517
                uuidList.add(uuid);
577 518

  
578
    private void registerHandlersAndListeners(AbstractLayer topMostLayer) {
579
        // add the ExportCommandHandler to the ViewportLayer in order to make
580
        // exporting work
581
        topMostLayer.registerCommandHandler(new ExportCommandHandler(topMostLayer));
519
            }
520
            IVocabularyService service =  CdmStore.getService(IVocabularyService.class);
521
            List<TermVocabulary> vocs = service.find(uuidList);
522
            split = valuesAreas.split(";");
523
            listValue = Arrays.asList(split);
524
            for (TermVocabulary voc: vocs){
525
                termlist.addAll(service.getTerms(voc, null, null, null, null).getRecords());
526
            }
527
            List<DefinedTermBase> filteredList = new ArrayList();
528
            for (DefinedTermBase area: termlist){
529
                if (listValue.contains(area.getUuid().toString())) {
530
                    filteredList.add(area);
531
                }
582 532

  
533
            }
534

  
535
            if (PreferencesUtil.isSortNamedAreaByOrderInVocabulary()){
536
                areas =  getTermsOrderedByVocabularyOrder(filteredList);
537
            } else if (PreferencesUtil.isShowIdInVocabularyInChecklistEditor()){
538
                areas = getTermsOrderedByIdInVocabulary(filteredList);
539
            }else{
540
                areas =  getTermsOrderedByLabels(filteredList, CdmStore.getDefaultLanguage());
541
            }
542
        }
543
        return null;
544
    }
545

  
546
    public SortedSet<DefinedTermBase> getTermsOrderedByLabels(List<DefinedTermBase> listTerm,Language language){
547
        TermLanguageComparator<?> comp = new TermLanguageComparator<>();
548
        comp.setCompareLanguage(language);
549
        SortedSet<DefinedTermBase> result = new TreeSet(comp);
550
        if(listTerm != null){
551
            result.addAll(listTerm);
552
        }
553
        return result;
554
    }
555

  
556
    public SortedSet<DefinedTermBase> getTermsOrderedByIdInVocabulary(List<DefinedTermBase> namedAreas) {
557
        TermIdInVocabularyComparator<?> comp = new TermIdInVocabularyComparator<>();
558

  
559
        SortedSet<DefinedTermBase> result = new TreeSet(comp);
560
        if(namedAreas != null){
561
            result.addAll(namedAreas);
562
        }
563
        return result;
564
    }
565

  
566
    public SortedSet<DefinedTermBase> getTermsOrderedByVocabularyOrder(List<DefinedTermBase> listAreas){
567
        HashMap<TermVocabulary<DefinedTermBase>, List<DefinedTermBase>> vocs = new HashMap<>();
568
        OrderedTermComparator<?> comp = new OrderedTermComparator<>();
569
        boolean allOrderedTerms = true;
570
        List<TermVocabulary> alreadyOrderIndexNull = new ArrayList<>();
571
        for (DefinedTermBase term: listAreas){
572
            if (!(term instanceof OrderedTermBase)){
573
                allOrderedTerms = false;
574
                break;
575
            }else if (((OrderedTermBase)term).getOrderIndex() == 0){
576
                if(alreadyOrderIndexNull.contains(term.getVocabulary())) {
577
                    allOrderedTerms = false;
578
                    break;
579
                }else{
580
                    alreadyOrderIndexNull.add(term.getVocabulary());
581
                }
582

  
583

  
584
            }
585
        }
586
        if (allOrderedTerms){
587
            SortedSet<DefinedTermBase> result = new TreeSet(comp.reversed());
588
            result.addAll(listAreas);
589
            return result;
590
        }else{
591
            return getTermsOrderedByLabels(listAreas, PreferencesUtil.getGlobalLanguage());
592
        }
593

  
594

  
595
    }
596

  
597
    private void registerHandlersAndListeners(AbstractLayer topMostLayer) {
583 598
        //selection listener
584 599
        E4SelectionListener selectionListener = new DistributionCellSelectionListener(part.getSelectionService(),
585
                bodyLayer.getSelectionLayer(), bodyDataProvider, part);
586
        bodyLayer.getSelectionLayer().addLayerListener(selectionListener);
600
                selectionLayer, bodyDataProvider, part);
601
        selectionLayer.addLayerListener(selectionListener);
587 602
        selectionListener.setFullySelectedRowsOnly(false);
588 603

  
589 604
        //register handler for view configuration menu
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/checklist/e4/DistributionEditorPart.java
24 24
import org.eclipse.e4.ui.model.application.ui.MDirtyable;
25 25
import org.eclipse.e4.ui.model.application.ui.basic.MPart;
26 26
import org.eclipse.e4.ui.workbench.modeling.ESelectionService;
27
import org.eclipse.swt.SWT;
28 27
import org.eclipse.swt.custom.StackLayout;
29 28
import org.eclipse.swt.widgets.Composite;
30
import org.eclipse.swt.widgets.Label;
31 29

  
32 30
import eu.etaxonomy.cdm.api.conversation.ConversationHolder;
33 31
import eu.etaxonomy.cdm.api.conversation.IConversationEnabled;
......
37 35
import eu.etaxonomy.cdm.api.service.dto.TaxonDistributionDTO;
38 36
import eu.etaxonomy.cdm.model.common.CdmBase;
39 37
import eu.etaxonomy.cdm.persistence.hibernate.CdmDataChangeMap;
40
import eu.etaxonomy.taxeditor.editor.l10n.Messages;
41 38
import eu.etaxonomy.taxeditor.model.IDirtyMarkable;
42 39
import eu.etaxonomy.taxeditor.model.IPartContentHasDetails;
43 40
import eu.etaxonomy.taxeditor.model.IPartContentHasSupplementalData;
......
99 96
        stackLayout = new StackLayout();
100 97
        parent.setLayout(stackLayout);
101 98
        editor = new DistributionEditor(parent, this);
102
        Label label = new Label(parent, SWT.NONE);
103
        label.setText(Messages.CharacterMatrixPart_LOADING_MATRIX);
104
        stackLayout.topControl = label;
99
//        Label label = new Label(parent, SWT.NONE);
100
//        label.setText(Messages.CharacterMatrixPart_LOADING_MATRIX);
101
   //     stackLayout.topControl = label;
105 102
        ContextInjectionFactory.inject(editor, context);
106 103
    }
107 104

  
108 105
    public void init(UUID parentTaxonUuid) {
109 106
        this.taxonList = CdmStore.getService(ITaxonNodeService.class).getTaxonDistributionDTOForSubtree(parentTaxonUuid, TAXONNODE_PROPERTY_PATH);
107

  
110 108
        if(taxonList!=null){
111
            editor.createTable( true);
112 109
            editor.loadDistributions(taxonList);
110
            editor.createTable();
111
            editor.pack();
112
            stackLayout.topControl = editor;
113
            editor.getParent().layout();
113 114
        }
114 115
    }
115 116
    public ESelectionService getSelectionService() {
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/checklist/e4/handler/OpenChecklistEditorHandlerE4.java
4 4

  
5 5
import javax.inject.Inject;
6 6

  
7
import org.apache.commons.lang.StringUtils;
8 7
import org.eclipse.e4.core.services.log.Logger;
9
import org.eclipse.e4.ui.model.application.ui.basic.MPart;
10
import org.eclipse.e4.ui.model.application.ui.basic.MPartStack;
11 8
import org.eclipse.e4.ui.workbench.modeling.EPartService;
12
import org.eclipse.e4.ui.workbench.modeling.EPartService.PartState;
13 9
import org.eclipse.swt.widgets.Shell;
14 10

  
15 11
import eu.etaxonomy.cdm.api.service.IClassificationService;
16 12
import eu.etaxonomy.cdm.api.service.ITaxonNodeService;
17
import eu.etaxonomy.cdm.model.metadata.PreferencePredicate;
18
import eu.etaxonomy.cdm.model.taxon.Classification;
19 13
import eu.etaxonomy.cdm.model.taxon.ITaxonTreeNode;
20
import eu.etaxonomy.cdm.model.taxon.TaxonNode;
21 14
import eu.etaxonomy.taxeditor.editor.AppModelId;
15
import eu.etaxonomy.taxeditor.editor.EditorUtil;
22 16
import eu.etaxonomy.taxeditor.editor.l10n.Messages;
23
import eu.etaxonomy.taxeditor.editor.view.checklist.ChecklistEditorInput;
24
import eu.etaxonomy.taxeditor.editor.view.checklist.e4.ChecklistEditorE4;
25 17
import eu.etaxonomy.taxeditor.handler.defaultHandler.e4.DefaultOpenHandlerBaseE4;
26
import eu.etaxonomy.taxeditor.model.MessagingUtils;
27 18
import eu.etaxonomy.taxeditor.preference.EditorPreferencePredicate;
28 19
import eu.etaxonomy.taxeditor.preference.PreferencesUtil;
29 20
import eu.etaxonomy.taxeditor.store.CdmStore;
30
import eu.etaxonomy.taxeditor.workbench.WorkbenchUtility;
31 21

  
32 22
public class OpenChecklistEditorHandlerE4 extends DefaultOpenHandlerBaseE4<ITaxonTreeNode> {
33 23
    @Inject
......
47 37
	@Override
48 38
	protected void open(ITaxonTreeNode entity, Shell shell, EPartService partService) {
49 39

  
50
		if (PreferencesUtil.getBooleanValue(EditorPreferencePredicate.DistributionEditorActivated.getKey())) {
51
			if (StringUtils.isBlank(PreferencesUtil.getStringValue(PreferencePredicate.AvailableDistributionAreaVocabularies.getKey()) )){
40
//		if (PreferencesUtil.getBooleanValue(EditorPreferencePredicate.DistributionEditorActivated.getKey())) {
41
//			if (StringUtils.isBlank(PreferencesUtil.getStringValue(PreferencePredicate.AvailableDistributionAreaVocabularies.getKey()) )){
42
//
43
//				MessagingUtils.informationDialog(Messages.OpenChecklistEditorHandler_NO_AREAS, Messages.OpenChecklistEditorHandler_CHOOSE_AREA
44
//						+ Messages.OpenChecklistEditorHandler_GOTO_PREFERENCES);
45
//				return;
46
//			}
47
//			if (entity instanceof Classification) {
48
//				ChecklistEditorInput input = new ChecklistEditorInput(((Classification) entity));
49
//				try {
50
//					openChecklistEditor(input, partService);
51
//				} catch (NullPointerException npe) {
52
//					MessagingUtils.messageDialog(COULD_NOT_OPEN_DISTRIBUTION_EDITOR, OpenChecklistEditorHandlerE4.class,
53
//							COULD_NOT_OPEN_DISTRIBUTION_EDITOR_THE_HIERARCHY_IS_CORRUPTED, npe);
54
//				}
55
//			} else if (entity instanceof TaxonNode) {
56
//				ChecklistEditorInput input = new ChecklistEditorInput((TaxonNode) entity);
57
//				try {
58
//					openChecklistEditor(input, partService);
59
//				} catch (NullPointerException npe) {
60
//					MessagingUtils.messageDialog(COULD_NOT_OPEN_DISTRIBUTION_EDITOR, OpenChecklistEditorHandlerE4.class,
61
//							COULD_NOT_OPEN_DISTRIBUTION_EDITOR_THE_HIERARCHY_IS_CORRUPTED, npe);
62
//				}
63
//			}
64
//		}
52 65

  
53
				MessagingUtils.informationDialog(Messages.OpenChecklistEditorHandler_NO_AREAS, Messages.OpenChecklistEditorHandler_CHOOSE_AREA
54
						+ Messages.OpenChecklistEditorHandler_GOTO_PREFERENCES);
55
				return;
56
			}
57
			if (entity instanceof Classification) {
58
				ChecklistEditorInput input = new ChecklistEditorInput(((Classification) entity));
59
				try {
60
					openChecklistEditor(input, partService);
61
				} catch (NullPointerException npe) {
62
					MessagingUtils.messageDialog(COULD_NOT_OPEN_DISTRIBUTION_EDITOR, OpenChecklistEditorHandlerE4.class,
63
							COULD_NOT_OPEN_DISTRIBUTION_EDITOR_THE_HIERARCHY_IS_CORRUPTED, npe);
64
				}
65
			} else if (entity instanceof TaxonNode) {
66
				ChecklistEditorInput input = new ChecklistEditorInput((TaxonNode) entity);
67
				try {
68
					openChecklistEditor(input, partService);
69
				} catch (NullPointerException npe) {
70
					MessagingUtils.messageDialog(COULD_NOT_OPEN_DISTRIBUTION_EDITOR, OpenChecklistEditorHandlerE4.class,
71
							COULD_NOT_OPEN_DISTRIBUTION_EDITOR_THE_HIERARCHY_IS_CORRUPTED, npe);
72
				}
73
			}
74
		}
66
	    EditorUtil.openDistributionEditor(entity.getUuid(), modelService, partService, application);
75 67
	}
76 68

  
77
	private void openChecklistEditor(ChecklistEditorInput input, EPartService partService) {
78
		MPart part = partService.createPart(AppModelId.PARTDESCRIPTOR_EU_ETAXONOMY_TAXEDITOR_EDITOR_VIEW_CHECKLIST_E4_CHECKLISTEDITORE4);
79
		MPartStack editorAreaPartStack = WorkbenchUtility.getEditorAreaPartStack(application, modelService);
80
		if(editorAreaPartStack!=null){
81
		    editorAreaPartStack.getChildren().add(part);
82
		}
83
		part = partService.showPart(part, PartState.ACTIVATE);
84
		ChecklistEditorE4 checklistEditor = (ChecklistEditorE4) part.getObject();
85
		if (checklistEditor != null){
86
			checklistEditor.init(input);
87
		}else{
88
			logger.debug("Editor is null");
89
		}
90
	}
69
//	private void openChecklistEditor(ChecklistEditorInput input, EPartService partService) {
70
//		MPart part = partService.createPart(AppModelId.PARTDESCRIPTOR_EU_ETAXONOMY_TAXEDITOR_EDITOR_VIEW_CHECKLIST_E4_CHECKLISTEDITORE4);
71
//		MPartStack editorAreaPartStack = WorkbenchUtility.getEditorAreaPartStack(application, modelService);
72
//		if(editorAreaPartStack!=null){
73
//		    editorAreaPartStack.getChildren().add(part);
74
//		}
75
//		part = partService.showPart(part, PartState.ACTIVATE);
76
//		ChecklistEditorE4 checklistEditor = (ChecklistEditorE4) part.getObject();
77
//		if (checklistEditor != null){
78
//			checklistEditor.init(input);
79
//		}else{
80
//			logger.debug("Editor is null");
81
//		}
82
//	}
91 83

  
92 84
    /**
93 85
     * {@inheritDoc}
......
99 91

  
100 92
    @Override
101 93
    protected String getPartId() {
102
        return AppModelId.PARTDESCRIPTOR_EU_ETAXONOMY_TAXEDITOR_EDITOR_VIEW_CHECKLIST_E4_CHECKLISTEDITORE4;
94
        return AppModelId.PARTDESCRIPTOR_EU_ETAXONOMY_TAXEDITOR_EDITOR_VIEW_CHECKLIST_E4_DISTRIBUTIONEDITORPART;
103 95
    }
104 96
}

Also available in: Unified diff

Add picture from clipboard (Maximum size: 40 MB)