Search in sources :

Example 66 with MessageBox

use of org.eclipse.swt.widgets.MessageBox in project tdi-studio-se by Talend.

the class ImportExchangeDialog method okPressed.

@Override
protected void okPressed() {
    //$NON-NLS-1$ //$NON-NLS-2$
    IPath tempPath = new Path(System.getProperty("user.dir")).append("temp");
    File pathFile = tempPath.toFile();
    if (downloadproperty.getFileName() == null || downloadproperty.getFileName() == null) {
        MessageBox box = new MessageBox(Display.getCurrent().getActiveShell(), SWT.ICON_WARNING | SWT.OK);
        //$NON-NLS-1$
        box.setText(Messages.getString("ImportExchangeDialog.WARNING"));
        //$NON-NLS-1$
        box.setMessage(Messages.getString("ImportExchangeDialog.NOTSELECTWARNING"));
        box.open();
        return;
    }
    tempFile = new File(pathFile, downloadproperty.getFileName());
    try {
        url = new URL(downloadproperty.getDownloadUrl());
    } catch (MalformedURLException e1) {
        ExceptionHandler.process(e1);
    }
    if (!pathFile.exists()) {
        pathFile.mkdirs();
    }
    ProgressMonitorDialog progressDialog = new ProgressMonitorDialog(PlatformUI.getWorkbench().getDisplay().getActiveShell().getShell());
    IRunnableWithProgress runnable = new IRunnableWithProgress() {

        @Override
        public void run(IProgressMonitor monitor) {
            //$NON-NLS-1$
            monitor.beginTask(Messages.getString("ImportExchangeDialog.downloadProgressBar"), IProgressMonitor.UNKNOWN);
            Display.getDefault().syncExec(new Runnable() {

                @Override
                public void run() {
                    try {
                        new DownloadHelper().download(url, tempFile);
                    } catch (Exception e) {
                        ExceptionHandler.process(e);
                    }
                }
            });
            monitor.done();
        }
    };
    try {
        progressDialog.run(true, true, runnable);
    } catch (InvocationTargetException e1) {
        ExceptionHandler.process(e1);
    } catch (InterruptedException e1) {
        ExceptionHandler.process(e1);
    }
    selectFile = tempFile.toString();
    super.okPressed();
}
Also used : IPath(org.eclipse.core.runtime.IPath) Path(org.eclipse.core.runtime.Path) MalformedURLException(java.net.MalformedURLException) IPath(org.eclipse.core.runtime.IPath) ProgressMonitorDialog(org.eclipse.jface.dialogs.ProgressMonitorDialog) DownloadHelper(org.talend.core.download.DownloadHelper) URL(java.net.URL) MalformedURLException(java.net.MalformedURLException) InvocationTargetException(java.lang.reflect.InvocationTargetException) InvocationTargetException(java.lang.reflect.InvocationTargetException) MessageBox(org.eclipse.swt.widgets.MessageBox) IRunnableWithProgress(org.eclipse.jface.operation.IRunnableWithProgress) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) File(java.io.File)

Example 67 with MessageBox

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

the class AddressBook method closeAddressBook.

private boolean closeAddressBook() {
    if (isModified) {
        // ask user if they want to save current address book
        MessageBox box = new MessageBox(shell, SWT.ICON_WARNING | SWT.YES | SWT.NO | SWT.CANCEL);
        box.setText(shell.getText());
        box.setMessage(resAddressBook.getString("Close_save"));
        int choice = box.open();
        if (choice == SWT.CANCEL) {
            return false;
        } else if (choice == SWT.YES) {
            if (!save())
                return false;
        }
    }
    TableItem[] items = table.getItems();
    for (TableItem item : items) {
        item.dispose();
    }
    return true;
}
Also used : TableItem(org.eclipse.swt.widgets.TableItem) MessageBox(org.eclipse.swt.widgets.MessageBox)

Example 68 with MessageBox

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

the class AddressBook method createHelpMenu.

/**
 * Creates all the items located in the Help submenu and
 * associate all the menu items with their appropriate
 * functions.
 *
 * @param	menuBar	Menu
 *				the <code>Menu</code> that file contain
 *				the Help submenu.
 */
