Search in sources :

Example 71 with MessageBox

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

the class Test_org_eclipse_swt_widgets_MessageBox method setUp.

@Override
@Before
public void setUp() {
    super.setUp();
    messageBox = new MessageBox(shell, SWT.NULL);
    setDialog(messageBox);
}
Also used : MessageBox(org.eclipse.swt.widgets.MessageBox) Before(org.junit.Before)

Example 72 with MessageBox

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

the class FileViewer method doDefaultFileAction.

/**
 * Performs the default action on a set of files.
 *
 * @param files the array of files to process
 */
void doDefaultFileAction(File[] files) {
    // only uses the 1st file (for now)
    if (files.length == 0)
        return;
    final File file = files[0];
    if (file.isDirectory()) {
        notifySelectedDirectory(file);
    } else {
        final String fileName = file.getAbsolutePath();
        if (!Program.launch(fileName)) {
            MessageBox dialog = new MessageBox(shell, SWT.ICON_ERROR | SWT.OK);
            dialog.setMessage(getResourceString("error.FailedLaunch.message", new Object[] { fileName }));
            dialog.setText(shell.getText());
            dialog.open();
        }
    }
}
Also used : File(java.io.File) MessageBox(org.eclipse.swt.widgets.MessageBox)

Example 73 with MessageBox

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

the class FileViewer method createHelpMenu.

/**
 * Creates the Help Menu.
 *
 * @param parent the parent menu
 */
private void createHelpMenu(Menu parent) {
    Menu menu = new Menu(parent);
    MenuItem header = new MenuItem(parent, SWT.CASCADE);
    header.setText(getResourceString("menu.Help.text"));
    header.setMenu(menu);
    MenuItem item = new MenuItem(menu, SWT.PUSH);
    item.setText(getResourceString("menu.Help.About.text"));
    item.addSelectionListener(widgetSelectedAdapter(e -> {
        MessageBox box = new MessageBox(shell, SWT.ICON_INFORMATION | SWT.OK);
        box.setText(getResourceString("dialog.About.title"));
        box.setMessage(getResourceString("dialog.About.description", new Object[] { System.getProperty("os.name") }));
        box.open();
    }));
}
Also used : SashForm(org.eclipse.swt.custom.SashForm) Date(java.util.Date) DND(org.eclipse.swt.dnd.DND) ProgressBar(org.eclipse.swt.widgets.ProgressBar) TableColumn(org.eclipse.swt.widgets.TableColumn) ToolBar(org.eclipse.swt.widgets.ToolBar) Point(org.eclipse.swt.graphics.Point) Program(org.eclipse.swt.program.Program) DropTargetEvent(org.eclipse.swt.dnd.DropTargetEvent) DropTargetAdapter(org.eclipse.swt.dnd.DropTargetAdapter) Composite(org.eclipse.swt.widgets.Composite) DateFormat(java.text.DateFormat) DropTarget(org.eclipse.swt.dnd.DropTarget) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) Button(org.eclipse.swt.widgets.Button) MissingResourceException(java.util.MissingResourceException) Display(org.eclipse.swt.widgets.Display) ToolItem(org.eclipse.swt.widgets.ToolItem) FileNotFoundException(java.io.FileNotFoundException) List(java.util.List) MenuItem(org.eclipse.swt.widgets.MenuItem) Tree(org.eclipse.swt.widgets.Tree) SWT(org.eclipse.swt.SWT) DragSourceEvent(org.eclipse.swt.dnd.DragSourceEvent) Label(org.eclipse.swt.widgets.Label) SelectionListener(org.eclipse.swt.events.SelectionListener) DragSourceListener(org.eclipse.swt.dnd.DragSourceListener) Image(org.eclipse.swt.graphics.Image) Rectangle(org.eclipse.swt.graphics.Rectangle) Table(org.eclipse.swt.widgets.Table) MessageFormat(java.text.MessageFormat) ArrayList(java.util.ArrayList) SelectionListener.widgetSelectedAdapter(org.eclipse.swt.events.SelectionListener.widgetSelectedAdapter) ResourceBundle(java.util.ResourceBundle) TreeEvent(org.eclipse.swt.events.TreeEvent) GridData(org.eclipse.swt.layout.GridData) FileTransfer(org.eclipse.swt.dnd.FileTransfer) DragSource(org.eclipse.swt.dnd.DragSource) TableItem(org.eclipse.swt.widgets.TableItem) Combo(org.eclipse.swt.widgets.Combo) Shell(org.eclipse.swt.widgets.Shell) FileWriter(java.io.FileWriter) IOException(java.io.IOException) TreeAdapter(org.eclipse.swt.events.TreeAdapter) TreeItem(org.eclipse.swt.widgets.TreeItem) File(java.io.File) ShellListener(org.eclipse.swt.events.ShellListener) MessageBox(org.eclipse.swt.widgets.MessageBox) FileReader(java.io.FileReader) SelectionEvent(org.eclipse.swt.events.SelectionEvent) Menu(org.eclipse.swt.widgets.Menu) GridLayout(org.eclipse.swt.layout.GridLayout) MenuItem(org.eclipse.swt.widgets.MenuItem) Menu(org.eclipse.swt.widgets.Menu) MessageBox(org.eclipse.swt.widgets.MessageBox)

