]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.eclipse.swt.win32.win32.x86_64/src/org/eclipse/swt/events/SelectionListener.java
Work around SWT 4.13 - 4.18 Win32 DnD bug 567422
[simantics/platform.git] / bundles / org.eclipse.swt.win32.win32.x86_64 / src / org / eclipse / swt / events / SelectionListener.java
1 /*******************************************************************************
2  * Copyright (c) 2000, 2016 IBM Corporation and others.
3  *
4  * This program and the accompanying materials
5  * are made available under the terms of the Eclipse Public License 2.0
6  * which accompanies this distribution, and is available at
7  * https://www.eclipse.org/legal/epl-2.0/
8  *
9  * SPDX-License-Identifier: EPL-2.0
10  *
11  * Contributors:
12  *     IBM Corporation - initial API and implementation
13  *     Lars Vogel <Lars.Vogel@vogella.com>  - Bug 441116
14  *******************************************************************************/
15 package org.eclipse.swt.events;
16
17
18 import java.util.function.*;
19
20 import org.eclipse.swt.internal.*;
21
22 /**
23  * Classes which implement this interface provide methods
24  * that deal with the events that are generated when selection
25  * occurs in a control.
26  * <p>
27  * After creating an instance of a class that implements
28  * this interface it can be added to a control using the
29  * <code>addSelectionListener</code> method and removed using
30  * the <code>removeSelectionListener</code> method. When
31  * selection occurs in a control the appropriate method
32  * will be invoked.
33  * </p>
34  *
35  * @see SelectionAdapter
36  * @see SelectionEvent
37  */
38 public interface SelectionListener extends SWTEventListener {
39
40 /**
41  * Sent when selection occurs in the control.
42  * <p>
43  * For example, selection occurs in a List when the user selects
44  * an item or items with the keyboard or mouse.  On some platforms,
45  * the event occurs when a mouse button or key is pressed.  On others,
46  * it happens when the mouse or key is released.  The exact key or
47  * mouse gesture that causes this event is platform specific.
48  * </p>
49  *
50  * @param e an event containing information about the selection
51  */
52 void widgetSelected(SelectionEvent e);
53
54 /**
55  * Sent when default selection occurs in the control.
56  * <p>
57  * For example, on some platforms default selection occurs in a List
58  * when the user double-clicks an item or types return in a Text.
59  * On some platforms, the event occurs when a mouse button or key is
60  * pressed.  On others, it happens when the mouse or key is released.
61  * The exact key or mouse gesture that causes this event is platform
62  * specific.
63  * </p>
64  *
65  * @param e an event containing information about the default selection
66  */
67 void widgetDefaultSelected(SelectionEvent e);
68
69
70
71 /**
72  * Static helper method to create a <code>SelectionListener</code> for the
73  * {@link #widgetSelected(SelectionEvent e)}) method, given a lambda expression
74  * or a method reference.
75  *
76  * @param c the consumer of the event
77  * @return SelectionListener
78  * @since 3.106
79  */
80 static SelectionListener widgetSelectedAdapter(Consumer<SelectionEvent> c) {
81         return new SelectionAdapter() {
82                 @Override
83                 public void widgetSelected(SelectionEvent e) {
84                         c.accept(e);
85                 }
86         };
87 }
88
89 /**
90  * Static helper method to create a <code>SelectionListener</code> for the
91  * {@link #widgetDefaultSelected(SelectionEvent e)}) method, given a lambda expression
92  * or a method reference.
93  *
94  * @param c the consumer of the event
95  * @return SelectionListener
96  * @since 3.106
97 */
98 static SelectionListener widgetDefaultSelectedAdapter(Consumer<SelectionEvent> c) {
99         return new SelectionAdapter() {
100                 @Override
101                 public void widgetDefaultSelected(SelectionEvent e) {
102                         c.accept(e);
103                 }
104         };
105 }
106
107 }
108