Search in sources :

Example 11 with TreeListener

use of org.eclipse.swt.events.TreeListener in project eclipse.platform.swt by eclipse.

the class Test_org_eclipse_swt_widgets_Tree method test_addTreeListenerTreeCollapsedAdapterLorg_eclipse_swt_events_TreeListener.

@Test
public void test_addTreeListenerTreeCollapsedAdapterLorg_eclipse_swt_events_TreeListener() {
    TreeListener listener = TreeListener.treeCollapsedAdapter(e -> eventOccurred = true);
    tree.addTreeListener(listener);
    eventOccurred = false;
    tree.notifyListeners(SWT.Collapse, new Event());
    assertTrue(eventOccurred);
    eventOccurred = false;
    tree.notifyListeners(SWT.Expand, new Event());
    assertFalse(eventOccurred);
    tree.removeTreeListener(listener);
    eventOccurred = false;
    tree.notifyListeners(SWT.Collapse, new Event());
    assertFalse(eventOccurred);
    tree.notifyListeners(SWT.Expand, new Event());
    assertFalse(eventOccurred);
}
Also used : TreeListener(org.eclipse.swt.events.TreeListener) Event(org.eclipse.swt.widgets.Event) Test(org.junit.Test)

Aggregations

TreeListener (org.eclipse.swt.events.TreeListener)11 TreeEvent (org.eclipse.swt.events.TreeEvent)9 SelectionEvent (org.eclipse.swt.events.SelectionEvent)7 SelectionListener (org.eclipse.swt.events.SelectionListener)6 TreeItem (org.eclipse.swt.widgets.TreeItem)5 MouseEvent (org.eclipse.swt.events.MouseEvent)4 GridData (org.eclipse.swt.layout.GridData)4 GridLayout (org.eclipse.swt.layout.GridLayout)4 Button (org.eclipse.swt.widgets.Button)4 Event (org.eclipse.swt.widgets.Event)4 Tree (org.eclipse.swt.widgets.Tree)4 Composite (org.eclipse.swt.widgets.Composite)3 Accessible (org.eclipse.swt.accessibility.Accessible)2 AccessibleAdapter (org.eclipse.swt.accessibility.AccessibleAdapter)2 AccessibleControlAdapter (org.eclipse.swt.accessibility.AccessibleControlAdapter)2 AccessibleControlEvent (org.eclipse.swt.accessibility.AccessibleControlEvent)2 AccessibleEvent (org.eclipse.swt.accessibility.AccessibleEvent)2 DropTargetEvent (org.eclipse.swt.dnd.DropTargetEvent)2 DropTargetListener (org.eclipse.swt.dnd.DropTargetListener)2 FocusEvent (org.eclipse.swt.events.FocusEvent)2