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

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

Introduction

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

Prototype

int ERROR

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

Click Source Link

Document

Constant for an error message (value 3).

Usage

From source file:org.eclipse.m2m.internal.qvt.oml.ui.wizards.project.Util.java

License:Open Source License

public static int getIMessageProviderSeverity(IStatus status) {
    int type = IMessageProvider.NONE;
    switch (status.getSeverity()) {
    case IStatus.INFO:
        type = IMessageProvider.INFORMATION;
        break;//from   w  ww.  j  ava 2  s. c o  m
    case IStatus.WARNING:
        type = IMessageProvider.WARNING;
        break;
    case IStatus.ERROR:
        type = IMessageProvider.ERROR;
        break;
    }

    return type;
}

From source file:org.eclipse.mat.ui.internal.acquire.ProviderArgumentsWizardPage.java

License:Open Source License

public void onFocus(String message) {
    if (getErrorMessage() != null)
        setMessage(getErrorMessage(), IMessageProvider.ERROR);
    else if (message != null)
        setMessage(message, IMessageProvider.INFORMATION);
    else//from   ww  w  .ja v a 2  s.c om
        setMessage(table.getProviderDescriptor().getName());
    getContainer().updateButtons();
}

From source file:org.eclipse.mat.ui.internal.acquire.ProviderConfigurationWizardPage.java

License:Open Source License

public void onFocus(String message) {
    if (getErrorMessage() != null)
        setMessage(getErrorMessage(), IMessageProvider.ERROR);
    else if (message != null)
        setMessage(message, IMessageProvider.INFORMATION);
    else/*from w w w  .j  av  a 2  s  .  c o m*/
        setMessage(table.getProviderDescriptor().getName());
    // Causes recursion from getNextPage();
    //getContainer().updateButtons();
}

From source file:org.eclipse.mat.ui.internal.query.arguments.ArgumentsWizardPage.java

License:Open Source License

public void onFocus(String message) {
    if (getErrorMessage() != null)
        setMessage(getErrorMessage(), IMessageProvider.ERROR);
    else if (message != null)
        setMessage(message, IMessageProvider.INFORMATION);
    else/*w  w  w.  j a v a 2s .  c om*/
        setMessage(argumentSet.getQueryDescriptor().getShortDescription());
    if (getContainer() != null)
        getContainer().updateButtons();
}

From source file:org.eclipse.mylyn.commons.repositories.ui.RepositoryLocationPart.java

License:Open Source License

protected void applyValidatorResult(RepositoryValidator validator) {
    IStatus status = validator.getResult();
    String message = status.getMessage();
    if (message == null || message.length() == 0) {
        message = null;/*w  w  w .j  a  va2s  .  c o m*/
    }
    switch (status.getSeverity()) {
    case IStatus.OK:
        if (status == Status.OK_STATUS) {
            //            if (getUserName().length() > 0) {
            //               message = "Credentials are valid.";
            //            } else {
            message = Messages.RepositoryLocationPart_Repository_is_valid;
            //            }
        }
        getPartContainer().setMessage(message, IMessageProvider.INFORMATION);
        break;
    case IStatus.INFO:
        getPartContainer().setMessage(message, IMessageProvider.INFORMATION);
        break;
    case IStatus.WARNING:
        getPartContainer().setMessage(message, IMessageProvider.WARNING);
        break;
    default:
        getPartContainer().setMessage(message, IMessageProvider.ERROR);
        break;
    }
}

From source file:org.eclipse.mylyn.commons.ui.CommonUiUtil.java

License:Open Source License

public static void setMessage(DialogPage page, IStatus status) {
    String message = status.getMessage();
    switch (status.getSeverity()) {
    case IStatus.OK:
        page.setMessage(null, IMessageProvider.NONE);
        break;/*from w w  w .j  a  v a2s  . c  o  m*/
    case IStatus.INFO:
        page.setMessage(message, IMessageProvider.INFORMATION);
        break;
    case IStatus.WARNING:
        page.setMessage(message, IMessageProvider.WARNING);
        break;
    default:
        page.setMessage(message, IMessageProvider.ERROR);
        break;
    }
}

From source file:org.eclipse.mylyn.internal.bugzilla.ui.action.BugzillaUpdateAttachmentAction.java

License:Open Source License

