Search in sources :

Example 96 with MenuItem

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

the class ImageAnalyzer method createAlphaMenu.

void createAlphaMenu(Menu menuBar) {
    // Alpha menu
    MenuItem item = new MenuItem(menuBar, SWT.CASCADE);
    item.setText(bundle.getString("Alpha"));
    Menu alphaMenu = new Menu(shell, SWT.DROP_DOWN);
    item.setMenu(alphaMenu);
    // Alpha -> K
    item = new MenuItem(alphaMenu, SWT.PUSH);
    item.setText("K");
    item.addSelectionListener(widgetSelectedAdapter(event -> menuComposeAlpha(ALPHA_CONSTANT)));
    // Alpha -> (K + x) % 256
    item = new MenuItem(alphaMenu, SWT.PUSH);
    item.setText("(K + x) % 256");
    item.addSelectionListener(widgetSelectedAdapter(event -> menuComposeAlpha(ALPHA_X)));
    // Alpha -> (K + y) % 256
    item = new MenuItem(alphaMenu, SWT.PUSH);
    item.setText("(K + y) % 256");
    item.addSelectionListener(widgetSelectedAdapter(event -> menuComposeAlpha(ALPHA_Y)));
}
Also used : ImageLoader(org.eclipse.swt.graphics.ImageLoader) StyledText(org.eclipse.swt.custom.StyledText) URL(java.net.URL) GC(org.eclipse.swt.graphics.GC) Point(org.eclipse.swt.graphics.Point) Dialog(org.eclipse.swt.widgets.Dialog) SWTError(org.eclipse.swt.SWTError) PaintEvent(org.eclipse.swt.events.PaintEvent) PrintDialog(org.eclipse.swt.printing.PrintDialog) Composite(org.eclipse.swt.widgets.Composite) KeyEvent(org.eclipse.swt.events.KeyEvent) SWTException(org.eclipse.swt.SWTException) KeyAdapter(org.eclipse.swt.events.KeyAdapter) Cursor(org.eclipse.swt.graphics.Cursor) Text(org.eclipse.swt.widgets.Text) Button(org.eclipse.swt.widgets.Button) Sash(org.eclipse.swt.widgets.Sash) Display(org.eclipse.swt.widgets.Display) List(java.util.List) MouseListener(org.eclipse.swt.events.MouseListener) MenuItem(org.eclipse.swt.widgets.MenuItem) SWT(org.eclipse.swt.SWT) Label(org.eclipse.swt.widgets.Label) SelectionListener(org.eclipse.swt.events.SelectionListener) Printer(org.eclipse.swt.printing.Printer) PrinterData(org.eclipse.swt.printing.PrinterData) Image(org.eclipse.swt.graphics.Image) Rectangle(org.eclipse.swt.graphics.Rectangle) ControlListener(org.eclipse.swt.events.ControlListener) ImageData(org.eclipse.swt.graphics.ImageData) MessageFormat(java.text.MessageFormat) ArrayList(java.util.ArrayList) ControlEvent(org.eclipse.swt.events.ControlEvent) SelectionListener.widgetSelectedAdapter(org.eclipse.swt.events.SelectionListener.widgetSelectedAdapter) ResourceBundle(java.util.ResourceBundle) RGB(org.eclipse.swt.graphics.RGB) Canvas(org.eclipse.swt.widgets.Canvas) Font(org.eclipse.swt.graphics.Font) GridData(org.eclipse.swt.layout.GridData) Combo(org.eclipse.swt.widgets.Combo) Shell(org.eclipse.swt.widgets.Shell) FileDialog(org.eclipse.swt.widgets.FileDialog) StyleRange(org.eclipse.swt.custom.StyleRange) ImageLoaderEvent(org.eclipse.swt.graphics.ImageLoaderEvent) Group(org.eclipse.swt.widgets.Group) RowLayout(org.eclipse.swt.layout.RowLayout) ShellListener(org.eclipse.swt.events.ShellListener) Color(org.eclipse.swt.graphics.Color) MessageBox(org.eclipse.swt.widgets.MessageBox) Menu(org.eclipse.swt.widgets.Menu) ScrollBar(org.eclipse.swt.widgets.ScrollBar) InputStream(java.io.InputStream) GridLayout(org.eclipse.swt.layout.GridLayout) MenuItem(org.eclipse.swt.widgets.MenuItem) Menu(org.eclipse.swt.widgets.Menu)

Example 97 with MenuItem

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

the class ImageAnalyzer method createFileMenu.

