Skip to content

Commit

Permalink
Replace usage of internal SWT TypedListener and SWTEventListener
Browse files Browse the repository at this point in the history
Leverage new methods introduced in
eclipse-platform/eclipse.platform.swt#1112
  • Loading branch information
HannesWell committed Mar 23, 2024
1 parent fddb19d commit 4ad2ebb
Show file tree
Hide file tree
Showing 60 changed files with 135 additions and 369 deletions.
5 changes: 5 additions & 0 deletions releng/org.eclipse.nebula.nebula-parent/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,11 @@ Contributors:
<layout>p2</layout>
<url>${target-platform}</url>
</repository>
<repository>
<id>eclipse-iBuild</id>
<layout>p2</layout>
<url>${https://download.eclipse.org/eclipse/updates/4.32-I-builds}</url>
</repository>
</repositories>

<!-- Metadata -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Bundle-ManifestVersion: 2
Bundle-Name: Nebula Calendar Combo Widget - Incubating
Bundle-SymbolicName: org.eclipse.nebula.widgets.calendarcombo
Bundle-Version: 1.0.0.qualifier
Require-Bundle: org.eclipse.swt
Require-Bundle: org.eclipse.swt;bundle-version="[3.126.0,4.0.0)"
Export-Package: org.eclipse.nebula.widgets.calendarcombo
Bundle-RequiredExecutionEnvironment: JavaSE-11
Bundle-Vendor: Eclipse Nebula
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
import org.eclipse.swt.widgets.Menu;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Text;
import org.eclipse.swt.widgets.TypedListener;
import org.eclipse.swt.widgets.Widget;

/**
Expand Down Expand Up @@ -259,11 +258,7 @@ public void add(String string, int index) {
* @see #removeModifyListener
*/
public void addModifyListener(ModifyListener listener) {
checkWidget();
if (listener == null)
SWT.error(SWT.ERROR_NULL_ARGUMENT);
TypedListener typedListener = new TypedListener(listener);
addListener(SWT.Modify, typedListener);
addTypedListener(listener, SWT.Modify);
}

/**
Expand Down Expand Up @@ -294,12 +289,7 @@ public void addModifyListener(ModifyListener listener) {
* @see SelectionEvent
*/
public void addSelectionListener(SelectionListener listener) {
checkWidget();
if (listener == null)
SWT.error(SWT.ERROR_NULL_ARGUMENT);
TypedListener typedListener = new TypedListener(listener);
addListener(SWT.Selection, typedListener);
addListener(SWT.DefaultSelection, typedListener);
addTypedListener(listener, SWT.Selection, SWT.DefaultSelection);
}

/**
Expand All @@ -325,11 +315,7 @@ public void addSelectionListener(SelectionListener listener) {
* @since 3.3
*/
public void addVerifyListener(VerifyListener listener) {
checkWidget();
if (listener == null)
SWT.error(SWT.ERROR_NULL_ARGUMENT);
TypedListener typedListener = new TypedListener(listener);
addListener(SWT.Verify, typedListener);
addTypedListener(listener, SWT.Verify);
}

void arrowEvent(Event event) {
Expand Down Expand Up @@ -1417,10 +1403,7 @@ public void removeAll() {
* @see #addModifyListener
*/
public void removeModifyListener(ModifyListener listener) {
checkWidget();
if (listener == null)
SWT.error(SWT.ERROR_NULL_ARGUMENT);
removeListener(SWT.Modify, listener);
removeTypedListener(SWT.Modify, listener);
}

/**
Expand All @@ -1442,11 +1425,8 @@ public void removeModifyListener(ModifyListener listener) {
* @see #addSelectionListener
*/
public void removeSelectionListener(SelectionListener listener) {
checkWidget();
if (listener == null)
SWT.error(SWT.ERROR_NULL_ARGUMENT);
removeListener(SWT.Selection, listener);
removeListener(SWT.DefaultSelection, listener);
removeTypedListener(SWT.Selection, listener);
removeTypedListener(SWT.DefaultSelection, listener);
}

/**
Expand All @@ -1470,10 +1450,7 @@ public void removeSelectionListener(SelectionListener listener) {
* @since 3.3
*/
public void removeVerifyListener(VerifyListener listener) {
checkWidget();
if (listener == null)
SWT.error(SWT.ERROR_NULL_ARGUMENT);
removeListener(SWT.Verify, listener);
removeTypedListener(SWT.Verify, listener);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@ Bundle-Vendor: Eclipse Nebula
Bundle-RequiredExecutionEnvironment: JavaSE-11
Export-Package: org.eclipse.nebula.widgets.carousel
Require-Bundle: org.eclipse.nebula.widgets.opal.commons;visibility:=reexport,
org.eclipse.swt
org.eclipse.swt;bundle-version="[3.126.0,4.0.0)"
Automatic-Module-Name: org.eclipse.nebula.widgets.carousel
Original file line number Diff line number Diff line change
Expand Up @@ -165,8 +165,7 @@ public void addImage(final Image image) {
* @see SelectionEvent
*/
public void addSelectionListener(final SelectionListener listener) {
checkWidget();
SelectionListenerUtil.addSelectionListener(this, listener);
addTypedListener(listener, SWT.Selection);
}

/**
Expand Down Expand Up @@ -219,8 +218,7 @@ public void removeImage(final Image image) {
* @see #addSelectionListener
*/
public void removeSelectionListener(final SelectionListener listener) {
checkWidget();
SelectionListenerUtil.removeSelectionListener(this, listener);
removeTypedListener(SWT.Selection, listener);
}

// ---- Getters & Setters
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Bundle-Vendor: %providerName
Bundle-Localization: plugin
Bundle-RequiredExecutionEnvironment: JavaSE-11
Require-Bundle: org.eclipse.core.runtime,
org.eclipse.swt,
org.eclipse.swt;bundle-version="[3.126.0,4.0.0)",
org.eclipse.nebula.cwt;bundle-version="0.9.0";visibility:=reexport
Export-Package: org.eclipse.nebula.widgets.cdatetime
Automatic-Module-Name: org.eclipse.nebula.widgets.cdatetime
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Spinner;
import org.eclipse.swt.widgets.Text;
import org.eclipse.swt.widgets.TypedListener;

/**
* The CDateTime provides both textual and graphical means selecting a
Expand Down Expand Up @@ -425,9 +424,7 @@ public CDateTime(Composite parent, int style) {
*/
public void addSelectionListener(SelectionListener listener) {
if (listener != null) {
TypedListener typedListener = new TypedListener(listener);
addListener(SWT.Selection, typedListener);
addListener(SWT.DefaultSelection, typedListener);
addTypedListener(listener, SWT.Selection, SWT.DefaultSelection);
}
}

Expand Down Expand Up @@ -1527,9 +1524,7 @@ protected void postClose(Shell popup) {
*/
public void removeSelectionListener(SelectionListener listener) {
if (listener != null) {
TypedListener l = new TypedListener(listener);
removeListener(SWT.Selection, l);
removeListener(SWT.DefaultSelection, l);
addTypedListener(listener, SWT.Selection, SWT.DefaultSelection);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@ Bundle-Vendor: Eclipse Nebula
Bundle-RequiredExecutionEnvironment: JavaSE-11
Export-Package: org.eclipse.nebula.widgets.chips
Require-Bundle: org.eclipse.nebula.widgets.opal.commons;visibility:=reexport,
org.eclipse.swt
org.eclipse.swt;bundle-version="[3.126.0,4.0.0)"
Automatic-Module-Name: org.eclipse.nebula.widgets.chips
Original file line number Diff line number Diff line change
Expand Up @@ -411,8 +411,7 @@ public void addListener(final int eventType, final Listener listener) {
* @see SelectionEvent
*/
public void addSelectionListener(final SelectionListener listener) {
checkWidget();
SelectionListenerUtil.addSelectionListener(this, listener);
addTypedListener(listener, SWT.Selection);
}

/**
Expand Down Expand Up @@ -466,8 +465,7 @@ public void removeCloseListener(final CloseListener listener) {
* @see #addSelectionListener
*/
public void removeSelectionListener(final SelectionListener listener) {
checkWidget();
SelectionListenerUtil.removeSelectionListener(this, listener);
removeTypedListener(SWT.Selection, listener);
}

// ---- Getters & Setters
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
*******************************************************************************/
package org.eclipse.nebula.widgets.chips;

import org.eclipse.swt.internal.SWTEventListener;
import java.util.EventListener;

/**
* Classes which implement this interface provide methods
Expand All @@ -28,9 +28,8 @@
*
* @see CloseEvent
*/
@SuppressWarnings("restriction")
@FunctionalInterface
public interface CloseListener extends SWTEventListener {
public interface CloseListener extends EventListener {
/**
* Sent when a Chips widget is closed.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@ Bundle-SymbolicName: org.eclipse.nebula.widgets.ctree
Bundle-Version: 0.8.0
Bundle-Vendor: Eclipse Nebula
Bundle-RequiredExecutionEnvironment: JavaSE-11
Require-Bundle: org.eclipse.swt
Require-Bundle: org.eclipse.swt;bundle-version="[3.126.0,4.0.0)"
Export-Package: org.eclipse.nebula.widgets.ctree
Automatic-Module-Name: org.eclipse.nebula.widgets.ctree
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@
import org.eclipse.swt.widgets.Menu;
import org.eclipse.swt.widgets.ScrollBar;
import org.eclipse.swt.widgets.Table;
import org.eclipse.swt.widgets.TypedListener;
import org.eclipse.swt.widgets.Widget;


Expand Down Expand Up @@ -389,18 +388,14 @@ public void addPaintedItemListener(Listener listener) {
public void addSelectionListener(SelectionListener listener) {
checkWidget();
if (listener != null) {
TypedListener typedListener = new TypedListener(listener);
addListener(SWT.Selection, typedListener);
addListener(SWT.DefaultSelection, typedListener);
addTypedListener(listener, SWT.Selection, SWT.DefaultSelection);
}
}

public void addTreeListener(TreeListener listener) {
checkWidget ();
if(listener != null) {
TypedListener typedListener = new TypedListener (listener);
addListener (SWT.Collapse, typedListener);
addListener (SWT.Expand, typedListener);
addTypedListener(listener, SWT.Collapse, SWT.Expand);
}
}

Expand Down Expand Up @@ -1367,16 +1362,16 @@ public void removePaintedItemListener(Listener listener) {
public void removeSelectionListener(SelectionListener listener) {
checkWidget();
if (listener != null) {
removeListener(SWT.Selection, listener);
removeListener(SWT.DefaultSelection, listener);
removeTypedListener(SWT.Selection, listener);
removeTypedListener(SWT.DefaultSelection, listener);
}
}

public void removeTreeListener(TreeListener listener) {
checkWidget ();
if(listener != null) {
removeListener(SWT.Collapse, listener);
removeListener(SWT.Expand, listener);
removeTypedListener(SWT.Collapse, listener);
removeTypedListener(SWT.Expand, listener);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Bundle-SymbolicName: org.eclipse.nebula.widgets.ctreecombo
Bundle-Version: 1.0.0.qualifier
Bundle-Vendor: Eclipse Nebula
Bundle-RequiredExecutionEnvironment: JavaSE-11
Require-Bundle: org.eclipse.swt,
Require-Bundle: org.eclipse.swt;bundle-version="[3.126.0,4.0.0)",
org.eclipse.jface,
org.eclipse.core.runtime;bundle-version="3.13.0",
org.eclipse.core.databinding.observable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@
import org.eclipse.swt.widgets.Tree;
import org.eclipse.swt.widgets.TreeColumn;
import org.eclipse.swt.widgets.TreeItem;
import org.eclipse.swt.widgets.TypedListener;
import org.eclipse.swt.widgets.Widget;

public class CTreeCombo extends Composite {
Expand Down Expand Up @@ -240,14 +239,7 @@ char _findMnemonic(String string) {
* @see SelectionEvent
*/
public void addSelectionListener(final SelectionListener listener) {
checkWidget();
if (listener == null) {
SWT.error(SWT.ERROR_NULL_ARGUMENT);
}

final TypedListener typedListener = new TypedListener(listener);
addListener(SWT.Selection, typedListener);
addListener(SWT.DefaultSelection, typedListener);
addTypedListener(listener, SWT.Selection, SWT.DefaultSelection);
}

/**
Expand Down Expand Up @@ -1125,12 +1117,8 @@ public void removeAll() {
* @see #addSelectionListener
*/
public void removeSelectionListener(final SelectionListener listener) {
checkWidget();
if (listener == null) {
SWT.error(SWT.ERROR_NULL_ARGUMENT);
}
removeListener(SWT.Selection, listener);
removeListener(SWT.DefaultSelection, listener);
removeTypedListener(SWT.Selection, listener);
removeTypedListener(SWT.DefaultSelection, listener);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Export-Package: org.eclipse.nebula.widgets.datechooser
Bundle-RequiredExecutionEnvironment: JavaSE-11
Bundle-Vendor: Eclipse Nebula
Import-Package: org.eclipse.jface.layout,
org.eclipse.swt,
org.eclipse.swt;bundle-version="[3.126.0,4.0.0)",
org.eclipse.swt.events,
org.eclipse.swt.graphics,
org.eclipse.swt.internal,
Expand Down
Loading

0 comments on commit 4ad2ebb

Please sign in to comment.