Search in sources :

Example 1 with ClientAreaAdapter

use of org.eclipse.nebula.widgets.nattable.util.ClientAreaAdapter in project nebula.widgets.nattable by eclipse.

the class _5043_VerticalSplitViewportExample method createSplitSliders.

private void createSplitSliders(Composite natTableParent, final ViewportLayer top, final ViewportLayer bottom) {
    Composite sliderComposite = new Composite(natTableParent, SWT.NONE);
    GridData gridData = new GridData();
    gridData.verticalAlignment = GridData.FILL;
    gridData.grabExcessHorizontalSpace = false;
    gridData.grabExcessVerticalSpace = true;
    gridData.widthHint = 17;
    sliderComposite.setLayoutData(gridData);
    GridLayout gridLayout = new GridLayout(1, false);
    gridLayout.marginHeight = 0;
    gridLayout.marginWidth = 0;
    gridLayout.horizontalSpacing = 0;
    gridLayout.verticalSpacing = 0;
    sliderComposite.setLayout(gridLayout);
    // Slider Left
    // Need a composite here to set preferred size because Slider can't be
    // subclassed.
    Composite sliderTopComposite = new Composite(sliderComposite, SWT.NONE) {

        @Override
        public Point computeSize(int wHint, int hHint, boolean changed) {
            int height = ((ClientAreaAdapter) top.getClientAreaProvider()).getHeight();
            return new Point(17, height);
        }
    };
    sliderTopComposite.setLayout(new FillLayout());
    gridData = new GridData();
    gridData.horizontalAlignment = GridData.BEGINNING;
    gridData.verticalAlignment = GridData.BEGINNING;
    sliderTopComposite.setLayoutData(gridData);
    Slider sliderTop = new Slider(sliderTopComposite, SWT.VERTICAL);
    gridData = new GridData();
    gridData.horizontalAlignment = GridData.FILL;
    gridData.verticalAlignment = GridData.FILL;
    sliderTop.setLayoutData(gridData);
    top.setVerticalScroller(new SliderScroller(sliderTop));
    // Slider Right
    Slider sliderBottom = new Slider(sliderComposite, SWT.VERTICAL);
    gridData = new GridData();
    gridData.horizontalAlignment = GridData.BEGINNING;
    gridData.verticalAlignment = GridData.FILL;
    gridData.grabExcessHorizontalSpace = false;
    gridData.grabExcessVerticalSpace = true;
    sliderBottom.setLayoutData(gridData);
    bottom.setVerticalScroller(new SliderScroller(sliderBottom));
}
Also used : ClientAreaAdapter(org.eclipse.nebula.widgets.nattable.util.ClientAreaAdapter) GridLayout(org.eclipse.swt.layout.GridLayout) Composite(org.eclipse.swt.widgets.Composite) Slider(org.eclipse.swt.widgets.Slider) GridData(org.eclipse.swt.layout.GridData) Point(org.eclipse.swt.graphics.Point) FillLayout(org.eclipse.swt.layout.FillLayout) SliderScroller(org.eclipse.nebula.widgets.nattable.viewport.SliderScroller) Point(org.eclipse.swt.graphics.Point)

Example 2 with ClientAreaAdapter

use of org.eclipse.nebula.widgets.nattable.util.ClientAreaAdapter in project nebula.widgets.nattable by eclipse.

the class _5045_ScrollableRowHeaderExample method createExampleControl.