void createFileMenu(Menu menuBar) {
    // File menu
    MenuItem item = new MenuItem(menuBar, SWT.CASCADE);
    item.setText(bundle.getString("File"));
    Menu fileMenu = new Menu(shell, SWT.DROP_DOWN);
    item.setMenu(fileMenu);
    // File -> Open File...
    item = new MenuItem(fileMenu, SWT.PUSH);
    item.setText(bundle.getString("OpenFile"));
    item.setAccelerator(SWT.MOD1 + 'O');
    item.addSelectionListener(widgetSelectedAdapter(event -> menuOpenFile()));
    // File -> Open URL...
    item = new MenuItem(fileMenu, SWT.PUSH);
    item.setText(bundle.getString("OpenURL"));
    item.setAccelerator(SWT.MOD1 + 'U');
    item.addSelectionListener(widgetSelectedAdapter(event -> menuOpenURL()));
    // File -> Reopen
    item = new MenuItem(fileMenu, SWT.PUSH);
    item.setText(bundle.getString("Reopen"));
    item.addSelectionListener(widgetSelectedAdapter(event -> menuReopen()));
    new MenuItem(fileMenu, SWT.SEPARATOR);
    // File -> Load File... (natively)
    item = new MenuItem(fileMenu, SWT.PUSH);
    item.setText(bundle.getString("LoadFile"));
    item.setAccelerator(SWT.MOD1 + 'L');
    item.addSelectionListener(widgetSelectedAdapter(event -> menuLoad()));
    new MenuItem(fileMenu, SWT.SEPARATOR);
    // File -> Save
    item = new MenuItem(fileMenu, SWT.PUSH);
    item.setText(bundle.getString("Save"));
    item.setAccelerator(SWT.MOD1 + 'S');
    item.addSelectionListener(widgetSelectedAdapter(event -> menuSave()));
    // File -> Save As...
    item = new MenuItem(fileMenu, SWT.PUSH);
    item.setText(bundle.getString("Save_as"));
    item.addSelectionListener(widgetSelectedAdapter(event -> menuSaveAs()));
    // File -> Save Mask As...
    item = new MenuItem(fileMenu, SWT.PUSH);
    item.setText(bundle.getString("Save_mask_as"));
    item.addSelectionListener(widgetSelectedAdapter(event -> menuSaveMaskAs()));
    new MenuItem(fileMenu, SWT.SEPARATOR);
    // File -> Print
    item = new MenuItem(fileMenu, SWT.PUSH);
    item.setText(bundle.getString("Print"));
    item.setAccelerator(SWT.MOD1 + 'P');
    item.addSelectionListener(widgetSelectedAdapter(event -> menuPrint()));
    new MenuItem(fileMenu, SWT.SEPARATOR);
    // File -> Exit
    item = new MenuItem(fileMenu, SWT.PUSH);
    item.setText(bundle.getString("Exit"));
    item.addSelectionListener(widgetSelectedAdapter(event -> shell.close()));
}
Also used : ImageLoader(org.eclipse.swt.graphics.ImageLoader) StyledText(org.eclipse.swt.custom.StyledText) URL(java.net.URL) GC(org.eclipse.swt.graphics.GC) Point(org.eclipse.swt.graphics.Point) Dialog(org.eclipse.swt.widgets.Dialog) SWTError(org.eclipse.swt.SWTError) PaintEvent(org.eclipse.swt.events.PaintEvent) PrintDialog(org.eclipse.swt.printing.PrintDialog) Composite(org.eclipse.swt.widgets.Composite) KeyEvent(org.eclipse.swt.events.KeyEvent) SWTException(org.eclipse.swt.SWTException) KeyAdapter(org.eclipse.swt.events.KeyAdapter) Cursor(org.eclipse.swt.graphics.Cursor) Text(org.eclipse.swt.widgets.Text) Button(org.eclipse.swt.widgets.Button) Sash(org.eclipse.swt.widgets.Sash) Display(org.eclipse.swt.widgets.Display) List(java.util.List) MouseListener(org.eclipse.swt.events.MouseListener) MenuItem(org.eclipse.swt.widgets.MenuItem) SWT(org.eclipse.swt.SWT) Label(org.eclipse.swt.widgets.Label) SelectionListener(org.eclipse.swt.events.SelectionListener) Printer(org.eclipse.swt.printing.Printer) PrinterData(org.eclipse.swt.printing.PrinterData) Image(org.eclipse.swt.graphics.Image) Rectangle(org.eclipse.swt.graphics.Rectangle) ControlListener(org.eclipse.swt.events.ControlListener) ImageData(org.eclipse.swt.graphics.ImageData) MessageFormat(java.text.MessageFormat) ArrayList(java.util.ArrayList) ControlEvent(org.eclipse.swt.events.ControlEvent) SelectionListener.widgetSelectedAdapter(org.eclipse.swt.events.SelectionListener.widgetSelectedAdapter) ResourceBundle(java.util.ResourceBundle) RGB(org.eclipse.swt.graphics.RGB) Canvas(org.eclipse.swt.widgets.Canvas) Font(org.eclipse.swt.graphics.Font) GridData(org.eclipse.swt.layout.GridData) Combo(org.eclipse.swt.widgets.Combo) Shell(org.eclipse.swt.widgets.Shell) FileDialog(org.eclipse.swt.widgets.FileDialog) StyleRange(org.eclipse.swt.custom.StyleRange) ImageLoaderEvent(org.eclipse.swt.graphics.ImageLoaderEvent) Group(org.eclipse.swt.widgets.Group) RowLayout(org.eclipse.swt.layout.RowLayout) ShellListener(org.eclipse.swt.events.ShellListener) Color(org.eclipse.swt.graphics.Color) MessageBox(org.eclipse.swt.widgets.MessageBox) Menu(org.eclipse.swt.widgets.Menu) ScrollBar(org.eclipse.swt.widgets.ScrollBar) InputStream(java.io.InputStream) GridLayout(org.eclipse.swt.layout.GridLayout) MenuItem(org.eclipse.swt.widgets.MenuItem) Menu(org.eclipse.swt.widgets.Menu)

