Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Impl #81 - Improve mouse move bindings #82

Merged
merged 4 commits into from
Apr 29, 2024
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
25 changes: 25 additions & 0 deletions .github/toolchains.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?xml version="1.0" encoding="UTF8"?>
<toolchains xmlns="http://maven.apache.org/TOOLCHAINS/1.1.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/TOOLCHAINS/1.1.0 http://maven.apache.org/xsd/toolchains-1.1.0.xsd">
<toolchain>
<type>jdk</type>
<provides>
<id>JavaSE-17</id>
<version>17</version>
</provides>
<configuration>
<jdkHome>${env.JAVA_HOME_17_X64}</jdkHome>
</configuration>
</toolchain>
<toolchain>
<type>jdk</type>
<provides>
<id>JavaSE-1.8</id>
<version>1.8</version>
</provides>
<configuration>
<jdkHome>${env.JAVA_HOME_8_X64}</jdkHome>
</configuration>
</toolchain>
</toolchains>
21 changes: 14 additions & 7 deletions .github/workflows/maven.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,27 @@ jobs:
build:

runs-on: ubuntu-latest
strategy:
matrix:
java: [ '17' ]
name: Java ${{ matrix.java }} compile
name: Java 17 compile
steps:
- name: Git Checkout
uses: actions/checkout@v4
- name: Set up JDK ${{ matrix.java }}
- name: Set up JDKs
uses: actions/setup-java@v4
with:
java-version: ${{ matrix.java }}
java-version: |
8
17
distribution: 'temurin' # See 'Supported distributions' for available options
cache: maven
- name: Set up Maven
uses: stCarolas/setup-maven@v5
with:
maven-version: 3.9.6
- name: Install xvfb
run: sudo apt-get install xvfb
- name: Build NatTable with Javadoc
run: xvfb-run mvn clean compile javadoc:aggregate verify
env:
JAVA_HOME: ${{ env.JAVA_HOME_17_X64 }}
run: |
cp .github/toolchains.xml ~/.m2/toolchains.xml
xvfb-run mvn clean compile javadoc:aggregate verify
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.3.1.qualifier"
version="2.4.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.tests
Bundle-Version: 2.3.1.qualifier
Bundle-Version: 2.4.0.qualifier
Fragment-Host: org.eclipse.nebula.widgets.nattable.core
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
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.

4 changes: 2 additions & 2 deletions org.eclipse.nebula.widgets.nattable.core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@
<parent>
<groupId>org.eclipse.nebula.widgets.nattable</groupId>
<artifactId>parent</artifactId>
<version>2.3.1-SNAPSHOT</version>
<version>2.4.0-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

<modelVersion>4.0.0</modelVersion>

<groupId>org.eclipse.nebula.widgets.nattable</groupId>
<artifactId>org.eclipse.nebula.widgets.nattable.core</artifactId>
<version>2.3.1-SNAPSHOT</version>
<version>2.4.0-SNAPSHOT</version>
<packaging>eclipse-plugin</packaging>

<name>Nebula NatTable Core</name>
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, 2024 CEA LIST.
*
* This program and the accompanying materials are made
* available under the terms of the Eclipse Public License 2.0
Expand All @@ -26,7 +26,6 @@
import org.eclipse.nebula.widgets.nattable.ui.action.ClearCursorAction;
import org.eclipse.nebula.widgets.nattable.ui.action.NoOpMouseAction;
import org.eclipse.nebula.widgets.nattable.ui.binding.UiBindingRegistry;
import org.eclipse.nebula.widgets.nattable.ui.matcher.MouseEventMatcher;