@SuppressWarnings("unchecked")
public void run(IAction action) {
    IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
    IWorkbenchPage page = window.getActivePage();
    IEditorPart activeEditor = page.getActiveEditor();
    if (activeEditor instanceof TaskEditor) {
        final TaskEditor taskEditor = (TaskEditor) activeEditor;
        IStructuredSelection selection = null;
        if (currentSelection instanceof IStructuredSelection) {
            selection = (IStructuredSelection) currentSelection;
        }/*from  ww w  .j a  v  a  2s  .  c o m*/
        if (selection == null || selection.isEmpty()) {
            return;
        }
        List<ITaskAttachment> attachment = selection.toList();
        if (attachment != null) {
            final UpdateAttachmentJob job = new UpdateAttachmentJob(attachment, taskEditor, obsolete);
            job.setUser(true);
            job.addJobChangeListener(new JobChangeAdapter() {

                @Override
                public void done(IJobChangeEvent event) {
                    if (job.getError() != null) {
                        IFormPage formPage = taskEditor.getActivePageInstance();
                        if (formPage instanceof BugzillaTaskEditorPage) {
                            final BugzillaTaskEditorPage bugzillaPage = (BugzillaTaskEditorPage) formPage;
                            PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable() {
                                public void run() {
                                    bugzillaPage.getTaskEditor().setMessage(job.getError().getMessage(),
                                            IMessageProvider.ERROR);
                                }
                            });
                        }
                    }
                }
            });
            job.schedule();
        }
    }
}

From source file:org.eclipse.mylyn.internal.bugzilla.ui.editor.BugzillaTaskEditorPage.java

License:Open Source License

@Override
public void doSubmit() {
    TaskAttribute summaryAttribute = getModel().getTaskData().getRoot()
            .getMappedAttribute(TaskAttribute.SUMMARY);
    if (summaryAttribute != null && summaryAttribute.getValue().length() == 0) {
        getTaskEditor().setMessage(/*from  w w  w  .j  a va2 s  . c o m*/
                Messages.BugzillaTaskEditorPage_Please_enter_a_short_summary_before_submitting,
                IMessageProvider.ERROR);
        AbstractTaskEditorPart part = getPart(ID_PART_SUMMARY);
        if (part != null) {
            part.setFocus();
        }
        return;
    }

    TaskAttribute componentAttribute = getModel().getTaskData().getRoot()
            .getMappedAttribute(BugzillaAttribute.COMPONENT.getKey());
    if (componentAttribute != null && componentAttribute.getValue().length() == 0) {
        getTaskEditor().setMessage(Messages.BugzillaTaskEditorPage_Please_select_a_component_before_submitting,
                IMessageProvider.ERROR);
        AbstractTaskEditorPart part = getPart(ID_PART_ATTRIBUTES);
        if (part != null) {
            part.setFocus();
        }
        return;
    }

    TaskAttribute descriptionAttribute = getModel().getTaskData().getRoot()
            .getMappedAttribute(TaskAttribute.DESCRIPTION);
    if (descriptionAttribute != null && descriptionAttribute.getValue().length() == 0
            && getModel().getTaskData().isNew()) {
        getTaskEditor().setMessage(Messages.BugzillaTaskEditorPage_Please_enter_a_description_before_submitting,
                IMessageProvider.ERROR);
        AbstractTaskEditorPart descriptionPart = getPart(ID_PART_DESCRIPTION);
        if (descriptionPart != null) {
            descriptionPart.setFocus();
        }
        return;
    }
    TaskAttribute targetMilestoneAttribute = getModel().getTaskData().getRoot()
            .getMappedAttribute(BugzillaAttribute.TARGET_MILESTONE.getKey());
    if (targetMilestoneAttribute != null && targetMilestoneAttribute.getValue().length() == 0
            && getModel().getTaskData().isNew()) {
        getTaskEditor().setMessage(
                Messages.BugzillaTaskEditorPage_Please_enter_a_target_milestone_before_submitting,
                IMessageProvider.ERROR);
        AbstractTaskEditorPart descriptionPart = getPart(ID_PART_ATTRIBUTES);
        if (descriptionPart != null) {
            descriptionPart.setFocus();
        }
        return;
    }

    TaskAttribute attributeOperation = getModel().getTaskData().getRoot()
            .getMappedAttribute(TaskAttribute.OPERATION);
    if (attributeOperation != null) {
        if ("duplicate".equals(attributeOperation.getValue())) { //$NON-NLS-1$
            TaskAttribute originalOperation = getModel().getTaskData().getRoot()
                    .getAttribute(TaskAttribute.PREFIX_OPERATION + attributeOperation.getValue());
            String inputAttributeId = originalOperation.getMetaData()
                    .getValue(TaskAttribute.META_ASSOCIATED_ATTRIBUTE_ID);
            if (inputAttributeId != null && !inputAttributeId.equals("")) { //$NON-NLS-1$
                TaskAttribute inputAttribute = attributeOperation.getTaskData().getRoot()
                        .getAttribute(inputAttributeId);
                if (inputAttribute != null) {
                    String dupValue = inputAttribute.getValue();
                    if (dupValue == null || dupValue.equals("")) { //$NON-NLS-1$
                        getTaskEditor().setMessage(
                                Messages.BugzillaTaskEditorPage_Please_enter_a_bugid_for_duplicate_of_before_submitting,
                                IMessageProvider.ERROR);
                        AbstractTaskEditorPart part = getPart(ID_PART_ACTIONS);
                        if (part != null) {
                            part.setFocus();
                        }
                        return;
                    }
                }
            }
        }
    }

    if (getModel().getTaskData().isNew()) {
        TaskAttribute productAttribute = getModel().getTaskData().getRoot()
                .getMappedAttribute(TaskAttribute.PRODUCT);
        if (productAttribute != null && productAttribute.getValue().length() > 0) {
            getModel().getTaskRepository().setProperty(IBugzillaConstants.LAST_PRODUCT_SELECTION,
                    productAttribute.getValue());
        }
        TaskAttribute componentSelectedAttribute = getModel().getTaskData().getRoot()
                .getMappedAttribute(TaskAttribute.COMPONENT);
        if (componentSelectedAttribute != null && componentSelectedAttribute.getValue().length() > 0) {
            getModel().getTaskRepository().setProperty(IBugzillaConstants.LAST_COMPONENT_SELECTION,
                    componentSelectedAttribute.getValue());
        }
    }

    // Force the most recent known good token onto the outgoing task data to ensure submit
    // bug#263318
    TaskAttribute attrToken = getModel().getTaskData().getRoot().getAttribute(BugzillaAttribute.TOKEN.getKey());
    if (attrToken != null) {
        String tokenString = getModel().getTask().getAttribute(BugzillaAttribute.TOKEN.getKey());
        if (tokenString != null) {
            attrToken.setValue(tokenString);
        }
    }
    for (ControlDecoration decoration : errorDecorations) {
        decoration.hide();
        decoration.dispose();
    }
    errorDecorations.clear();
    editorsWithError.clear();
    if (!checkCanSubmit(IMessageProvider.ERROR)) {
        return;
    }
    getTaskEditor().setMessage("", IMessageProvider.NONE); //$NON-NLS-1$
    super.doSubmit();
}

