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
22 changes: 6 additions & 16 deletions .github/toolchains.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,31 +5,21 @@
<toolchain>
<type>jdk</type>
<provides>
<id>JavaSE-17</id>
<version>17</version>
<id>JavaSE-21</id>
<version>21</version>
</provides>
<configuration>
<jdkHome>${env.JAVA_HOME_17_X64}</jdkHome>
<jdkHome>${env.JAVA_HOME_21_X64}</jdkHome>
</configuration>
</toolchain>
<toolchain>
<type>jdk</type>
<provides>
<id>JavaSE-11</id>
<version>11</version>
</provides>
<configuration>
<jdkHome>${env.JAVA_HOME_11_X64}</jdkHome>
</configuration>
</toolchain>
<toolchain>
<type>jdk</type>
<provides>
<id>JavaSE-1.8</id>
<version>1.8</version>
<id>JavaSE-17</id>
<version>17</version>
</provides>
<configuration>
<jdkHome>${env.JAVA_HOME_8_X64}</jdkHome>
<jdkHome>${env.JAVA_HOME_17_X64}</jdkHome>
</configuration>
</toolchain>
</toolchains>
11 changes: 6 additions & 5 deletions .github/workflows/maven.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,28 +7,29 @@ jobs:
build:

runs-on: ubuntu-latest
name: Java 17 compile
name: Java 21 compile
permissions:
contents: read
steps:
- name: Git Checkout
uses: actions/checkout@v4
- name: Set up JDKs
uses: actions/setup-java@v4
with:
java-version: |
8
11
17
21
distribution: 'temurin' # See 'Supported distributions' for available options
cache: maven
- name: Set up Maven
uses: stCarolas/setup-maven@v5
with:
maven-version: 3.9.8
maven-version: 3.9.14
- name: Install xvfb
run: sudo apt-get install xvfb
- name: Build NatTable with Javadoc
env:
JAVA_HOME: ${{ env.JAVA_HOME_17_X64 }}
JAVA_HOME: ${{ env.JAVA_HOME_21_X64 }}
run: |
cp .github/toolchains.xml ~/.m2/toolchains.xml
xvfb-run mvn clean compile javadoc:aggregate verify
5 changes: 3 additions & 2 deletions .mvn/extensions.xml
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<extensions>
<extensions xmlns="http://maven.apache.org/EXTENSIONS/1.1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/EXTENSIONS/1.1.0 https://maven.apache.org/xsd/core-extensions-1.1.0.xsd">
<extension>
<groupId>org.eclipse.tycho</groupId>
<artifactId>tycho-build</artifactId>
<version>4.0.13</version>
<version>5.0.3</version>
</extension>
</extensions>
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2012, 2020 Original authors and others.
* Copyright (c) 2012, 2026 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 @@ -37,7 +37,6 @@
import org.eclipse.nebula.widgets.nattable.test.fixture.PropertiesFixture;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.Font;
import org.eclipse.swt.widgets.Display;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

Expand Down Expand Up @@ -120,12 +119,7 @@ public void loadFontSettings() throws Exception {
Style style = StylePersistor.loadStyle(TEST_PREFIX, this.propertiesFixture);

Font font = style.getAttributeValue(CellStyleAttributes.FONT);
// workaround on Bug 559884
if (Display.getDefault().getDPI().x == 144) {
assertTrue(font.getFontData()[0].toString().contains("|Tahoma|8.5|"));
} else {
assertTrue(font.getFontData()[0].toString().contains("|Tahoma|8.25|"));
}
assertTrue(font.getFontData()[0].toString().contains("|Tahoma|8.25|"));
}

