Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2013, 2021 Edwin Park and others.
* Copyright (c) 2013, 2025 Edwin Park and others.
*
* This program and the accompanying materials are made
* available under the terms of the Eclipse Public License 2.0
Expand All @@ -19,11 +19,26 @@
public class SliderScroller implements IScroller<Slider> {

private Slider slider;
private boolean handleVisibilityChange = true;

public SliderScroller(Slider slider) {
this.slider = slider;
}

/**
*
* @param slider
* The {@link Slider} to use as the scroller.
* @param handleVisibilityChange
* Configure if the scroller will handle visibility changes of
* the slider.
* @since 2.6
*/
public SliderScroller(Slider slider, boolean handleVisibilityChange) {
this.slider = slider;
this.handleVisibilityChange = handleVisibilityChange;
}

@Override
public Slider getUnderlying() {
return this.slider;
Expand Down Expand Up @@ -112,15 +127,17 @@ public boolean getVisible() {

@Override
public void setVisible(boolean b) {
boolean visible = this.slider.isVisible();
this.slider.setVisible(b);
// if the slider becomes invisible we fire a resize event to trigger
// re-calculation of percentage sized columns to take the slider
// space
if (!b && visible
&& !isDisposed()
&& !this.slider.getParent().isDisposed()) {
this.slider.getParent().notifyListeners(SWT.Resize, null);
if (this.handleVisibilityChange) {
boolean visible = this.slider.isVisible();
this.slider.setVisible(b);
// if the slider becomes invisible we fire a resize event to trigger
// re-calculation of percentage sized columns to take the slider
// space
if (!b && visible
&& !isDisposed()
&& !this.slider.getParent().isDisposed()) {
this.slider.getParent().notifyListeners(SWT.Resize, null);
}
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2012, 2023 Original authors and others.
* Copyright (c) 2012, 2025 Original authors and others.
*
* This program and the accompanying materials are made
* available under the terms of the Eclipse Public License 2.0
Expand Down Expand Up @@ -170,6 +170,15 @@ public void setHorizontalScroller(IScroller<?> scroller) {
}
}

/**
*
* @return The scroller that is used for horizontal scrolling.
* @since 2.6
*/
public IScroller<?> getHorizontalScroller() {
return this.horizontalScroller;
}

/**
* Set a different vertical scroller than the default one.
*
Expand All @@ -185,6 +194,15 @@ public void setVerticalScroller(IScroller<?> scroller) {
}
}

/**
*
* @return The scroller that is used for vertical scrolling.
* @since 2.6
*/
public IScroller<?> getVerticalScroller() {
return this.verticalScroller;
}

public int getMaxWidth() {
if (getMaxColumnPosition() < 0) {
return -1;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2013, 2021 Dirk Fauth and others.
* Copyright (c) 2013, 2025 Dirk Fauth and others.
*
* This program and the accompanying materials are made
* available under the terms of the Eclipse Public License 2.0
Expand Down Expand Up @@ -188,11 +188,6 @@ public Point computeSize(int wHint, int hHint, boolean changed) {
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
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2013, 2021 Dirk Fauth and others.
* Copyright (c) 2013, 2025 Dirk Fauth and others.
*
* This program and the accompanying materials are made
* available under the terms of the Eclipse Public License 2.0
Expand Down Expand Up @@ -187,11 +187,6 @@ public Point computeSize(int wHint, int hHint, boolean changed) {
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 Bottom
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2013, 2021 Dirk Fauth and others.
* Copyright (c) 2013, 2025 Dirk Fauth and others.
*
* This program and the accompanying materials are made
* available under the terms of the Eclipse Public License 2.0
Expand Down Expand Up @@ -321,11 +321,6 @@ public Point computeSize(int wHint, int hHint, boolean changed) {
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
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2015, 2024 Dirk Fauth and others.
* Copyright (c) 2015, 2025 Dirk Fauth and others.
*
* This program and the accompanying materials are made
* available under the terms of the Eclipse Public License 2.0
Expand All @@ -15,6 +15,7 @@
import java.util.HashMap;
import java.util.Map;

import org.eclipse.jface.layout.GridDataFactory;
import org.eclipse.nebula.widgets.nattable.NatTable;
import org.eclipse.nebula.widgets.nattable.data.IColumnPropertyAccessor;
import org.eclipse.nebula.widgets.nattable.data.IDataProvider;
Expand Down Expand Up @@ -183,6 +184,8 @@ public int getColumnCount() {
gridLayout.verticalSpacing = 0;
composite.setLayout(gridLayout);

GridDataFactory.fillDefaults().grab(true, true).applyTo(composite);

NatTable natTable = new NatTable(composite, gridLayer);
GridData gridData = new GridData();
gridData.horizontalAlignment = GridData.FILL;
Expand Down Expand Up @@ -219,14 +222,16 @@ public void paintOverlay(GC gc, ILayer layer) {
return natTable;
}

private void createSplitSliders(
Composite natTableParent, final ViewportLayer left, int fixedHeaderWidth, final ViewportLayer right) {
private void createSplitSliders(Composite natTableParent, final ViewportLayer left, int fixedHeaderWidth, final ViewportLayer right) {
// calculate the slider height according to the display scaling
int sliderHeight = GUIHelper.convertHorizontalPixelToDpi(17, true);

Composite sliderComposite = new Composite(natTableParent, SWT.NONE);
GridData gridData = new GridData();
gridData.horizontalAlignment = GridData.FILL;
gridData.grabExcessHorizontalSpace = true;
gridData.grabExcessVerticalSpace = false;
gridData.heightHint = 17;
gridData.heightHint = sliderHeight;
sliderComposite.setLayoutData(gridData);

GridLayout gridLayout = new GridLayout(2, false);
Expand All @@ -243,7 +248,7 @@ private void createSplitSliders(
@Override
public Point computeSize(int wHint, int hHint, boolean changed) {
int width = ((ClientAreaAdapter) left.getClientAreaProvider()).getWidth() + fixedHeaderWidth;
return new Point(width, 17);
return new Point(width, sliderHeight);
}
};
sliderLeftComposite.setLayout(new FillLayout());
Expand All @@ -253,11 +258,6 @@ public Point computeSize(int wHint, int hHint, boolean changed) {
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
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2016, 2024 Dirk Fauth and others.
* Copyright (c) 2016, 2025 Dirk Fauth and others.
*
* This program and the accompanying materials are made
* available under the terms of the Eclipse Public License 2.0
Expand All @@ -16,6 +16,7 @@
import java.util.List;
import java.util.Map;

import org.eclipse.jface.layout.GridDataFactory;
import org.eclipse.nebula.widgets.nattable.NatTable;
import org.eclipse.nebula.widgets.nattable.command.ILayerCommand;
import org.eclipse.nebula.widgets.nattable.data.ExtendedReflectiveColumnPropertyAccessor;
Expand Down Expand Up @@ -152,6 +153,7 @@ public Control createExampleControl(Composite parent) {
contentColumnHeaderLayer.setLayerPainter(new CellLayerPainter(true, false));

ScrolledComposite sc = new ScrolledComposite(parent, SWT.H_SCROLL | SWT.V_SCROLL);
GridDataFactory.fillDefaults().grab(true, true).applyTo(sc);

// Wrap NatTable in composite so we can slap on the external horizontal
// sliders
Expand All @@ -163,6 +165,8 @@ public Control createExampleControl(Composite parent) {
gridLayout.verticalSpacing = 0;
composite.setLayout(gridLayout);

GridDataFactory.fillDefaults().grab(true, true).applyTo(composite);

NatTable natTable = new NatTable(composite, gridLayer);
GridData gridData = new GridData();
gridData.horizontalAlignment = GridData.FILL;
Expand Down Expand Up @@ -222,14 +226,16 @@ private void updateScrolledCompositeSize(ScrolledComposite sc, ExtendedGridLayer
* @param gridLayer
* @param fixedHeaderWidth
*/
private void createSplitSliders(
Composite natTableParent, ExtendedGridLayer gridLayer, int fixedHeaderWidth) {
private void createSplitSliders(Composite natTableParent, ExtendedGridLayer gridLayer, int fixedHeaderWidth) {
// calculate the slider height according to the display scaling
int sliderHeight = GUIHelper.convertHorizontalPixelToDpi(17, true);

Composite sliderComposite = new Composite(natTableParent, SWT.NONE);
GridData gridData = new GridData();
gridData.horizontalAlignment = GridData.FILL;
gridData.grabExcessHorizontalSpace = true;
gridData.grabExcessVerticalSpace = false;
gridData.heightHint = 17;
gridData.heightHint = sliderHeight;
sliderComposite.setLayoutData(gridData);

GridLayout gridLayout = new GridLayout(2, false);
Expand All @@ -246,7 +252,7 @@ private void createSplitSliders(
@Override
public Point computeSize(int wHint, int hHint, boolean changed) {
int width = ((ClientAreaAdapter) gridLayer.getStructureBody().getViewportLayer().getClientAreaProvider()).getWidth() + fixedHeaderWidth;
return new Point(width, 17);
return new Point(width, sliderHeight);
}
};
sliderLeftComposite.setLayout(new FillLayout());
Expand All @@ -256,11 +262,6 @@ public Point computeSize(int wHint, int hHint, boolean changed) {
sliderLeftComposite.setLayoutData(gridData);

Slider sliderLeft = new Slider(sliderLeftComposite, SWT.HORIZONTAL);
gridData = new GridData();
gridData.horizontalAlignment = GridData.FILL;
gridData.verticalAlignment = GridData.FILL;
sliderLeft.setLayoutData(gridData);

gridLayer.getStructureBody().getViewportLayer().setHorizontalScroller(new SliderScroller(sliderLeft));

// Slider Right
Expand Down