Skip to content

Commit

Permalink
Fix event target type erasure (#1525)
Browse files Browse the repository at this point in the history
  • Loading branch information
Siedlerchr committed Oct 27, 2023
1 parent d141298 commit dc172e7
Show file tree
Hide file tree
Showing 10 changed files with 41 additions and 56 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/build.yml
Expand Up @@ -12,13 +12,13 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v4

- name: Setup Java
uses: actions/setup-java@v2
uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-version: '11'
java-version: '17'
cache: 'gradle'

- name: Grant execute permission for gradlew
Expand Down Expand Up @@ -46,4 +46,4 @@ jobs:
# Drafts your next Release notes as Pull Requests are merged into "master"
uses: release-drafter/release-drafter@v5
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
8 changes: 4 additions & 4 deletions .github/workflows/release.yml
Expand Up @@ -9,15 +9,15 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v4
with:
fetch-depth: 5

- name: Setup Java
uses: actions/setup-java@v2
uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-version: '11'
java-version: '17'
cache: 'gradle'

- name: Grant execute permission for gradlew
Expand Down Expand Up @@ -74,4 +74,4 @@ jobs:
TAG=${GITHUB_REF/refs\/tags\//}
bash .github/scripts/update-javadoc.sh "$TAG"
env:
PAT: ${{ secrets.PAT }}
PAT: ${{ secrets.PAT }}
2 changes: 1 addition & 1 deletion .lgtm.yml
@@ -1,4 +1,4 @@
extraction:
java:
index:
java_version: 11
java_version: 17
2 changes: 1 addition & 1 deletion build.gradle
Expand Up @@ -84,4 +84,4 @@ nexusPublishing {
password = project.hasProperty('sonatypePassword') ? project.property('sonatypePassword') : ''
}
}
}
}
@@ -1,5 +1,5 @@
/**
* Copyright (c) 2013, 2018 ControlsFX
* Copyright (c) 2013, 2023 ControlsFX
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
Expand Down Expand Up @@ -29,6 +29,7 @@
import java.util.Collection;
import javafx.beans.property.BooleanProperty;
import javafx.collections.ObservableList;
import javafx.event.Event;
import javafx.event.EventHandler;
import javafx.event.EventType;

Expand Down Expand Up @@ -241,7 +242,7 @@ public interface Grid {
* @param eventHandler the handler to register
* @throws NullPointerException if the event type or handler is null
*/
public <E extends GridChange> void addEventHandler(EventType<E> eventType, EventHandler<E> eventHandler);
public <E extends Event> void addEventHandler(EventType<E> eventType, EventHandler<? super E> eventHandler);

