Example usage for org.eclipse.jface.dialogs MessageDialog NONE

List of usage examples for org.eclipse.jface.dialogs MessageDialog NONE

Introduction

In this page you can find the example usage for org.eclipse.jface.dialogs MessageDialog NONE.

Prototype

int NONE

To view the source code for org.eclipse.jface.dialogs MessageDialog NONE.

Click Source Link

Document

Constant for no image (value 0).

Usage

From source file:org.eclipse.riena.internal.ui.ridgets.swt.MessageBoxRidget.java

License:Open Source License

private int getType(final Type type) {

    switch (type) {
    case PLAIN:/*from  w ww .  j  a v a 2s  .  co  m*/
        return MessageDialog.NONE;
    case INFORMATION:
        return MessageDialog.INFORMATION;
    case WARNING:
        return MessageDialog.WARNING;
    case ERROR:
        return MessageDialog.ERROR;
    case HELP:
        return MessageDialog.INFORMATION;
    case QUESTION:
        return MessageDialog.QUESTION;
    default:
        return MessageDialog.NONE;
    }
}

From source file:org.eclipse.riena.internal.ui.ridgets.swt.MessageBoxRidgetTest.java

License:Open Source License

public void testSetType() throws Exception {

    // show message box to transfer values set
    getRidget().show();/*w  w  w. j a  va  2 s.co m*/

    assertEquals(MessageDialog.NONE, getWidget().type);
    assertEquals(IMessageBoxRidget.Type.PLAIN, getRidget().getType());

    getRidget().setType(IMessageBoxRidget.Type.ERROR);
    // show message box to transfer values set
    getRidget().show();

    assertEquals(MessageDialog.ERROR, getWidget().type);
    assertEquals(IMessageBoxRidget.Type.ERROR, getRidget().getType());

    getRidget().setType(IMessageBoxRidget.Type.WARNING);
    // show message box to transfer values set
    getRidget().show();

    assertEquals(MessageDialog.WARNING, getWidget().type);
    assertEquals(IMessageBoxRidget.Type.WARNING, getRidget().getType());

    getRidget().setType(IMessageBoxRidget.Type.INFORMATION);
    // show message box to transfer values set
    getRidget().show();

    assertEquals(MessageDialog.INFORMATION, getWidget().type);
    assertEquals(IMessageBoxRidget.Type.INFORMATION, getRidget().getType());

    getRidget().setType(IMessageBoxRidget.Type.HELP);
    // show message box to transfer values set
    getRidget().show();

    assertEquals(MessageDialog.INFORMATION, getWidget().type);
    assertEquals(IMessageBoxRidget.Type.HELP, getRidget().getType());

    getRidget().setType(IMessageBoxRidget.Type.QUESTION);
    // show message box to transfer values set
    getRidget().show();

    assertEquals(MessageDialog.QUESTION, getWidget().type);
    assertEquals(IMessageBoxRidget.Type.QUESTION, getRidget().getType());

    getRidget().setType(null);
    // show message box to transfer values set
    getRidget().show();

    assertEquals(MessageDialog.NONE, getWidget().type);
    assertEquals(IMessageBoxRidget.Type.PLAIN, getRidget().getType());
}

From source file:org.eclipse.swtbot.mockdialogs.factory.NativeDialogFactory.java

License:Open Source License

/**
 * Show message box.//w  w  w.java2s  .c o  m
 * 
 * In default mode, a native MessageBox is used.
 * In testing mode, we use a MessageDialog, showing the same title and message.
 *      
 * @param messageText the text of the message
 * @param title the title
 * @param iconStyle the icon style
 * @param shell the parent shell
 */
