Skip to content

Commit

Permalink
Deprecate TypedListener for removal to make it strongly internal later
Browse files Browse the repository at this point in the history
  • Loading branch information
HannesWell committed Nov 28, 2024
1 parent fa71076 commit cfa74b4
Show file tree
Hide file tree
Showing 8 changed files with 16 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -749,6 +749,7 @@ public String getTextRange(int start, int length) {
* </ul>
*/
@Override
@SuppressWarnings("removal")
public void removeTextChangeListener(TextChangeListener listener){
if (listener == null) error(SWT.ERROR_NULL_ARGUMENT);
for (int i = 0; i < textListeners.size(); i++) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import org.eclipse.swt.internal.*;
import org.eclipse.swt.widgets.*;

@SuppressWarnings("removal")
class StyledTextListener extends TypedListener {
StyledTextListener(SWTEventListener listener) {
super(listener);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
import org.eclipse.swt.internal.*;
import org.eclipse.swt.widgets.*;


@SuppressWarnings("removal")
class DNDListener extends TypedListener {
Widget dndWidget;
/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -500,6 +500,7 @@ protected void addTypedListener (EventListener listener, int... eventTypes) {
if (listener == null) {
SWT.error(SWT.ERROR_NULL_ARGUMENT);
}
@SuppressWarnings("removal")
TypedListener typedListener = new TypedListener(listener);
for (int eventType : eventTypes) {
_addListener(eventType, typedListener);
Expand Down Expand Up @@ -1028,6 +1029,7 @@ public Listener[] getListeners (int eventType) {
*
* @since 3.126
*/
@SuppressWarnings("removal")
public <L extends EventListener> Stream<L> getTypedListeners (int eventType, Class<L> listenerType) {
return Arrays.stream(getListeners(eventType)) //
.filter(TypedListener.class::isInstance).map(l -> ((TypedListener) l).eventListener)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ public void unhook (int eventType, Listener listener) {
}
}

@SuppressWarnings("removal")
public void unhook (int eventType, EventListener listener) {
if (types == null) return;
for (int i=0; i<types.length; i++) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,13 @@
* @noreference This class is not intended to be referenced by clients.
* @noextend This class is not intended to be subclassed by clients.
* @noinstantiate This class is not intended to be instantiated by clients.
* @deprecated This class will become 'strongly' internal. For custom widgets
* {@link Widget#addTypedListener(EventListener, int...)},
* {@link Widget#getTypedListeners(int, Class)} or
* {@link Widget#removeTypedListener(int, EventListener)} can
* probably be used instead.
*/
@Deprecated(forRemoval = true, since = "3.129.0 (removal in 2027-03 or later)")
public class TypedListener implements Listener {

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -361,6 +361,7 @@ protected void addTypedListener (EventListener listener, int... eventTypes) {
if (listener == null) {
SWT.error(SWT.ERROR_NULL_ARGUMENT);
}
@SuppressWarnings("removal")
TypedListener typedListener = new TypedListener(listener);
for (int eventType : eventTypes) {
_addListener(eventType, typedListener);
Expand Down Expand Up @@ -730,6 +731,7 @@ public Listener[] getListeners (int eventType) {
*
* @since 3.126
*/
@SuppressWarnings("removal")
public <L extends EventListener> Stream<L> getTypedListeners (int eventType, Class<L> listenerType) {
return Arrays.stream(getListeners(eventType)) //
.filter(TypedListener.class::isInstance).map(l -> ((TypedListener) l).eventListener)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,7 @@ protected void addTypedListener (EventListener listener, int... eventTypes) {
if (listener == null) {
SWT.error(SWT.ERROR_NULL_ARGUMENT);
}
@SuppressWarnings("removal")
TypedListener typedListener = new TypedListener(listener);
for (int eventType : eventTypes) {
_addListener(eventType, typedListener);
Expand Down Expand Up @@ -668,6 +669,7 @@ public Listener[] getListeners (int eventType) {
*
* @since 3.126
*/
@SuppressWarnings("removal")
public <L extends EventListener> Stream<L> getTypedListeners (int eventType, Class<L> listenerType) {
return Arrays.stream(getListeners(eventType)) //
.filter(TypedListener.class::isInstance).map(l -> ((TypedListener) l).eventListener)
Expand Down

0 comments on commit cfa74b4

Please sign in to comment.