Search in sources :

Example 71 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_indexOfLorg_eclipse_swt_widgets_MenuItem.

@Test
public void test_indexOfLorg_eclipse_swt_widgets_MenuItem() {
    int number = 10;
    MenuItem[] mis = new MenuItem[number];
    for (int i = 0; i < number; i++) {
        mis[i] = new MenuItem(menu, SWT.NULL);
    }
    for (int i = 0; i < number; i++) {
        assertEquals(menu.indexOf(mis[i]), i);
        if (i > 1)
            assertTrue(menu.indexOf(mis[i - 1]) != i);
    }
}
Also used : MenuItem(org.eclipse.swt.widgets.MenuItem) Point(org.eclipse.swt.graphics.Point) Test(org.junit.Test)

Example 72 with MenuItem

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

the class Test_org_eclipse_swt_widgets_MenuItem method test_ConstructorLorg_eclipse_swt_widgets_MenuI.

@Test
public void test_ConstructorLorg_eclipse_swt_widgets_MenuI() {
    MenuItem mItem = new MenuItem(menu, SWT.NULL);
    assertNotNull(mItem);
    try {
        new MenuItem(null, SWT.NULL);
        fail("No exception thrown");
    } catch (IllegalArgumentException e) {
    }
    mItem = new MenuItem(menu, SWT.CHECK);
    assertTrue(mItem.getStyle() == SWT.CHECK);
    mItem.dispose();
    mItem = new MenuItem(menu, SWT.CASCADE);
    assertTrue(mItem.getStyle() == SWT.CASCADE);
    mItem.dispose();
    mItem = new MenuItem(menu, SWT.PUSH);
    assertTrue(mItem.getStyle() == SWT.PUSH);
    mItem.dispose();
    mItem = new MenuItem(menu, SWT.SEPARATOR);
    assertTrue(mItem.getStyle() == SWT.SEPARATOR);
    mItem.dispose();
    mItem = new MenuItem(menu, SWT.RADIO);
    assertTrue(mItem.getStyle() == SWT.RADIO);
    mItem.dispose();
}
Also used : MenuItem(org.eclipse.swt.widgets.MenuItem) Test(org.junit.Test)

Example 73 with MenuItem

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

the class Test_org_eclipse_swt_widgets_MenuItem method setUp.

@Override
@Before
public void setUp() {
    super.setUp();
    menu = new Menu(shell);
    menuItem = new MenuItem(menu, 0);
    setWidget(menuItem);
}
Also used : MenuItem(org.eclipse.swt.widgets.MenuItem) Menu(org.eclipse.swt.widgets.Menu) Before(org.junit.Before)

Example 74 with MenuItem

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

the class Test_org_eclipse_swt_widgets_MenuItem method test_setSelectionZ.

@Test
public void test_setSelectionZ() {
    int[] itemStyles = { SWT.CHECK, SWT.RADIO };
    for (int i = 0; i < itemStyles.length; i++) {
        MenuItem mItem = new MenuItem(menu, itemStyles[i]);
        mItem.setSelection(false);
        assertEquals(mItem.getSelection(), false);
        mItem.setSelection(true);
        assertTrue(mItem.getSelection());
        mItem.dispose();
    }
}
Also used : MenuItem(org.eclipse.swt.widgets.MenuItem) Test(org.junit.Test)

Example 75 with MenuItem

use of org.eclipse.swt.widgets.MenuItem in project hale by halestudio.

the class StackTraceErrorDialog method createDropDownList.

/**
 * @see ErrorDialog#createDropDownList(Composite)
 */
@Override
protected List createDropDownList(Composite parent) {
    _list = super.createDropDownList(parent);
    _list.removeAll();
    // replace context menu
    _list.getMenu().dispose();
    Menu copyMenu = new Menu(_list);
    MenuItem copyItem = new MenuItem(copyMenu, SWT.NONE);
    copyItem.addSelectionListener(new SelectionListener() {

        @Override
        public void widgetDefaultSelected(SelectionEvent e) {
            copyToClipboard();
        }

        @Override
        public void widgetSelected(SelectionEvent e) {
            copyToClipboard();
        }
    });
    // $NON-NLS-1$
    copyItem.setText(JFaceResources.getString("copy"));
    _list.setMenu(copyMenu);
    // convert stack trace to string
    String stackTrace = stackTraceToString(_status.getException());
    if (stackTrace != null) {
        // add stack trace to list
        // $NON-NLS-1$ //$NON-NLS-2$
        stackTrace = stackTrace.replaceAll("\r", "");
        // $NON-NLS-1$ //$NON-NLS-2$
        stackTrace = stackTrace.replaceAll("\t", "    ");
        // $NON-NLS-1$
        String[] lines = stackTrace.split("\n");
        for (String l : lines) {
            _list.add(l);
        }
    }
    return _list;
}
Also used : SelectionEvent(org.eclipse.swt.events.SelectionEvent) MenuItem(org.eclipse.swt.widgets.MenuItem) Menu(org.eclipse.swt.widgets.Menu) SelectionListener(org.eclipse.swt.events.SelectionListener)

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