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:de.quamoco.adaptation.util.swt.SWTUtil.java

License:Apache License

/**
 * Create and opens simple error dialog with an OK button.
 * @param shell the shell of the dialog//from   w  ww .ja v a2 s  . c om
 * @param title the title of the dialog
 * @param message the message of the dialog
 * @param exeception the exception that was thrown (optional)
 */
public static void showErrorDialog(Shell shell, String title, String message, Exception exception) {
    String[] buttons = { IDialogConstants.OK_LABEL };
    if (exception != null) {
        message = message + "\n\nException: " + exception.getClass().getSimpleName() + "\nMessage: "
                + exception.getMessage();
    }
    new MessageDialog(shell, title, null, message, MessageDialog.ERROR, buttons, 0).open();
}

From source file:de.quamoco.qm.properties.eval.util.Util.java

License:Apache License

public static void showErrorDialog(String title, String message) {
    showOkMessageDialog(title, message, MessageDialog.ERROR);
}

From source file:de.uni_jena.iaa.linktype.atomic.model.pepper.exportwizard.PepperExportWizard.java

License:Apache License

@Override
public void init(IWorkbench workbench, IStructuredSelection selection) {
    initialize();/*from  w  w  w . j a  v a  2  s .c o m*/
    if (1 == selection.size()) {
        Object element = selection.getFirstElement();
        if (element instanceof IProject) {
            selectedProject = (IProject) element;
        } else {
            new MessageDialog(this.getShell(), "Error", null, "Selection is not a project!",
                    MessageDialog.ERROR, new String[] { IDialogConstants.OK_LABEL }, 0).open();
        }
    } else {
        new MessageDialog(this.getShell(), "Error", null,
                "To run the Pepper Export Wizard select exactly one project!", MessageDialog.ERROR,
                new String[] { IDialogConstants.OK_LABEL }, 0).open();
    }
}

From source file:de.uni_jena.iaa.linktype.atomic.model.pepper.wizard.AbstractPepperWizard.java

License:Apache License

public List<P> getPepperModules() {
    if (pepperModuleList == null) {
        List<P> modules = null;
        if (pepperConverter != null) {
            PepperModuleResolver pepperModuleResolver = pepperConverter.getPepperModuleResolver();
            if (pepperModuleResolver != null) {
                modules = resolvePepperModules(pepperModuleResolver);
                if (modules != null) {
                    Collections.sort(modules, new Comparator<P>() {
                        @Override
                        public int compare(P o1, P o2) {
                            return o1.getName().compareTo(o2.getName());
                        }/* www  .  j a va 2  s .c  om*/
                    });
                } else {
                    new MessageDialog(this.getShell(), "Error", null, "Did not found any Pepper module!",
                            MessageDialog.ERROR, new String[] { IDialogConstants.OK_LABEL }, 0).open();
                }
            } else {
                new MessageDialog(this.getShell(), "Error", null, "Did not found Pepper module resolver!",
                        MessageDialog.ERROR, new String[] { IDialogConstants.OK_LABEL }, 0).open();
            }
        }

        pepperModuleList = modules != null ? modules : Collections.<P>emptyList();
    }

    return pepperModuleList;
}

From source file:descent.internal.ui.text.java.CompletionProposalComputerRegistry.java

License:Open Source License

/**
 * Log the status and inform the user about a misbehaving extension.
 * //  w  w w .j a v a2 s . com
 * @param descriptor the descriptor of the misbehaving extension
 * @param status a status object that will be logged
 */
