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

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

Introduction

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

Prototype

int NONE

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

Click Source Link

Document

Constant for a regular message (value 0).

Usage

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  a  2  s  . co  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.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(/*  w w w  .ja v a 2s.  co  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.tasks.ui.deprecated.AbstractRepositoryTaskEditor.java

License:Open Source License

private void previewWiki(final Browser browser, String sourceText) {
    final class PreviewWikiJob extends Job {
        private final String sourceText;

        private String htmlText;

        private IStatus jobStatus;

        public PreviewWikiJob(String sourceText) {
            super("Formatting Wiki Text");

            if (sourceText == null) {
                throw new IllegalArgumentException("source text must not be null");
            }//from  w  w w .j  a va 2s. co m

            this.sourceText = sourceText;
        }

        @Override
        protected IStatus run(IProgressMonitor monitor) {
            AbstractRenderingEngine htmlRenderingEngine = getRenderingEngine();
            if (htmlRenderingEngine == null) {
                jobStatus = new RepositoryStatus(repository, IStatus.INFO, TasksUiPlugin.ID_PLUGIN,
                        RepositoryStatus.ERROR_INTERNAL, "The repository does not support HTML preview.");
                return Status.OK_STATUS;
            }

            jobStatus = Status.OK_STATUS;
            try {
                htmlText = htmlRenderingEngine.renderAsHtml(repository, sourceText, monitor);
            } catch (CoreException e) {
                jobStatus = e.getStatus();
            }
            return Status.OK_STATUS;
        }

        public String getHtmlText() {
            return htmlText;
        }

        public IStatus getStatus() {
            return jobStatus;
        }

    }

    final PreviewWikiJob job = new PreviewWikiJob(sourceText);

    job.addJobChangeListener(new JobChangeAdapter() {

        @Override
        public void done(final IJobChangeEvent event) {
            if (!form.isDisposed()) {
                if (job.getStatus().isOK()) {
                    getPartControl().getDisplay().asyncExec(new Runnable() {
                        public void run() {
                            AbstractRepositoryTaskEditor.this.setText(browser, job.getHtmlText());
                            parentEditor.setMessage(null, IMessageProvider.NONE);
                        }
                    });
                } else {
                    getPartControl().getDisplay().asyncExec(new Runnable() {
                        public void run() {
                            parentEditor.setMessage(job.getStatus().getMessage(), IMessageProvider.ERROR);
                        }
                    });
                }
            }
            super.done(event);
        }
    });

    job.setUser(true);
    job.schedule();
}

From source file:org.eclipse.mylyn.tasks.ui.wizards.AbstractRepositorySettingsPage.java

License:Open Source License

@Override
public boolean isPageComplete() {
    String errorMessage = null;/*w  w w. j a  v  a2s  .  co m*/
    String url = getRepositoryUrl();
    // check for errors
    errorMessage = isUniqueUrl(url);
    if (errorMessage == null) {
        for (TaskRepository repository : TasksUi.getRepositoryManager().getAllRepositories()) {
            if (!repository.equals(getRepository())
                    && getRepositoryLabel().equals(repository.getRepositoryLabel())) {
                errorMessage = Messages.AbstractRepositorySettingsPage_A_repository_with_this_name_already_exists;
                break;
            }
        }
    }
    if (errorMessage == null) {
        // check for messages
        if (!isValidUrl(url)) {
            errorMessage = Messages.AbstractRepositorySettingsPage_Enter_a_valid_server_url;
        }
        if (errorMessage == null && needsRepositoryCredentials()
                && (!needsAnonymousLogin() || !anonymousButton.getSelection()) && isMissingCredentials()) {
            errorMessage = Messages.AbstractRepositorySettingsPage_Enter_a_user_id_Message0;
        }
        setMessage(errorMessage, repository == null ? IMessageProvider.NONE : IMessageProvider.ERROR);
    } else {
        setMessage(errorMessage, IMessageProvider.ERROR);
    }
    return errorMessage == null && super.isPageComplete();
}

From source file:org.eclipse.oomph.setup.internal.installer.AbstractPreferenceDialog.java

License:Open Source License

public void updateMessage() {
    String message = null;//from   ww w  .ja v a 2  s  .  co  m
    String errorMessage = null;
    if (preferencePage != null) {
        message = preferencePage.getMessage();
        errorMessage = preferencePage.getErrorMessage();
    }

    int messageType = IMessageProvider.NONE;
    if (message != null) {
        messageType = ((IMessageProvider) preferencePage).getMessageType();
    }

    if (errorMessage == null) {
        if (showingError) {
            // We were previously showing an error
            showingError = false;
        }
    } else {
        message = errorMessage;
        messageType = IMessageProvider.ERROR;
        if (!showingError) {
            // We were not previously showing an error
            showingError = true;
        }
    }

    if (message == null) {
        message = getDefaultMessage();
    }

    setMessage(message, messageType);
}

From source file:org.eclipse.osee.framework.ui.skynet.Import.ArtifactImportPage.java

License:Open Source License

protected boolean executeOperation(final IOperation operation) {
    final IStatus[] status = new IStatus[1];
    try {//from  w w w . ja  va  2s  . c o m
        getContainer().run(true, true, new IRunnableWithProgress() {

            @Override
            public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
                try {
                    status[0] = Operations.executeWorkAndCheckStatus(operation, monitor);
                } catch (OseeCoreException ex) {
                    if (monitor.isCanceled()) {
                        throw new InterruptedException();
                    } else {
                        throw new InvocationTargetException(ex);
                    }
                }
            }
        });
    } catch (InterruptedException e) {
        return false;
    } catch (InvocationTargetException e) {
        displayErrorDialog(e.getTargetException());
        return false;
    }

    //grab the error here and
    if (operationReportMessages.length() != 0) {
        setMessage(operationReportMessages.toString(), IMessageProvider.WARNING);
    } else {
        setMessage("", IMessageProvider.NONE);
    }

    if (status[0].isOK()) {
        setErrorMessage(null);
    } else {
        setErrorMessage(status[0].getMessage());
    }
    return true;
}

