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.jst.ws.internal.axis.consumption.ui.preferences.AxisEmitterPreferencePage.java

License:Open Source License

private void applyToStatusLine(DialogPage page, IStatus status) {
    String message = status.getMessage();
    switch (status.getSeverity()) {
    case IStatus.OK:
        page.setMessage(null, IMessageProvider.NONE);
        page.setErrorMessage(null);/*  w ww .j  a va  2 s .  c  o  m*/
        break;
    case IStatus.WARNING:
        page.setMessage(message, IMessageProvider.WARNING);
        page.setErrorMessage(null);
        break;
    case IStatus.INFO:
        page.setMessage(message, IMessageProvider.INFORMATION);
        page.setErrorMessage(null);
        break;
    default:
        if (message.length() == 0) {
            message = null;
        }
        page.setMessage(null);
        page.setErrorMessage(message);
        break;
    }
}

From source file:org.eclipse.jubula.client.ui.rcp.widgets.autconfig.AutConfigComponent.java

License:Open Source License

/**
 * Sets no error text / image.//from  w ww  .  j  a va 2  s. c o  m
 * @param noEntries true if there are neither errors nor warnings
 */
private void setIsValid(boolean noEntries) {
    if (noEntries) {
        DialogStatusParameter param = new DialogStatusParameter();
        param.setButtonState(true);
        param.setStatusType(IMessageProvider.NONE);
        param.setMessage(Messages.ProjectWizardAUTData);
        m_paramList.clear();
        m_paramList.add(param);
    }
    DataEventDispatcher.getInstance().getDialogStatusListenerMgr().fireNotification(m_paramList);
}

From source file:org.eclipse.jubula.client.ui.rcp.wizards.pages.AUTSettingWizardPage.java

License:Open Source License

/**
 * Sets the "Next>"-button true, if all fields are filled in correctly.
 *//*w w  w.  ja v a 2 s .  c o m*/
private void checkCompleteness() {
    if (modifyAUTNameFieldAction() && modifyAutToolkitComboAction()) {

        setMessage(Messages.ProjectWizardNewAUT, IMessageProvider.NONE);
        setPageComplete(true);
        confirmNextButton();
    } else {
        setPageComplete(false);
    }
}

From source file:org.eclipse.libra.framework.editor.ui.internal.AbstractBundleEditorPage.java

License:Open Source License

/**
 * Converts an IStatus message type to Form message type. 
 *///  ww w. j  a v a  2 s.co m
private int getMessageType(IStatus status) {
    switch (status.getSeverity()) {
    case IStatus.ERROR:
        return IMessageProvider.ERROR;
    case IStatus.WARNING:
        return IMessageProvider.WARNING;
    case IStatus.INFO:
        return IMessageProvider.INFORMATION;
    default:
        return IMessageProvider.NONE;
    }
}

From source file:org.eclipse.m2e.editor.pom.DependencyTreePage.java

License:Open Source License

