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

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

Introduction

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

Prototype

int WARNING

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

Click Source Link

Document

Constant for a warning message (value 2).

Usage

From source file:org.emonic.base.wizards.NewDotNetTypeWizardPage.java

License:Open Source License

boolean verify() {
    /* check source folder */
    String folder = getSourceFolder();
    if (folder != null) {
        if (folder.equals("")) { //$NON-NLS-1$
            // the user has not entered in a source folder
            setPageComplete("Source folder is empty.");
            return false;
        }/*  w  ww . j  a  va 2s.  co  m*/

        IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
        Path path = new Path(folder);
        IContainer sourceFolder = null;
        if (path.segmentCount() == 1) {
            sourceFolder = root.getProject(folder);
        } else {
            sourceFolder = root.getFolder(path);
        }
        // make sure that the folder exists
        if (!sourceFolder.exists()) {
            setPageComplete("Folder '" + folder + "' does not exist.");
            return false;
        }
        if (!sourceFolder.isAccessible()) {
            // warn the user if the folder is not accessible
            setPageComplete("Folder '" + folder + "' is not accessible.");
            return false;
        }
        try {
            String[] natures = sourceFolder.getProject().getDescription().getNatureIds();
            boolean hasNature = false;
            for (int i = 0; i < natures.length; i++) {
                if (natures[i].equals(Constants.EmonicNatureID)) {
                    hasNature = true;
                    break;
                }
            }

            if (!hasNature) {
                setPageComplete("Source folder is not a .NET project.");
                return false;
            }
        } catch (CoreException e) {
            // technically this should not happen as we have checked
            // to make sure that the folder exists and is accessible
            setPageComplete("The project's properties could not be read.");
        }
    }

    /* check namespace */
    String namespace = getNamespace();
    if (namespace != null && !namespace.equals("")) { //$NON-NLS-1$
        // ensure that the first letter of the namespace name is a letter
        if (!Character.isLetter(namespace.charAt(0))) {
            setPageComplete(
                    "Namespace is not valid. The namespace '" + namespace + "' is not a valid identifier.");
            return false;
        }
    }

    /* check for name */
    String typeName = getTypeName();
    // check that a name has been entered
    if (typeName != null && typeName.equals("")) { //$NON-NLS-1$
        setPageComplete("Type name is empty.");
        return false;
    }

    /* check for discouraged name */
    if (typeName != null) {
        // ensure that the first character of the type name is a letter
        if (!Character.isLetter(typeName.charAt(0))) {
            setPageComplete(
                    "Type name is not valid. The type name '" + typeName + "' is not a valid identifier.");
            return false;
        }
        if (Character.isLowerCase(typeName.charAt(0))) {
            // if it's a lowercase character, warn the user that the
            // convention is to use uppercase letters
            setMessage(
                    "Type name is discouraged. By convention, .NET type names usually start with an uppercase letter.",
                    IMessageProvider.WARNING);
        } else {
            setMessage(getDescription());
        }
    }
    // all checks have passed, the page is complete
    setPageComplete(null);
    return true;
}

From source file:org.erlide.ui.prefs.plugin.EditorPreferencePage.java

License:Open Source License

/**
 * Applies the status to the status line of a dialog page.
 * //  www.  java 2  s.  c  o m
 * @param page
 *            the dialog page
 * @param status
 *            the status
 */