From source file:org.eclipse.osee.framework.ui.skynet.widgets.XWidgetValidateUtility.java

License:Open Source License

public static int toMessageProviderLevel(int level) {
    int toReturn = IMessageProvider.NONE;
    if (level == IStatus.INFO) {
        toReturn = IMessageProvider.INFORMATION;
    } else if (level == IStatus.WARNING) {
        toReturn = IMessageProvider.WARNING;
    } else if (level == IStatus.ERROR) {
        toReturn = IMessageProvider.ERROR;
    }//www . j a v  a2  s  .  c om
    return toReturn;
}

From source file:org.eclipse.pde.internal.ua.ui.editor.ctxhelp.CtxHelpPage.java

License:Open Source License

public void setActive(boolean active) {
    super.setActive(active);
    if (active) {
        CtxHelpModel model = (CtxHelpModel) getModel();
        if ((model == null) || (model.isLoaded() == false)) {
            createErrorContent(getManagedForm());
        } else {//from  w  ww  .j av a  2s.c om
            // Clear the error message
            getManagedForm().getForm().setMessage("", IMessageProvider.NONE);
        }

        IFormPage page = getPDEEditor().findPage(CtxHelpInputContext.CONTEXT_ID);
        if (page instanceof CtxHelpSourcePage
                && ((CtxHelpSourcePage) page).getInputContext().isInSourceMode()) {
            ISourceViewer viewer = ((CtxHelpSourcePage) page).getViewer();
            if (viewer == null) {
                return;
            }

            StyledText text = viewer.getTextWidget();
            if (text == null) {
                return;
            }

            int offset = text.getCaretOffset();
            if (offset < 0) {
                return;
            }

            IDocumentRange range = ((CtxHelpSourcePage) page).getRangeElement(offset, true);
            if (range instanceof IDocumentAttributeNode) {
                range = ((IDocumentAttributeNode) range).getEnclosingElement();
            } else if (range instanceof IDocumentTextNode) {
                range = ((IDocumentTextNode) range).getEnclosingElement();
            }

            if (range instanceof CtxHelpObject) {
                fBlock.getMasterSection().setSelection(new StructuredSelection(range));
            }
        }
    }
}

From source file:org.eclipse.pde.internal.ua.ui.editor.toc.TocPage.java

License:Open Source License

public void setActive(boolean active) {
    super.setActive(active);
    if (active) {
        TocModel model = (TocModel) getModel();
        if ((model == null) || (model.isLoaded() == false)) {
            createErrorContent(getManagedForm());
        } else {// w ww .  ja va  2s  . c om
            // Clear the error message
            getManagedForm().getForm().setMessage("", IMessageProvider.NONE);
        }

        IFormPage page = getPDEEditor().findPage(TocInputContext.CONTEXT_ID);
        if (page instanceof TocSourcePage && ((TocSourcePage) page).getInputContext().isInSourceMode()) {
            ISourceViewer viewer = ((TocSourcePage) page).getViewer();
            if (viewer == null) {
                return;
            }

            StyledText text = viewer.getTextWidget();
            if (text == null) {
                return;
            }

            int offset = text.getCaretOffset();
            if (offset < 0) {
                return;
            }

            IDocumentRange range = ((TocSourcePage) page).getRangeElement(offset, true);
            if (range instanceof IDocumentAttributeNode) {
                range = ((IDocumentAttributeNode) range).getEnclosingElement();
            } else if (range instanceof IDocumentTextNode) {
                range = ((IDocumentTextNode) range).getEnclosingElement();
            }

            if (range instanceof TocObject) {
                fBlock.getMasterSection().setSelection(new StructuredSelection(range));
            }
        }
    }
}

From source file:org.eclipse.pde.internal.ui.editor.targetdefinition.TargetEditor.java

License:Open Source License

public void doSaveAs() {
    commitPages(true);/*from w  w  w . j a va  2 s.c  om*/
    ITargetDefinition target = getTarget();

    SaveAsDialog dialog = new SaveAsDialog(getSite().getShell());
    dialog.create();
    dialog.setMessage(PDEUIMessages.TargetEditor_0, IMessageProvider.NONE);
    if (target.getHandle() instanceof WorkspaceFileTargetHandle) {
        WorkspaceFileTargetHandle currentTargetHandle = (WorkspaceFileTargetHandle) target.getHandle();
        dialog.setOriginalFile(currentTargetHandle.getTargetFile());
    }
    dialog.open();

    IPath path = dialog.getResult();

    if (path == null) {
        return;
    }
    if (!"target".equalsIgnoreCase(path.getFileExtension())) { //$NON-NLS-1$
        path = path.addFileExtension("target"); //$NON-NLS-1$
    }

    IWorkspace workspace = ResourcesPlugin.getWorkspace();
    IFile file = workspace.getRoot().getFile(path);

    if (workspace.validateEdit(new IFile[] { file }, getSite().getShell()).isOK()) {
        try {
            WorkspaceFileTargetHandle newFileTarget = new WorkspaceFileTargetHandle(file);
            newFileTarget.save(target);
            setInput(new FileEditorInput(file));
        } catch (CoreException e) {
            PDEPlugin.log(e);
            showError(PDEUIMessages.TargetEditor_3, e);
        }
    }
}