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.equinox.p2.authoring.forms.EditAdapter.java

License:Open Source License

/**
 * Sets a single error message keyed by this edit adapter. Replaces any earlier message set for the edit adapter.
 * /*from w  w w  .  j a v a 2s . c o m*/
 * @param message
 */
public void setErrorMessage(String message) {
    m_formPart.getManagedForm().getMessageManager().addMessage(this, message, null, IMessageProvider.ERROR,
            m_control);
}

From source file:org.eclipse.equinox.p2.authoring.forms.RichFormPage.java

License:Open Source License

private void configureFormText(final Form form, FormText text) {
    text.addHyperlinkListener(new HyperlinkAdapter() {
        @Override/* w  w w  . ja  v  a  2s.  c o m*/
        public void linkActivated(HyperlinkEvent e) {
            String is = (String) e.getHref();
            try {
                int index = Integer.parseInt(is);
                IMessage[] messages = form.getChildrenMessages();
                IMessage message = messages[index];
                Control c = message.getControl();
                ((FormText) e.widget).getShell().dispose();
                if (c != null)
                    c.setFocus();
            } catch (ArrayIndexOutOfBoundsException ex) {
                // This can happens if message array changes while menu is up
                ((FormText) e.widget).getShell().dispose();
            } catch (NumberFormatException ex) {
            }
        }
    });
    text.setImage("error", getImage(IMessageProvider.ERROR)); //$NON-NLS-1$
    text.setImage("warning", getImage(IMessageProvider.WARNING)); //$NON-NLS-1$
    text.setImage("info", getImage(IMessageProvider.INFORMATION)); //$NON-NLS-1$
}

From source file:org.eclipse.equinox.p2.authoring.forms.RichFormPage.java

License:Open Source License

/**
 * Formats messages into a form string//from w  w  w . j av  a2 s .co m
 * 
 * @param messages
 *            - messages to format
 * @return a form string
 */
private String createFormTextContent(IMessage[] messages) {
    StringWriter sw = new StringWriter();
    PrintWriter pw = new PrintWriter(sw);
    pw.println("<form>"); //$NON-NLS-1$
    for (int i = 0; i < messages.length; i++) {
        IMessage message = messages[i];
        pw.print("<li vspace=\"false\" style=\"image\" indent=\"16\" value=\""); //$NON-NLS-1$
        switch (message.getMessageType()) {
        case IMessageProvider.ERROR:
            pw.print("error"); //$NON-NLS-1$
            break;
        case IMessageProvider.WARNING:
            pw.print("warning"); //$NON-NLS-1$
            break;
        case IMessageProvider.INFORMATION:
            pw.print("info"); //$NON-NLS-1$
            break;
        }
        pw.print("\"> <a href=\""); //$NON-NLS-1$
        pw.print(i + ""); //$NON-NLS-1$
        pw.print("\">");//$NON-NLS-1$
        if (message.getPrefix() != null)
            pw.print(message.getPrefix());
        pw.print(message.getMessage());
        pw.println("</a></li>"); //$NON-NLS-1$
    }
    pw.println("</form>"); //$NON-NLS-1$
    pw.flush();
    return sw.toString();
}

From source file:org.eclipse.equinox.p2.authoring.forms.RichFormPage.java

License:Open Source License

/**
 * Convenience method to pick up platform images for error and warning.
 * //from   w ww.  j a  v a2s  . c  o  m
 * @param type
 * @return
 */
private Image getImage(int type) {
    switch (type) {
    case IMessageProvider.ERROR:
        return PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_OBJS_ERROR_TSK);
    case IMessageProvider.WARNING:
        return PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_OBJS_WARN_TSK);
    case IMessageProvider.INFORMATION:
        return PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_OBJS_INFO_TSK);
    }
    return null;
}

From source file:org.eclipse.fx.ide.fxml.wizards.FXMLWizardPage.java

License:Open Source License

@Override
protected void revalidate() {
    if (getClazz().getName() == null || getClazz().getName().trim().length() == 0) {
        setPageComplete(false);//  ww  w .  j a  va  2 s . c  o  m
        setMessage(Messages.FXMLWizardPage_2, IMessageProvider.ERROR);
    } else if (getClazz().getRootElement() == null) {
        setPageComplete(false);
        setMessage(Messages.FXMLWizardPage_10, IMessageProvider.ERROR);
    } else if (Character.isLowerCase(getClazz().getName().charAt(0))) {
        setPageComplete(true);
        setMessage(Messages.FXMLWizardPage_5, IMessageProvider.WARNING);
    } else {
        setPageComplete(true);
        setMessage(null);
    }
}