From source file:org.eclipse.mylyn.internal.bugzilla.ui.editor.BugzillaTaskEditorPage.java

License:Open Source License

/**
 * @param bugzillaStatus/* w  w w . j  av a 2 s .c  om*/
 * @param resultDetail
 * @param oneError
 * @param fieldString
 */
private void updateTaskEditorPageMessageWithError(BugzillaStatus bugzillaStatus, String resultDetail,
        boolean oneError, String fieldString) {
    String resultString;
    final String titleString;
    switch (bugzillaStatus.getCode()) {
    case BugzillaStatus.ERROR_CONFIRM_MATCH:
        if (oneError) {
            resultString = MessageFormat.format(Messages.BugzillaTaskEditorPage_Message_one,
                    Messages.BugzillaTaskEditorPage_Confirm, fieldString);
        } else {
            resultString = MessageFormat.format(Messages.BugzillaTaskEditorPage_Message_more,
                    Messages.BugzillaTaskEditorPage_Confirm, fieldString);
        }
        titleString = Messages.BugzillaTaskEditorPage_ConfirmDetailTitle;
        break;
    case BugzillaStatus.ERROR_MATCH_FAILED:
        if (oneError) {
            resultString = MessageFormat.format(Messages.BugzillaTaskEditorPage_Message_one,
                    Messages.BugzillaTaskEditorPage_Error, fieldString);
        } else {
            resultString = MessageFormat.format(Messages.BugzillaTaskEditorPage_Message_more,
                    Messages.BugzillaTaskEditorPage_Error, fieldString);
        }
        titleString = Messages.BugzillaTaskEditorPage_ErrorDetailTitle;
        break;
    default:
        throw new RuntimeException("unexpected BugzillaStatus: " + bugzillaStatus.getCode()); //$NON-NLS-1$
    }

    final String resultDetailString = resultDetail;
    getTaskEditor().setMessage(resultString, IMessageProvider.ERROR, new HyperlinkAdapter() {
        @Override
        public void linkActivated(HyperlinkEvent event) {
            BugzillaResponseDetailDialog dialog = new BugzillaResponseDetailDialog(WorkbenchUtil.getShell(),
                    titleString, resultDetailString);
            dialog.open();
        }
    });
}

From source file:org.eclipse.mylyn.internal.bugzilla.ui.search.BugzillaSearchPage.java

License:Open Source License