public static void showMessageBox(Shell shell, String messageText, final String title, final int iconStyle) {
    if (shell == null) {
        //         logger
        //               .fatal("Shell not yet instantiated, cannot display error message");
        System.err.println("Shell not yet instantiated, cannot display error message");
    } else {
        switch (getMode()) {
        case DEFAULT: {
            MessageBox messageBox = new MessageBox(shell, iconStyle);
            messageBox.setMessage(messageText);

            messageBox.setText(title);

            messageBox.open();
            break;
        }
        case TESTING: {
            // ignore the iconStyle, this only creates trouble when testing.
            MessageDialog messagDialog = new MessageDialog(shell, title, null, messageText, MessageDialog.NONE,
                    new String[] { "OK" }, 0);
            messagDialog.open();
            break;
        }
        default:
            final String msg = "Reached default case in NativeDialogFactory, this is a bug, unknown state "
                    + getMode();
            //            logger.warn(msg);
            System.err.println(msg);
            throw new RuntimeException(msg);
        }
    }
}

From source file:org.eclipse.team.svn.ui.dialog.DefaultDialog.java

License:Open Source License

public DefaultDialog(Shell parentShell, IDialogPanel panel) {
    super(parentShell, panel.getDialogTitle(), null, null, MessageDialog.NONE, panel.getButtonNames(), 0);
    this.setShellStyle(this.getShellStyle() | SWT.RESIZE);
    this.panel = panel;
    this.levelOkImage = this.findImage("icons/common/level_ok.gif"); //$NON-NLS-1$
    this.levelWarningImage = this.findImage("icons/common/level_warning.gif"); //$NON-NLS-1$
    this.levelErrorImage = this.findImage("icons/common/level_error.gif"); //$NON-NLS-1$
}

From source file:org.eclipse.titan.common.actions.MergeLog.java

License:Open Source License

private void askUserToCreateOrOverwrite(final IPreferenceStore prefStore, final IFile originalFile) {
    final String[] buttonLabels = new String[] { "Create a new file", "Overwrite" };

    final MessageDialogWithToggle msgDialog = new MessageDialogWithToggle(null, "File already exists", null,
            "An error occured during log file merging. The file '" + outputFile.getName() + "' already exists. "
                    + "Do you want to keep the original file and choose another location/name for the new one?",
            MessageDialog.NONE, buttonLabels, SWT.DEFAULT, "Don't ask again", false);

    msgDialog.setBlockOnOpen(true);/*from  ww w . ja v  a  2  s .c o m*/

    final int result = msgDialog.open() - 256;

    if (result == SWT.DEFAULT) {
        // The dialog was closed
        setOutputFile(null);
        return;
    }

    // lets save the chosen option to the preference store if the user checked the 'Dont ask' checkbox
    final boolean dontAskChecked = msgDialog.getToggleState();
    if (dontAskChecked) {
        if (result == 0) {
            // create a new file pressed
            prefStore.setValue(PreferenceConstants.LOG_MERGE_OPTIONS,
                    PreferenceConstants.LOG_MERGE_OPTIONS_CREATE);
        } else if (result == 1) {
            // overwrite
            prefStore.setValue(PreferenceConstants.LOG_MERGE_OPTIONS,
                    PreferenceConstants.LOG_MERGE_OPTIONS_OVERWRITE);
        }
    } else {
        prefStore.setValue(PreferenceConstants.LOG_MERGE_OPTIONS, PreferenceConstants.LOG_MERGE_OPTIONS_ASK);
    }

    if (result == 0) {
        // create a new file pressed
        if (dontAskChecked) {
            setOutputFile(createNewFileWithUniqueName(originalFile));
            return;
        }
        displayOutputSelectionDialog();
    } else {
        // overwrite
        FileUtils.deleteQuietly(outputFile);
    }
}

From source file:org.eclipse.ui.dialogs.WizardDataTransferPage.java

License:Open Source License

/**
 * Displays a Yes/No question to the user with the specified message and returns
 * the user's response./*from   w  w w.j ava  2s  .com*/
 *
 * @param message the question to ask
 * @return <code>true</code> for Yes, and <code>false</code> for No
 */
protected boolean queryYesNoQuestion(String message) {
    MessageDialog dialog = new MessageDialog(getContainer().getShell(), IDEWorkbenchMessages.Question,
            (Image) null, message, MessageDialog.NONE,
            new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL }, 0) {
        protected int getShellStyle() {
            return super.getShellStyle() | SWT.SHEET;
        }
    };
    // ensure yes is the default

    return dialog.open() == 0;
}