private void createHelpMenu(Menu menuBar) {
    // Help Menu
    MenuItem item = new MenuItem(menuBar, SWT.CASCADE);
    item.setText(resAddressBook.getString("Help_menu_title"));
    Menu menu = new Menu(shell, SWT.DROP_DOWN);
    item.setMenu(menu);
    // Help -> About Text Editor
    MenuItem subItem = new MenuItem(menu, SWT.NONE);
    subItem.setText(resAddressBook.getString("About"));
    subItem.addSelectionListener(widgetSelectedAdapter(e -> {
        MessageBox box = new MessageBox(shell, SWT.NONE);
        box.setText(resAddressBook.getString("About_1") + shell.getText());
        box.setMessage(shell.getText() + resAddressBook.getString("About_2"));
        box.open();
    }));
}
Also used : Arrays(java.util.Arrays) TableColumn(org.eclipse.swt.widgets.TableColumn) Table(org.eclipse.swt.widgets.Table) SelectionListener.widgetSelectedAdapter(org.eclipse.swt.events.SelectionListener.widgetSelectedAdapter) ResourceBundle(java.util.ResourceBundle) FillLayout(org.eclipse.swt.layout.FillLayout) Cursor(org.eclipse.swt.graphics.Cursor) SelectionListener.widgetDefaultSelectedAdapter(org.eclipse.swt.events.SelectionListener.widgetDefaultSelectedAdapter) TableItem(org.eclipse.swt.widgets.TableItem) Shell(org.eclipse.swt.widgets.Shell) FileDialog(org.eclipse.swt.widgets.FileDialog) FileWriter(java.io.FileWriter) IOException(java.io.IOException) Display(org.eclipse.swt.widgets.Display) File(java.io.File) FileNotFoundException(java.io.FileNotFoundException) MenuListener.menuShownAdapter(org.eclipse.swt.events.MenuListener.menuShownAdapter) ShellListener(org.eclipse.swt.events.ShellListener) MenuItem(org.eclipse.swt.widgets.MenuItem) SWT(org.eclipse.swt.SWT) MessageBox(org.eclipse.swt.widgets.MessageBox) BufferedReader(java.io.BufferedReader) FileReader(java.io.FileReader) Menu(org.eclipse.swt.widgets.Menu) Comparator(java.util.Comparator) MenuItem(org.eclipse.swt.widgets.MenuItem) Menu(org.eclipse.swt.widgets.Menu) MessageBox(org.eclipse.swt.widgets.MessageBox)

Example 69 with MessageBox

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

the class BrowserTab method createExampleWidgets.

/**
 * Creates the "Example" widgets.
 */
@Override
void createExampleWidgets() {
    /* Compute the widget style */
    int style = getDefaultStyle();
    if (borderButton.getSelection())
        style |= SWT.BORDER;
    if (webKitButton.getSelection())
        style |= SWT.WEBKIT;
    /* Create the example widgets */
    try {
        browser = new Browser(browserGroup, style);
    } catch (SWTError e) {
        // Probably missing browser
        try {
            browser = new Browser(browserGroup, style & ~(SWT.WEBKIT));
        } catch (SWTError e2) {
            // Unsupported platform
            errorMessage = e.getMessage();
            return;
        }
        MessageBox dialog = new MessageBox(shell, SWT.ICON_WARNING | SWT.OK);
        String resourceString = "WebKitNotFound";
        dialog.setMessage(ControlExample.getResourceString(resourceString, e.getMessage()));
        dialog.open();
    }
    if (lastUrl != null) {
        browser.setUrl(lastUrl);
    } else if (lastText != null) {
        browser.setText(lastText);
    } else {
        StringBuilder sb = new StringBuilder(300);
        try (InputStream htmlStream = ControlExample.class.getResourceAsStream("browser-content.html");
            BufferedReader br = new BufferedReader(new InputStreamReader(htmlStream))) {
            int read = 0;
            while ((read = br.read()) != -1) sb.append((char) read);
        } catch (IOException e) {
            log(e.getMessage());
        }
        String text = sb.toString();
        browser.setText(text);
    }
    lastText = lastUrl = null;
}
Also used : SWTError(org.eclipse.swt.SWTError) InputStreamReader(java.io.InputStreamReader) InputStream(java.io.InputStream) BufferedReader(java.io.BufferedReader) IOException(java.io.IOException) Browser(org.eclipse.swt.browser.Browser) MessageBox(org.eclipse.swt.widgets.MessageBox)

Example 70 with MessageBox

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

the class DialogTab method createControlWidgets.

/**
 * Creates the "Control" widget children.
 */