void informUser(CompletionProposalComputerDescriptor descriptor, IStatus status) {
    JavaPlugin.log(status);
    String title = JavaTextMessages.CompletionProposalComputerRegistry_error_dialog_title;
    CompletionProposalCategory category = descriptor.getCategory();
    IContributor culprit = descriptor.getContributor();
    Set affectedPlugins = getAffectedContributors(category, culprit);

    final String avoidHint;
    final String culpritName = culprit == null ? null : culprit.getName();
    if (affectedPlugins.isEmpty())
        avoidHint = Messages.format(JavaTextMessages.CompletionProposalComputerRegistry_messageAvoidanceHint,
                new Object[] { culpritName, category.getDisplayName() });
    else
        avoidHint = Messages.format(
                JavaTextMessages.CompletionProposalComputerRegistry_messageAvoidanceHintWithWarning,
                new Object[] { culpritName, category.getDisplayName(), toString(affectedPlugins) });

    String message = status.getMessage();
    // inlined from MessageDialog.openError
    MessageDialog dialog = new MessageDialog(JavaPlugin.getActiveWorkbenchShell(), title,
            null /* default image */, message, MessageDialog.ERROR, new String[] { IDialogConstants.OK_LABEL },
            0) {
        protected Control createCustomArea(Composite parent) {
            Link link = new Link(parent, SWT.NONE);
            link.setText(avoidHint);
            link.addSelectionListener(new SelectionAdapter() {
                public void widgetSelected(SelectionEvent e) {
                    PreferencesUtil.createPreferenceDialogOn(getShell(),
                            "descent.ui.preferences.CodeAssistPreferenceAdvanced", null, null).open(); //$NON-NLS-1$
                }
            });
            GridData gridData = new GridData(SWT.FILL, SWT.BEGINNING, true, false);
            gridData.widthHint = this.getMinimumMessageWidth();
            link.setLayoutData(gridData);
            return link;
        }
    };
    dialog.open();
}

From source file:edu.toronto.cs.se.modelepedia.petrinet.operator.PetriNetSimulate.java

License:Open Source License

@Override
public EList<Model> execute(EList<Model> actualParameters) throws Exception {

    // simulate/*w ww  .ja  v  a 2  s . com*/
    PetriNet petrinet = (PetriNet) actualParameters.get(0).getEMFInstanceRoot();
    boolean goodResult = !petrinet.getNodes().isEmpty();

    // show result
    Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();
    int dialogType = (goodResult) ? MessageDialog.INFORMATION : MessageDialog.ERROR;
    String dialogMessage = (goodResult) ? "Good simulation result" : "Bad simulation result";
    MessageDialog dialog = new MessageDialog(shell, "Simulation results", null, dialogMessage, dialogType,
            new String[] { "Ok" }, 0);
    dialog.open();

    return null;
}

From source file:era.foss.typeeditor.TypeDialog.java

License:Open Source License

/**
 * Ok pressed.//w w  w  .j ava2  s. c  om
 * 
 * @see org.eclipse.jface.dialogs.Dialog#okPressed()
 * @since 03.03.2010
 */
protected void okPressed() {
    // validate model
    BasicDiagnostic diagnostic = Diagnostician.INSTANCE.createDefaultDiagnostic(erfModel.getCoreContent());
    for (DatatypeDefinition dataType : erfModel.getCoreContent().getDataTypes()) {
        Diagnostician.INSTANCE.validate(dataType, diagnostic);
    }
    for (SpecType specType : erfModel.getCoreContent().getSpecTypes()) {
        Diagnostician.INSTANCE.validate(specType, diagnostic);
    }
    Diagnostician.INSTANCE.validate(toolExtension, diagnostic);

    if (!diagnostic.getChildren().isEmpty()) {
        MessageDialog dialog = new MessageDialog(this.getShell(),
                typeEditorActivator.getString("_UI_ValidationErrorDialog_title"), null,
                typeEditorActivator.getString("_UI_ValidationErrorDialog_text"), MessageDialog.ERROR,
                new String[] { "OK" }, 0);
        dialog.open();

        String errorMessage = "";
        for (Diagnostic diagnosticChildren : diagnostic.getChildren()) {
            errorMessage += diagnosticChildren.getMessage() + "\n";
        }
        this.setErrorMessage(errorMessage);
    } else {
        super.okPressed();
        // the performed commands should not be available for undo after OK.
        eraCommandStack.inhibitUndos();

        // redraw the SpecObject editor
        if (editor instanceof IViewerProvider) {
            Viewer viewer = ((IViewerProvider) editor).getViewer();
            if (viewer instanceof IAllowViewerSchemaChange) {
                ((IAllowViewerSchemaChange) viewer).recreateViewerSchema();
            }
        }
    }

}

