Skip to content

Commit

Permalink
Impl #131 - Feature Request: Row Hover
Browse files Browse the repository at this point in the history
Add options to configure the type of visual update event that should be
fired on hover. Also added a new example to verify the different
configuration types.

Signed-off-by: Dirk Fauth <dirk.fauth@googlemail.com>
  • Loading branch information
fipro78 committed Dec 9, 2024
1 parent 1a89836 commit a712754
Show file tree
Hide file tree
Showing 29 changed files with 815 additions and 322 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<feature
id="org.eclipse.nebula.widgets.nattable.core.feature"
label="%featureName"
version="2.5.1.qualifier"
version="2.6.0.qualifier"
provider-name="%providerName"
license-feature="org.eclipse.license"
license-feature-version="0.0.0">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: NatTable Core Tests
Bundle-SymbolicName: org.eclipse.nebula.widgets.nattable.core.test
Bundle-Version: 2.5.1.qualifier
Bundle-Version: 2.6.0.qualifier
Fragment-Host: org.eclipse.nebula.widgets.nattable.core
Bundle-RequiredExecutionEnvironment: JavaSE-11
Import-Package: org.eclipse.core.commands.common,
Expand Down
354 changes: 177 additions & 177 deletions org.eclipse.nebula.widgets.nattable.core/META-INF/MANIFEST.MF

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion org.eclipse.nebula.widgets.nattable.core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>org.eclipse.nebula.widgets.nattable</groupId>
<artifactId>parent</artifactId>
<version>2.5.1-SNAPSHOT</version>
<version>2.6.0-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2013, 2022 Dirk Fauth and others.
* Copyright (c) 2013, 2024 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 @@ -20,6 +20,9 @@
import org.eclipse.nebula.widgets.nattable.layer.IUniqueIndexLayer;
import org.eclipse.nebula.widgets.nattable.layer.cell.ILayerCell;
import org.eclipse.nebula.widgets.nattable.layer.event.CellVisualUpdateEvent;
import org.eclipse.nebula.widgets.nattable.layer.event.ColumnVisualUpdateEvent;
import org.eclipse.nebula.widgets.nattable.layer.event.RowVisualUpdateEvent;
import org.eclipse.nebula.widgets.nattable.layer.event.VisualRefreshEvent;
import org.eclipse.nebula.widgets.nattable.style.DisplayMode;
import org.eclipse.swt.graphics.Point;

Expand Down Expand Up @@ -49,6 +52,19 @@ public class HoverLayer extends AbstractIndexLayerTransform {
* located.
*/
private Point currentHoveredCellPosition;
/**
* If set to <code>true</code> it will fire a {@link RowVisualUpdateEvent}
* on hover. If also {@link #fireColumnUpdates} it set to <code>true</code>,
* a {@link VisualRefreshEvent} will be fired on hover.
*/
private boolean fireRowUpdates = false;
/**
* If set to <code>true</code> it will fire a
* {@link ColumnVisualUpdateEvent} on hover. If also {@link #fireRowUpdates}
* it set to <code>true</code>, a {@link VisualRefreshEvent} will be fired
* on hover.
*/
private boolean fireColumnUpdates = false;

/**
* Create a new HoverLayer that uses the default configuration.
Expand Down Expand Up @@ -124,6 +140,38 @@ public boolean isCellPositionHovered(int columnPosition, int rowPosition) {
return false;
}

/**
* Check if this HoverLayer knows the current hovered cell and if that cell
* is at the given row position.
*
* @param rowPosition
* The row position of the cell that should be checked.
* @return <code>true</code> if the current hovered cell is in the given row
* position, <code>false</code> if not.
*
* @since 2.6
*/
public boolean isRowPositionHovered(int rowPosition) {
return this.currentHoveredCellPosition != null
&& this.currentHoveredCellPosition.y == rowPosition;
}

/**
* Check if this HoverLayer knows the current hovered cell and if that cell
* is at the given column position.
*
* @param columnPosition
* The column position of the cell that should be checked.
* @return <code>true</code> if the current hovered cell is in the given
* column position, <code>false</code> if not.
*
* @since 2.6
*/
public boolean isColumnPositionHovered(int columnPosition) {
return this.currentHoveredCellPosition != null
&& this.currentHoveredCellPosition.x == columnPosition;
}

/**
* @return The position of the cell that is currently hovered.
*/
Expand Down Expand Up @@ -185,11 +233,11 @@ public void setCurrentHoveredCellPosition(Point cellPosition) {
}

if (oldHover != null) {
fireLayerEvent(new CellVisualUpdateEvent(this, oldHover.x, oldHover.y));
fireUpdateEvent(oldHover.x, oldHover.y);
}
fireLayerEvent(new CellVisualUpdateEvent(this,
fireUpdateEvent(
this.currentHoveredCellPosition.x,
this.currentHoveredCellPosition.y));
this.currentHoveredCellPosition.y);
}
}

Expand All @@ -202,7 +250,85 @@ public void clearCurrentHoveredCellPosition() {
if (this.currentHoveredCellPosition != null) {
Point oldHover = this.currentHoveredCellPosition;
this.currentHoveredCellPosition = null;
fireLayerEvent(new CellVisualUpdateEvent(this, oldHover.x, oldHover.y));
fireUpdateEvent(oldHover.x, oldHover.y);
}
}