@Override
public Control createExampleControl(Composite parent) {
    // property names of the Person class
    String[] propertyNames = { "firstName", "lastName", "gender", "married", "birthday" };
    // mapping from property to label, needed for column header labels
    Map<String, String> propertyToLabelMap = new HashMap<>();
    propertyToLabelMap.put("firstName", "Firstname");
    propertyToLabelMap.put("lastName", "Lastname");
    propertyToLabelMap.put("gender", "Gender");
    propertyToLabelMap.put("married", "Married");
    propertyToLabelMap.put("birthday", "Birthday");
    IColumnPropertyAccessor<Person> columnPropertyAccessor = new ReflectiveColumnPropertyAccessor<>(propertyNames);
    IDataProvider bodyDataProvider = new ListDataProvider<>(PersonService.getPersons(10), columnPropertyAccessor);
    DataLayer bodyDataLayer = new DataLayer(bodyDataProvider);
    SelectionLayer selectionLayer = new SelectionLayer(bodyDataLayer);
    ViewportLayer viewportLayer = new ViewportLayer(selectionLayer);
    DataLayer rowDataLayer = new DataLayer(new IDataProvider() {

        @Override
        public void setDataValue(int columnIndex, int rowIndex, Object newValue) {
        }

        @Override
        public int getRowCount() {
            return bodyDataProvider.getRowCount();
        }

        @Override
        public Object getDataValue(int columnIndex, int rowIndex) {
            return "Lorem ipsum dolor";
        }

        @Override
        public int getColumnCount() {
            return 1;
        }
    });
    rowDataLayer.setDefaultColumnWidth(150);
    ViewportLayer rowViewport = new ViewportLayer(rowDataLayer);
    RowHeaderLayer scrollableRowHeaderLayer = new RowHeaderLayer(rowViewport, viewportLayer, selectionLayer);
    RowHeaderLayer rowHeaderLayer = new RowHeaderLayer(new DefaultRowHeaderDataLayer(new DefaultRowHeaderDataProvider(bodyDataProvider)), viewportLayer, selectionLayer);
    CompositeLayer compositeLayer = new CompositeLayer(2, 1);
    compositeLayer.setChildLayer(GridRegion.ROW_HEADER, rowHeaderLayer, 0, 0);
    compositeLayer.setChildLayer(GridRegion.ROW_HEADER, scrollableRowHeaderLayer, 1, 0);
    // build the column header layer
    IDataProvider columnHeaderDataProvider = new DefaultColumnHeaderDataProvider(propertyNames, propertyToLabelMap);
    final DataLayer columnHeaderDataLayer = new DefaultColumnHeaderDataLayer(columnHeaderDataProvider);
    final AbstractLayer columnHeaderLayer = new ColumnHeaderLayer(columnHeaderDataLayer, viewportLayer, selectionLayer);
    // build the corner layer
    IDataProvider cornerDataProvider = new DefaultCornerDataProvider(columnHeaderDataProvider, rowDataLayer.getDataProvider());
    DataLayer cornerDataLayer = new DataLayer(cornerDataProvider);
    final ILayer cornerLayer = new CornerLayer(cornerDataLayer, compositeLayer, columnHeaderLayer);
    GridLayer gridLayer = new GridLayer(viewportLayer, columnHeaderLayer, compositeLayer, cornerLayer);
    // MULTI-VIEWPORT-CONFIGURATION
    // use a cell layer painter that is configured for left clipping
    // this ensures that the rendering works correctly for split
    // viewports
    selectionLayer.setLayerPainter(new SelectionLayerPainter(true, false));
    columnHeaderLayer.setLayerPainter(new CellLayerPainter(true, false));
    // as the CompositeLayer is setting a IClientAreaProvider for the
    // composition we need to set a special ClientAreaAdapter after the
    // creation of the CompositeLayer to support split viewports
    int leftWidth = 100;
    ClientAreaAdapter leftClientAreaAdapter = new ClientAreaAdapter(rowViewport.getClientAreaProvider());
    leftClientAreaAdapter.setWidth(leftWidth);
    rowViewport.setClientAreaProvider(leftClientAreaAdapter);
    // Wrap NatTable in composite so we can slap on the external horizontal
    // sliders
    Composite composite = new Composite(parent, SWT.NONE);
    GridLayout gridLayout = new GridLayout(1, false);
    gridLayout.marginHeight = 0;
    gridLayout.marginWidth = 0;
    gridLayout.horizontalSpacing = 0;
    gridLayout.verticalSpacing = 0;
    composite.setLayout(gridLayout);
    NatTable natTable = new NatTable(composite, gridLayer);
    GridData gridData = new GridData();
    gridData.horizontalAlignment = GridData.FILL;
    gridData.verticalAlignment = GridData.FILL;
    gridData.grabExcessHorizontalSpace = true;
    gridData.grabExcessVerticalSpace = true;
    natTable.setLayoutData(gridData);
    createSplitSliders(composite, rowViewport, rowHeaderLayer.getWidth(), viewportLayer);
    // add an IOverlayPainter to render the split viewport border
    natTable.addOverlayPainter(new IOverlayPainter() {

        @Override
        public void paintOverlay(GC gc, ILayer layer) {
            Color beforeColor = gc.getForeground();
            gc.setForeground(GUIHelper.COLOR_GRAY);
            int viewportBorderX = compositeLayer.getWidth() - 1;
            gc.drawLine(viewportBorderX, 0, viewportBorderX, layer.getHeight() - 1);
            gc.setForeground(beforeColor);
        }
    });
    // Mouse move - Show resize cursor
    natTable.getUiBindingRegistry().registerFirstMouseMoveBinding(new ClientAreaResizeMatcher(compositeLayer), new VerticalResizeCursorAction());
    natTable.getUiBindingRegistry().registerFirstMouseDragMode(new ClientAreaResizeMatcher(compositeLayer), new ClientAreaResizeDragMode(compositeLayer, rowDataLayer, leftClientAreaAdapter, rowViewport, viewportLayer));
    return natTable;
}
Also used : ListDataProvider(org.eclipse.nebula.widgets.nattable.data.ListDataProvider) AbstractLayer(org.eclipse.nebula.widgets.nattable.layer.AbstractLayer) HashMap(java.util.HashMap) ColumnHeaderLayer(org.eclipse.nebula.widgets.nattable.grid.layer.ColumnHeaderLayer) DefaultCornerDataProvider(org.eclipse.nebula.widgets.nattable.grid.data.DefaultCornerDataProvider) IDataProvider(org.eclipse.nebula.widgets.nattable.data.IDataProvider) ViewportLayer(org.eclipse.nebula.widgets.nattable.viewport.ViewportLayer) ClientAreaAdapter(org.eclipse.nebula.widgets.nattable.util.ClientAreaAdapter) DataLayer(org.eclipse.nebula.widgets.nattable.layer.DataLayer) DefaultRowHeaderDataLayer(org.eclipse.nebula.widgets.nattable.grid.layer.DefaultRowHeaderDataLayer) DefaultColumnHeaderDataLayer(org.eclipse.nebula.widgets.nattable.grid.layer.DefaultColumnHeaderDataLayer) GridLayout(org.eclipse.swt.layout.GridLayout) DefaultRowHeaderDataLayer(org.eclipse.nebula.widgets.nattable.grid.layer.DefaultRowHeaderDataLayer) NatTable(org.eclipse.nebula.widgets.nattable.NatTable) GC(org.eclipse.swt.graphics.GC) Composite(org.eclipse.swt.widgets.Composite) IOverlayPainter(org.eclipse.nebula.widgets.nattable.painter.IOverlayPainter) ILayer(org.eclipse.nebula.widgets.nattable.layer.ILayer) Color(org.eclipse.swt.graphics.Color) DefaultRowHeaderDataProvider(org.eclipse.nebula.widgets.nattable.grid.data.DefaultRowHeaderDataProvider) DefaultColumnHeaderDataLayer(org.eclipse.nebula.widgets.nattable.grid.layer.DefaultColumnHeaderDataLayer) CompositeLayer(org.eclipse.nebula.widgets.nattable.layer.CompositeLayer) Point(org.eclipse.swt.graphics.Point) ReflectiveColumnPropertyAccessor(org.eclipse.nebula.widgets.nattable.data.ReflectiveColumnPropertyAccessor) RowHeaderLayer(org.eclipse.nebula.widgets.nattable.grid.layer.RowHeaderLayer) SelectionLayerPainter(org.eclipse.nebula.widgets.nattable.selection.SelectionLayerPainter) CornerLayer(org.eclipse.nebula.widgets.nattable.grid.layer.CornerLayer) SelectionLayer(org.eclipse.nebula.widgets.nattable.selection.SelectionLayer) CellLayerPainter(org.eclipse.nebula.widgets.nattable.painter.layer.CellLayerPainter) GridData(org.eclipse.swt.layout.GridData) GridLayer(org.eclipse.nebula.widgets.nattable.grid.layer.GridLayer) DefaultColumnHeaderDataProvider(org.eclipse.nebula.widgets.nattable.grid.data.DefaultColumnHeaderDataProvider) VerticalResizeCursorAction(org.eclipse.nebula.widgets.nattable.resize.action.VerticalResizeCursorAction) Person(org.eclipse.nebula.widgets.nattable.dataset.person.Person)

