Search in sources :

Example 66 with MenuItem

use of org.eclipse.swt.widgets.MenuItem in project eclipse.platform.swt by eclipse.

the class Test_org_eclipse_swt_widgets_Menu method test_getParentItem.

@Test
public void test_getParentItem() {
    MenuItem mItem = new MenuItem(menu, SWT.CASCADE);
    Menu newMenu = new Menu(shell, SWT.DROP_DOWN);
    assertNull(newMenu.getParentItem());
    mItem.setMenu(newMenu);
    assertEquals(newMenu.getParentItem(), mItem);
}
Also used : MenuItem(org.eclipse.swt.widgets.MenuItem) Menu(org.eclipse.swt.widgets.Menu) Test(org.junit.Test)

Example 67 with MenuItem

use of org.eclipse.swt.widgets.MenuItem in project eclipse.platform.swt by eclipse.

the class Test_org_eclipse_swt_widgets_Menu method test_ConstructorLorg_eclipse_swt_widgets_MenuItem.

@Test
public void test_ConstructorLorg_eclipse_swt_widgets_MenuItem() {
    Menu newMenu;
    MenuItem mItem = null;
    try {
        newMenu = new Menu(mItem);
        newMenu.dispose();
        fail("No exception thrown for parent == null");
    } catch (IllegalArgumentException e) {
    }
    mItem = new MenuItem(menu, SWT.NULL);
    newMenu = new Menu(mItem);
}
Also used : MenuItem(org.eclipse.swt.widgets.MenuItem) Menu(org.eclipse.swt.widgets.Menu) Test(org.junit.Test)

Example 68 with MenuItem

use of org.eclipse.swt.widgets.MenuItem in project eclipse.platform.swt by eclipse.

the class Test_org_eclipse_swt_widgets_Menu method test_getItemI.

@Test
public void test_getItemI() {
    MenuItem mItem0 = new MenuItem(menu, SWT.NULL);
    MenuItem mItem1 = new MenuItem(menu, SWT.NULL);
    assertEquals(menu.getItem(0), mItem0);
    assertEquals(menu.getItem(1), mItem1);
}
Also used : MenuItem(org.eclipse.swt.widgets.MenuItem) Test(org.junit.Test)

Example 69 with MenuItem

use of org.eclipse.swt.widgets.MenuItem in project eclipse.platform.swt by eclipse.

the class Test_org_eclipse_swt_widgets_Menu method test_getItemCount.

@Test
public void test_getItemCount() {
    int number = 10;
    for (int i = 0; i < number; i++) {
        assertEquals(menu.getItemCount(), i);
        new MenuItem(menu, 0);
    }
}
Also used : MenuItem(org.eclipse.swt.widgets.MenuItem) Point(org.eclipse.swt.graphics.Point) Test(org.junit.Test)

Example 70 with MenuItem

use of org.eclipse.swt.widgets.MenuItem in project eclipse.platform.swt by eclipse.

the class Test_org_eclipse_swt_widgets_Menu method test_getItems.

@Test
public void test_getItems() {
    int number = 5;
    MenuItem[] items = new MenuItem[number];
    for (int i = 0; i < number; i++) {
        items[i] = new MenuItem(menu, 0);
    }
    assertArrayEquals(":a:", items, menu.getItems());
    menu.getItems()[0].dispose();
    assertArrayEquals(":b:", new MenuItem[] { items[1], items[2], items[3], items[4] }, menu.getItems());
    menu.getItems()[3].dispose();
    assertArrayEquals(":c:", new MenuItem[] { items[1], items[2], items[3] }, menu.getItems());
    menu.getItems()[1].dispose();
    assertArrayEquals(":d:", new MenuItem[] { items[1], items[3] }, menu.getItems());
}
Also used : MenuItem(org.eclipse.swt.widgets.MenuItem) Point(org.eclipse.swt.graphics.Point) Test(org.junit.Test)

Aggregations

MenuItem (org.eclipse.swt.widgets.MenuItem)386 Menu (org.eclipse.swt.widgets.Menu)259 SelectionEvent (org.eclipse.swt.events.SelectionEvent)247 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)208 Event (org.eclipse.swt.widgets.Event)58 ArrayList (java.util.ArrayList)55 Point (org.eclipse.swt.graphics.Point)52 GridData (org.eclipse.swt.layout.GridData)49 Listener (org.eclipse.swt.widgets.Listener)48 SelectionListener (org.eclipse.swt.events.SelectionListener)46 Composite (org.eclipse.swt.widgets.Composite)43 GridLayout (org.eclipse.swt.layout.GridLayout)42 Rectangle (org.eclipse.swt.graphics.Rectangle)35 Label (org.eclipse.swt.widgets.Label)34 Shell (org.eclipse.swt.widgets.Shell)34 Table (org.eclipse.swt.widgets.Table)33 MenuEvent (org.eclipse.swt.events.MenuEvent)32 Button (org.eclipse.swt.widgets.Button)32 List (java.util.List)31 NatTable (org.eclipse.nebula.widgets.nattable.NatTable)29