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
2 changes: 1 addition & 1 deletion .mvn/extensions.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
<extension>
<groupId>org.eclipse.tycho</groupId>
<artifactId>tycho-build</artifactId>
<version>4.0.10</version>
<version>4.0.12</version>
</extension>
</extensions>
6 changes: 4 additions & 2 deletions org.eclipse.nebula.widgets.nattable.core/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
Expand Up @@ -222,10 +222,12 @@ Import-Package: org.eclipse.collections.api;version="10.1.0",
org.eclipse.swt.events,
org.eclipse.swt.graphics,
org.eclipse.swt.layout,
org.eclipse.swt.printing,
org.eclipse.swt.program,
org.eclipse.swt.printing;resolution:=optional,
org.eclipse.swt.program;resolution:=optional,
org.eclipse.swt.widgets,
org.osgi.framework;version="[1.10.0,2.0.0)",
org.slf4j;version="1.7.2"
Bundle-Vendor: Eclipse Nebula NatTable
Require-Bundle: org.eclipse.equinox.common
Automatic-Module-Name: org.eclipse.nebula.widgets.nattable.core
Bundle-Activator: org.eclipse.nebula.widgets.nattable.Activator
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
/*******************************************************************************
* Copyright (c) 2025 Dirk Fauth and others.
*
* This program and the accompanying materials are made
* available under the terms of the Eclipse Public License 2.0
* which is available at https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* Dirk Fauth <dirk.fauth@googlemail.com> - initial API and implementation
******************************************************************************/
package org.eclipse.nebula.widgets.nattable;

import java.lang.reflect.InvocationTargetException;

import org.osgi.framework.BundleActivator;
import org.osgi.framework.BundleContext;