@Override
void createControlWidgets() {
    /* Create the combo */
    String[] strings = { ControlExample.getResourceString("ColorDialog"), ControlExample.getResourceString("DirectoryDialog"), ControlExample.getResourceString("FileDialog"), ControlExample.getResourceString("FontDialog"), ControlExample.getResourceString("PrintDialog"), ControlExample.getResourceString("MessageBox") };
    dialogCombo = new Combo(dialogStyleGroup, SWT.READ_ONLY);
    dialogCombo.setItems(strings);
    dialogCombo.setText(strings[0]);
    dialogCombo.setVisibleItemCount(strings.length);
    /* Create the create dialog button */
    createButton = new Button(dialogStyleGroup, SWT.NONE);
    createButton.setText(ControlExample.getResourceString("Create_Dialog"));
    createButton.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_CENTER));
    /* Create a group for the various dialog button style controls */
    Group buttonStyleGroup = new Group(controlGroup, SWT.NONE);
    buttonStyleGroup.setLayout(new GridLayout());
    buttonStyleGroup.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_FILL));
    buttonStyleGroup.setText(ControlExample.getResourceString("Button_Styles"));
    /* Create the button style buttons */
    okButton = new Button(buttonStyleGroup, SWT.CHECK);
    okButton.setText("SWT.OK");
    cancelButton = new Button(buttonStyleGroup, SWT.CHECK);
    cancelButton.setText("SWT.CANCEL");
    yesButton = new Button(buttonStyleGroup, SWT.CHECK);
    yesButton.setText("SWT.YES");
    noButton = new Button(buttonStyleGroup, SWT.CHECK);
    noButton.setText("SWT.NO");
    retryButton = new Button(buttonStyleGroup, SWT.CHECK);
    retryButton.setText("SWT.RETRY");
    abortButton = new Button(buttonStyleGroup, SWT.CHECK);
    abortButton.setText("SWT.ABORT");
    ignoreButton = new Button(buttonStyleGroup, SWT.CHECK);
    ignoreButton.setText("SWT.IGNORE");
    /* Create a group for the icon style controls */
    Group iconStyleGroup = new Group(controlGroup, SWT.NONE);
    iconStyleGroup.setLayout(new GridLayout());
    iconStyleGroup.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_FILL));
    iconStyleGroup.setText(ControlExample.getResourceString("Icon_Styles"));
    /* Create the icon style buttons */
    iconErrorButton = new Button(iconStyleGroup, SWT.RADIO);
    iconErrorButton.setText("SWT.ICON_ERROR");
    iconInformationButton = new Button(iconStyleGroup, SWT.RADIO);
    iconInformationButton.setText("SWT.ICON_INFORMATION");
    iconQuestionButton = new Button(iconStyleGroup, SWT.RADIO);
    iconQuestionButton.setText("SWT.ICON_QUESTION");
    iconWarningButton = new Button(iconStyleGroup, SWT.RADIO);
    iconWarningButton.setText("SWT.ICON_WARNING");
    iconWorkingButton = new Button(iconStyleGroup, SWT.RADIO);
    iconWorkingButton.setText("SWT.ICON_WORKING");
    noIconButton = new Button(iconStyleGroup, SWT.RADIO);
    noIconButton.setText(ControlExample.getResourceString("No_Icon"));
    /* Create a group for the modal style controls */
    Group modalStyleGroup = new Group(controlGroup, SWT.NONE);
    modalStyleGroup.setLayout(new GridLayout());
    modalStyleGroup.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_FILL));
    modalStyleGroup.setText(ControlExample.getResourceString("Modal_Styles"));
    /* Create the modal style buttons */
    primaryModalButton = new Button(modalStyleGroup, SWT.RADIO);
    primaryModalButton.setText("SWT.PRIMARY_MODAL");
    applicationModalButton = new Button(modalStyleGroup, SWT.RADIO);
    applicationModalButton.setText("SWT.APPLICATION_MODAL");
    systemModalButton = new Button(modalStyleGroup, SWT.RADIO);
    systemModalButton.setText("SWT.SYSTEM_MODAL");
    /* Create a group for the file dialog style controls */
    Group fileDialogStyleGroup = new Group(controlGroup, SWT.NONE);
    fileDialogStyleGroup.setLayout(new GridLayout());
    fileDialogStyleGroup.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_FILL));
    fileDialogStyleGroup.setText(ControlExample.getResourceString("File_Dialog_Styles"));
    /* Create the file dialog style buttons */
    openButton = new Button(fileDialogStyleGroup, SWT.RADIO);
    openButton.setText("SWT.OPEN");
    saveButton = new Button(fileDialogStyleGroup, SWT.RADIO);
    saveButton.setText("SWT.SAVE");
    multiButton = new Button(fileDialogStyleGroup, SWT.CHECK);
    multiButton.setText("SWT.MULTI");
    /* Create the orientation group */
    if (RTL_SUPPORT_ENABLE) {
        createOrientationGroup();
    }
    /* Create a group for other style and setting controls */
    Group otherGroup = new Group(controlGroup, SWT.NONE);
    otherGroup.setLayout(new GridLayout());
    otherGroup.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_FILL));
    otherGroup.setText(ControlExample.getResourceString("Other"));
    /* Create the other style and setting controls */
    sheetButton = new Button(otherGroup, SWT.CHECK);
    sheetButton.setText("SWT.SHEET");
    usePreviousResultButton = new Button(otherGroup, SWT.CHECK);
    usePreviousResultButton.setText(ControlExample.getResourceString("Use_Previous_Result"));
    effectsVisibleButton = new Button(otherGroup, SWT.CHECK);
    effectsVisibleButton.setText("FontDialog.setEffectsVisible");
    /* Add the listeners */
    dialogCombo.addSelectionListener(widgetSelectedAdapter(event -> dialogSelected(event)));
    createButton.addSelectionListener(widgetSelectedAdapter(event -> createButtonSelected(event)));
    SelectionListener buttonStyleListener = widgetSelectedAdapter(event -> buttonStyleSelected(event));
    okButton.addSelectionListener(buttonStyleListener);
    cancelButton.addSelectionListener(buttonStyleListener);
    yesButton.addSelectionListener(buttonStyleListener);
    noButton.addSelectionListener(buttonStyleListener);
    retryButton.addSelectionListener(buttonStyleListener);
    abortButton.addSelectionListener(buttonStyleListener);
    ignoreButton.addSelectionListener(buttonStyleListener);
    /* Set default values for style buttons */
    okButton.setEnabled(false);
    cancelButton.setEnabled(false);
    yesButton.setEnabled(false);
    noButton.setEnabled(false);
    retryButton.setEnabled(false);
    abortButton.setEnabled(false);
    ignoreButton.setEnabled(false);
    iconErrorButton.setEnabled(false);
    iconInformationButton.setEnabled(false);
    iconQuestionButton.setEnabled(false);
    iconWarningButton.setEnabled(false);
    iconWorkingButton.setEnabled(false);
    noIconButton.setEnabled(false);
    saveButton.setEnabled(false);
    openButton.setEnabled(false);
    openButton.setSelection(true);
    multiButton.setEnabled(false);
    noIconButton.setSelection(true);
    effectsVisibleButton.setEnabled(false);
    effectsVisibleButton.setSelection(true);
}
Also used : Text(org.eclipse.swt.widgets.Text) Combo(org.eclipse.swt.widgets.Combo) Button(org.eclipse.swt.widgets.Button) PrinterData(org.eclipse.swt.printing.PrinterData) FileDialog(org.eclipse.swt.widgets.FileDialog) FontDialog(org.eclipse.swt.widgets.FontDialog) Group(org.eclipse.swt.widgets.Group) SelectionListener.widgetSelectedAdapter(org.eclipse.swt.events.SelectionListener.widgetSelectedAdapter) ColorDialog(org.eclipse.swt.widgets.ColorDialog) PrintDialog(org.eclipse.swt.printing.PrintDialog) SWT(org.eclipse.swt.SWT) FontData(org.eclipse.swt.graphics.FontData) DirectoryDialog(org.eclipse.swt.widgets.DirectoryDialog) MessageBox(org.eclipse.swt.widgets.MessageBox) RGB(org.eclipse.swt.graphics.RGB) SelectionEvent(org.eclipse.swt.events.SelectionEvent) GridData(org.eclipse.swt.layout.GridData) Widget(org.eclipse.swt.widgets.Widget) SelectionListener(org.eclipse.swt.events.SelectionListener) GridLayout(org.eclipse.swt.layout.GridLayout) Group(org.eclipse.swt.widgets.Group) GridLayout(org.eclipse.swt.layout.GridLayout) Button(org.eclipse.swt.widgets.Button) GridData(org.eclipse.swt.layout.GridData) Combo(org.eclipse.swt.widgets.Combo) SelectionListener(org.eclipse.swt.events.SelectionListener)

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