Project

General

Profile

Revision 84093d41

ID84093d415e8e5e1ebffbf52c25f71b41047cab89
Parent c895abf3
Child 64ed19fc

Added by Patrick Plitzner almost 4 years ago

ref #7095 Style enhancements

View differences:

eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/workingSet/matrix/CharacterMatrix.java
68 68
import org.eclipse.nebula.widgets.nattable.grid.layer.CornerLayer;
69 69
import org.eclipse.nebula.widgets.nattable.grid.layer.DefaultRowHeaderDataLayer;
70 70
import org.eclipse.nebula.widgets.nattable.grid.layer.GridLayer;
71
import org.eclipse.nebula.widgets.nattable.grid.layer.config.DefaultRowStyleConfiguration;
71 72
import org.eclipse.nebula.widgets.nattable.hideshow.ColumnHideShowLayer;
72 73
import org.eclipse.nebula.widgets.nattable.hideshow.RowHideShowLayer;
73 74
import org.eclipse.nebula.widgets.nattable.layer.CompositeLayer;
......
76 77
import org.eclipse.nebula.widgets.nattable.layer.ILayerListener;
77 78
import org.eclipse.nebula.widgets.nattable.layer.cell.ColumnOverrideLabelAccumulator;
78 79
import org.eclipse.nebula.widgets.nattable.layer.cell.ILayerCell;
80
import org.eclipse.nebula.widgets.nattable.layer.config.DefaultColumnHeaderStyleConfiguration;
81
import org.eclipse.nebula.widgets.nattable.layer.config.DefaultRowHeaderStyleConfiguration;
79 82
import org.eclipse.nebula.widgets.nattable.layer.event.ILayerEvent;
80 83
import org.eclipse.nebula.widgets.nattable.persistence.PersistenceHelper;
81 84
import org.eclipse.nebula.widgets.nattable.persistence.command.DisplayPersistenceDialogCommand;
......
86 89
import org.eclipse.nebula.widgets.nattable.reorder.ColumnReorderLayer;
87 90
import org.eclipse.nebula.widgets.nattable.reorder.RowReorderLayer;
88 91
import org.eclipse.nebula.widgets.nattable.selection.SelectionLayer;
92
import org.eclipse.nebula.widgets.nattable.selection.config.DefaultSelectionStyleConfiguration;
89 93
import org.eclipse.nebula.widgets.nattable.selection.event.CellSelectionEvent;
90 94
import org.eclipse.nebula.widgets.nattable.sort.SortHeaderLayer;
91 95
import org.eclipse.nebula.widgets.nattable.sort.config.SingleClickSortConfiguration;
96
import org.eclipse.nebula.widgets.nattable.style.BorderStyle;
97
import org.eclipse.nebula.widgets.nattable.style.BorderStyle.LineStyleEnum;
98
import org.eclipse.nebula.widgets.nattable.style.CellStyleAttributes;
92 99
import org.eclipse.nebula.widgets.nattable.style.DisplayMode;
100
import org.eclipse.nebula.widgets.nattable.style.HorizontalAlignmentEnum;
101
import org.eclipse.nebula.widgets.nattable.style.Style;
102
import org.eclipse.nebula.widgets.nattable.style.VerticalAlignmentEnum;
93 103
import org.eclipse.nebula.widgets.nattable.summaryrow.FixedSummaryRowLayer;
94 104
import org.eclipse.nebula.widgets.nattable.summaryrow.SummaryRowLayer;
95 105
import org.eclipse.nebula.widgets.nattable.tree.ITreeRowModel;
......
97 107
import org.eclipse.nebula.widgets.nattable.tree.command.TreeCollapseAllCommand;
98 108
import org.eclipse.nebula.widgets.nattable.tree.command.TreeExpandAllCommand;
99 109
import org.eclipse.nebula.widgets.nattable.ui.menu.AbstractHeaderMenuConfiguration;
110
import org.eclipse.nebula.widgets.nattable.ui.menu.HeaderMenuConfiguration;
100 111
import org.eclipse.nebula.widgets.nattable.ui.menu.PopupMenuBuilder;
112
import org.eclipse.nebula.widgets.nattable.util.GUIHelper;
101 113
import org.eclipse.nebula.widgets.nattable.viewport.ViewportLayer;
102 114
import org.eclipse.swt.SWT;
103 115
import org.eclipse.swt.events.SelectionAdapter;
104 116
import org.eclipse.swt.events.SelectionEvent;
117
import org.eclipse.swt.graphics.Color;
118
import org.eclipse.swt.graphics.FontData;
105 119
import org.eclipse.swt.layout.GridData;
106 120
import org.eclipse.swt.layout.GridLayout;
107 121
import org.eclipse.swt.layout.RowLayout;
......
132 146
import eu.etaxonomy.taxeditor.editor.workingSet.matrix.quantitative.QuantitativeDataCellEditor;
133 147
import eu.etaxonomy.taxeditor.editor.workingSet.matrix.quantitative.QuantitativeDataDisplayConverter;
134 148
import eu.etaxonomy.taxeditor.editor.workingSet.matrix.supplementalInfo.SupplementalInfoDisplayConverter;
149
import eu.etaxonomy.taxeditor.model.ColorResources;
135 150
import eu.etaxonomy.taxeditor.model.DescriptionHelper;
136 151
import eu.etaxonomy.taxeditor.model.IDirtyMarkable;
137 152
import eu.etaxonomy.taxeditor.model.IPartContentHasDetails;
138 153
import eu.etaxonomy.taxeditor.model.ImageResources;
139 154
import eu.etaxonomy.taxeditor.model.MessagingUtils;
155
import eu.etaxonomy.taxeditor.preference.Resources;
140 156
import eu.etaxonomy.taxeditor.session.ICdmEntitySession;
141 157
import eu.etaxonomy.taxeditor.session.ICdmEntitySessionEnabled;
142 158
import eu.etaxonomy.taxeditor.store.CdmStore;
......
392 408
                }