/**
* Activator that will call the RAPInitializer if available. Needed in an
* activator to ensure that the RAPInitializer is called before any NatTable
* class is loaded.
*
* @since 2.6
*/
public class Activator implements BundleActivator {

@Override
public void start(BundleContext context) {
try {
Class<?> forName = getClass().getClassLoader().loadClass("org.eclipse.nebula.widgets.nattable.RAPInitializer"); //$NON-NLS-1$
if (forName != null) {
forName.getMethod("initialize").invoke(null); //$NON-NLS-1$
}
} catch (ClassNotFoundException | IllegalAccessException | IllegalArgumentException | InvocationTargetException | NoSuchMethodException | SecurityException e) {
// do nothing, if not running in RAP there is no initializer
}
}

@Override
public void stop(BundleContext context) throws Exception {
}
}
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 @@ -72,6 +72,7 @@
import org.eclipse.nebula.widgets.nattable.ui.mode.ModeSupport;
import org.eclipse.nebula.widgets.nattable.util.GUIHelper;
import org.eclipse.nebula.widgets.nattable.util.IClientAreaProvider;
import org.eclipse.nebula.widgets.nattable.util.PlatformHelper;
import org.eclipse.nebula.widgets.nattable.viewport.command.RecalculateScrollBarsCommand;
import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.BusyIndicator;
Expand Down Expand Up @@ -281,14 +282,18 @@ public NatTable(
this.conflaterChain.add(getVisualChangeEventConflater());
this.conflaterChain.start();

parent.addListener(SWT.Resize, this.closeEditorOnParentResize);
if (!PlatformHelper.isRAP()) {
parent.addListener(SWT.Resize, this.closeEditorOnParentResize);
}

addDisposeListener(e -> {
doCommand(new DisposeResourcesCommand());
NatTable.this.conflaterChain.stop();
layer.dispose();

parent.removeListener(SWT.Resize, NatTable.this.closeEditorOnParentResize);
if (!PlatformHelper.isRAP()) {
parent.removeListener(SWT.Resize, NatTable.this.closeEditorOnParentResize);
}
});
}

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, 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 @@ -393,16 +393,19 @@ public boolean commit(MoveDirectionEnum direction, boolean closeAfterCommit, boo

@Override
public void close() {
this.closed = true;
if (this.parent != null && !this.parent.isDisposed()) {
this.parent.forceFocus();
}
if (!this.closed) {
this.closed = true;

removeEditorControlListeners();
removeEditorControlListeners();

Control editorControl = getEditorControl();
if (editorControl != null && !editorControl.isDisposed()) {
editorControl.dispose();
if (this.parent != null && !this.parent.isDisposed()) {
this.parent.forceFocus();
}

Control editorControl = getEditorControl();
if (editorControl != null && !editorControl.isDisposed()) {
editorControl.dispose();
}
}
}

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, 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 All @@ -15,6 +15,7 @@
import org.eclipse.jface.fieldassist.ControlDecoration;
import org.eclipse.jface.fieldassist.FieldDecoration;
import org.eclipse.jface.fieldassist.FieldDecorationRegistry;
import org.eclipse.nebula.widgets.nattable.util.PlatformHelper;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.PaintEvent;
import org.eclipse.swt.events.PaintListener;
Expand Down Expand Up @@ -116,7 +117,7 @@ public void setErrorDecorationText(String errorText) {
public void showErrorDecorationHover(String errorText) {
if (this.errorDecoration != null) {
this.errorDecoration.show();
this.errorDecoration.showHoverText(errorText);
PlatformHelper.callSetter(this.errorDecoration, "showHoverText", String.class, errorText); //$NON-NLS-1$
}
}

Expand Down Expand Up @@ -175,8 +176,10 @@ public void hideDecoration() {
*/
public void dispose() {
if (this.errorDecoration != null) {
this.errorDecoration.hide();
this.errorDecoration.dispose();
if (this.errorDecoration.getControl() != null && !this.errorDecoration.getControl().isDisposed()) {
this.errorDecoration.hide();
this.errorDecoration.dispose();
}
this.errorDecoration = null;
}
}
Expand All @@ -193,43 +196,28 @@ public void createErrorDecorationIfRequired(final Control controlToDecorate) {

if (this.errorDecorationEnabled) {

final Image errorImage = FieldDecorationRegistry.getDefault()
.getFieldDecoration(this.fieldDecorationId).getImage();
final Image errorImage = FieldDecorationRegistry.getDefault().getFieldDecoration(this.fieldDecorationId).getImage();
if (this.decorationPositionOverride == SWT.DEFAULT) {
controlToDecorate.addPaintListener(new PaintListener() { // Using
// a
// PaintListener
// as
// bounds
// are
// only
// set
// AFTER
// activateCell()
// Using a PaintListener as bounds are only set AFTER
// activateCell()
PlatformHelper.callSetter(controlToDecorate, "addPaintListener", PaintListener.class, new PaintListener() { //$NON-NLS-1$

@Override
public void paintControl(PaintEvent e) {

controlToDecorate.removePaintListener(this);
PlatformHelper.callSetter(controlToDecorate, "removePaintListener", PaintListener.class, this); //$NON-NLS-1$
int position = SWT.TOP;
final Rectangle textBounds = controlToDecorate
.getBounds();
final Rectangle parentClientArea = controlToDecorate
.getParent().getClientArea();
if ((parentClientArea.x + parentClientArea.width) > (textBounds.x
+ textBounds.width + errorImage
.getBounds().width)) {
final Rectangle textBounds = controlToDecorate.getBounds();
final Rectangle parentClientArea = controlToDecorate.getParent().getClientArea();
if ((parentClientArea.x + parentClientArea.width) > (textBounds.x + textBounds.width + errorImage.getBounds().width)) {
position |= SWT.RIGHT;
} else {
position |= SWT.LEFT;
}
ControlDecorationProvider.this.errorDecoration = newControlDecoration(
controlToDecorate, errorImage, position);
ControlDecorationProvider.this.errorDecoration = newControlDecoration(controlToDecorate, errorImage, position);
}
});
} else {
this.errorDecoration = newControlDecoration(controlToDecorate,
errorImage, this.decorationPositionOverride);
this.errorDecoration = newControlDecoration(controlToDecorate, errorImage, this.decorationPositionOverride);
}
}
}
Expand All @@ -250,10 +238,8 @@ public void paintControl(PaintEvent e) {
* <code>SWT.RIGHT</code>, and <code>SWT.CENTER</code>).
* @return The created {@link ControlDecoration}
*/
private ControlDecoration newControlDecoration(Control controlToDecorate,
Image errorImage, int position) {
final ControlDecoration errorDecoration = new ControlDecoration(
controlToDecorate, position);
private ControlDecoration newControlDecoration(Control controlToDecorate, Image errorImage, int position) {
final ControlDecoration errorDecoration = new ControlDecoration(controlToDecorate, position);
errorDecoration.setImage(errorImage);
errorDecoration.setDescriptionText(this.errorDecorationText);
errorDecoration.hide();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2013, 2024 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 @@ -41,6 +41,7 @@
import org.eclipse.nebula.widgets.nattable.style.IStyle;
import org.eclipse.nebula.widgets.nattable.style.Style;
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.FocusEvent;
Expand Down Expand Up @@ -434,6 +435,12 @@ protected Object[] getDataAsArray(Object cellData) {
* results in using the OS default height based on the font.
*/
public int getFixedSubCellHeight() {
if (PlatformHelper.isRAP()) {
// RAP does not know the SWT.MeasureItem event
// it is therefore only possible to use the the default height based
// on the font
return -1;
}
return this.fixedSubCellHeight;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2012, 2024 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 @@ -28,6 +28,7 @@
import org.eclipse.nebula.widgets.nattable.style.DisplayMode;
import org.eclipse.nebula.widgets.nattable.style.HorizontalAlignmentEnum;
import org.eclipse.nebula.widgets.nattable.style.IStyle;
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.KeyAdapter;
Expand Down Expand Up @@ -384,6 +385,13 @@ public void keyPressed(KeyEvent event) {
if (isCommitWithCtrlKey()) {
commit = (event.stateMask == SWT.MOD1) ? true : false;
}

// in case of RAP we need to avoid the commit in an edit
// dialog, as the commit from the dialog otherwise fails
if (PlatformHelper.isRAP() && TextCellEditor.this.editMode == EditModeEnum.DIALOG) {
commit = false;
}

MoveDirectionEnum move = MoveDirectionEnum.NONE;
if (TextCellEditor.this.moveSelectionOnEnter
&& TextCellEditor.this.editMode == EditModeEnum.INLINE) {
Expand Down
Loading