@Override
public boolean isPageComplete() {
    setMessage(""); //$NON-NLS-1$
    if (errorDecorations.size() > 0) {
        for (ControlDecoration decoration : errorDecorations) {
            decoration.hide();//from   w w w.j a  va2s.  c o m
            decoration.dispose();
        }
        errorDecorations.clear();
    }
    if (daysText != null) {
        String days = daysText.getText();
        if (days.length() > 0) {
            try {
                if (Integer.parseInt(days) < 0) {
                    throw new NumberFormatException();
                }
            } catch (NumberFormatException ex) {
                if (getContainer() != null) {
                    setMessage(NLS.bind(Messages.BugzillaSearchPage_Number_of_days_must_be_a_positive_integer,
                            days), IMessageProvider.ERROR);
                } else {
                    ErrorDialog.openError(getShell(), Messages.BugzillaSearchPage_ValidationTitle,
                            Messages.BugzillaSearchPage_Number_of_days_is_invalid,
                            new Status(IStatus.ERROR, BugzillaUiPlugin.ID_PLUGIN, NLS.bind(
                                    Messages.BugzillaSearchPage_days_must_be_an_positve_integer_value_but_is,
                                    days)));

                }
                return false;
            }
        }
    }
    if (emailPattern != null) {
        String email = emailPattern.getText();
        if (email.length() > 0) {
            boolean selectionMade = false;
            for (Button button : emailButtons) {
                if (button.getSelection()) {
                    selectionMade = true;
                    break;
                }
            }
            if (!selectionMade) {
                FieldDecorationRegistry registry = FieldDecorationRegistry.getDefault();
                FieldDecoration fieldDecoration = registry
                        .getFieldDecoration(FieldDecorationRegistry.DEC_ERROR);
                final ControlDecoration decoration = new ControlDecoration(emailPattern, SWT.LEFT | SWT.DOWN);
                decoration.setImage(fieldDecoration.getImage());
                decoration.setDescriptionText(NLS.bind(Messages.BugzillaSearchPage_ValidationMessage,
                        new String[] { Messages.BugzillaSearchPage_Email.replace('&', ' '),
                                Messages.BugzillaSearchPage_owner, Messages.BugzillaSearchPage_reporter,
                                Messages.BugzillaSearchPage_cc, Messages.BugzillaSearchPage_commenter,
                                Messages.BugzillaSearchPage_qacontact }));
                errorDecorations.add(decoration);
                if (getContainer() != null) {
                    setMessage(NLS.bind(Messages.BugzillaSearchPage_ValidationMessage,
                            new String[] { Messages.BugzillaSearchPage_Email.replace('&', ' '),
                                    Messages.BugzillaSearchPage_owner, Messages.BugzillaSearchPage_reporter,
                                    Messages.BugzillaSearchPage_cc, Messages.BugzillaSearchPage_commenter,
                                    Messages.BugzillaSearchPage_qacontact }),
                            IMessageProvider.ERROR);
                }
                return false;
            }
        }
    }
    if (emailPattern2 != null) {
        String email2 = emailPattern2.getText();
        if (email2.length() > 0) {
            boolean selectionMade = false;
            for (Button button : emailButtons2) {
                if (button.getSelection()) {
                    selectionMade = true;
                    break;
                }
            }
            if (!selectionMade) {
                FieldDecorationRegistry registry = FieldDecorationRegistry.getDefault();
                FieldDecoration fieldDecoration = registry
                        .getFieldDecoration(FieldDecorationRegistry.DEC_ERROR);
                final ControlDecoration decoration = new ControlDecoration(emailPattern, SWT.LEFT | SWT.DOWN);
                decoration.setImage(fieldDecoration.getImage());
                decoration.setDescriptionText(NLS.bind(Messages.BugzillaSearchPage_ValidationMessage,
                        new String[] { Messages.BugzillaSearchPage_Email_2.replace('&', ' '),
                                Messages.BugzillaSearchPage_owner, Messages.BugzillaSearchPage_reporter,
                                Messages.BugzillaSearchPage_cc, Messages.BugzillaSearchPage_commenter,
                                Messages.BugzillaSearchPage_qacontact }));
                errorDecorations.add(decoration);
                if (getContainer() != null) {
                    setMessage(NLS.bind(Messages.BugzillaSearchPage_ValidationMessage,
                            new String[] { Messages.BugzillaSearchPage_Email_2.replace('&', ' '),
                                    Messages.BugzillaSearchPage_owner, Messages.BugzillaSearchPage_reporter,
                                    Messages.BugzillaSearchPage_cc, Messages.BugzillaSearchPage_commenter,
                                    Messages.BugzillaSearchPage_qacontact }),
                            IMessageProvider.ERROR);
                }
                return false;
            }
        }
    }
    if (getWizard() == null) {
        return canQuery();
    } else {
        if (super.isPageComplete()) {
            if (canQuery()) {
                return true;
            }
        }
        return false;
    }
}