Search in sources :

Example 41 with MessageBox

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

the class StyledTextContentSpec method main.

public static void main(String[] args) {
    StyledTextContentSpec spec = new StyledTextContentSpec();
    if (args.length > 0) {
        contentClassName = args[0];
    } else {
        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;
    }
    spec.run();
    System.out.println();
    System.out.println(failCount + " TEST FAILURES.");
    System.out.println(errorCount + " UNEXPECTED ERRORS.");
}
Also used : MessageBox(org.eclipse.swt.widgets.MessageBox)

Example 42 with MessageBox

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

the class AddressBook method saveAs.

private boolean saveAs() {
    FileDialog saveDialog = new FileDialog(shell, SWT.SAVE);
    saveDialog.setFilterExtensions(new String[] { "*.adr;", "*.*" });
    saveDialog.setFilterNames(new String[] { "Address Books (*.adr)", "All Files " });
    saveDialog.open();
    String name = saveDialog.getFileName();
    if (name.isEmpty())
        return false;
    if (name.indexOf(".adr") != name.length() - 4) {
        name += ".adr";
    }
    File file = new File(saveDialog.getFilterPath(), name);
    if (file.exists()) {
        MessageBox box = new MessageBox(shell, SWT.ICON_WARNING | SWT.YES | SWT.NO);
        box.setText(resAddressBook.getString("Save_as_title"));
        box.setMessage(resAddressBook.getString("File") + file.getName() + " " + resAddressBook.getString("Query_overwrite"));
        if (box.open() != SWT.YES) {
            return false;
        }
    }
    this.file = file;
    return save();
}
Also used : FileDialog(org.eclipse.swt.widgets.FileDialog) File(java.io.File) MessageBox(org.eclipse.swt.widgets.MessageBox)

Example 43 with MessageBox

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

the class AddressBook method displayError.

private 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 44 with MessageBox

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

the class BrowserTab method createTabFolderPage.

/**
 * Creates the tab folder page.
 *
 * @param tabFolder org.eclipse.swt.widgets.TabFolder
 * @return the new page for the tab folder
 */
@Override
Composite createTabFolderPage(final TabFolder tabFolder) {
    super.createTabFolderPage(tabFolder);
    /*
		 * Add a resize listener to the tabFolderPage so that
		 * if the user types into the example widget to change
		 * its preferred size, and then resizes the shell, we
		 * recalculate the preferred size correctly.
		 */
    tabFolderPage.addControlListener(ControlListener.controlResizedAdapter(e -> setExampleWidgetSize()));
    /*
		 * Add a selection listener to the tabFolder to bring up a
		 * dialog if this platform does not support the Browser.
		 */
    tabFolder.addSelectionListener(widgetSelectedAdapter(e -> {
        if (errorMessage != null && tabFolder.getSelection()[0].getText().equals(getTabText())) {
            MessageBox dialog = new MessageBox(shell, SWT.ICON_WARNING | SWT.OK);
            dialog.setMessage(ControlExample.getResourceString("BrowserNotFound", errorMessage));
            dialog.open();
        }
    }));
    return tabFolderPage;
}
Also used : Browser(org.eclipse.swt.browser.Browser) TabFolder(org.eclipse.swt.widgets.TabFolder) Button(org.eclipse.swt.widgets.Button) IOException(java.io.IOException) ProgressListener(org.eclipse.swt.browser.ProgressListener) ControlListener(org.eclipse.swt.events.ControlListener) InputStreamReader(java.io.InputStreamReader) Group(org.eclipse.swt.widgets.Group) SWTError(org.eclipse.swt.SWTError) SelectionListener.widgetSelectedAdapter(org.eclipse.swt.events.SelectionListener.widgetSelectedAdapter) ProgressEvent(org.eclipse.swt.browser.ProgressEvent) Composite(org.eclipse.swt.widgets.Composite) SWT(org.eclipse.swt.SWT) WindowEvent(org.eclipse.swt.browser.WindowEvent) MessageBox(org.eclipse.swt.widgets.MessageBox) LocationListener(org.eclipse.swt.browser.LocationListener) LocationEvent(org.eclipse.swt.browser.LocationEvent) BufferedReader(java.io.BufferedReader) GridData(org.eclipse.swt.layout.GridData) Widget(org.eclipse.swt.widgets.Widget) VisibilityWindowListener(org.eclipse.swt.browser.VisibilityWindowListener) InputStream(java.io.InputStream) GridLayout(org.eclipse.swt.layout.GridLayout) MessageBox(org.eclipse.swt.widgets.MessageBox)

