Skip to content

Commit

Permalink
Impl #81 -Improve mouse move bindings
Browse files Browse the repository at this point in the history
Implement a mouse move binding that supports enter and exit and changed
all default move bindings.
  • Loading branch information
fipro78 committed Apr 26, 2024
1 parent 91b4dda commit 3510d60
Show file tree
Hide file tree
Showing 49 changed files with 1,038 additions and 535 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.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());
}

}
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, 2024 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 @@ -21,6 +21,7 @@
import org.eclipse.nebula.widgets.nattable.resize.action.ColumnResizeCursorAction;
import org.eclipse.nebula.widgets.nattable.resize.event.ColumnResizeEventMatcher;
import org.eclipse.nebula.widgets.nattable.resize.mode.ColumnResizeDragMode;
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;
Expand All @@ -46,25 +47,15 @@ public void configureUiBindings(UiBindingRegistry uiBindingRegistry) {
// Mouse move - Show resize cursor
uiBindingRegistry.registerFirstMouseMoveBinding(
new ColumnResizeEventMatcher(SWT.NONE, GridRegion.COLUMN_HEADER, 0),
new ColumnResizeCursorAction());
new ColumnResizeCursorAction(),
new ClearCursorAction());

// apply a hover styling on moving the mouse over a NatTable and clear
// the cursor
uiBindingRegistry.registerMouseMoveBinding(
new MouseEventMatcher(GridRegion.COLUMN_HEADER),
new HoverStylingByIndexAction(this.layer));

// clear any hover styling if the mouse is moved out of a NatTable
// region
uiBindingRegistry.registerMouseMoveBinding((natTable, event, regionLabels) -> ((natTable != null && regionLabels == null) || regionLabels != null
&& regionLabels.hasLabel(GridRegion.CORNER)), 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 HoverStylingByIndexAction(this.layer),
new ClearHoverStylingAction());

// Column resize
uiBindingRegistry.registerFirstMouseDragMode(
Expand Down
Loading

0 comments on commit 3510d60

Please sign in to comment.