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

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

Introduction

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

Prototype

int ERROR

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

Click Source Link

Document

Constant for the error image, or a simple dialog with the error image and a single OK button (value 1).

Usage

From source file:org.eclipse.rap.examples.pages.MessageDialogUtil.java

License:Open Source License

private static String[] getButtonLabels(int kind) {
    String[] dialogButtonLabels;/*from  w ww. j  a  v  a 2 s  .  co m*/
    switch (kind) {
    case MessageDialog.ERROR:
    case MessageDialog.INFORMATION:
    case MessageDialog.WARNING: {
        dialogButtonLabels = new String[] { IDialogConstants.get().OK_LABEL };
        break;
    }
    case MessageDialog.CONFIRM: {
        dialogButtonLabels = new String[] { IDialogConstants.get().OK_LABEL,
                IDialogConstants.get().CANCEL_LABEL };
        break;
    }
    case MessageDialog.QUESTION: {
        dialogButtonLabels = new String[] { IDialogConstants.get().YES_LABEL, IDialogConstants.get().NO_LABEL };
        break;
    }
    case MessageDialog.QUESTION_WITH_CANCEL: {
        dialogButtonLabels = new String[] { IDialogConstants.get().YES_LABEL, IDialogConstants.get().NO_LABEL,
                IDialogConstants.get().CANCEL_LABEL };
        break;
    }
    default: {
        throw new IllegalArgumentException("Illegal value for kind in MessageDialog.open()");
    }
    }
    return dialogButtonLabels;
}

From source file:org.eclipse.rcptt.ctx.preferences.ui.wizard.WizardPreferencesPage.java

License:Open Source License

public boolean finish(IQ7Editor<Context> contextEditor) {
    FileInputStream fis = null;/*w  ww. java 2s.c om*/

    try {
        fis = new FileInputStream(getDestinationValue());
    } catch (FileNotFoundException e) {
        Q7UIPlugin.log(e.getMessage(), e);
        MessageDialog.open(MessageDialog.ERROR, getControl().getShell(), new String(), e.getLocalizedMessage(),
                SWT.SHEET);
        return false;
    }
    IPreferencesService service = Platform.getPreferencesService();
    try {
        IExportedPreferences prefs;
        prefs = service.readPreferences(fis);
        PrefNode prefNode = PrefUtils.convertPreferences(prefs);
        PreferencesContext context = PreferencesFactory.eINSTANCE.createPreferencesContext();
        if (prefNode != null) {
            context.getContent().addAll(prefNode.getChilds());
        }

        contextEditor.copyContentFrom(context, new NullProgressMonitor());

    } catch (CoreException e) {
        Q7UIPlugin.log(e.getMessage(), e);
    } catch (BackingStoreException e) {
        Q7UIPlugin.log(e.getMessage(), e);
    } finally {
        try {
            if (fis != null) {
                fis.close();
            }
        } catch (IOException e) {
            Q7UIPlugin.log(e.getMessage(), e);
        }
    }
    return true;
}

From source file:org.eclipse.rcptt.ui.launching.aut.AUTConnectionErrorDialog.java

License:Open Source License

private AUTConnectionErrorDialog(Shell parentShell, String message, boolean showLogFile) {
    super(parentShell, DIALOG_TITLE, null, getMessage(showLogFile, message), MessageDialog.ERROR,
            getDialogButtonsLabels(showLogFile), 0);
}

From source file:org.eclipse.rcptt.ui.panels.main.ControlPanelWindow.java

License:Open Source License

private void save() {
    try {/*from   ww  w  .j  a v  a2 s  . c om*/
        ITestCase model = getModel();
        NullProgressMonitor monitor = new NullProgressMonitor();
        if (model.exists()) {
            model = (ITestCase) model.getWorkingCopy(monitor);
            copyContent(scenario, (Scenario) model.getNamedElement());
            WriteAccessChecker writeAccessChecker = new WriteAccessChecker(getShell());

            try {
                if (!writeAccessChecker.makeResourceWritable(model)) {
                    return;
                }
                model.commitWorkingCopy(true, monitor);
            } catch (CoreException e) {
                Q7UIPlugin.log(e);
            } finally {
                model.discardWorkingCopy();
            }
            contextsTable.setProject(getSavedProject());
            verificationsTable.setProject(getSavedProject());
            copyContent((Scenario) model.getNamedElement(), this.scenario);
        } else {
            MessageDialog dialog = new MessageDialog(getShell(), Messages.ControlPanelWindow_SaveDialogTitle,
                    null, "Failed to save testcase because underlying resources is not exist.",
                    MessageDialog.ERROR, new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL,
                            IDialogConstants.CANCEL_LABEL },
                    0);
            int value = dialog.open(); // Number of pressed button
            if (value == 0) {
                saveAs();
            }
        }
    } catch (ModelException e) {
        Q7UIPlugin.log(e);
    }
}

