Search in sources :

Example 76 with MessageBox

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

the class GraphicsExample method checkAdvancedGraphics.

boolean checkAdvancedGraphics() {
    if (advanceGraphicsInit)
        return advanceGraphics;
    advanceGraphicsInit = true;
    Display display = parent.getDisplay();
    try {
        Path path = new Path(display);
        path.dispose();
    } catch (SWTException e) {
        Shell shell = display.getActiveShell(), newShell = null;
        if (shell == null)
            shell = newShell = new Shell(display);
        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();
        if (newShell != null)
            newShell.dispose();
        return false;
    }
    return advanceGraphics = true;
}
Also used : Path(org.eclipse.swt.graphics.Path) Shell(org.eclipse.swt.widgets.Shell) SWTException(org.eclipse.swt.SWTException) Display(org.eclipse.swt.widgets.Display) MessageBox(org.eclipse.swt.widgets.MessageBox)

Example 77 with MessageBox

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

the class ImageAnalyzer method showErrorDialog.

/*
	 * Open an error dialog displaying the specified information.
	 */
void showErrorDialog(String operation, String filename, Throwable e) {
    MessageBox box = new MessageBox(shell, SWT.ICON_ERROR);
    String message = createMsg(bundle.getString("Error"), new String[] { operation, filename });
    String errorMessage = "";
    if (e != null) {
        if (e instanceof SWTException) {
            SWTException swte = (SWTException) e;
            errorMessage = swte.getMessage();
            if (swte.throwable != null) {
                errorMessage += ":\n" + swte.throwable.toString();
            }
        } else if (e instanceof SWTError) {
            SWTError swte = (SWTError) e;
            errorMessage = swte.getMessage();
            if (swte.throwable != null) {
                errorMessage += ":\n" + swte.throwable.toString();
            }
        } else {
            errorMessage = e.toString();
        }
    }
    box.setMessage(message + errorMessage);
    box.open();
}
Also used : SWTError(org.eclipse.swt.SWTError) SWTException(org.eclipse.swt.SWTException) MessageBox(org.eclipse.swt.widgets.MessageBox)

Example 78 with MessageBox

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

the class ImageAnalyzer method menuPrint.

void menuPrint() {
    if (image == null)
        return;
    try {
        // Ask the user to specify the printer.
        PrintDialog dialog = new PrintDialog(shell, SWT.NONE);
        if (printerData != null)
            dialog.setPrinterData(printerData);
        printerData = dialog.open();
        if (printerData == null)
            return;
        Printer printer = new Printer(printerData);
        Point screenDPI = display.getDPI();
        Point printerDPI = printer.getDPI();
        int scaleFactor = printerDPI.x / screenDPI.x;
        Rectangle trim = printer.computeTrim(0, 0, 0, 0);
        if (printer.startJob(currentName)) {
            if (printer.startPage()) {
                GC gc = new GC(printer);
                int transparentPixel = imageData.transparentPixel;
                if (transparentPixel != -1 && !transparent) {
                    imageData.transparentPixel = -1;
                }
                Image printerImage = new Image(printer, imageData);
                gc.drawImage(printerImage, 0, 0, imageData.width, imageData.height, -trim.x, -trim.y, scaleFactor * imageData.width, scaleFactor * imageData.height);
                if (transparentPixel != -1 && !transparent) {
                    imageData.transparentPixel = transparentPixel;
                }
                printerImage.dispose();
                gc.dispose();
                printer.endPage();
            }
            printer.endJob();
        }
        printer.dispose();
    } catch (SWTError e) {
        MessageBox box = new MessageBox(shell, SWT.ICON_ERROR);
        box.setMessage(bundle.getString("Printing_error") + e.getMessage());
        box.open();
    }
}
Also used : SWTError(org.eclipse.swt.SWTError) PrintDialog(org.eclipse.swt.printing.PrintDialog) Rectangle(org.eclipse.swt.graphics.Rectangle) Point(org.eclipse.swt.graphics.Point) Printer(org.eclipse.swt.printing.Printer) GC(org.eclipse.swt.graphics.GC) Image(org.eclipse.swt.graphics.Image) Point(org.eclipse.swt.graphics.Point) MessageBox(org.eclipse.swt.widgets.MessageBox)

Example 79 with MessageBox

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

the class JavaViewer method displayError.

void displayError(String msg) {
    MessageBox box = new MessageBox(shell, SWT.ICON_ERROR);
    box.setMessage(msg);
    box.open();
}
Also used : MessageBox(org.eclipse.swt.widgets.MessageBox)

Example 80 with MessageBox

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

the class StyledTextContentSpec method run.

public void run() {
    if (contentClassName.isEmpty()) {
        MessageBox box = new MessageBox(Display.getDefault().getActiveShell(), SWT.ICON_ERROR);
        // $NON-NLS-1$
        box.setMessage("Content class must be specified as an execution argument.");
        box.open();
        return;
    }
    if (contentClass == null) {
        try {
            contentClass = Class.forName(contentClassName);
        } catch (ClassNotFoundException e) {
            MessageBox box = new MessageBox(Display.getDefault().getActiveShell(), SWT.ICON_ERROR);
            // $NON-NLS-1$
            box.setMessage("Content class:\n" + contentClassName + "\nnot found");
            box.open();
            return;
        }
    }
    try {
        contentInstance = (StyledTextContent) contentClass.newInstance();
    } catch (IllegalAccessException e) {
        MessageBox box = new MessageBox(Display.getDefault().getActiveShell(), SWT.ICON_ERROR);
        // $NON-NLS-1$
        box.setMessage("Unable to access content class:\n" + contentClassName);
        box.open();
        return;
    } catch (InstantiationException e) {
        MessageBox box = new MessageBox(Display.getDefault().getActiveShell(), SWT.ICON_ERROR);
        // $NON-NLS-1$
        box.setMessage("Unable to instantiate content class:\n" + contentClassName);
        box.open();
        return;
    }
    Class<?> clazz;
    clazz = this.getClass();
    Method[] methods = clazz.getDeclaredMethods();
    for (int i = 0; i < methods.length; i++) {
        setUp();
        currentMethod = methods[i];
        failed = false;
        try {
            if (currentMethod.getName().startsWith("test_")) {
                System.out.println();
                System.out.println(currentMethod.getName() + "...");
                currentMethod.invoke(this);
                if (!failed) {
                    System.out.println("PASSED.");
                } else {
                    System.out.println("FAILED");
                }
            }
        } catch (InvocationTargetException ex) {
            System.out.println("\t" + currentMethod.getName() + " ERROR ==> " + ex.getTargetException().toString());
            System.out.println("FAILED");
            errorCount++;
        } catch (Exception ex) {
            System.out.println("\t" + currentMethod.getName() + " ERROR ==> " + ex.toString());
            System.out.println("FAILED");
            errorCount++;
        }
        if (verify != 0) {
            verify = 0;
            contentInstance.removeTextChangeListener(this);
        }
        tearDown();
    }
}
Also used : Method(java.lang.reflect.Method) InvocationTargetException(java.lang.reflect.InvocationTargetException) InvocationTargetException(java.lang.reflect.InvocationTargetException) 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