Example 98 with MenuItem

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

the class JavaViewer method createMenuBar.

void createMenuBar() {
    Menu bar = new Menu(shell, SWT.BAR);
    shell.setMenuBar(bar);
    MenuItem fileItem = new MenuItem(bar, SWT.CASCADE);
    fileItem.setText(resources.getString("File_menuitem"));
    fileItem.setMenu(createFileMenu());
}
Also used : MenuItem(org.eclipse.swt.widgets.MenuItem) Menu(org.eclipse.swt.widgets.Menu)

Example 99 with MenuItem

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

the class JavaViewer method createFileMenu.

Menu createFileMenu() {
    Menu bar = shell.getMenuBar();
    Menu menu = new Menu(bar);
    MenuItem item;
    // Open
    item = new MenuItem(menu, SWT.PUSH);
    item.setText(resources.getString("Open_menuitem"));
    item.setAccelerator(SWT.MOD1 + 'O');
    item.addSelectionListener(widgetSelectedAdapter(event -> openFile()));
    // Exit
    item = new MenuItem(menu, SWT.PUSH);
    item.setText(resources.getString("Exit_menuitem"));
    item.addSelectionListener(widgetSelectedAdapter(e -> menuFileExit()));
    return menu;
}
Also used : Shell(org.eclipse.swt.widgets.Shell) StyledText(org.eclipse.swt.custom.StyledText) FileDialog(org.eclipse.swt.widgets.FileDialog) IOException(java.io.IOException) FileInputStream(java.io.FileInputStream) Reader(java.io.Reader) Display(org.eclipse.swt.widgets.Display) InputStreamReader(java.io.InputStreamReader) File(java.io.File) FileNotFoundException(java.io.FileNotFoundException) MessageFormat(java.text.MessageFormat) SelectionListener.widgetSelectedAdapter(org.eclipse.swt.events.SelectionListener.widgetSelectedAdapter) ResourceBundle(java.util.ResourceBundle) ShellListener(org.eclipse.swt.events.ShellListener) Color(org.eclipse.swt.graphics.Color) MenuItem(org.eclipse.swt.widgets.MenuItem) SWT(org.eclipse.swt.SWT) MessageBox(org.eclipse.swt.widgets.MessageBox) BufferedReader(java.io.BufferedReader) GridData(org.eclipse.swt.layout.GridData) Menu(org.eclipse.swt.widgets.Menu) GridLayout(org.eclipse.swt.layout.GridLayout) MenuItem(org.eclipse.swt.widgets.MenuItem) Menu(org.eclipse.swt.widgets.Menu)

Example 100 with MenuItem

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

the class TreeTab method specialPopupMenuItems.

@Override
protected void specialPopupMenuItems(Menu menu, Event event) {
    MenuItem item = new MenuItem(menu, SWT.PUSH);
    item.setText("getItem(Point) on mouse coordinates");
    final Tree t = (Tree) event.widget;
    menuMouseCoords = t.toControl(new Point(event.x, event.y));
    item.addSelectionListener(widgetSelectedAdapter(e -> {
        eventConsole.append("getItem(Point(" + menuMouseCoords + ")) returned: " + t.getItem(menuMouseCoords));
        eventConsole.append("\n");
    }));
}
Also used : TableItem(org.eclipse.swt.widgets.TableItem) Button(org.eclipse.swt.widgets.Button) Image(org.eclipse.swt.graphics.Image) Point(org.eclipse.swt.graphics.Point) Group(org.eclipse.swt.widgets.Group) TreeItem(org.eclipse.swt.widgets.TreeItem) Event(org.eclipse.swt.widgets.Event) SelectionListener.widgetSelectedAdapter(org.eclipse.swt.events.SelectionListener.widgetSelectedAdapter) Color(org.eclipse.swt.graphics.Color) Item(org.eclipse.swt.widgets.Item) MenuItem(org.eclipse.swt.widgets.MenuItem) Tree(org.eclipse.swt.widgets.Tree) SWT(org.eclipse.swt.SWT) FontData(org.eclipse.swt.graphics.FontData) RGB(org.eclipse.swt.graphics.RGB) Font(org.eclipse.swt.graphics.Font) GridData(org.eclipse.swt.layout.GridData) Menu(org.eclipse.swt.widgets.Menu) Widget(org.eclipse.swt.widgets.Widget) TreeColumn(org.eclipse.swt.widgets.TreeColumn) SelectionListener(org.eclipse.swt.events.SelectionListener) GridLayout(org.eclipse.swt.layout.GridLayout) Tree(org.eclipse.swt.widgets.Tree) MenuItem(org.eclipse.swt.widgets.MenuItem) Point(org.eclipse.swt.graphics.Point)

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