Example 3 with ClientAreaAdapter

use of org.eclipse.nebula.widgets.nattable.util.ClientAreaAdapter in project nebula.widgets.nattable by eclipse.

the class _5046_MultiScrollExample method createExampleControl.

@Override
public Control createExampleControl(Composite parent) {
    List<PersonWithAddress> values = PersonService.getPersonsWithAddress(10);
    ContentBodyLayerStack contentBodyLayer = new ContentBodyLayerStack(values);
    StructureBodyLayerStack structureBodyLayer = new StructureBodyLayerStack(values, contentBodyLayer);
    // build the column header layer
    IDataProvider contentHeaderDataProvider = new DefaultColumnHeaderDataProvider(contentBodyLayer.propertyNames, contentBodyLayer.propertyToLabelMap);
    DataLayer contentHeaderDataLayer = new DefaultColumnHeaderDataLayer(contentHeaderDataProvider);
    AbstractLayer contentColumnHeaderLayer = new ColumnHeaderLayer(contentHeaderDataLayer, contentBodyLayer, contentBodyLayer.getSelectionLayer());
    IDataProvider structureHeaderDataProvider = new DefaultColumnHeaderDataProvider(structureBodyLayer.propertyNames, structureBodyLayer.propertyToLabelMap);
    DataLayer structureHeaderDataLayer = new DefaultColumnHeaderDataLayer(structureHeaderDataProvider);
    ColumnHeaderLayer structureColumnHeaderLayer = new ColumnHeaderLayer(structureHeaderDataLayer, structureBodyLayer, structureBodyLayer.selectionLayer);
    structureColumnHeaderLayer.setVerticalLayerDependency(contentColumnHeaderLayer);
    DataLayer rowHeaderDataLayer = new DefaultRowHeaderDataLayer(new DefaultRowHeaderDataProvider(contentBodyLayer.bodyDataProvider));
    ILayer rowHeaderLayer = new RowHeaderLayer(rowHeaderDataLayer, contentBodyLayer, (SelectionLayer) null);
    // build the corner layer
    IDataProvider cornerDataProvider = new DefaultCornerDataProvider(contentHeaderDataProvider, rowHeaderDataLayer.getDataProvider());
    DataLayer cornerDataLayer = new DataLayer(cornerDataProvider);
    ILayer cornerLayer = new CornerLayer(cornerDataLayer, rowHeaderLayer, contentColumnHeaderLayer);
    ExtendedGridLayer gridLayer = new ExtendedGridLayer(contentBodyLayer, contentColumnHeaderLayer, structureBodyLayer, structureColumnHeaderLayer, rowHeaderLayer, cornerLayer);
    // MULTI-VIEWPORT-CONFIGURATION
    // as the CompositeLayer is setting a IClientAreaProvider for the
    // composition we need to set a special ClientAreaAdapter after the
    // creation of the CompositeLayer to support split viewports
    int leftWidth = 80;
    ClientAreaAdapter leftClientAreaAdapter = new ClientAreaAdapter(structureBodyLayer.getViewportLayer().getClientAreaProvider());
    leftClientAreaAdapter.setWidth(leftWidth);
    structureBodyLayer.getViewportLayer().setClientAreaProvider(leftClientAreaAdapter);
    structureBodyLayer.getViewportLayer().setVerticalScrollbarEnabled(false);
    // use a cell layer painter that is configured for left clipping
    // this ensures that the rendering works correctly for split
    // viewports
    contentBodyLayer.getSelectionLayer().setLayerPainter(new SelectionLayerPainter(true, false));
    contentColumnHeaderLayer.setLayerPainter(new CellLayerPainter(true, false));
    ScrolledComposite sc = new ScrolledComposite(parent, SWT.H_SCROLL | SWT.V_SCROLL);
    // Wrap NatTable in composite so we can slap on the external horizontal
    // sliders
    Composite composite = new Composite(sc, SWT.NONE);
    GridLayout gridLayout = new GridLayout(1, false);
    gridLayout.marginHeight = 0;
    gridLayout.marginWidth = 0;
    gridLayout.horizontalSpacing = 0;
    gridLayout.verticalSpacing = 0;
    composite.setLayout(gridLayout);
    NatTable natTable = new NatTable(composite, gridLayer);
    GridData gridData = new GridData();
    gridData.horizontalAlignment = GridData.FILL;
    gridData.verticalAlignment = GridData.FILL;
    gridData.grabExcessHorizontalSpace = true;
    gridData.grabExcessVerticalSpace = true;
    natTable.setLayoutData(gridData);
    createSplitSliders(composite, gridLayer, rowHeaderLayer.getWidth());
    sc.setContent(composite);
    sc.setExpandHorizontal(true);
    sc.setExpandVertical(true);
    updateScrolledCompositeSize(sc, gridLayer);
    // add an IOverlayPainter to render the split viewport border
    natTable.addOverlayPainter(new IOverlayPainter() {

        @Override
        public void paintOverlay(GC gc, ILayer layer) {
            Color beforeColor = gc.getForeground();
            gc.setForeground(GUIHelper.COLOR_GRAY);
            int viewportBorderX = rowHeaderLayer.getWidth() + gridLayer.getStructureBody().getWidth() - 1;
            gc.drawLine(viewportBorderX, 0, viewportBorderX, layer.getHeight() - 1);
            gc.setForeground(beforeColor);
        }
    });
    // Mouse move - Show resize cursor
    natTable.getUiBindingRegistry().registerFirstMouseMoveBinding(new ClientAreaResizeMatcher(gridLayer), new VerticalResizeCursorAction());
    natTable.getUiBindingRegistry().registerFirstMouseDragMode(new ClientAreaResizeMatcher(gridLayer), new ClientAreaResizeDragMode(gridLayer, sc));
    return natTable;
}
Also used : AbstractLayer(org.eclipse.nebula.widgets.nattable.layer.AbstractLayer) ColumnHeaderLayer(org.eclipse.nebula.widgets.nattable.grid.layer.ColumnHeaderLayer) DefaultCornerDataProvider(org.eclipse.nebula.widgets.nattable.grid.data.DefaultCornerDataProvider) IDataProvider(org.eclipse.nebula.widgets.nattable.data.IDataProvider) ClientAreaAdapter(org.eclipse.nebula.widgets.nattable.util.ClientAreaAdapter) DataLayer(org.eclipse.nebula.widgets.nattable.layer.DataLayer) DefaultRowHeaderDataLayer(org.eclipse.nebula.widgets.nattable.grid.layer.DefaultRowHeaderDataLayer) DefaultColumnHeaderDataLayer(org.eclipse.nebula.widgets.nattable.grid.layer.DefaultColumnHeaderDataLayer) GridLayout(org.eclipse.swt.layout.GridLayout) DefaultRowHeaderDataLayer(org.eclipse.nebula.widgets.nattable.grid.layer.DefaultRowHeaderDataLayer) ScrolledComposite(org.eclipse.swt.custom.ScrolledComposite) NatTable(org.eclipse.nebula.widgets.nattable.NatTable) PersonWithAddress(org.eclipse.nebula.widgets.nattable.dataset.person.PersonWithAddress) GC(org.eclipse.swt.graphics.GC) Composite(org.eclipse.swt.widgets.Composite) ScrolledComposite(org.eclipse.swt.custom.ScrolledComposite) IOverlayPainter(org.eclipse.nebula.widgets.nattable.painter.IOverlayPainter) ILayer(org.eclipse.nebula.widgets.nattable.layer.ILayer) Color(org.eclipse.swt.graphics.Color) DefaultColumnHeaderDataLayer(org.eclipse.nebula.widgets.nattable.grid.layer.DefaultColumnHeaderDataLayer) DefaultRowHeaderDataProvider(org.eclipse.nebula.widgets.nattable.grid.data.DefaultRowHeaderDataProvider) Point(org.eclipse.swt.graphics.Point) RowHeaderLayer(org.eclipse.nebula.widgets.nattable.grid.layer.RowHeaderLayer) SelectionLayerPainter(org.eclipse.nebula.widgets.nattable.selection.SelectionLayerPainter) CornerLayer(org.eclipse.nebula.widgets.nattable.grid.layer.CornerLayer) CellLayerPainter(org.eclipse.nebula.widgets.nattable.painter.layer.CellLayerPainter) GridData(org.eclipse.swt.layout.GridData) DefaultColumnHeaderDataProvider(org.eclipse.nebula.widgets.nattable.grid.data.DefaultColumnHeaderDataProvider) VerticalResizeCursorAction(org.eclipse.nebula.widgets.nattable.resize.action.VerticalResizeCursorAction)

