Project

General

Profile

« Previous | Next » 

Revision 19fc4473

Added by Patrick Plitzner about 6 years ago

ref #7095 Freeze/stick supplemental info columns

  • Add button for unfreezing

View differences:

eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/workingSet/matrix/CharacterMatrix.java
8 8
 */
9 9
package eu.etaxonomy.taxeditor.editor.workingSet.matrix;
10 10

  
11
import java.awt.Button;
12
import java.awt.Color;
13
import java.awt.Composite;
14
import java.awt.DisplayMode;
15
import java.awt.GridLayout;
16
import java.awt.Label;
17
import java.awt.Window;
11 18
import java.io.File;
12 19
import java.io.FileInputStream;
13 20
import java.io.FileOutputStream;
......
26 33

  
27 34
import javax.annotation.PostConstruct;
28 35
import javax.annotation.PreDestroy;
36
import javax.annotation.Resources;
29 37
import javax.inject.Inject;
30 38

  
31 39
import org.apache.commons.collections4.map.LinkedMap;
......
40 48
import org.eclipse.jface.viewers.ComboViewer;
41 49
import org.eclipse.jface.viewers.LabelProvider;
42 50
import org.eclipse.jface.viewers.StructuredSelection;
43
import org.eclipse.jface.window.Window;
44 51
import org.eclipse.nebula.widgets.nattable.NatTable;
45 52
import org.eclipse.nebula.widgets.nattable.config.AbstractRegistryConfiguration;
46 53
import org.eclipse.nebula.widgets.nattable.config.CellConfigAttributes;
......
57 64
import org.eclipse.nebula.widgets.nattable.extension.glazedlists.GlazedListsSortModel;
58 65
import org.eclipse.nebula.widgets.nattable.extension.glazedlists.tree.GlazedListTreeData;
59 66
import org.eclipse.nebula.widgets.nattable.extension.glazedlists.tree.GlazedListTreeRowModel;
67
import org.eclipse.nebula.widgets.nattable.freeze.FreezeHelper;
68
import org.eclipse.nebula.widgets.nattable.freeze.config.DefaultFreezeGridBindings;
60 69
import org.eclipse.nebula.widgets.nattable.grid.GridRegion;
61 70
import org.eclipse.nebula.widgets.nattable.grid.command.ClientAreaResizeCommand;
62 71
import org.eclipse.nebula.widgets.nattable.grid.data.DefaultColumnHeaderDataProvider;
......
68 77
import org.eclipse.nebula.widgets.nattable.grid.layer.DefaultRowHeaderDataLayer;
69 78
import org.eclipse.nebula.widgets.nattable.grid.layer.GridLayer;
70 79
import org.eclipse.nebula.widgets.nattable.grid.layer.config.DefaultRowStyleConfiguration;
71
import org.eclipse.nebula.widgets.nattable.hideshow.ColumnHideShowLayer;
72
import org.eclipse.nebula.widgets.nattable.hideshow.RowHideShowLayer;
80
import org.eclipse.nebula.widgets.nattable.layer.AbstractLayer;
73 81
import org.eclipse.nebula.widgets.nattable.layer.CompositeLayer;
74 82
import org.eclipse.nebula.widgets.nattable.layer.DataLayer;
75 83
import org.eclipse.nebula.widgets.nattable.layer.ILayer;
......
85 93
import org.eclipse.nebula.widgets.nattable.persistence.command.IStateChangedListener;
86 94
import org.eclipse.nebula.widgets.nattable.persistence.command.StateChangeEvent;
87 95
import org.eclipse.nebula.widgets.nattable.persistence.gui.PersistenceDialog;
88
import org.eclipse.nebula.widgets.nattable.reorder.ColumnReorderLayer;
89
import org.eclipse.nebula.widgets.nattable.reorder.RowReorderLayer;
90 96
import org.eclipse.nebula.widgets.nattable.selection.SelectionLayer;
91 97
import org.eclipse.nebula.widgets.nattable.selection.config.DefaultSelectionStyleConfiguration;
92 98
import org.eclipse.nebula.widgets.nattable.selection.event.CellSelectionEvent;
93 99
import org.eclipse.nebula.widgets.nattable.sort.SortHeaderLayer;
94 100
import org.eclipse.nebula.widgets.nattable.sort.config.SingleClickSortConfiguration;
95 101
import org.eclipse.nebula.widgets.nattable.style.CellStyleAttributes;
96
import org.eclipse.nebula.widgets.nattable.style.DisplayMode;
97 102
import org.eclipse.nebula.widgets.nattable.style.HorizontalAlignmentEnum;
98
import org.eclipse.nebula.widgets.nattable.style.Style;
99 103
import org.eclipse.nebula.widgets.nattable.style.VerticalAlignmentEnum;
100 104
import org.eclipse.nebula.widgets.nattable.summaryrow.FixedSummaryRowLayer;
101 105
import org.eclipse.nebula.widgets.nattable.summaryrow.SummaryRowLayer;
......
106 110
import org.eclipse.nebula.widgets.nattable.ui.menu.AbstractHeaderMenuConfiguration;
107 111
import org.eclipse.nebula.widgets.nattable.ui.menu.PopupMenuBuilder;
108 112
import org.eclipse.nebula.widgets.nattable.util.GUIHelper;
109
import org.eclipse.nebula.widgets.nattable.viewport.ViewportLayer;
110 113
import org.eclipse.swt.SWT;
111 114
import org.eclipse.swt.events.SelectionAdapter;
112 115
import org.eclipse.swt.events.SelectionEvent;
113
import org.eclipse.swt.graphics.Color;
114 116
import org.eclipse.swt.graphics.FontData;
115 117
import org.eclipse.swt.layout.GridData;
116
import org.eclipse.swt.layout.GridLayout;
117 118
import org.eclipse.swt.layout.RowLayout;
118
import org.eclipse.swt.widgets.Button;
119
import org.eclipse.swt.widgets.Composite;
120
import org.eclipse.swt.widgets.Label;
121 119

  
122 120
import ca.odell.glazedlists.EventList;
123 121
import ca.odell.glazedlists.GlazedLists;
......
132 130
import eu.etaxonomy.cdm.model.description.FeatureTree;
133 131
import eu.etaxonomy.cdm.model.description.MeasurementUnit;
134 132
import eu.etaxonomy.cdm.model.description.SpecimenDescription;
135
import eu.etaxonomy.cdm.model.description.State;
136
import eu.etaxonomy.cdm.model.description.WorkingSet;
137 133
import eu.etaxonomy.cdm.model.occurrence.SpecimenOrObservationBase;
138 134
import eu.etaxonomy.cdm.persistence.hibernate.CdmDataChangeMap;
139 135
import eu.etaxonomy.taxeditor.editor.workingSet.matrix.categorical.CategoricalDataCellEditor;
......
147 143
import eu.etaxonomy.taxeditor.model.IPartContentHasDetails;
148 144
import eu.etaxonomy.taxeditor.model.ImageResources;
149 145
import eu.etaxonomy.taxeditor.model.MessagingUtils;
150
import eu.etaxonomy.taxeditor.preference.Resources;
151 146
import eu.etaxonomy.taxeditor.session.ICdmEntitySession;
152 147
import eu.etaxonomy.taxeditor.session.ICdmEntitySessionEnabled;
153 148
import eu.etaxonomy.taxeditor.store.CdmStore;
......
155 150
import eu.etaxonomy.taxeditor.workbench.part.IE4SavablePart;
156 151

  
157 152
/**
153
 * Character matrix editor for editing specimen/taxon descriptions in a table
158 154
 * @author pplitzner
159 155
 * @since Nov 26, 2017
160 156
 *
......
209 205

  
210 206
    private ListDataProvider<Object> bodyDataProvider;
211 207

  
208
    private FreezeLayer freezeLayer;
209

  
210
    private ViewportLayer viewportLayer;
211

  
212 212
    private Label wsLabel;
213 213

  
214 214
    private Composite parent;
......
233 233

  
234 234
        Composite toolbarComposite = new Composite(parent, SWT.NONE);
235 235
        toolbarComposite.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
236
        toolbarComposite.setLayout(new GridLayout(8, false));
236
        toolbarComposite.setLayout(new GridLayout(9, false));
237 237
        natTable = new NatTable(parent, false);
238 238

  
239 239
        wsLabel = new Label(toolbarComposite, SWT.NONE);
......
242 242
        Button btnToggleFlat = new Button(toolbarComposite, SWT.PUSH);
243 243
        Button btnCollapseAll = new Button(toolbarComposite, SWT.PUSH);
244 244
        Button btnExpandAll = new Button(toolbarComposite, SWT.PUSH);
245
        Button btnFreezeSuppInfo = new Button(toolbarComposite, SWT.TOGGLE);
245 246
        ComboViewer comboStates = new ComboViewer(toolbarComposite, SWT.DROP_DOWN);
246 247
        Button btnManageState = new Button(toolbarComposite, SWT.PUSH);
247 248
        Button btnExcelExport = new Button(toolbarComposite, SWT.PUSH);
......
297 298
            }
298 299
        });
299 300

  
301
        /**
302
         * Freeze supplemental info button
303
         */