/**
* Unregisters a previously registered event handler from this Grid. One
Expand All @@ -254,5 +255,5 @@ public interface Grid {
* @param eventHandler the handler to unregister
* @throws NullPointerException if the event type or handler is null
*/
public <E extends GridChange> void removeEventHandler(EventType<E> eventType, EventHandler<E> eventHandler);
}
public <E extends Event> void removeEventHandler(EventType<E> eventType, EventHandler<? super E> eventHandler);
}
@@ -1,5 +1,5 @@
/**
* Copyright (c) 2013, 2018 ControlsFX
* Copyright (c) 2013, 2023 ControlsFX
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
Expand Down Expand Up @@ -423,14 +423,12 @@ public boolean isCellDisplaySelection(int row, int column) {
}

/** {@inheritDoc} */
@Override
public <E extends GridChange> void addEventHandler(EventType<E> eventType, EventHandler<E> eventHandler) {
public <E extends Event> void addEventHandler(EventType<E> eventType, EventHandler<? super E> eventHandler) {
eventHandlerManager.addEventHandler(eventType, eventHandler);
}

/** {@inheritDoc} */
@Override
public <E extends GridChange> void removeEventHandler(EventType<E> eventType, EventHandler<E> eventHandler) {
public <E extends Event> void removeEventHandler(EventType<E> eventType, EventHandler<? super E> eventHandler) {
eventHandlerManager.removeEventHandler(eventType, eventHandler);
}

Expand Down
@@ -1,5 +1,5 @@
/**
* Copyright (c) 2014, 2018 ControlsFX
* Copyright (c) 2014, 2023 ControlsFX
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
Expand Down Expand Up @@ -68,7 +68,7 @@ public interface SpreadsheetCell {
*/
public static final EventType<Event> CORNER_EVENT_TYPE
= new EventType<>("CornerEventType" + UUID.randomUUID().toString()); //$NON-NLS-1$

/**
* This enum states the four different corner available for positioning
* some elements in a cell.
Expand Down Expand Up @@ -405,16 +405,16 @@ public static enum CornerPosition {
* @return the tooltip associated with this {@code SpreadsheetCell}
*/
public Optional<String> getTooltip();

/**
* Registers an event handler to this SpreadsheetCell.
*
* @param eventType the type of the events to receive by the handler
* @param eventHandler the handler to register
* @throws NullPointerException if the event type or handler is null
*/
public void addEventHandler(EventType<Event> eventType, EventHandler<Event> eventHandler);
public <E extends Event> void addEventHandler(EventType<E> eventType, EventHandler<? super E> eventHandler);

/**
* Unregisters a previously registered event handler from this
* SpreadsheetCell.
Expand All @@ -423,5 +423,8 @@ public static enum CornerPosition {
* @param eventHandler the handler to unregister
* @throws NullPointerException if the event type or handler is null
*/
public void removeEventHandler(EventType<Event> eventType, EventHandler<Event> eventHandler);
public <E extends Event> void removeEventHandler(EventType<E> eventType, EventHandler<? super E> eventHandler);


}

@@ -1,5 +1,5 @@
/**
* Copyright (c) 2013, 2016, 2018 ControlsFX
* Copyright (c) 2013, 2023 ControlsFX
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
Expand Down Expand Up @@ -596,36 +596,20 @@ public final int hashCode() {
result = prime * result + Objects.hashCode(getStyleClass());
return result;
}

/**
* Registers an event handler to this SpreadsheetCell. The SpreadsheetCell class allows
* registration of listeners which will be notified when a corner state of
* the editable state of this SpreadsheetCell have changed.
*
* @param eventType the type of the events to receive by the handler
* @param eventHandler the handler to register
* @throws NullPointerException if the event type or handler is null
*/

/** {@inheritDoc} */
@Override
public void addEventHandler(EventType<Event> eventType, EventHandler<Event> eventHandler) {
eventHandlerManager.addEventHandler(eventType, eventHandler);
public <E extends Event> void addEventHandler(EventType<E> eventType, EventHandler<? super E> eventHandler) {
eventHandlerManager.addEventHandler(eventType, eventHandler);
}

/**
* Unregisters a previously registered event handler from this SpreadsheetCell. One
* handler might have been registered for different event types, so the
* caller needs to specify the particular event type from which to
* unregister the handler.
*
* @param eventType the event type from which to unregister
* @param eventHandler the handler to unregister
* @throws NullPointerException if the event type or handler is null
*/
/** {@inheritDoc} */
@Override
public void removeEventHandler(EventType<Event> eventType, EventHandler<Event> eventHandler) {
eventHandlerManager.removeEventHandler(eventType, eventHandler);
public <E extends Event> void removeEventHandler(EventType<E> eventType, EventHandler<? super E> eventHandler) {
eventHandlerManager.removeEventHandler(eventType, eventHandler);
}



/***************************************************************************
*
* Private Implementation
Expand Down Expand Up @@ -690,7 +674,6 @@ private boolean setMask(boolean flag, int position) {
}

/**
* @param mask
* @param position
* @return whether the specified bit position is true.
*/
Expand Down
@@ -1,5 +1,5 @@
/**
* Copyright (c) 2014, 2016, 2020 ControlsFX
* Copyright (c) 2014, 2023 ControlsFX
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
Expand Down Expand Up @@ -547,7 +547,7 @@ public String getName() {
* @param eventHandler the handler to register
* @throws NullPointerException if the event type or handler is null
*/
public <E extends Event> void addEventHandler(EventType<E> eventType, EventHandler<E> eventHandler) {
public <E extends Event> void addEventHandler(EventType<E> eventType, EventHandler<? super E> eventHandler) {
eventHandlerManager.addEventHandler(eventType, eventHandler);
}

Expand All @@ -562,7 +562,7 @@ public <E extends Event> void addEventHandler(EventType<E> eventType, EventHandl
* @param eventHandler the handler to unregister
* @throws NullPointerException if the event type or handler is null
*/
public <E extends Event> void removeEventHandler(EventType<E> eventType, EventHandler<E> eventHandler) {
public <E extends Event> void removeEventHandler(EventType<E> eventType, EventHandler<? super E> eventHandler) {
eventHandlerManager.removeEventHandler(eventType, eventHandler);
}

Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
@@ -1,4 +1,4 @@
group = org.controlsfx
controlsfx_version = 11.1.3-SNAPSHOT
fxsampler_version = 1.0.12-SNAPSHOT
javafx_version = 13
javafx_version = 17

0 comments on commit dc172e7

Please sign in to comment.