Example 74 with MessageBox

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

the class FileViewer method createToolBar.

/**
 * Creates the toolbar
 *
 * @param shell the shell on which to attach the toolbar
 * @param layoutData the layout data
 */
private void createToolBar(final Shell shell, Object layoutData) {
    toolBar = new ToolBar(shell, SWT.NONE);
    toolBar.setLayoutData(layoutData);
    ToolItem item = new ToolItem(toolBar, SWT.SEPARATOR);
    item = new ToolItem(toolBar, SWT.PUSH);
    item.setImage(iconCache.stockImages[iconCache.cmdParent]);
    item.setToolTipText(getResourceString("tool.Parent.tiptext"));
    item.addSelectionListener(widgetSelectedAdapter(e -> doParent()));
    item = new ToolItem(toolBar, SWT.PUSH);
    item.setImage(iconCache.stockImages[iconCache.cmdRefresh]);
    item.setToolTipText(getResourceString("tool.Refresh.tiptext"));
    item.addSelectionListener(widgetSelectedAdapter(e -> doRefresh()));
    SelectionListener unimplementedListener = widgetSelectedAdapter(e -> {
        MessageBox box = new MessageBox(shell, SWT.ICON_INFORMATION | SWT.OK);
        box.setText(getResourceString("dialog.NotImplemented.title"));
        box.setMessage(getResourceString("dialog.ActionNotImplemented.description"));
        box.open();
    });
    item = new ToolItem(toolBar, SWT.SEPARATOR);
    item = new ToolItem(toolBar, SWT.PUSH);
    item.setImage(iconCache.stockImages[iconCache.cmdCut]);
    item.setToolTipText(getResourceString("tool.Cut.tiptext"));
    item.addSelectionListener(unimplementedListener);
    item = new ToolItem(toolBar, SWT.PUSH);
    item.setImage(iconCache.stockImages[iconCache.cmdCopy]);
    item.setToolTipText(getResourceString("tool.Copy.tiptext"));
    item.addSelectionListener(unimplementedListener);
    item = new ToolItem(toolBar, SWT.PUSH);
    item.setImage(iconCache.stockImages[iconCache.cmdPaste]);
    item.setToolTipText(getResourceString("tool.Paste.tiptext"));
    item.addSelectionListener(unimplementedListener);
    item = new ToolItem(toolBar, SWT.SEPARATOR);
    item = new ToolItem(toolBar, SWT.PUSH);
    item.setImage(iconCache.stockImages[iconCache.cmdDelete]);
    item.setToolTipText(getResourceString("tool.Delete.tiptext"));
    item.addSelectionListener(unimplementedListener);
    item = new ToolItem(toolBar, SWT.PUSH);
    item.setImage(iconCache.stockImages[iconCache.cmdRename]);
    item.setToolTipText(getResourceString("tool.Rename.tiptext"));
    item.addSelectionListener(unimplementedListener);
    item = new ToolItem(toolBar, SWT.SEPARATOR);
    item = new ToolItem(toolBar, SWT.PUSH);
    item.setImage(iconCache.stockImages[iconCache.cmdSearch]);
    item.setToolTipText(getResourceString("tool.Search.tiptext"));
    item.addSelectionListener(unimplementedListener);
    item = new ToolItem(toolBar, SWT.PUSH);
    item.setImage(iconCache.stockImages[iconCache.cmdPrint]);
    item.setToolTipText(getResourceString("tool.Print.tiptext"));
    item.addSelectionListener(unimplementedListener);
}
Also used : SashForm(org.eclipse.swt.custom.SashForm) Date(java.util.Date) DND(org.eclipse.swt.dnd.DND) ProgressBar(org.eclipse.swt.widgets.ProgressBar) TableColumn(org.eclipse.swt.widgets.TableColumn) ToolBar(org.eclipse.swt.widgets.ToolBar) Point(org.eclipse.swt.graphics.Point) Program(org.eclipse.swt.program.Program) DropTargetEvent(org.eclipse.swt.dnd.DropTargetEvent) DropTargetAdapter(org.eclipse.swt.dnd.DropTargetAdapter) Composite(org.eclipse.swt.widgets.Composite) DateFormat(java.text.DateFormat) DropTarget(org.eclipse.swt.dnd.DropTarget) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) Button(org.eclipse.swt.widgets.Button) MissingResourceException(java.util.MissingResourceException) Display(org.eclipse.swt.widgets.Display) ToolItem(org.eclipse.swt.widgets.ToolItem) FileNotFoundException(java.io.FileNotFoundException) List(java.util.List) MenuItem(org.eclipse.swt.widgets.MenuItem) Tree(org.eclipse.swt.widgets.Tree) SWT(org.eclipse.swt.SWT) DragSourceEvent(org.eclipse.swt.dnd.DragSourceEvent) Label(org.eclipse.swt.widgets.Label) SelectionListener(org.eclipse.swt.events.SelectionListener) DragSourceListener(org.eclipse.swt.dnd.DragSourceListener) Image(org.eclipse.swt.graphics.Image) Rectangle(org.eclipse.swt.graphics.Rectangle) Table(org.eclipse.swt.widgets.Table) MessageFormat(java.text.MessageFormat) ArrayList(java.util.ArrayList) SelectionListener.widgetSelectedAdapter(org.eclipse.swt.events.SelectionListener.widgetSelectedAdapter) ResourceBundle(java.util.ResourceBundle) TreeEvent(org.eclipse.swt.events.TreeEvent) GridData(org.eclipse.swt.layout.GridData) FileTransfer(org.eclipse.swt.dnd.FileTransfer) DragSource(org.eclipse.swt.dnd.DragSource) TableItem(org.eclipse.swt.widgets.TableItem) Combo(org.eclipse.swt.widgets.Combo) Shell(org.eclipse.swt.widgets.Shell) FileWriter(java.io.FileWriter) IOException(java.io.IOException) TreeAdapter(org.eclipse.swt.events.TreeAdapter) TreeItem(org.eclipse.swt.widgets.TreeItem) File(java.io.File) ShellListener(org.eclipse.swt.events.ShellListener) MessageBox(org.eclipse.swt.widgets.MessageBox) FileReader(java.io.FileReader) SelectionEvent(org.eclipse.swt.events.SelectionEvent) Menu(org.eclipse.swt.widgets.Menu) GridLayout(org.eclipse.swt.layout.GridLayout) ToolBar(org.eclipse.swt.widgets.ToolBar) ToolItem(org.eclipse.swt.widgets.ToolItem) SelectionListener(org.eclipse.swt.events.SelectionListener) MessageBox(org.eclipse.swt.widgets.MessageBox)