304
        btnFreezeSuppInfo.setImage(ImageResources.getImage(ImageResources.LOCK_ICON));
305
        btnFreezeSuppInfo.setToolTipText("Lock specimen columns");
306
        btnFreezeSuppInfo.setSelection(true);
307
        btnFreezeSuppInfo.addSelectionListener(new SelectionAdapter() {
308
            @Override
309
            public void widgetSelected(SelectionEvent e) {
310
              FreezeHelper.unfreeze(freezeLayer, viewportLayer);
311

  
312
            }
313
        });
314

  
300 315
        /**
301 316
         * Table state persistence
302 317
         */
......
558 573
        GlazedListTreeData treeData = new GlazedListTreeData<>(treeList);
559 574
        ITreeRowModel treeRowModel = new GlazedListTreeRowModel<>(treeData);
560 575

  
561
        ColumnReorderLayer columnReorderLayer;
562
        ColumnHideShowLayer columnHideShowLayer;
563
        SelectionLayer selectionLayer;
564
        TreeLayer treeLayer;
565
        ViewportLayer viewportLayer;
566
        if(treeView){
567
            columnReorderLayer = new ColumnReorderLayer(eventLayer);
568
            columnHideShowLayer = new ColumnHideShowLayer(columnReorderLayer);
569
            selectionLayer = new SelectionLayer(columnHideShowLayer);
570
            treeLayer = new TreeLayer(selectionLayer, treeRowModel);
571
            viewportLayer = treeView?new ViewportLayer(treeLayer):new ViewportLayer(selectionLayer);
572
        }
