import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.jface.layout.GridDataFactory;
import org.eclipse.jface.viewers.ComboViewer;
-import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.nebula.widgets.nattable.NatTable;
import org.eclipse.nebula.widgets.nattable.config.ConfigRegistry;
import org.eclipse.nebula.widgets.nattable.config.DefaultNatTableStyleConfiguration;
import org.eclipse.nebula.widgets.nattable.layer.CompositeLayer;
import org.eclipse.nebula.widgets.nattable.layer.DataLayer;
import org.eclipse.nebula.widgets.nattable.layer.ILayer;
-import org.eclipse.nebula.widgets.nattable.layer.ILayerListener;
import org.eclipse.nebula.widgets.nattable.layer.cell.ColumnOverrideLabelAccumulator;
-import org.eclipse.nebula.widgets.nattable.layer.cell.ILayerCell;
-import org.eclipse.nebula.widgets.nattable.layer.event.ILayerEvent;
import org.eclipse.nebula.widgets.nattable.layer.stack.DefaultBodyLayerStack;
import org.eclipse.nebula.widgets.nattable.selection.SelectionLayer;
-import org.eclipse.nebula.widgets.nattable.selection.event.CellSelectionEvent;
import org.eclipse.nebula.widgets.nattable.sort.SortHeaderLayer;
import org.eclipse.nebula.widgets.nattable.sort.config.SingleClickSortConfiguration;
import org.eclipse.nebula.widgets.nattable.style.HorizontalAlignmentEnum;
import org.eclipse.nebula.widgets.nattable.summaryrow.SummaryRowLayer;
import org.eclipse.nebula.widgets.nattable.tree.ITreeRowModel;
import org.eclipse.nebula.widgets.nattable.tree.TreeLayer;
-import org.eclipse.nebula.widgets.nattable.ui.menu.AbstractHeaderMenuConfiguration;
-import org.eclipse.nebula.widgets.nattable.ui.menu.PopupMenuBuilder;
import org.eclipse.nebula.widgets.nattable.util.GUIHelper;
import org.eclipse.nebula.widgets.nattable.viewport.ViewportLayer;
import org.eclipse.swt.SWT;
private void applyStyles(){
ModernNatTableThemeConfiguration configuration = new ModernNatTableThemeConfiguration();
configuration.summaryRowHAlign = HorizontalAlignmentEnum.CENTER;
+ // NOTE: Getting the colors and fonts from the GUIHelper ensures that
+ // they are disposed properly (required by SWT)
configuration.summaryRowBgColor = GUIHelper.getColor(255, 255, 153);
configuration.cHeaderBgColor = GUIHelper.getColor(211, 211, 211);
configuration.rHeaderBgColor = GUIHelper.getColor(211, 211, 211);
natTable.addConfiguration(configuration);
-// // NOTE: Getting the colors and fonts from the GUIHelper ensures that
-// // they are disposed properly (required by SWT)
-// DefaultNatTableStyleConfiguration natTableConfiguration = new DefaultNatTableStyleConfiguration();
-// natTableConfiguration.bgColor = GUIHelper.getColor(249, 172, 7);
-// natTableConfiguration.fgColor = GUIHelper.getColor(30, 76, 19);
-// natTableConfiguration.hAlign = HorizontalAlignmentEnum.LEFT;
-// natTableConfiguration.vAlign = VerticalAlignmentEnum.TOP;
-//// natTableConfiguration.borderStyle = new BorderStyle(1, GUIHelper.getColor(249, 172, 7), LineStyleEnum.SOLID);
-//
-// // Setup even odd row colors - row colors override the NatTable default
-// // colors
-// DefaultRowStyleConfiguration rowStyleConfiguration = new DefaultRowStyleConfiguration();
-// rowStyleConfiguration.oddRowBgColor = ColorResources.getColor(Resources.COLOR_LIST_ODD);
-// rowStyleConfiguration.evenRowBgColor = ColorResources.getColor(Resources.COLOR_LIST_EVEN);
-//
-// // Setup selection styling
-// DefaultSelectionStyleConfiguration selectionStyle = new DefaultSelectionStyleConfiguration();
-//// selectionStyle.selectionFont = GUIHelper.getFont(new FontData("Verdana", 8, SWT.NORMAL));
-//// selectionStyle.selectionBgColor = GUIHelper.getColor(217, 232, 251);
-//// selectionStyle.selectionFgColor = GUIHelper.COLOR_BLACK;
-//// selectionStyle.anchorBorderStyle = new BorderStyle(1, GUIHelper.COLOR_DARK_GRAY, LineStyleEnum.SOLID);
-//// selectionStyle.anchorBgColor = GUIHelper.getColor(65, 113, 43);
-// selectionStyle.selectedHeaderBgColor = GUIHelper.getColor(156, 209, 103);
-//
-// // Add all style configurations to NatTable
-// natTable.addConfiguration(natTableConfiguration);
-// natTable.addConfiguration(rowStyleConfiguration);
-// natTable.addConfiguration(selectionStyle);
-//
-// // Column/Row header style and custom painters
-// DefaultRowHeaderStyleConfiguration rowHeaderConfig = new DefaultRowHeaderStyleConfiguration();
-// Color rowColumnColor = GUIHelper.getColor(230, 255, 255);
-// rowHeaderConfig.bgColor = rowColumnColor;
-// natTable.addConfiguration(rowHeaderConfig);
-// DefaultColumnHeaderStyleConfiguration columnHeaderStyle = new DefaultColumnHeaderStyleConfiguration();
-// columnHeaderStyle.bgColor = rowColumnColor;
-// columnHeaderStyle.font = GUIHelper.getFont(new FontData("Verdana", 9, SWT.BOLD)); //$NON-NLS-1$
-// natTable.addConfiguration(columnHeaderStyle);
}
*/
registerHandlersAndListeners(topMostLayer);
+ //grab all space
GridDataFactory.fillDefaults().grab(true, true).applyTo(natTable);
+ //update label to current data set
toolbar.getWsLabel().setText(descriptiveDataSet.getLabel());
toolbar.getWsLabel().setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
toolbar.getWsLabel().getParent().layout();
+ //initial freeze of supplemental columns
freezeSupplementalColumns(true);
this.layout();
topMostLayer.registerCommandHandler(new ExportCommandHandler(topMostLayer));
//propagate single cell selection
- natTable.addLayerListener(new ILayerListener() {
- @Override
- public void handleLayerEvent(ILayerEvent event) {
- if(event instanceof CellSelectionEvent){
- CellSelectionEvent cellSelectionEvent = (CellSelectionEvent)event;
- int columnPosition = cellSelectionEvent.getColumnPosition();
- if(columnPosition>LEADING_COLUMN_COUNT){
- Collection<ILayerCell> selectedCells = cellSelectionEvent.getSelectionLayer().getSelectedCells();
- StructuredSelection selection = new StructuredSelection();
- if(selectedCells.size()==1){
- ILayerCell cell = selectedCells.iterator().next();
- Object dataValue = cell.getDataValue();
- if(dataValue!=null){
- selection = new StructuredSelection(dataValue);
- }
- }
- part.getSelectionService().setSelection(selection);
- }
- }
- }
- });
+ natTable.addLayerListener(new CellSelectionListener(part));
//register handler for view configuration menu
natTable.registerCommandHandler(toolbar.getDisplayPersistenceDialogCommandHandler());
// add the header menu configuration for adding the column header menu
// with hide/show actions
- natTable.addConfiguration(new AbstractHeaderMenuConfiguration(natTable) {
-
- @Override
- protected PopupMenuBuilder createColumnHeaderMenu(NatTable natTable) {
- return super.createColumnHeaderMenu(natTable)
- .withHideColumnMenuItem()
- .withShowAllColumnsMenuItem();
- }
-
- });
+ natTable.addConfiguration(new CharacterMatrixHeaderMenuConfiguration(natTable));
// add custom configuration for data conversion and add column labels to viewport layer
topMostLayer.addConfiguration(new DataConversionConfiguration(this));
- //no summary for the supplemental columns
- summaryRowLayer.addConfiguration(new SummaryRowConfiguration());
-
- //register aggregation configuration for each feature
- features.forEach(feature->summaryRowLayer.addConfiguration(new AggregationConfiguration(bodyDataProvider, feature)));
+ //register aggregation configuration
+ summaryRowLayer.addConfiguration(new AggregationConfiguration(this));
natTable.configure();
}
}
monitor.done();
});
- job.schedule();
+ job.schedule(1000);
}
public List<State> getSupportedStatesForCategoricalFeature(Feature feature){