void loadData(final boolean force) {
    // form.setMessage() forces the panel layout, which messes up the viewers
    // (e.g. long entries in the tree cause it to expand horizontally so much
    // doesn't fit into the editor anymore). Clearing the input in the viewers
    // helps to ensure they won't change the size when the message is set.
    if (treeViewer.getTree().isDisposed()) {
        return;/*from  ww w .  j a v a 2  s .  co  m*/
    }
    treeViewer.setInput(null);
    if (listViewer.getTable().isDisposed()) {
        return;
    }
    listViewer.setInput(null);
    FormUtils.setMessage(getManagedForm().getForm(), Messages.DependencyTreePage_message_resolving,
            IMessageProvider.WARNING);

    dataLoadingJob = new Job(Messages.DependencyTreePage_job_loading) {
        protected IStatus run(IProgressMonitor monitor) {
            try {
                mavenProject = pomEditor.readMavenProject(force, monitor);
                if (mavenProject == null) {
                    log.error("Unable to read maven project. Dependencies not updated."); //$NON-NLS-1$
                    return Status.CANCEL_STATUS;
                }

                final DependencyNode dependencyNode = pomEditor.readDependencyTree(force, currentClasspath,
                        monitor);
                if (dependencyNode == null) {
                    return Status.CANCEL_STATUS;
                }
                dependencyNode.accept(new DependencyVisitor() {
                    public boolean visitEnter(DependencyNode node) {
                        if (node.getDependency() != null) {
                            dependencyNodes.add(node);
                        }
                        return true;
                    }

                    public boolean visitLeave(DependencyNode dependencynode) {
                        return true;
                    }
                });

                getPartControl().getDisplay().syncExec(new Runnable() {
                    public void run() {
                        FormUtils.setMessage(getManagedForm().getForm(), null, IMessageProvider.NONE);
                        if (treeViewer.getTree().isDisposed()) {
                            return;
                        }
                        treeViewer.setInput(dependencyNode);
                        treeViewer.expandAll();
                        if (listViewer.getTable().isDisposed()) {
                            return;
                        }
                        listViewer.setInput(mavenProject);
                    }
                });
            } catch (final CoreException ex) {
                log.error(ex.getMessage(), ex);
                getPartControl().getDisplay().asyncExec(new Runnable() {
                    public void run() {
                        FormUtils.setMessage(getManagedForm().getForm(), ex.getMessage(),
                                IMessageProvider.ERROR);
                    }
                });
            }

            return Status.OK_STATUS;
        }
    };
    dataLoadingJob.schedule();
}

From source file:org.eclipse.m2e.editor.pom.MavenPomEditor.java

License:Open Source License

/**
 * Closes all project files on project close.
 */// ww w. jav  a  2  s.c  o m
public void resourceChanged(final IResourceChangeEvent event) {
    if (pomFile == null) {
        return;
    }

    //handle project delete
    if (event.getType() == IResourceChangeEvent.PRE_CLOSE
            || event.getType() == IResourceChangeEvent.PRE_DELETE) {
        if (pomFile.getProject().equals(event.getResource())) {
            Display.getDefault().asyncExec(new Runnable() {
                public void run() {
                    close(false);
                }
            });
        }
        return;
    }
    //handle pom delete
    class RemovedResourceDeltaVisitor implements IResourceDeltaVisitor {
        boolean removed = false;

        public boolean visit(IResourceDelta delta) throws CoreException {
            if (delta.getResource() == pomFile //
                    && (delta.getKind() & (IResourceDelta.REMOVED)) != 0) {
                removed = true;
                return false;
            }
            return true;
        }
    }
    ;

    try {
        RemovedResourceDeltaVisitor visitor = new RemovedResourceDeltaVisitor();
        event.getDelta().accept(visitor);
        if (visitor.removed) {
            Display.getDefault().asyncExec(new Runnable() {
                public void run() {
                    close(true);
                }
            });
        }
    } catch (CoreException ex) {
        log.error(ex.getMessage(), ex);
    }

    // Reload model if pom file was changed externally.
    // TODO implement generic merge scenario (when file is externally changed and is dirty)

    // suppress a prompt to reload the pom if modifications were caused by workspace actions
    //XXX: mkleint: why is this called outside of the ChangedResourceDeltaVisitor?
    if (sourcePage != null) {
        sourcePage.updateModificationStamp();
    }
    class ChangedResourceDeltaVisitor implements IResourceDeltaVisitor {

        public boolean visit(IResourceDelta delta) throws CoreException {
            if (delta.getResource().equals(pomFile) && (delta.getKind() & IResourceDelta.CHANGED) != 0
                    && delta.getResource().exists()) {
                int flags = delta.getFlags();
                if ((flags & IResourceDelta.CONTENT) != 0 || (flags & IResourceDelta.REPLACED) != 0) {
                    handleContentChanged();
                    return false;
                }
                if ((flags & IResourceDelta.MARKERS) != 0) {
                    handleMarkersChanged();
                    return false;
                }
            }
            return true;
        }

        /**
         * this method never got called with the current editor changes/saves the file. the doSave() method removed/added
         * the resource listener when saving it did get called however when external editor (txt/xml) saved the file..
         * I've changed that behaviour to only avoid the reload() call when current editor saves the file. we still want
         * to attempt to reload the mavenproject instance.. please read <code>mavenProjectChanged</code> javadoc for
         * details on when this works and when not.
         */
        private void handleContentChanged() {
            reloadMavenProjectCache();
            if (!resourceChangeEventSkip) {
                Display.getDefault().asyncExec(new Runnable() {
                    public void run() {
                        /* MNGECLIPSE-1789: commented this out since forced model reload caused the XML editor to go crazy;
                                            the model is already updated at this point so reloading from file is unnecessary;
                                            externally originated file updates are checked in handleActivation() */
                        //            try {
                        //              structuredModel.reload(pomFile.getContents());
                        reload();
                        //            } catch(CoreException e) {
                        //              log.error(e.getMessage(), e);
                        //            } catch(Exception e) {
                        //              log.error("Error loading pom editor model.", e);
                        //            }
                    }
                });
            }

        }

        private void handleMarkersChanged() {
            try {
                IMarker[] markers = pomFile.findMarkers(IMavenConstants.MARKER_ID, true, IResource.DEPTH_ZERO);
                final String msg = markers != null && markers.length > 0 //
                        ? markers[0].getAttribute(IMarker.MESSAGE, "Unknown error")
                        : null;
                final int severity = markers != null && markers.length > 0
                        ? (markers[0].getAttribute(IMarker.SEVERITY,
                                IMarker.SEVERITY_ERROR) == IMarker.SEVERITY_WARNING ? IMessageProvider.WARNING
                                        : IMessageProvider.ERROR)
                        : IMessageProvider.NONE;

                Display.getDefault().asyncExec(new Runnable() {
                    public void run() {
                        for (MavenPomEditorPage page : getMavenPomEditorPages()) {
                            page.setErrorMessage(msg, msg == null ? IMessageProvider.NONE : severity);
                        }
                    }
                });
            } catch (CoreException ex) {
                log.error("Error updating pom file markers.", ex); //$NON-NLS-1$
            }
        }
    }
    ;

    try {
        ChangedResourceDeltaVisitor visitor = new ChangedResourceDeltaVisitor();
        event.getDelta().accept(visitor);
    } catch (CoreException ex) {
        log.error(ex.getMessage(), ex);
    }

}