Example 4 with ClientAreaAdapter

use of org.eclipse.nebula.widgets.nattable.util.ClientAreaAdapter in project nebula.widgets.nattable by eclipse.

the class _5042_HorizontalSplitViewportExample method createExampleControl.

@Override
public Control createExampleControl(Composite parent) {
    // property names of the Person class
    String[] propertyNames = { "firstName", "lastName", "gender", "married", "birthday", "address.street", "address.housenumber", "address.postalCode", "address.city" };
    IColumnPropertyAccessor<PersonWithAddress> columnPropertyAccessor = new ExtendedReflectiveColumnPropertyAccessor<>(propertyNames);
    IDataProvider bodyDataProvider = new ListDataProvider<>(PersonService.getPersonsWithAddress(50), columnPropertyAccessor);
    DataLayer bodyDataLayer = new DataLayer(bodyDataProvider);
    // use a cell layer painter that is configured for left clipping
    // this ensures that the rendering works correctly for split viewports
    bodyDataLayer.setLayerPainter(new GridLineCellLayerPainter(true, false));
    // create a ViewportLayer for the left part of the table and configure
    // it to only contain the first 5 columns
    final ViewportLayer viewportLayerLeft = new ViewportLayer(bodyDataLayer);
    viewportLayerLeft.setMaxColumnPosition(5);
    // create a ViewportLayer for the right part of the table and configure
    // it to only contain the last 4 columns
    ViewportLayer viewportLayerRight = new ViewportLayer(bodyDataLayer);
    viewportLayerRight.setMinColumnPosition(5);
    // create a CompositeLayer that contains both ViewportLayers
    CompositeLayer compositeLayer = new CompositeLayer(2, 1);
    compositeLayer.setChildLayer("REGION_A", viewportLayerLeft, 0, 0);
    compositeLayer.setChildLayer("REGION_B", viewportLayerRight, 1, 0);
    // in order to make printing and exporting work correctly you need to
    // register the following command handlers
    // although in this example printing and exporting is not enabled, we
    // show the registering
    compositeLayer.registerCommandHandler(new MultiTurnViewportOnCommandHandler(viewportLayerLeft, viewportLayerRight));
    compositeLayer.registerCommandHandler(new MultiTurnViewportOffCommandHandler(viewportLayerLeft, viewportLayerRight));
    // set the width of the left viewport to only showing 2 columns at the
    // same time
    int leftWidth = bodyDataLayer.getStartXOfColumnPosition(2);
    // as the CompositeLayer is setting a IClientAreaProvider for the
    // composition we need to set a special ClientAreaAdapter after the
    // creation of the CompositeLayer to support split viewports
    ClientAreaAdapter leftClientAreaAdapter = new ClientAreaAdapter(viewportLayerLeft.getClientAreaProvider());
    leftClientAreaAdapter.setWidth(leftWidth);
    viewportLayerLeft.setClientAreaProvider(leftClientAreaAdapter);
    // Wrap NatTable in composite so we can slap on the external horizontal
    // sliders
    Composite composite = new Composite(parent, SWT.NONE);
    GridLayout gridLayout = new GridLayout(1, false);
    gridLayout.marginHeight = 0;
    gridLayout.marginWidth = 0;
    gridLayout.horizontalSpacing = 0;
    gridLayout.verticalSpacing = 0;
    composite.setLayout(gridLayout);
    NatTable natTable = new NatTable(composite, compositeLayer);
    GridData gridData = new GridData();
    gridData.horizontalAlignment = GridData.FILL;
    gridData.verticalAlignment = GridData.FILL;
    gridData.grabExcessHorizontalSpace = true;
    gridData.grabExcessVerticalSpace = true;
    natTable.setLayoutData(gridData);
    createSplitSliders(composite, viewportLayerLeft, viewportLayerRight);
    // add an IOverlayPainter to ensure the right border of the left
    // viewport always this is necessary because the left border of layer
    // stacks is not rendered by default
    natTable.addOverlayPainter(new IOverlayPainter() {

        @Override
        public void paintOverlay(GC gc, ILayer layer) {
            Color beforeColor = gc.getForeground();
            gc.setForeground(GUIHelper.COLOR_GRAY);
            int viewportBorderX = viewportLayerLeft.getWidth() - 1;
            gc.drawLine(viewportBorderX, 0, viewportBorderX, layer.getHeight() - 1);
            gc.setForeground(beforeColor);
        }
    });
    return composite;
}
Also used : ListDataProvider(org.eclipse.nebula.widgets.nattable.data.ListDataProvider) Composite(org.eclipse.swt.widgets.Composite) IOverlayPainter(org.eclipse.nebula.widgets.nattable.painter.IOverlayPainter) ILayer(org.eclipse.nebula.widgets.nattable.layer.ILayer) Color(org.eclipse.swt.graphics.Color) IDataProvider(org.eclipse.nebula.widgets.nattable.data.IDataProvider) ViewportLayer(org.eclipse.nebula.widgets.nattable.viewport.ViewportLayer) CompositeLayer(org.eclipse.nebula.widgets.nattable.layer.CompositeLayer) Point(org.eclipse.swt.graphics.Point) MultiTurnViewportOffCommandHandler(org.eclipse.nebula.widgets.nattable.print.command.MultiTurnViewportOffCommandHandler) MultiTurnViewportOnCommandHandler(org.eclipse.nebula.widgets.nattable.print.command.MultiTurnViewportOnCommandHandler) ClientAreaAdapter(org.eclipse.nebula.widgets.nattable.util.ClientAreaAdapter) DataLayer(org.eclipse.nebula.widgets.nattable.layer.DataLayer) GridLayout(org.eclipse.swt.layout.GridLayout) ExtendedReflectiveColumnPropertyAccessor(org.eclipse.nebula.widgets.nattable.data.ExtendedReflectiveColumnPropertyAccessor) GridData(org.eclipse.swt.layout.GridData) NatTable(org.eclipse.nebula.widgets.nattable.NatTable) PersonWithAddress(org.eclipse.nebula.widgets.nattable.dataset.person.PersonWithAddress) GridLineCellLayerPainter(org.eclipse.nebula.widgets.nattable.painter.layer.GridLineCellLayerPainter) GC(org.eclipse.swt.graphics.GC)