573
        else{
574
            RowReorderLayer rowReorderLayer = new RowReorderLayer(eventLayer);
575
            columnReorderLayer = new ColumnReorderLayer(rowReorderLayer);
576
            columnHideShowLayer = new ColumnHideShowLayer(columnReorderLayer);
577
            RowHideShowLayer rowHideShowLayer = new RowHideShowLayer(columnHideShowLayer);
578
            selectionLayer = new SelectionLayer(rowHideShowLayer);
579
            treeLayer = new TreeLayer(selectionLayer, treeRowModel);
580
            viewportLayer = treeView?new ViewportLayer(treeLayer):new ViewportLayer(selectionLayer);
581
        }
576
//        ColumnReorderLayer columnReorderLayer;
577
//        ColumnHideShowLayer columnHideShowLayer;
578
//        SelectionLayer selectionLayer;
579
//        TreeLayer treeLayer;
580
//        ViewportLayer viewportLayer;
581
//        if(treeView){
582
//            columnReorderLayer = new ColumnReorderLayer(eventLayer);
583
//            columnHideShowLayer = new ColumnHideShowLayer(columnReorderLayer);
584
//            selectionLayer = new SelectionLayer(columnHideShowLayer);
585
//            treeLayer = new TreeLayer(selectionLayer, treeRowModel);
586
//            viewportLayer = treeView?new ViewportLayer(treeLayer):new ViewportLayer(selectionLayer);
587
//        }
588
//        else{
589
//            RowReorderLayer rowReorderLayer = new RowReorderLayer(eventLayer);
590
//            columnReorderLayer = new ColumnReorderLayer(rowReorderLayer);
591
//            columnHideShowLayer = new ColumnHideShowLayer(columnReorderLayer);
592
//            RowHideShowLayer rowHideShowLayer = new RowHideShowLayer(columnHideShowLayer);
593
//            selectionLayer = new SelectionLayer(rowHideShowLayer);
594
//            treeLayer = new TreeLayer(selectionLayer, treeRowModel);
595
//            viewportLayer = treeView?new ViewportLayer(treeLayer):new ViewportLayer(selectionLayer);
596
//        }
597
        final DefaultBodyLayerStack bodyLayer = new DefaultBodyLayerStack(
598
                bodyDataLayer);
599
        viewportLayer = bodyLayer.getViewportLayer();
600
        final SelectionLayer selectionLayer = bodyLayer.getSelectionLayer();
601
        freezeLayer = new FreezeLayer(selectionLayer);
602
        final CompositeFreezeLayer compositeFreezeLayer = new CompositeFreezeLayer(
603
                freezeLayer, bodyLayer.getViewportLayer(), selectionLayer);