From source file:org.eclipse.recommenders.internal.rcp.BundleResolutionFailureDialog.java

License:Open Source License

public BundleResolutionFailureDialog(Shell parentShell, Version recommendersVersion,
        Collection<Bundle> unresolvedBundles) {
    super(parentShell, Messages.DIALOG_TITLE_BUNDLE_RESOLUTION_FAILURE, null,
            Messages.DIALOG_MESSAGE_BUNDLE_RESOLUTION_FAILURE, MessageDialog.ERROR,
            new String[] { IDialogConstants.CANCEL_LABEL, Messages.DIALOG_BUTTON_RESTART }, 1,
            Messages.DIALOG_TOGGLE_IGNORE_BUNDLE_RESOLUTION_FAILURES, false);
    this.recommendersVersion = recommendersVersion;
    this.unresolvedBundles = unresolvedBundles;
    setPrefStore(new ScopedPreferenceStore(InstanceScope.INSTANCE, Constants.BUNDLE_ID));
    setPrefKey(Constants.PREF_IGNORE_BUNDLE_RESOLUTION_FAILURE);
}

From source file:org.eclipse.recommenders.internal.snipmatch.rcp.BranchCheckoutFailureDialog.java

License:Open Source License

public BranchCheckoutFailureDialog(Shell parentShell, String repository, String failedVersion,
        String substituteVersion) {
    super(parentShell, Messages.DIALOG_TITLE_BRANCH_CHECKOUT_FAILURE, null,
            format(Messages.DIALOG_MESSAGE_BRANCH_CHECKOUT_FAILURE, repository, failedVersion,
                    substituteVersion),//from  w  w w . j  av  a 2  s. co  m
            MessageDialog.ERROR, new String[] { IDialogConstants.OK_LABEL }, 0);
}

From source file:org.eclipse.recommenders.internal.snipmatch.rcp.BranchCheckoutFailureDialog.java

License:Open Source License

public BranchCheckoutFailureDialog(Shell parentShell, String repository, String failedVersion) {
    super(parentShell, Messages.DIALOG_TITLE_BRANCH_CHECKOUT_FAILURE, null,
            format(Messages.DIALOG_MESSAGE_NO_FORMAT_BRANCH_FAILURE, repository, failedVersion),
            MessageDialog.ERROR, new String[] { IDialogConstants.OK_LABEL }, 0);
}

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 w w  . j av a 2s . c  o 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();/* ww  w. java  2  s  . c  o 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.team.internal.ccvs.ui.wizards.GenerateDiffFileWizard.java

License:Open Source License

public boolean validateFile(File file) {

    if (file == null)
        return false;

    /**//w  w  w . j  a  va2s .  c  o m
     * Consider file valid if it doesn't exist for now.
     */
    if (!file.exists())
        return true;

    /**
     * The file exists.
     */
    if (!file.canWrite()) {
        final String title = CVSUIMessages.GenerateCVSDiff_1;
        final String msg = CVSUIMessages.GenerateCVSDiff_2;
        final MessageDialog dialog = new MessageDialog(getShell(), title, null, msg, MessageDialog.ERROR,
                new String[] { IDialogConstants.OK_LABEL }, 0);
        dialog.open();
        return false;
    }

    final String title = CVSUIMessages.GenerateCVSDiff_overwriteTitle;
    final String msg = CVSUIMessages.GenerateCVSDiff_overwriteMsg;
    final MessageDialog dialog = new MessageDialog(getShell(), title, null, msg, MessageDialog.QUESTION,
            new String[] { IDialogConstants.YES_LABEL, IDialogConstants.CANCEL_LABEL }, 0);
    dialog.open();
    if (dialog.getReturnCode() != 0)
        return false;

    return true;
}