Example 5 with ClientAreaAdapter

use of org.eclipse.nebula.widgets.nattable.util.ClientAreaAdapter in project nebula.widgets.nattable by eclipse.

the class _5042_HorizontalSplitViewportExample method createSplitSliders.

private void createSplitSliders(Composite natTableParent, final ViewportLayer left, final ViewportLayer right) {
    Composite sliderComposite = new Composite(natTableParent, SWT.NONE);
    GridData gridData = new GridData();
    gridData.horizontalAlignment = GridData.FILL;
    gridData.grabExcessHorizontalSpace = true;
    gridData.grabExcessVerticalSpace = false;
    gridData.heightHint = 17;
    sliderComposite.setLayoutData(gridData);
    GridLayout gridLayout = new GridLayout(2, false);
    gridLayout.marginHeight = 0;
    gridLayout.marginWidth = 0;
    gridLayout.horizontalSpacing = 0;
    gridLayout.verticalSpacing = 0;
    sliderComposite.setLayout(gridLayout);
    // Slider Left
    // Need a composite here to set preferred size because Slider can't be
    // subclassed.
    Composite sliderLeftComposite = new Composite(sliderComposite, SWT.NONE) {

        @Override
        public Point computeSize(int wHint, int hHint, boolean changed) {
            int width = ((ClientAreaAdapter) left.getClientAreaProvider()).getWidth();
            return new Point(width, 17);
        }
    };
    sliderLeftComposite.setLayout(new FillLayout());
    gridData = new GridData();
    gridData.horizontalAlignment = GridData.BEGINNING;
    gridData.verticalAlignment = GridData.BEGINNING;
    sliderLeftComposite.setLayoutData(gridData);
    Slider sliderLeft = new Slider(sliderLeftComposite, SWT.HORIZONTAL);
    gridData = new GridData();
    gridData.horizontalAlignment = GridData.FILL;
    gridData.verticalAlignment = GridData.FILL;
    sliderLeft.setLayoutData(gridData);
    left.setHorizontalScroller(new SliderScroller(sliderLeft));
    // Slider Right
    Slider sliderRight = new Slider(sliderComposite, SWT.HORIZONTAL);
    gridData = new GridData();
    gridData.horizontalAlignment = GridData.FILL;
    gridData.verticalAlignment = GridData.BEGINNING;
    gridData.grabExcessHorizontalSpace = true;
    gridData.grabExcessVerticalSpace = false;
    sliderRight.setLayoutData(gridData);
    right.setHorizontalScroller(new SliderScroller(sliderRight));
}
Also used : ClientAreaAdapter(org.eclipse.nebula.widgets.nattable.util.ClientAreaAdapter) GridLayout(org.eclipse.swt.layout.GridLayout) Composite(org.eclipse.swt.widgets.Composite) Slider(org.eclipse.swt.widgets.Slider) GridData(org.eclipse.swt.layout.GridData) Point(org.eclipse.swt.graphics.Point) FillLayout(org.eclipse.swt.layout.FillLayout) SliderScroller(org.eclipse.nebula.widgets.nattable.viewport.SliderScroller) Point(org.eclipse.swt.graphics.Point)