From source file:org.eclipse.ui.externaltools.internal.ui.FileSelectionDialog.java

License:Open Source License

/**
 * Creates a resource selection dialog rooted at the given element.
 * //  w w  w.  j a va  2 s .  c  o  m
 * @param parentShell
 *            the parent shell
 * @param rootElement
 *            the root element to populate this dialog with
 * @param message
 *            the message to be displayed at the top of this dialog, or
 *            <code>null</code> to display a default message
 */
public FileSelectionDialog(Shell parentShell, IAdaptable rootElement, String message) {
    super(parentShell, ExternalToolsUIMessages.FileSelectionDialog_Choose_Location_1, null, message,
            MessageDialog.NONE, new String[] { ExternalToolsUIMessages.FileSelectionDialog_Ok_2,
                    ExternalToolsUIMessages.FileSelectionDialog_Cancel_3 },
            0);
    root = rootElement;
    setShellStyle(getShellStyle() | SWT.RESIZE);
}

From source file:org.eclipse.ui.internal.cheatsheets.handlers.OpenMessageDialogHandler.java

License:Open Source License

public Object execute(ExecutionEvent event) throws ExecutionException {

    String title = event.getParameter(PARAM_ID_TITLE);
    String message = event.getParameter(PARAM_ID_MESSAGE);

    int imageType = MessageDialog.NONE;
    if (event.getParameter(PARAM_ID_IMAGE_TYPE) != null) {
        Integer imageTypeInteger = (Integer) event.getObjectParameterForExecution(PARAM_ID_IMAGE_TYPE);
        imageType = imageTypeInteger.intValue();
    }//from w w w . j  av  a2 s  .  c  om

    int defaultValue = 0;
    if (event.getParameter(PARAM_ID_DEFAULT_INDEX) != null) {
        Integer defaultValueInteger = (Integer) event.getObjectParameterForExecution(PARAM_ID_DEFAULT_INDEX);
        defaultValue = defaultValueInteger.intValue();
    }

    String[] buttonLabels = collectButtonLabels(event);

    IWorkbenchWindow activeWindow = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
    Shell shell = (activeWindow != null) ? activeWindow.getShell() : null;

    MessageDialog dialog = new MessageDialog(shell, title, null, message, imageType, buttonLabels,
            defaultValue);
    int returnCode = dialog.open();

    if (returnCode == CANCEL_RETURN_CODE) {
        String cancelReturns = event.getParameter(PARAM_ID_CANCEL_RETURNS);
        if (cancelReturns != null)
            return cancelReturns;
        else
            throw new ExecutionException("dialog canceled"); //$NON-NLS-1$
    }

    return buttonLabels[returnCode];
}

From source file:org.eclipse.ui.internal.wizards.preferences.WizardPreferencesPage.java

License:Open Source License

/**
 * Displays a Yes/No question to the user with the specified message and
 * returns the user's response.//w  w  w. j  a va  2  s  .co m
 * 
 * @param message
 *            the question to ask
 * @return <code>true</code> for Yes, and <code>false</code> for No
 */
protected boolean queryYesNoQuestion(String message) {
    MessageDialog dialog = new MessageDialog(getContainer().getShell(), PreferencesMessages.Question,
            (Image) null, message, MessageDialog.NONE,
            new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL }, 0) {
        protected int getShellStyle() {
            return super.getShellStyle() | SWT.SHEET;
        }
    };
    // ensure yes is the default

    return dialog.open() == 0;
}

From source file:org.eclipselabs.spray.runtime.graphiti.containers.SampleUtil.java

License:Open Source License

public static boolean confirmDialog(String dialogTitle, String dialogMessage) {
    Shell shell = getShell();//from w  w w.  j av  a  2 s  .c o  m
    MessageDialog dialog = new MessageDialog(shell, dialogTitle, (Image) null, dialogMessage,
            MessageDialog.NONE, new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL }, 0) {
        protected int getShellStyle() {
            return super.getShellStyle() | SWT.SHEET;
        }
    };
    // ensure yes is the default

    return dialog.open() == 0;
}