604
        TreeLayer treeLayer = new TreeLayer(compositeFreezeLayer, treeRowModel);
605
//        ViewportLayer viewportLayer = new ViewportLayer(treeLayer);
606
//        FreezeLayer freezeLayer = new FreezeLayer(viewportLayer);
607
//        CompositeFreezeLayer compositeFreezeLayer = new CompositeFreezeLayer(freezeLayer, viewportLayer, selectionLayer);
608

  
609

  
610
        AbstractLayer topMostLayer = treeView?treeLayer:compositeFreezeLayer;
582 611

  
583 612
        // create a standalone FixedSummaryRowLayer
584 613
        // since the summary row should be fixed at the top of the body
585 614
        // region the horizontal dependency of the FixedSummaryRowLayer
586 615
        // is the ViewportLayer
587 616
        FixedSummaryRowLayer summaryRowLayer =
588
                new FixedSummaryRowLayer(bodyDataLayer, viewportLayer, configRegistry, false);
589
        //register labels with summary prefix for summary layer
617
                new FixedSummaryRowLayer(bodyDataLayer, topMostLayer, configRegistry, false);
618
        //regoster labels with summary prefix for summary layer
590 619
        ColumnOverrideLabelAccumulator summaryColumnLabelAccumulator =new ColumnOverrideLabelAccumulator(bodyDataLayer);
591 620
        summaryRowLayer.setConfigLabelAccumulator(summaryColumnLabelAccumulator);
592 621
        for(int i=0;i<features.size();i++){
......
601 630

  
602 631
        CompositeLayer composite = new CompositeLayer(1, 2);
603 632
        composite.setChildLayer("SUMMARY", summaryRowLayer, 0, 0);
604
        composite.setChildLayer(GridRegion.BODY, viewportLayer, 0, 1);
633
        composite.setChildLayer(GridRegion.BODY, topMostLayer, 0, 1);
605 634

  
606 635

  
607 636
        /**
......
610 639
        IDataProvider columnHeaderDataProvider = new DefaultColumnHeaderDataProvider(
611 640
                propertyToLabelMap.values().toArray(new String[] {}), propertyToLabelMap);
612 641
        DataLayer columnHeaderDataLayer = new DataLayer(columnHeaderDataProvider);
613
        ColumnHeaderLayer columnHeaderLayer = new ColumnHeaderLayer(columnHeaderDataLayer, viewportLayer, selectionLayer);
642
        ColumnHeaderLayer columnHeaderLayer = new ColumnHeaderLayer(columnHeaderDataLayer, topMostLayer, selectionLayer);
614 643

  
615 644
        // add the SortHeaderLayer to the column header layer stack
616 645
        // as we use GlazedLists, we use the GlazedListsSortModel which
......
683 712
        cellStyle.setAttributeValue(CellStyleAttributes.HORIZONTAL_ALIGNMENT, HorizontalAlignmentEnum.LEFT);
684 713

  
685 714
        // add custom configuration for data conversion and add column labels to viewport layer
686
        viewportLayer.addConfiguration(new AbstractRegistryConfiguration() {
715
        topMostLayer.addConfiguration(new AbstractRegistryConfiguration() {
687 716
            @Override
688 717
            public void configureRegistry(IConfigRegistry configRegistry) {
689 718
                //add display converter for string representation
......
737 766

  
738 767
        // add the ExportCommandHandler to the ViewportLayer in order to make
739 768
        // exporting work
740
        viewportLayer.registerCommandHandler(new ExportCommandHandler(viewportLayer));
769
        topMostLayer.registerCommandHandler(new ExportCommandHandler(topMostLayer));
741 770

  
742 771
        //propagate single cell selection
743 772
        natTable.addLayerListener(new ILayerListener() {
......
774 803
        wsLabel.getParent().layout();
775 804

  
776 805
        parent.layout();
806

  
807
        natTable.addConfiguration(new DefaultFreezeGridBindings());
808

  
809
        //freeze supplemental info columns
810
        //TODO: calculate row count for freeze position
811
        FreezeHelper.freeze(freezeLayer, viewportLayer,
812
                new PositionCoordinate(viewportLayer, 0, 0),
813
                new PositionCoordinate(viewportLayer, LEADING_COLUMN_COUNT-1, Integer.MAX_VALUE));
814

  
777 815
    }
778 816

  
779 817
    private void selectStateItem(ComboViewer comboStates, String stateName){

Also available in: Unified diff