public static void applyToStatusLine(final DialogPage page, final IStatus status) {
    String message = status.getMessage();
    switch (status.getSeverity()) {
    case IStatus.OK:
        page.setMessage(message, IMessageProvider.NONE);
        page.setErrorMessage(null);
        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.erlide.ui.prefs.plugin.IndentationPreferencePage.java

License:Open Source License

/**
 * Applies the status to the status line of a dialog page.
 * //from  www.jav  a  2 s  .  com
 * @param page
 *            the dialog page
 * @param status
 *            the status
 */
public void applyToStatusLine(final DialogPage page, final IStatus status) {
    String message = status.getMessage();
    switch (status.getSeverity()) {
    case IStatus.OK:
        page.setMessage(message, IMessageProvider.NONE);
        page.setErrorMessage(null);
        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.fornax.cartridges.sculptor.framework.richclient.controller.AbstractWizardController.java

License:Apache License

/**
 * //from   ww  w .  j  a v a2  s  .co m
 * @return true if page is valid
 */
protected boolean updateValidationMessages() {
    boolean messageSet = false;
    IStatus statusParent = AggregateValidationStatus.getStatusMerged(getBindingContext().getBindings());

    // Iter for errors
    for (IStatus statusChild : statusParent.getChildren()) {
        if (statusChild.getSeverity() == IStatus.ERROR) {
            presentation.setErrorMessage(statusChild.getMessage());
            messageSet = true;
            if (statusChild.getException() != null) {
                statusChild.getException().printStackTrace();
            }
            break;
        }
    }
    if (!messageSet) {
        presentation.clearErrorMessage();
        // Iter for warnings
        for (IStatus statusChild : statusParent.getChildren()) {
            if (statusChild.getSeverity() == IStatus.WARNING) {
                presentation.setMessage(statusChild.getMessage(), IMessageProvider.WARNING);
                messageSet = true;
                break;
            }
        }
    }
    if (!messageSet) {
        // Iter for information
        for (IStatus statusChild : statusParent.getChildren()) {
            if (statusChild.getSeverity() == IStatus.INFO) {
                presentation.setMessage(statusChild.getMessage(), IMessageProvider.INFORMATION);
                messageSet = true;
                break;
            }
        }
    }

    if (!messageSet) {
        IStatus customValidationStatus = getValidationStatus();
        if (customValidationStatus == null) {
            presentation.clearErrorMessage();
            presentation.setMessage(null, IMessageProvider.NONE);
        } else if (customValidationStatus.getSeverity() == IStatus.ERROR) {
            presentation.setErrorMessage(customValidationStatus.getMessage());
        } else if (customValidationStatus.getSeverity() == IStatus.WARNING) {
            presentation.setMessage(customValidationStatus.getMessage(), IMessageProvider.WARNING);

        } else if (customValidationStatus.getSeverity() == IStatus.INFO) {
            presentation.setMessage(customValidationStatus.getMessage(), IMessageProvider.INFORMATION);
        }
    }

    if (!messageSet) {
        presentation.setMessage(null, IMessageProvider.NONE);
    }

    return !presentation.hasErrorMessage();
}

From source file:org.franca.core.ui.addons.wizard.StatusWizardPage.java

License:Open Source License

/**
 * Applies the status to the status line of the wizard page.
 * @param status the status to apply/*  ww w .j  av a 2s . com*/
 */
protected void applyStatus(IStatus status) {
    String msg = status.getMessage();
    if (msg != null && msg.length() == 0) {
        msg = null;
    }

    switch (status.getSeverity()) {
    case IStatus.OK:
        setMessage(msg, IMessageProvider.NONE);
        setErrorMessage(null);
        break;
    case IStatus.WARNING:
        setMessage(msg, IMessageProvider.WARNING);
        setErrorMessage(null);
        break;
    case IStatus.INFO:
        setMessage(msg, IMessageProvider.INFORMATION);
        setErrorMessage(null);
        break;
    default:
        setMessage(null);
        setErrorMessage(msg);
        break;
    }
}

From source file:org.fusesource.ide.camel.editor.preferences.PreferredLabelDialog.java

License:Open Source License

public void setWarning(String msg) {
    Button okButton = getButton(IDialogConstants.OK_ID);
    if (okButton != null) {
        setMessage(msg, msg == null ? IMessageProvider.NONE : IMessageProvider.WARNING);
        okButton.setEnabled(msg == null);
    }//  www .j  av a  2 s.  c  o  m
}

From source file:org.fusesource.ide.jvmmonitor.internal.tools.ToolsPreferencePage.java

License:Open Source License

/**
 * Validates the JDK root directory./*from  w  w  w  . j  a  v a2 s  .c o  m*/
 */
void validateJdkRootDirectory() {

    // check if text is empty
    String jdkRootDirectory = jdkRootDirectoryText.getText();
    if (jdkRootDirectory.isEmpty()) {
        setMessage(Messages.jdkRootDirectoryNotEnteredMsg, IMessageProvider.WARNING);
        return;
    }

    String message = Tools.getInstance().validateJdkRootDirectory(jdkRootDirectory);
    setMessage(message, IMessageProvider.WARNING);
}

From source file:org.fusesource.ide.jvmmonitor.internal.tools.ToolsPreferencePage.java

License:Open Source License

/**
 * Validates the update period./*w ww  .  j  a  va 2 s .co  m*/
 */
void validateUpdatePeriod() {

    // check if text is empty
    String period = updatePeriodText.getText();
    if (period.isEmpty()) {
        setMessage(Messages.updatePeriodNotEnteredMsg, IMessageProvider.WARNING);
        return;
    }

    // check if text is integer
    try {
        Integer.parseInt(period);
    } catch (NumberFormatException e) {
        setMessage(Messages.illegalUpdatePeriodMsg, IMessageProvider.ERROR);
        return;
    }

    // check if the value is within valid range
    if (Integer.valueOf(period) < MIN_UPDATE_PERIOD) {
        setMessage(Messages.updatePeriodOutOfRangeMsg, IMessageProvider.ERROR);
        return;
    }

    setMessage(null);
}

From source file:org.fusesource.ide.jvmmonitor.internal.tools.ToolsPreferencePage.java

License:Open Source License

/**
 * Validates the max number of classes.//from   w w w.  j a v a2s .  c  om
 * 
 */
void validateMaxNumberOfClasses() {

    // check if text is empty
    String period = maxNumberOfClassesText.getText();
    if (period.isEmpty()) {
        setMessage(Messages.enterMaxNumberOfClassesMsg, IMessageProvider.WARNING);
        return;
    }

    // check if text is integer
    try {
        Integer.parseInt(period);
    } catch (NumberFormatException e) {
        setMessage(Messages.maxNumberOfClassesInvalidMsg, IMessageProvider.ERROR);
        return;
    }

    // check if the value is within valid range
    if (Integer.valueOf(period) <= 0) {
        setMessage(Messages.maxNumberOfClassesOutOfRangeMsg, IMessageProvider.ERROR);
        return;
    }

    setMessage(null);
}