From source file:org.eclipse.fx.ide.ui.wizards.AbstractJDTElementPage.java

License:Open Source License

protected AbstractJDTElementPage(String pageName, String title, String description, IPackageFragmentRoot froot,
        IPackageFragment fragment, IWorkspaceRoot fWorkspaceRoot) {
    super(pageName);
    if (froot == null) {
        setMessage("Root is not a java project", IMessageProvider.ERROR);
    }//from   ww w . j  a va2  s  .c o  m
    this.froot = froot;
    this.fragment = fragment;
    this.fWorkspaceRoot = fWorkspaceRoot;

    setTitle(title);
    setDescription(description);
    setImageDescriptor(getTitleAreaImage(Display.getCurrent()));
}

From source file:org.eclipse.fx.ide.ui.wizards.AbstractJDTElementPage.java

License:Open Source License

protected void revalidate() {
    if (getClazz().getName() == null || getClazz().getName().trim().length() == 0) {
        setPageComplete(false);/*  w w  w  . jav a  2  s .  c  o  m*/
        setMessage("Enter a name", IMessageProvider.ERROR);
    } else if (froot == null) {
        setPageComplete(false);
        setMessage("Root is not a java project", IMessageProvider.ERROR);
    } else {
        setPageComplete(true);
        setMessage(null);
    }
}

From source file:org.eclipse.gmf.runtime.emf.ui.preferences.NewPathVariableDialog.java

License:Open Source License

/**
 * Validates the current values of the variable name and location entry
 * fields. A warning or error message is shown in the title area, if
 * appropriate, and the OK button is disabled if any input is invalid.
 * Moreover, in edit mode, the OK button is disabled if the user hasn't
 * changed either the variable name or the location.
 *//*from  w  w w  .jav  a 2  s  .  c o  m*/
private void validateInputs() {
    IStatus status = Status.OK_STATUS;
    boolean isError = false;

    String name = nameText.getText();
    String location = locationText.getText();
    boolean hasName = name.length() > 0;
    boolean hasLocation = location.length() > 0;

    if (hasName && !name.equals(initialName)) {
        status = validateName(name);
    }

    if (!status.isOK()) {
        isError = true;
        setMessage(status.getMessage(), IMessageProvider.ERROR);
    } else if (hasLocation && !location.equals(initialLocation)) {
        status = validateLocation(new Path(location));
        if (!status.isOK()) {
            isError = status.getSeverity() >= IStatus.ERROR;

            setMessage(status.getMessage(), isError ? IMessageProvider.ERROR : IMessageProvider.WARNING);
        }
    }

    if (status.isOK()) {
        setMessage(plainMsg);
    }

    if (initialName != null) {
        // edit mode. Check that either the name or the location is changed
        if (name.equals(initialName) && location.equals(initialLocation)) {
            // force OK button to be disabled
            hasName = false;
        }
    }

    // dialog not complete if error or missing an input
    getButton(IDialogConstants.OK_ID).setEnabled(!isError && hasName && hasLocation);
}

From source file:org.eclipse.gmt.modisco.jm2t.internal.ui.wizard.TaskWizardPage.java

License:Open Source License

public void setMessage(String message, int type) {
    if (type == IMessageProvider.ERROR && "".equals(message)) {
        message = null;//w  ww  .j  a v a  2  s.c  o m
    }
    super.setMessage(message, type);
    WizardFragment frag = ((TaskWizard) getWizard()).getCurrentWizardFragment();
    if (!fragment.equals(frag))
        return;
    getContainer().updateButtons();
}

From source file:org.eclipse.gmt.modisco.jm2t.ui.wizard.page.NewGeneratorConfigurationComposite.java

License:Open Source License

protected void validate() {
    if (generatorConfiguration == null) {
        wizard.setMessage("", IMessageProvider.ERROR);
        return;/*from  ww  w  .  j a v a 2s. co m*/
    }
    IStatus status = generatorConfiguration.validate();
    if (status == null || status.isOK())
        wizard.setMessage(null, IMessageProvider.NONE);
    else if (status.getSeverity() == IStatus.WARNING)
        wizard.setMessage(status.getMessage(), IMessageProvider.WARNING);
    else
        wizard.setMessage(status.getMessage(), IMessageProvider.ERROR);
    wizard.update();
}