@Test
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2012, 2022 Original authors and others.
* Copyright (c) 2012, 2026 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 @@ -59,7 +59,7 @@ public void setUp() {
new DefaultNatTableStyleConfiguration()
.configureRegistry(this.configRegistry);

this.img = new Image(Display.getDefault(), new Rectangle(0, 0, 200, 150));
this.img = new Image(Display.getDefault(), 200, 150);
this.gcFactory = new GCFactory(this.img);

// Use a common, foxed width font to avoid failing the test on a
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2012, 2020 Original authors and others.
* Copyright (c) 2012, 2026 Original authors and others.
*
* This program and the accompanying materials are made
* available under the terms of the Eclipse Public License 2.0
Expand All @@ -20,15 +20,14 @@
import org.eclipse.nebula.widgets.nattable.test.fixture.layer.DataLayerFixture;
import org.eclipse.nebula.widgets.nattable.util.GCFactory;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.graphics.Rectangle;
import org.eclipse.swt.widgets.Display;

public class AutoResizeColumnCommandFixture extends
InitializeAutoResizeColumnsCommand {

public AutoResizeColumnCommandFixture() {
super(new DataLayerFixture(), 2, new ConfigRegistry(), new GCFactory(
new Image(Display.getDefault(), new Rectangle(0, 0, 100, 100))));
new Image(Display.getDefault(), 100, 100)));

ConfigRegistry configRegistry = (ConfigRegistry) getConfigRegistry();
configRegistry.registerConfigAttribute(CellConfigAttributes.CELL_STYLE,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2012, 2020 Original authors and others.
* Copyright (c) 2012, 2026 Original authors and others.
*
* This program and the accompanying materials are made
* available under the terms of the Eclipse Public License 2.0
Expand All @@ -20,15 +20,14 @@
import org.eclipse.nebula.widgets.nattable.test.fixture.layer.DataLayerFixture;
import org.eclipse.nebula.widgets.nattable.util.GCFactory;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.graphics.Rectangle;
import org.eclipse.swt.widgets.Display;

public class AutoResizeRowCommandFixture extends
InitializeAutoResizeRowsCommand {

public AutoResizeRowCommandFixture() {
super(new DataLayerFixture(), 2, new ConfigRegistry(), new GCFactory(
new Image(Display.getDefault(), new Rectangle(0, 0, 100, 100))));
new Image(Display.getDefault(), 100, 100)));

ConfigRegistry configRegistry = (ConfigRegistry) getConfigRegistry();
configRegistry.registerConfigAttribute(CellConfigAttributes.CELL_STYLE,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2012, 2025 Original authors and others.
* Copyright (c) 2012, 2026 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 @@ -40,8 +40,7 @@
import org.eclipse.nebula.widgets.nattable.edit.editor.ICellEditor;
import org.eclipse.nebula.widgets.nattable.grid.command.ClientAreaResizeCommand;
import org.eclipse.nebula.widgets.nattable.grid.command.InitializeGridCommand;
import org.eclipse.nebula.widgets.nattable.layer.DefaultHorizontalDpiConverter;
import org.eclipse.nebula.widgets.nattable.layer.DefaultVerticalDpiConverter;
import org.eclipse.nebula.widgets.nattable.layer.DefaultZoomDpiConverter;
import org.eclipse.nebula.widgets.nattable.layer.IDpiConverter;
import org.eclipse.nebula.widgets.nattable.layer.ILayer;
import org.eclipse.nebula.widgets.nattable.layer.ILayerListener;
Expand Down Expand Up @@ -90,7 +89,6 @@
import org.eclipse.swt.widgets.Canvas;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Event;
import org.eclipse.swt.widgets.Listener;
import org.eclipse.swt.widgets.ScrollBar;
Expand Down Expand Up @@ -343,8 +341,7 @@ private void internalSetLayer(ILayer layer) {
// register the DPI scaling on the layers
this.underlyingLayer.doCommand(
new ConfigureScalingCommand(
new DefaultHorizontalDpiConverter(),
new DefaultVerticalDpiConverter()));
new DefaultZoomDpiConverter(getParent())));
}
}

Expand Down Expand Up @@ -377,7 +374,7 @@ public IConfigRegistry getConfigRegistry() {
if (this.configRegistry == null) {
this.configRegistry = new ConfigRegistry();
this.themeManager = new ThemeManager(this.configRegistry);
configureScaling(new DefaultHorizontalDpiConverter(), new DefaultVerticalDpiConverter());
configureScaling(new DefaultZoomDpiConverter(getParent()));
}
return this.configRegistry;
}
Expand All @@ -400,7 +397,20 @@ public void setConfigRegistry(IConfigRegistry configRegistry) {

this.configRegistry = configRegistry;
this.themeManager = new ThemeManager(configRegistry);
configureScaling(new DefaultHorizontalDpiConverter(), new DefaultVerticalDpiConverter());
configureScaling(new DefaultZoomDpiConverter(getParent()));
}

/**
* Add the given {@link IDpiConverter} to the {@link IConfigRegistry} so it
* can be used by painters and set the system properties to use the
* configured scaling for images.
*
* @param dpiConverter
* The {@link IDpiConverter} for scaling.
* @since 2.7
*/
protected void configureScaling(IDpiConverter dpiConverter) {
configureScaling(dpiConverter, dpiConverter);
}