From source file:eu.aniketos.securebpmn.util.DialogUtil.java

License:Apache License

/**
 * Opens a dialog window that contains an image and a message.
 *
 * @param title/*from   ww w  .j a v a2 s. co  m*/
 *            The title of the message window.
 * @param message
 *            The message to be displayed in the window.
 * @param image
 *            The image that should be displayed in the window.
 * @param buttons
 *            The labels of the Buttons the window should contain.
 * @param defaultButton
 *            The index of the Button that should be selected by default.
 * @return The index of the Button that was pressed.
 */
public static int openMessageDialog(String title, String message, int image, String[] buttons,
        int defaultButton) {
    MessageDialog dialog;
    switch (image) {
    case INFO:
        dialog = new MessageDialog(getShell(), title, null, message, MessageDialog.INFORMATION, buttons,
                defaultButton);
        break;
    case WARNING:
        dialog = new MessageDialog(getShell(), title, null, message, MessageDialog.WARNING, buttons,
                defaultButton);
        break;
    case ERROR:
        dialog = new MessageDialog(getShell(), title, null, message, MessageDialog.ERROR, buttons,
                defaultButton);
        break;
    default:
        dialog = new MessageDialog(getShell(), title, null, message, MessageDialog.NONE, buttons,
                defaultButton);
        break;
    }
    return dialog.open();
}

From source file:eu.cloudwave.wp5.feedback.eclipse.base.core.feedbackhandler.RequestExceptionHandler.java

License:Apache License

public boolean handle(final IProject project, final RequestException exception,
        final ErrorType... handledErrorTypes) {
    final ErrorType type = exception.getType();
    if (ImmutableList.copyOf(handledErrorTypes).contains(type)) {
        switch (type) {

        case FEEDBACK_HANDLER_NOT_AVAILABLE:
            new AbstractMessageDialog() {
                @Override//from   w  w  w .java2 s.  c  o  m
                public void action(final Shell shell) {
                    final PreferenceDialog preferencePage = PreferencesUtil.createPreferenceDialogOn(shell,
                            BaseIds.PREFERENCE_PAGE, null, null);
                    if (preferencePage != null) {
                        preferencePage.open();
                    }
                }
            }.display(type.getTitle(), Messages.MESSAGE__FEEDBACK_HANDLER_NOT_AVAILABLE, MessageDialog.ERROR,
                    Messages.OPEN_PREFERENCES);
            return true;

        case INVALID_APPLICATION_ID:
            openPropertyPage(project, BaseIds.PROPERTIES_PAGE__FDD_MAIN, type.getTitle(),
                    Messages.MESSAGE__INVALID_APPLICATION_ID);
            return true;

        case WRONG_ACCESS_TOKEN:
            openPropertyPage(project, BaseIds.PROPERTIES_PAGE__FDD_MAIN, type.getTitle(),
                    Messages.MESSAGE__WRONG_ACCESS_TOKEN);
            return true;

        default:
            break;
        }
    }
    Logger.print(exception.getMessage());
    return false;
}

From source file:eu.cloudwave.wp5.feedback.eclipse.base.core.feedbackhandler.RequestExceptionHandler.java

License:Apache License

private void openPropertyPage(final IProject project, final String propertyPageId, final String title,
        final String message) {
    new AbstractMessageDialog() {
        @Override//w  w w.j a  v  a 2 s.  c o m
        public void action(final Shell shell) {
            final PreferenceDialog propertyDialog = PreferencesUtil.createPropertyDialogOn(shell, project,
                    propertyPageId, null, null);
            if (propertyDialog != null) {
                propertyDialog.open();
            }
        }
    }.display(title, message, MessageDialog.ERROR, Messages.OPEN_PROPERTIES);
}