From source file:org.eclipse.m2e.editor.pom.MavenPomEditorPage.java

License:Open Source License

private void doLoadData(boolean active) {
    try {/*from w  ww .  j av  a2  s  .com*/
        if (active && !dataLoaded) {
            dataLoaded = true;
            if (getPartControl() != null) {
                getPartControl().getDisplay().asyncExec(new Runnable() {
                    public void run() {
                        try {
                            loadData();
                            updateParentAction();
                        } catch (Throwable e) {
                            LOG.error("Error loading data", e); //$NON-NLS-1$
                        }
                    }
                });
            }

        }

        //error markers have to be always updated..
        IFile pomFile = pomEditor.getPomFile();
        if (pomFile != null) {
            String text = ""; //$NON-NLS-1$
            IMarker[] markers = pomFile.findMarkers(IMavenConstants.MARKER_ID, true, IResource.DEPTH_ZERO);
            IMarker max = null;
            int maxSev = -1;
            if (markers != null) {
                for (IMarker mark : markers) {
                    IMarker toAdd = max;
                    int sev = mark.getAttribute(IMarker.SEVERITY, -1);
                    if (sev > maxSev) {
                        max = mark;
                        maxSev = sev;
                    } else {
                        toAdd = mark;
                    }
                    if (toAdd != null) {
                        //errors get prepended while warnings get appended.
                        if (toAdd.getAttribute(IMarker.SEVERITY, -1) == IMarker.SEVERITY_ERROR) {
                            text = NLS.bind(Messages.MavenPomEditorPage_error_add,
                                    toAdd.getAttribute(IMarker.MESSAGE, "")) + text; //$NON-NLS-2$
                        } else {
                            text = text + NLS.bind(Messages.MavenPomEditorPage_warning_add,
                                    toAdd.getAttribute(IMarker.MESSAGE, "")); //$NON-NLS-2$
                        }
                    }
                }
            }
            if (max != null) {
                String head;
                String maxText = max.getAttribute(IMarker.MESSAGE, Messages.MavenPomEditorPage_error_unknown);
                if (text.length() > 0) {
                    //if we have multiple errors
                    text = NLS.bind(Messages.MavenPomEditorPage_add_desc, maxText, text);
                    if (markers != null) {
                        String number = new Integer(markers.length - 1).toString();
                        head = NLS.bind(Messages.FormUtils_click_for_details2,
                                maxText.length() > FormUtils.MAX_MSG_LENGTH
                                        ? maxText.substring(0, FormUtils.MAX_MSG_LENGTH)
                                        : maxText,
                                number);
                    } else {
                        head = maxText;
                        if (head.length() > FormUtils.MAX_MSG_LENGTH) {
                            head = NLS.bind(Messages.FormUtils_click_for_details,
                                    head.substring(0, FormUtils.MAX_MSG_LENGTH));
                        }
                    }
                } else {
                    //only this one
                    text = maxText;
                    head = maxText;
                    if (head.length() > FormUtils.MAX_MSG_LENGTH) {
                        head = NLS.bind(Messages.FormUtils_click_for_details,
                                head.substring(0, FormUtils.MAX_MSG_LENGTH));
                    }
                }
                int severity;
                switch (max.getAttribute(IMarker.SEVERITY, -1)) {
                case IMarker.SEVERITY_ERROR: {
                    severity = IMessageProvider.ERROR;
                    break;
                }
                case IMarker.SEVERITY_WARNING: {
                    severity = IMessageProvider.WARNING;
                    break;
                }
                case IMarker.SEVERITY_INFO: {
                    severity = IMessageProvider.INFORMATION;
                    break;
                }
                default: {
                    severity = IMessageProvider.NONE;
                }
                }
                setErrorMessageForMarkers(head, text, severity, markers);
            } else {
                setErrorMessageForMarkers(null, null, IMessageProvider.NONE, new IMarker[0]);
            }
        }
    } catch (final CoreException ex) {
        LOG.error(ex.getMessage(), ex);
        final String msg = ex.getMessage();
        setErrorMessageForMarkers(msg, msg, IMessageProvider.ERROR, new IMarker[0]);
    }

}

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