Aggregations

ClientAreaAdapter (org.eclipse.nebula.widgets.nattable.util.ClientAreaAdapter)7 Point (org.eclipse.swt.graphics.Point)7 GridData (org.eclipse.swt.layout.GridData)7 GridLayout (org.eclipse.swt.layout.GridLayout)7 Composite (org.eclipse.swt.widgets.Composite)7 NatTable (org.eclipse.nebula.widgets.nattable.NatTable)4 IDataProvider (org.eclipse.nebula.widgets.nattable.data.IDataProvider)4 DataLayer (org.eclipse.nebula.widgets.nattable.layer.DataLayer)4 ILayer (org.eclipse.nebula.widgets.nattable.layer.ILayer)4 IOverlayPainter (org.eclipse.nebula.widgets.nattable.painter.IOverlayPainter)4 Color (org.eclipse.swt.graphics.Color)4 GC (org.eclipse.swt.graphics.GC)4 ListDataProvider (org.eclipse.nebula.widgets.nattable.data.ListDataProvider)3 PersonWithAddress (org.eclipse.nebula.widgets.nattable.dataset.person.PersonWithAddress)3 CompositeLayer (org.eclipse.nebula.widgets.nattable.layer.CompositeLayer)3 SliderScroller (org.eclipse.nebula.widgets.nattable.viewport.SliderScroller)3 ViewportLayer (org.eclipse.nebula.widgets.nattable.viewport.ViewportLayer)3 FillLayout (org.eclipse.swt.layout.FillLayout)3 Slider (org.eclipse.swt.widgets.Slider)3 ExtendedReflectiveColumnPropertyAccessor (org.eclipse.nebula.widgets.nattable.data.ExtendedReflectiveColumnPropertyAccessor)2