/**
* Configure whether visual updates for the whole row should be fired.
* <p>
* <b>Note:</b><br>
* If {@link #fireColumnUpdates} and {@link #fireRowUpdates} are set to
* <code>true</code> the whole table will be refreshed on hovering a single
* cell.
* </p>
*
* @param fireRowUpdates
* <code>true</code> if visual updates for the whole row should
* be fired.
*
* @since 2.6
*/
public void setFireRowUpdates(boolean fireRowUpdates) {
this.fireRowUpdates = fireRowUpdates;
}

/**
*
* @return <code>true</code> if visual updates for the whole row are fired.
* @since 2.6
*/
public boolean isFireRowUpdates() {
return this.fireRowUpdates;
}

/**
* Configure whether visual updates for the whole column should be fired.
* <p>
* <b>Note:</b><br>
* If {@link #fireColumnUpdates} and {@link #fireRowUpdates} are set to
* <code>true</code> the whole table will be refreshed on hovering a single
* cell.
* </p>
*
* @param fireColumnUpdates
* <code>true</code> if visual updates for the whole column
* should be fired.
*
* @since 2.6
*/
public void setFireColumnUpdates(boolean fireColumnUpdates) {
this.fireColumnUpdates = fireColumnUpdates;
}

/**
*
* @return <code>true</code> if visual updates for the whole column are
* fired.
* @since 2.6
*/
public boolean isFireColumnUpdates() {
return this.fireColumnUpdates;
}

/**
* Fire a visual update event according to the configuration of
* {@link #fireColumnUpdates} and {@link #fireRowUpdates}.
*
* @param x
* The column position for the visual update event.
* @param y
* The row position of the visual update event.
*/
private void fireUpdateEvent(int x, int y) {
if (this.fireRowUpdates && this.fireColumnUpdates) {
fireLayerEvent(new VisualRefreshEvent(this));
} else if (this.fireRowUpdates) {
fireLayerEvent(new RowVisualUpdateEvent(this, y));
} else if (this.fireColumnUpdates) {
fireLayerEvent(new ColumnVisualUpdateEvent(this, x));
} else {
fireLayerEvent(new CellVisualUpdateEvent(this, x, y));
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: NatTable Dataset Utilities (internal usage)
Bundle-SymbolicName: org.eclipse.nebula.widgets.nattable.dataset
Bundle-Version: 2.5.1.qualifier
Bundle-Version: 2.6.0.qualifier
Bundle-RequiredExecutionEnvironment: JavaSE-11
Export-Package: org.eclipse.nebula.widgets.nattable.dataset;version="1.4.0",
org.eclipse.nebula.widgets.nattable.dataset.car;version="1.5.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<feature
id="org.eclipse.nebula.widgets.nattable.examples.e4.feature"
label="%featureName"
version="2.5.1.qualifier"
version="2.6.0.qualifier"
provider-name="%providerName"
license-feature="org.eclipse.license"
license-feature-version="0.0.0">
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<?pde version="3.5"?>

<product name="org.eclipse.nebula.widgets.nattable.examples.e4" uid="org.eclipse.nebula.widgets.nattable.examples.e4.product" id="org.eclipse.nebula.widgets.nattable.examples.e4.product" application="org.eclipse.e4.ui.workbench.swt.E4Application" version="2.5.1.qualifier" type="features" includeLaunchers="true" autoIncludeRequirements="true">
<product name="org.eclipse.nebula.widgets.nattable.examples.e4" uid="org.eclipse.nebula.widgets.nattable.examples.e4.product" id="org.eclipse.nebula.widgets.nattable.examples.e4.product" application="org.eclipse.e4.ui.workbench.swt.E4Application" version="2.6.0.qualifier" type="features" includeLaunchers="true" autoIncludeRequirements="true">

<configIni use="default">
</configIni>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<parent>
<artifactId>parent</artifactId>
<groupId>org.eclipse.nebula.widgets.nattable</groupId>
<version>2.5.1-SNAPSHOT</version>
<version>2.6.0-SNAPSHOT</version>
<relativePath>..</relativePath>
</parent>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: NatTable Eclipse 4 Examples
Bundle-SymbolicName: org.eclipse.nebula.widgets.nattable.examples.e4;singleton:=true
Bundle-Version: 2.5.1.qualifier
Bundle-Version: 2.6.0.qualifier
Require-Bundle: org.eclipse.core.runtime;bundle-version="0.0.0",
org.eclipse.swt;bundle-version="0.0.0",
org.eclipse.e4.ui.model.workbench;bundle-version="0.0.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: NatTable Examples
Bundle-SymbolicName: org.eclipse.nebula.widgets.nattable.examples
Bundle-Version: 2.5.1.qualifier
Bundle-Version: 2.6.0.qualifier
Bundle-RequiredExecutionEnvironment: JavaSE-11
Require-Bundle: ca.odell.glazedlists,
org.eclipse.swt,
Expand Down
2 changes: 1 addition & 1 deletion org.eclipse.nebula.widgets.nattable.examples/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>org.eclipse.nebula.widgets.nattable</groupId>
<artifactId>parent</artifactId>
<version>2.5.1-SNAPSHOT</version>
<version>2.6.0-SNAPSHOT</version>
<relativePath>..</relativePath>
</parent>

Expand Down
Loading

0 comments on commit a712754

Please sign in to comment.