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);
}
}
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();
}
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);
}
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();
}
}
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;
}
Aggregations