Example 45 with MessageBox

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

the class DialogTab method createButtonSelected.

/**
 * Handle the create button selection event.
 *
 * @param event org.eclipse.swt.events.SelectionEvent
 */
void createButtonSelected(SelectionEvent event) {
    /* Compute the appropriate dialog style */
    int style = getDefaultStyle();
    if (okButton.getEnabled() && okButton.getSelection())
        style |= SWT.OK;
    if (cancelButton.getEnabled() && cancelButton.getSelection())
        style |= SWT.CANCEL;
    if (yesButton.getEnabled() && yesButton.getSelection())
        style |= SWT.YES;
    if (noButton.getEnabled() && noButton.getSelection())
        style |= SWT.NO;
    if (retryButton.getEnabled() && retryButton.getSelection())
        style |= SWT.RETRY;
    if (abortButton.getEnabled() && abortButton.getSelection())
        style |= SWT.ABORT;
    if (ignoreButton.getEnabled() && ignoreButton.getSelection())
        style |= SWT.IGNORE;
    if (iconErrorButton.getEnabled() && iconErrorButton.getSelection())
        style |= SWT.ICON_ERROR;
    if (iconInformationButton.getEnabled() && iconInformationButton.getSelection())
        style |= SWT.ICON_INFORMATION;
    if (iconQuestionButton.getEnabled() && iconQuestionButton.getSelection())
        style |= SWT.ICON_QUESTION;
    if (iconWarningButton.getEnabled() && iconWarningButton.getSelection())
        style |= SWT.ICON_WARNING;
    if (iconWorkingButton.getEnabled() && iconWorkingButton.getSelection())
        style |= SWT.ICON_WORKING;
    if (primaryModalButton.getEnabled() && primaryModalButton.getSelection())
        style |= SWT.PRIMARY_MODAL;
    if (applicationModalButton.getEnabled() && applicationModalButton.getSelection())
        style |= SWT.APPLICATION_MODAL;
    if (systemModalButton.getEnabled() && systemModalButton.getSelection())
        style |= SWT.SYSTEM_MODAL;
    if (sheetButton.getSelection())
        style |= SWT.SHEET;
    if (saveButton.getEnabled() && saveButton.getSelection())
        style |= SWT.SAVE;
    if (openButton.getEnabled() && openButton.getSelection())
        style |= SWT.OPEN;
    if (multiButton.getEnabled() && multiButton.getSelection())
        style |= SWT.MULTI;
    /* Open the appropriate dialog type */
    String name = dialogCombo.getText();
    if (name.equals(ControlExample.getResourceString("ColorDialog"))) {
        ColorDialog dialog = new ColorDialog(shell, style);
        if (usePreviousResultButton.getSelection()) {
            dialog.setRGB(colorDialogResult);
            dialog.setRGBs(colorDialogCustomColors);
        }
        dialog.setText(ControlExample.getResourceString("Title"));
        RGB result = dialog.open();
        textWidget.append(ControlExample.getResourceString("ColorDialog") + Text.DELIMITER);
        textWidget.append(ControlExample.getResourceString("Result", "" + result) + Text.DELIMITER);
        textWidget.append("getRGB() = " + dialog.getRGB() + Text.DELIMITER);
        textWidget.append("getRGBs() =" + Text.DELIMITER);
        RGB[] rgbs = dialog.getRGBs();
        if (rgbs != null) {
            for (RGB rgbColor : rgbs) {
                textWidget.append("\t" + rgbColor + Text.DELIMITER);
            }
        }
        textWidget.append(Text.DELIMITER);
        colorDialogResult = result;
        colorDialogCustomColors = rgbs;
        return;
    }
    if (name.equals(ControlExample.getResourceString("DirectoryDialog"))) {
        DirectoryDialog dialog = new DirectoryDialog(shell, style);
        if (usePreviousResultButton.getSelection()) {
            dialog.setFilterPath(directoryDialogResult);
        }
        dialog.setMessage(ControlExample.getResourceString("Example_string"));
        dialog.setText(ControlExample.getResourceString("Title"));
        String result = dialog.open();
        textWidget.append(ControlExample.getResourceString("DirectoryDialog") + Text.DELIMITER);
        textWidget.append(ControlExample.getResourceString("Result", "" + result) + Text.DELIMITER + Text.DELIMITER);
        directoryDialogResult = result;
        return;
    }
    if (name.equals(ControlExample.getResourceString("FileDialog"))) {
        FileDialog dialog = new FileDialog(shell, style);
        if (usePreviousResultButton.getSelection()) {
            dialog.setFileName(fileDialogResult);
            dialog.setFilterIndex(fileDialogIndexResult);
        }
        dialog.setFilterNames(FilterNames);
        dialog.setFilterExtensions(FilterExtensions);
        dialog.setText(ControlExample.getResourceString("Title"));
        String result = dialog.open();
        textWidget.append(ControlExample.getResourceString("FileDialog") + Text.DELIMITER);
        textWidget.append(ControlExample.getResourceString("Result", "" + result) + Text.DELIMITER);
        textWidget.append("getFilterIndex() =" + dialog.getFilterIndex() + Text.DELIMITER);
        textWidget.append("getFilterPath() =" + dialog.getFilterPath() + Text.DELIMITER);
        textWidget.append("getFileName() =" + dialog.getFileName() + Text.DELIMITER);
        textWidget.append("getFileNames() =" + Text.DELIMITER);
        String[] files = dialog.getFileNames();
        for (String file : files) {
            textWidget.append("\t" + file + Text.DELIMITER);
        }
        textWidget.append(Text.DELIMITER);
        fileDialogResult = result;
        fileDialogIndexResult = dialog.getFilterIndex();
        return;
    }
    if (name.equals(ControlExample.getResourceString("FontDialog"))) {
        FontDialog dialog = new FontDialog(shell, style);
        if (usePreviousResultButton.getSelection()) {
            dialog.setFontList(fontDialogFontListResult);
            dialog.setRGB(fontDialogColorResult);
        }
        dialog.setEffectsVisible(effectsVisibleButton.getSelection());
        dialog.setText(ControlExample.getResourceString("Title"));
        FontData result = dialog.open();
        textWidget.append(ControlExample.getResourceString("FontDialog") + Text.DELIMITER);
        textWidget.append(ControlExample.getResourceString("Result", "" + result) + Text.DELIMITER);
        textWidget.append("getFontList() =" + Text.DELIMITER);
        FontData[] fonts = dialog.getFontList();
        if (fonts != null) {
            for (FontData font : fonts) {
                textWidget.append("\t" + font + Text.DELIMITER);
            }
        }
        textWidget.append("getEffectsVisible() = " + dialog.getEffectsVisible() + Text.DELIMITER);
        textWidget.append("getRGB() = " + dialog.getRGB() + Text.DELIMITER + Text.DELIMITER);
        fontDialogFontListResult = dialog.getFontList();
        fontDialogColorResult = dialog.getRGB();
        return;
    }
    if (name.equals(ControlExample.getResourceString("PrintDialog"))) {
        PrintDialog dialog = new PrintDialog(shell, style);
        if (usePreviousResultButton.getSelection()) {
            dialog.setPrinterData(printDialogResult);
        }
        dialog.setText(ControlExample.getResourceString("Title"));
        PrinterData result = dialog.open();
        textWidget.append(ControlExample.getResourceString("PrintDialog") + Text.DELIMITER);
        textWidget.append(ControlExample.getResourceString("Result", "" + result) + Text.DELIMITER);
        if (result != null) {
            textWidget.append("printerData.scope = " + (result.scope == PrinterData.PAGE_RANGE ? "PAGE_RANGE" : result.scope == PrinterData.SELECTION ? "SELECTION" : "ALL_PAGES") + Text.DELIMITER);
            textWidget.append("printerData.startPage = " + result.startPage + Text.DELIMITER);
            textWidget.append("printerData.endPage = " + result.endPage + Text.DELIMITER);
            textWidget.append("printerData.printToFile = " + result.printToFile + Text.DELIMITER);
            textWidget.append("printerData.fileName = " + result.fileName + Text.DELIMITER);
            textWidget.append("printerData.orientation = " + (result.orientation == PrinterData.LANDSCAPE ? "LANDSCAPE" : "PORTRAIT") + Text.DELIMITER);
            textWidget.append("printerData.copyCount = " + result.copyCount + Text.DELIMITER);
            textWidget.append("printerData.collate = " + result.collate + Text.DELIMITER);
            textWidget.append("printerData.duplex = " + (result.duplex == PrinterData.DUPLEX_LONG_EDGE ? "DUPLEX_LONG_EDGE" : result.duplex == PrinterData.DUPLEX_SHORT_EDGE ? "DUPLEX_SHORT_EDGE" : "NONE") + Text.DELIMITER);
        }
        textWidget.append(Text.DELIMITER);
        printDialogResult = result;
        return;
    }
    if (name.equals(ControlExample.getResourceString("MessageBox"))) {
        MessageBox dialog = new MessageBox(shell, style);
        dialog.setMessage(ControlExample.getResourceString("Example_string"));
        dialog.setText(ControlExample.getResourceString("Title"));
        int result = dialog.open();
        textWidget.append(ControlExample.getResourceString("MessageBox") + Text.DELIMITER);
        /*
			 * The resulting integer depends on the original
			 * dialog style.  Decode the result and display it.
			 */
        switch(result) {
            case SWT.OK:
                textWidget.append(ControlExample.getResourceString("Result", "SWT.OK"));
                break;
            case SWT.YES:
                textWidget.append(ControlExample.getResourceString("Result", "SWT.YES"));
                break;
            case SWT.NO:
                textWidget.append(ControlExample.getResourceString("Result", "SWT.NO"));
                break;
            case SWT.CANCEL:
                textWidget.append(ControlExample.getResourceString("Result", "SWT.CANCEL"));
                break;
            case SWT.ABORT:
                textWidget.append(ControlExample.getResourceString("Result", "SWT.ABORT"));
                break;
            case SWT.RETRY:
                textWidget.append(ControlExample.getResourceString("Result", "SWT.RETRY"));
                break;
            case SWT.IGNORE:
                textWidget.append(ControlExample.getResourceString("Result", "SWT.IGNORE"));
                break;
            default:
                textWidget.append(ControlExample.getResourceString("Result", "" + result));
                break;
        }
        textWidget.append(Text.DELIMITER + Text.DELIMITER);
    }
}
Also used : FontDialog(org.eclipse.swt.widgets.FontDialog) PrintDialog(org.eclipse.swt.printing.PrintDialog) FontData(org.eclipse.swt.graphics.FontData) RGB(org.eclipse.swt.graphics.RGB) MessageBox(org.eclipse.swt.widgets.MessageBox) ColorDialog(org.eclipse.swt.widgets.ColorDialog) PrinterData(org.eclipse.swt.printing.PrinterData) FileDialog(org.eclipse.swt.widgets.FileDialog) DirectoryDialog(org.eclipse.swt.widgets.DirectoryDialog)

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