License:Open Source License

final protected void updateStatus(IStatus[] result) {
    // select most sever status
    fStatus = Status.OK_STATUS;/*from  w w  w. jav a  2 s .  c o m*/
    for (IStatus status : result) {
        if (status.getSeverity() > fStatus.getSeverity()) {
            fStatus = status;
        }
    }

    if (!fStatus.isOK()) {
        int type = IMessageProvider.NONE;
        switch (fStatus.getSeverity()) {
        case IStatus.ERROR:
            type = IMessageProvider.ERROR;
            break;
        case IStatus.WARNING:
            type = IMessageProvider.WARNING;
            break;
        case IStatus.INFO:
            type = IMessageProvider.INFORMATION;
            break;
        }

        setMessage(fStatus.getMessage(), type);
        setPageComplete(isValid());
        setPageComplete(true);

    } else {
        setErrorMessage(null);
        setMessage(null);

        setPageComplete(true);
    }
}

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

License:Open Source License

protected boolean validateQvtSourceContainer() {
    IStatus status = SourceContainerUpdater.validate(getQVTSourceContainerValue());

    if (!status.isOK()) {
        int type = IMessageProvider.NONE;
        switch (status.getSeverity()) {
        case IStatus.INFO:
            type = IMessageProvider.INFORMATION;
            break;
        case IStatus.WARNING:
            type = IMessageProvider.WARNING;
            break;
        case IStatus.ERROR:
            type = IMessageProvider.ERROR;
            break;
        }/* w w  w. j  a  v  a2s .  com*/

        setMessage(status.getMessage(), type);
        return status.getSeverity() <= IStatus.INFO;
    }

    return true;
}

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;/* ww  w . j a v  a2 s. co  m*/
    case IStatus.WARNING:
        type = IMessageProvider.WARNING;
        break;
    case IStatus.ERROR:
        type = IMessageProvider.ERROR;
        break;
    }

    return type;
}