Example 75 with MessageBox

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

the class AdvancedGraphics method open.

public Shell open(final Display display) {
    final Shell shell = new Shell(display);
    // $NON-NLS-1$
    shell.setText(RESOURCE_BUNDLE.getString("AdvancedGraphics"));
    try {
        Path path = new Path(display);
        path.dispose();
    } catch (SWTException e) {
        MessageBox dialog = new MessageBox(shell, SWT.ICON_WARNING | SWT.OK);
        // $NON-NLS-1$
        dialog.setText(RESOURCE_BUNDLE.getString("Warning"));
        // $NON-NLS-1$
        dialog.setMessage(RESOURCE_BUNDLE.getString("LibNotFound"));
        dialog.open();
        shell.dispose();
        return null;
    }
    FontData fd = shell.getFont().getFontData()[0];
    final Font font = new Font(display, fd.getName(), 96, SWT.BOLD | SWT.ITALIC);
    final Image image = loadImage(display, AdvancedGraphics.class, "irmaos.jpg");
    final Rectangle rect = image.getBounds();
    shell.addListener(SWT.Paint, event -> {
        GC gc = event.gc;
        Transform tr = new Transform(display);
        tr.translate(rect.width / 4, rect.height / 2);
        tr.rotate(-30);
        if (image != null) {
            gc.drawImage(image, 0, 0, rect.width, rect.height, 0, 0, rect.width, rect.height);
        }
        gc.setAlpha(100);
        gc.setTransform(tr);
        Path path = new Path(display);
        path.addString("SWT", 0, 0, font);
        gc.setBackground(display.getSystemColor(SWT.COLOR_GREEN));
        gc.setForeground(display.getSystemColor(SWT.COLOR_BLUE));
        gc.fillPath(path);
        gc.drawPath(path);
        tr.dispose();
        path.dispose();
    });
    shell.setSize(shell.computeSize(rect.width, rect.height));
    shell.open();
    shell.addListener(SWT.Dispose, event -> {
        if (image != null)
            image.dispose();
        font.dispose();
    });
    return shell;
}
Also used : Path(org.eclipse.swt.graphics.Path) Shell(org.eclipse.swt.widgets.Shell) SWTException(org.eclipse.swt.SWTException) FontData(org.eclipse.swt.graphics.FontData) Rectangle(org.eclipse.swt.graphics.Rectangle) Image(org.eclipse.swt.graphics.Image) GC(org.eclipse.swt.graphics.GC) Transform(org.eclipse.swt.graphics.Transform) Font(org.eclipse.swt.graphics.Font) MessageBox(org.eclipse.swt.widgets.MessageBox)

Aggregations

MessageBox (org.eclipse.swt.widgets.MessageBox)99 Shell (org.eclipse.swt.widgets.Shell)17 ArrayList (java.util.ArrayList)13 File (java.io.File)11 IOException (java.io.IOException)10 SelectionEvent (org.eclipse.swt.events.SelectionEvent)10 GridData (org.eclipse.swt.layout.GridData)9 GridLayout (org.eclipse.swt.layout.GridLayout)9 WorkflowManager (org.knime.core.node.workflow.WorkflowManager)9 Point (org.eclipse.swt.graphics.Point)8 Button (org.eclipse.swt.widgets.Button)8 Display (org.eclipse.swt.widgets.Display)8 Composite (org.eclipse.swt.widgets.Composite)7 FileDialog (org.eclipse.swt.widgets.FileDialog)7 Label (org.eclipse.swt.widgets.Label)7 List (java.util.List)6 SWTError (org.eclipse.swt.SWTError)6 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)6 SelectionListener (org.eclipse.swt.events.SelectionListener)6 SWT (org.eclipse.swt.SWT)5