/**
* Default configuration for fill handle functionality. Registers the
Expand Down Expand Up @@ -82,9 +81,7 @@ public void configureUiBindings(UiBindingRegistry uiBindingRegistry) {
// Show fill handle cursor
uiBindingRegistry.registerFirstMouseMoveBinding(
matcher,
new FillHandleCursorAction());
uiBindingRegistry.registerMouseMoveBinding(
new MouseEventMatcher(),
new FillHandleCursorAction(),
new ClearCursorAction());

// Mouse drag
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2018, 2020 Dirk Fauth and others.
* Copyright (c) 2018, 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 Down Expand Up @@ -127,7 +127,8 @@ public void configureUiBindings(UiBindingRegistry uiBindingRegistry) {
GridRegion.COLUMN_HEADER,
0,
this.columnHeaderLayer),
new ColumnResizeCursorAction());
new ColumnResizeCursorAction(),
new ClearCursorAction());

uiBindingRegistry.registerFirstMouseDownBinding(
new ColumnHideIndicatorEventMatcher(
Expand All @@ -146,7 +147,8 @@ public void configureUiBindings(UiBindingRegistry uiBindingRegistry) {
GridRegion.ROW_HEADER,
0,
this.rowHeaderLayer),
new RowResizeCursorAction());
new RowResizeCursorAction(),
new ClearCursorAction());

uiBindingRegistry.registerFirstMouseDownBinding(
new RowHideIndicatorEventMatcher(
Expand All @@ -156,13 +158,6 @@ public void configureUiBindings(UiBindingRegistry uiBindingRegistry) {
this.rowHeaderLayer),
new PopupMenuAction(this.rowHideIndicatorMenu));
}

if (this.columnHideIndicatorMenu != null
|| this.rowHideIndicatorMenu != null) {
uiBindingRegistry.registerMouseMoveBinding(
new MouseEventMatcher(),
new ClearCursorAction());
}
}

}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2018, 2020 Dirk Fauth and others.
* Copyright (c) 2018, 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 Down Expand Up @@ -114,7 +114,8 @@ public void configureUiBindings(UiBindingRegistry uiBindingRegistry) {
GridRegion.COLUMN_HEADER,
0,
this.columnHeaderLayer),
new ColumnResizeCursorAction());
new ColumnResizeCursorAction(),
new ClearCursorAction());

uiBindingRegistry.registerFirstMouseDownBinding(
new ColumnHideIndicatorEventMatcher(
Expand All @@ -131,21 +132,15 @@ public void configureUiBindings(UiBindingRegistry uiBindingRegistry) {
new HierarchicalRowHideIndicatorEventMatcher(
SWT.NONE,
0),
new RowResizeCursorAction());
new RowResizeCursorAction(),
new ClearCursorAction());

uiBindingRegistry.registerFirstMouseDownBinding(
new HierarchicalRowHideIndicatorEventMatcher(
SWT.NONE,
MouseEventMatcher.RIGHT_BUTTON),
new PopupMenuAction(this.rowHideIndicatorMenu));
}

if (this.columnHideIndicatorMenu != null
|| this.rowHideIndicatorMenu != null) {
uiBindingRegistry.registerMouseMoveBinding(
new MouseEventMatcher(),
new ClearCursorAction());
}
}

}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2013, 2020 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 @@ -15,7 +15,7 @@
import org.eclipse.nebula.widgets.nattable.NatTable;
import org.eclipse.nebula.widgets.nattable.hover.HoverLayer;
import org.eclipse.nebula.widgets.nattable.hover.command.ClearHoverStylingCommand;
import org.eclipse.nebula.widgets.nattable.ui.action.ClearCursorAction;
import org.eclipse.nebula.widgets.nattable.ui.action.IMouseAction;
import org.eclipse.swt.events.MouseEvent;

/**
Expand All @@ -24,12 +24,10 @@
* <p>
* Will also clear any set cursor by default.
*
* @author Dirk Fauth
*
* @see HoverLayer
* @see ClearHoverStylingCommand
*/
public class ClearHoverStylingAction extends ClearCursorAction {
public class ClearHoverStylingAction implements IMouseAction {

/**
* The HoverLayer whose hover styling should not be cleared.
Expand Down Expand Up @@ -57,8 +55,6 @@ public ClearHoverStylingAction(HoverLayer hoverLayer) {

@Override
public void run(NatTable natTable, MouseEvent event) {
super.run(natTable, event);

natTable.doCommand(new ClearHoverStylingCommand(this.hoverLayer));
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2013, 2020 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 @@ -14,9 +14,8 @@

import org.eclipse.nebula.widgets.nattable.NatTable;
import org.eclipse.nebula.widgets.nattable.hover.HoverLayer;
import org.eclipse.nebula.widgets.nattable.hover.command.ClearHoverStylingCommand;
import org.eclipse.nebula.widgets.nattable.hover.command.HoverStylingCommand;
import org.eclipse.nebula.widgets.nattable.ui.action.ClearCursorAction;
import org.eclipse.nebula.widgets.nattable.ui.action.IMouseAction;
import org.eclipse.swt.events.MouseEvent;

/**
Expand All @@ -25,12 +24,10 @@
* <p>
* Will also clear any set cursor by default.
*
* @author Dirk Fauth
*
* @see HoverLayer
* @see HoverStylingCommand
*/
public class HoverStylingAction extends ClearCursorAction {
public class HoverStylingAction implements IMouseAction {

/**
* The HoverLayer that is responsible for handling the hover styling
Expand All @@ -51,13 +48,6 @@ public HoverStylingAction(HoverLayer hoverLayer) {

@Override
public void run(NatTable natTable, MouseEvent event) {
// clear the cursor on hovering
super.run(natTable, event);

// ensure to clear the hover styling in other possible HoverLayer in the
// composition
natTable.doCommand(new ClearHoverStylingCommand(this.hoverLayer));

int natColumnPos = natTable.getColumnPositionByX(event.x);
int natRowPos = natTable.getRowPositionByY(event.y);

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2022 Dirk Fauth and others.
* Copyright (c) 2022, 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 @@ -14,14 +14,13 @@

import org.eclipse.nebula.widgets.nattable.NatTable;
import org.eclipse.nebula.widgets.nattable.hover.HoverLayer;
import org.eclipse.nebula.widgets.nattable.hover.command.ClearHoverStylingCommand;
import org.eclipse.nebula.widgets.nattable.hover.command.HoverStylingByIndexCommand;
import org.eclipse.nebula.widgets.nattable.ui.action.ClearCursorAction;
import org.eclipse.nebula.widgets.nattable.ui.action.IMouseAction;
import org.eclipse.swt.events.MouseEvent;

/**
* Action that will execute the HoverStylingByIndexCommand which applies hover styling
* in a NatTable.
* Action that will execute the HoverStylingByIndexCommand which applies hover
* styling in a NatTable.
* <p>
* Will also clear any set cursor by default.
*
Expand All @@ -30,7 +29,7 @@
*
* @since 2.1
*/
public class HoverStylingByIndexAction extends ClearCursorAction {
public class HoverStylingByIndexAction implements IMouseAction {

/**
* The HoverLayer that is responsible for handling the hover styling
Expand All @@ -51,13 +50,6 @@ public HoverStylingByIndexAction(HoverLayer hoverLayer) {

@Override
public void run(NatTable natTable, MouseEvent event) {
// clear the cursor on hovering
super.run(natTable, event);

// ensure to clear the hover styling in other possible HoverLayer in the
// composition
natTable.doCommand(new ClearHoverStylingCommand(this.hoverLayer));

int natColumnPos = natTable.getColumnPositionByX(event.x);
int natRowPos = natTable.getRowPositionByY(event.y);

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2013, 2020 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 Down Expand Up @@ -46,31 +46,8 @@ public void configureUiBindings(UiBindingRegistry uiBindingRegistry) {
uiBindingRegistry.registerFirstMouseMoveBinding(
(natTable, event, regionLabels) -> BodyHoverStylingBindings.this.layer.getClientAreaProvider().getClientArea()
.contains(event.x, event.y),
new HoverStylingAction(this.layer));

// clear any hover styling if the mouse is moved out of the region area
// uiBindingRegistry.registerMouseMoveBinding(
// new IMouseEventMatcher() {
// @Override
// public boolean matches(NatTable natTable, MouseEvent event,
// LabelStack regionLabels) {
// return
// (!layer.getClientAreaProvider().getClientArea().contains(event.x,
// event.y));
// }
//
// }, new ClearHoverStylingAction());

// clear any hover styling if the mouse is moved out of a NatTable
// region
uiBindingRegistry.registerMouseMoveBinding((natTable, event, regionLabels) -> (natTable != null && regionLabels == null), new ClearHoverStylingAction());

// clear any hover styling if the mouse is moved out of the NatTable
// area
// always return true for the matcher because it is only asked in case
// the mouse exits the NatTable client area, therefore further checks
// are not necessary
uiBindingRegistry.registerMouseExitBinding((natTable, event, regionLabels) -> true, new ClearHoverStylingAction());
new HoverStylingAction(this.layer),
new ClearHoverStylingAction());
}

}
Loading