/**
Expand All @@ -420,7 +430,7 @@ protected void configureScaling(IDpiConverter horizontalConverter, IDpiConverter
// match the updated view
if (!commitAndCloseActiveCellEditor()) {
// if committing didn't work out we need to perform a hard
// close otherwise the state of the table would be unstale
// close otherwise the state of the table would be unstable
getActiveCellEditor().close();
}

Expand All @@ -437,11 +447,21 @@ protected void configureScaling(IDpiConverter horizontalConverter, IDpiConverter

// register the font scaling factor
float dpiFactor = GUIHelper.getDpiFactor(GUIHelper.getDpiX());
float displayDpiFactor = GUIHelper.getDpiFactor(Display.getDefault().getDPI().x);
float fontScalingFactor = (dpiFactor / displayDpiFactor);

String autoScaleProperty = GUIHelper.getAutoScaleProperty(getParent().getDisplay());
Object zoomObject = PlatformHelper.callGetter(getShell(), "getZoom"); //$NON-NLS-1$
int shellZoom = zoomObject != null ? (int) zoomObject : 100;
if ("false".equals(autoScaleProperty)) { //$NON-NLS-1$
dpiFactor = dpiFactor / (shellZoom / 100f);
} else if ("integer".equals(autoScaleProperty) //$NON-NLS-1$
|| "half".equals(autoScaleProperty)) { //$NON-NLS-1$
int autoscaledZoom = GUIHelper.getAutoScaleZoom(getParent(), shellZoom);
dpiFactor = Float.valueOf(autoscaledZoom) / shellZoom * dpiFactor;
}

getConfigRegistry().registerConfigAttribute(
NatTableConfigAttributes.FONT_SCALING_FACTOR,
fontScalingFactor);
dpiFactor);

this.themeManager.refreshCurrentTheme();
}
Expand Down Expand Up @@ -500,6 +520,14 @@ public void focusGained(final FocusEvent arg0) {
doCommand(new ClientAreaResizeCommand(NatTable.this));
redraw();
});

if (!PlatformHelper.isRAP() && GUIHelper.isRescalingAtRuntime(getParent().getDisplay())) {
addListener(SWT.ZoomChanged, e -> {
// if the zoom level changes we need to reconfigure the scaling
// converters to ensure that the DPI values are correct
doCommand(new ConfigureScalingCommand(new DefaultZoomDpiConverter(getParent())));
});
}
}

// Painting ///////////////////////////////////////////////////////////////
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import org.eclipse.nebula.widgets.nattable.layer.cell.ILayerCell;
import org.eclipse.nebula.widgets.nattable.selection.SelectionLayer.MoveDirectionEnum;
import org.eclipse.nebula.widgets.nattable.util.GUIHelper;
import org.eclipse.nebula.widgets.nattable.util.PlatformHelper;
import org.eclipse.nebula.widgets.nattable.widget.EditModeEnum;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.KeyEvent;
Expand Down Expand Up @@ -255,7 +256,7 @@ public boolean commit(Object canonicalValue, MoveDirectionEnum direction) {
@Override
protected void createButtonsForButtonBar(Composite parent) {
if (this.editDialogSettings != null && (boolean) this.editDialogSettings.getOrDefault(DIALOG_COMMIT_EDITOR_ON_EDIT, Boolean.FALSE)) {
createButton(parent, IDialogConstants.CANCEL_ID, IDialogConstants.CLOSE_LABEL, true);
createButton(parent, IDialogConstants.CANCEL_ID, PlatformHelper.getIDialogConstantsLabel("CLOSE_LABEL"), true); //$NON-NLS-1$
} else {
super.createButtonsForButtonBar(parent);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*****************************************************************************
* Copyright (c) 2015, 2020 CEA LIST.
* Copyright (c) 2015, 2026 CEA LIST.
*
* This program and the accompanying materials are made
* available under the terms of the Eclipse Public License 2.0
Expand All @@ -13,14 +13,14 @@
*****************************************************************************/
package org.eclipse.nebula.widgets.nattable.fillhandle.action;

import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.nebula.widgets.nattable.NatTable;
import org.eclipse.nebula.widgets.nattable.fillhandle.config.FillHandleConfiguration;
import org.eclipse.nebula.widgets.nattable.ui.action.IMouseAction;
import org.eclipse.nebula.widgets.nattable.util.GUIHelper;
import org.eclipse.swt.events.MouseEvent;
import org.eclipse.swt.graphics.Cursor;
import org.eclipse.swt.graphics.ImageData;
import org.eclipse.swt.graphics.PaletteData;
import org.eclipse.swt.graphics.RGB;
import org.eclipse.swt.graphics.ImageDataProvider;
import org.eclipse.swt.widgets.Display;

/**
Expand All @@ -38,54 +38,11 @@ public class FillHandleCursorAction implements IMouseAction {
@Override
public void run(NatTable natTable, MouseEvent event) {
if (this.fillHandleCursor == null) {
PaletteData paletteData = new PaletteData(new RGB[] {
new RGB(0, 0, 0), new RGB(255, 255, 255)
});
ImageData sourceData = new ImageData(16, 16, 1, paletteData);
ImageData maskData = new ImageData(16, 16, 1, paletteData);

byte[] cursorSource = new byte[] {
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1,
1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1,
1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1,
1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1,
1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1,
1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
ImageDescriptor imageDescriptor = GUIHelper.getImageDescriptor("fill_handle"); //$NON-NLS-1$
ImageDataProvider imageDataProvider = zoom -> {
return imageDescriptor.getImageData(zoom);
};

sourceData.setPixels(0, 0, 256, cursorSource, 0);
maskData.setPixels(0, 0, 256, cursorMask, 0);

this.fillHandleCursor = new Cursor(Display.getDefault(), sourceData, maskData, 7, 7);
this.fillHandleCursor = new Cursor(Display.getDefault(), imageDataProvider, 7, 7);

natTable.addDisposeListener(e -> FillHandleCursorAction.this.fillHandleCursor.dispose());
}
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Loading