393 409
            }
394 410
        });
411

  
412
        applyStyles();
413
    }
414

  
415
    private void applyStyles(){
416
        // NOTE: Getting the colors and fonts from the GUIHelper ensures that
417
        // they are disposed properly (required by SWT)
418
        DefaultNatTableStyleConfiguration natTableConfiguration = new DefaultNatTableStyleConfiguration();
419
        natTableConfiguration.bgColor = GUIHelper.getColor(249, 172, 7);
420
        natTableConfiguration.fgColor = GUIHelper.getColor(30, 76, 19);
421
        natTableConfiguration.hAlign = HorizontalAlignmentEnum.LEFT;
422
        natTableConfiguration.vAlign = VerticalAlignmentEnum.TOP;
423

  
424
        // Setup even odd row colors - row colors override the NatTable default
425
        // colors
426
        DefaultRowStyleConfiguration rowStyleConfiguration = new DefaultRowStyleConfiguration();
427
        rowStyleConfiguration.oddRowBgColor = ColorResources.getColor(Resources.COLOR_LIST_ODD);
428
        rowStyleConfiguration.evenRowBgColor = ColorResources.getColor(Resources.COLOR_LIST_EVEN);
429

  
430
        // Setup selection styling
431
        DefaultSelectionStyleConfiguration selectionStyle = new DefaultSelectionStyleConfiguration();
432
//        selectionStyle.selectionFont = GUIHelper.getFont(new FontData("Verdana", 8, SWT.NORMAL));
433
//        selectionStyle.selectionBgColor = GUIHelper.getColor(217, 232, 251);
434
//        selectionStyle.selectionFgColor = GUIHelper.COLOR_BLACK;
435
        selectionStyle.anchorBorderStyle = new BorderStyle(1, GUIHelper.COLOR_DARK_GRAY, LineStyleEnum.SOLID);
436
//        selectionStyle.anchorBgColor = GUIHelper.getColor(65, 113, 43);
437
        selectionStyle.selectedHeaderBgColor = GUIHelper.getColor(156, 209, 103);
438

  
439
        // Add all style configurations to NatTable
440
        natTable.addConfiguration(natTableConfiguration);
441
        natTable.addConfiguration(rowStyleConfiguration);
442
        natTable.addConfiguration(selectionStyle);
443

  
444
        // Column/Row header style and custom painters
445
        DefaultRowHeaderStyleConfiguration rowHeaderConfig = new DefaultRowHeaderStyleConfiguration();
446
        Color rowColumnColor = GUIHelper.getColor(230, 255, 255);
447
        rowHeaderConfig.bgColor = rowColumnColor;
448
        natTable.addConfiguration(rowHeaderConfig);
449
        DefaultColumnHeaderStyleConfiguration columnHeaderStyle = new DefaultColumnHeaderStyleConfiguration();
450
        columnHeaderStyle.bgColor = rowColumnColor;
451
        columnHeaderStyle.font = GUIHelper.getFont(new FontData("Verdana", 8, SWT.BOLD));
452
        natTable.addConfiguration(columnHeaderStyle);
453

  
454
        // Add popup menu - build your own popup menu using the PopupMenuBuilder
455
        natTable.addConfiguration(new HeaderMenuConfiguration(natTable));
395 456
    }
396 457

  
397 458
    private void toggleTreeFlat(boolean isTree, Button btnToggleFlat, Button btnToggleTree, Button btnCollapseAll, Button btnExpandAll) {
......
611 672
            }
612 673
        });
613 674

  
675
        Style cellStyle = new Style();
676
        cellStyle.setAttributeValue(CellStyleAttributes.HORIZONTAL_ALIGNMENT, HorizontalAlignmentEnum.LEFT);
677

  
614 678
        // add custom configuration for data conversion and add column labels to viewport layer
615 679
        viewportLayer.addConfiguration(new AbstractRegistryConfiguration() {
616 680
            @Override
......
622 686
                        DisplayMode.NORMAL,
623 687
                        TAXON_COLUMN);
624 688
                configRegistry.registerConfigAttribute(
689
                        CellConfigAttributes.CELL_STYLE,
690
                        cellStyle,
691
                        DisplayMode.NORMAL,
692
                        TAXON_COLUMN);
693
                configRegistry.registerConfigAttribute(
625 694
                        CellConfigAttributes.DISPLAY_CONVERTER,
626 695
                        new SupplementalInfoDisplayConverter(),
627 696
                        DisplayMode.NORMAL,
628 697
                        COLLECTOR_COLUMN);
629 698
                configRegistry.registerConfigAttribute(
699
                        CellConfigAttributes.CELL_STYLE,
700
                        cellStyle,
701
                        DisplayMode.NORMAL,
702
                        COLLECTOR_COLUMN);
703
                configRegistry.registerConfigAttribute(
630 704
                        CellConfigAttributes.DISPLAY_CONVERTER,
631 705
                        new SupplementalInfoDisplayConverter(),
632 706
                        DisplayMode.NORMAL,
633 707
                        IDENTIFIER_COLUMN);
634 708
                configRegistry.registerConfigAttribute(
709
                        CellConfigAttributes.CELL_STYLE,
710
                        cellStyle,
711
                        DisplayMode.NORMAL,
712
                        IDENTIFIER_COLUMN);
713
                configRegistry.registerConfigAttribute(
635 714
                        CellConfigAttributes.DISPLAY_CONVERTER,
636 715
                        new SupplementalInfoDisplayConverter(),
637 716
                        DisplayMode.NORMAL,
638 717
                        COUNTRY_COLUMN);
718
                configRegistry.registerConfigAttribute(
719
                        CellConfigAttributes.CELL_STYLE,
720
                        cellStyle,
721
                        DisplayMode.NORMAL,
722
                        COUNTRY_COLUMN);
639 723
                features.forEach(feature->registerColumnConfiguration(feature, configRegistry));
640 724
            }
641 725

  

Also available in: Unified diff

Add picture from clipboard (Maximum size: 40 MB)