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:com.android.ide.eclipse.adt.internal.wizards.templates.NewTemplatePage.java

License:Open Source License

private void validatePage() {
    int minSdk = getMinSdk();
    int buildApi = getBuildApi();
    IStatus status = mValues.getTemplateHandler().validateTemplate(minSdk, buildApi);

    if (status == null || status.isOK()) {
        if (mChooseProject && mValues.project == null) {
            status = new Status(IStatus.ERROR, AdtPlugin.PLUGIN_ID, "Please select an Android project.");
        }//from ww w. j av  a 2s .c om
    }

    for (Parameter parameter : mShowingTemplate.getParameters()) {
        if (parameter.type == Parameter.Type.SEPARATOR) {
            continue;
        }
        IInputValidator validator = parameter.getValidator(mValues.project);
        if (validator != null) {
            ControlDecoration decoration = mDecorations.get(parameter.id);
            String value = parameter.value == null ? "" : parameter.value.toString();
            String error = validator.isValid(value);
            if (error != null) {
                IStatus s = new Status(IStatus.ERROR, AdtPlugin.PLUGIN_ID, error);
                if (decoration != null) {
                    updateDecorator(decoration, s, parameter.help);
                }
                if (status == null || status.isOK()) {
                    status = s;
                }
            } else if (decoration != null) {
                updateDecorator(decoration, null, parameter.help);
            }
        }

        if (status == null || status.isOK()) {
            if (parameter.control instanceof Combo) {
                status = validateCombo(status, parameter, minSdk, buildApi);
            }
        }
    }

    setPageComplete(status == null || status.getSeverity() != IStatus.ERROR);
    if (status != null) {
        setMessage(status.getMessage(),
                status.getSeverity() == IStatus.ERROR ? IMessageProvider.ERROR : IMessageProvider.WARNING);
    } else {
        setErrorMessage(null);
        setMessage(null);
    }
}

From source file:com.android.ide.eclipse.adt.internal.wizards.templates.ProjectContentsPage.java

License:Open Source License

void validatePage() {
    IStatus status = validateProjectLocation();

    setPageComplete(status == null || status.getSeverity() != IStatus.ERROR);
    if (status != null) {
        setMessage(status.getMessage(),// w  w  w .  ja  v a2 s.co m
                status.getSeverity() == IStatus.ERROR ? IMessageProvider.ERROR : IMessageProvider.WARNING);
    } else {
        setErrorMessage(null);
        setMessage(null);
    }
}

From source file:com.android.ide.eclipse.adt.internal.wizards.templates.TemplateTestPage.java

License:Open Source License

private boolean validatePage() {
    String error = null;//from  w ww.j  a v  a  2s  .c  o m

    String path = mLocation.getText().trim();
    if (path == null || path.length() == 0) {
        error = "Select a template directory";
        mTemplate = null;
    } else {
        mTemplate = new File(path);
        if (!mTemplate.exists()) {
            error = String.format("%1$s does not exist", path);
        } else {
            // Preserve across wizard sessions
            sLocation = path;

            if (mTemplate.isDirectory()) {
                if (!new File(mTemplate, TemplateHandler.TEMPLATE_XML).exists()) {
                    error = String.format("Not a template: missing template.xml file in %1$s ", path);
                }
            } else {
                if (mTemplate.getName().equals(TemplateHandler.TEMPLATE_XML)) {
                    mTemplate = mTemplate.getParentFile();
                } else {
                    error = String.format("Select a directory containing a template");
                }
            }
        }
    }

    setPageComplete(error == null);
    if (error != null) {
        setMessage(error, IMessageProvider.ERROR);
    } else {
        setErrorMessage(null);
        setMessage(null);
    }

    return error == null;
}

From source file:com.android.ide.eclipse.auidt.internal.assetstudio.ConfigureAssetSetPage.java

License:Open Source License

private boolean validatePage() {
    String error = null;/* ww w .  jav  a 2  s. co m*/
    //String warning = null;

    if (mImageRadio.getSelection()) {
        String path = mValues.imagePath != null ? mValues.imagePath.getPath() : null;
        if (path == null || path.length() == 0) {
            error = "Select an image";
        } else if (!(new File(path).exists())) {
            error = String.format("%1$s does not exist", path);
        } else {
            // Preserve across wizard sessions
            sImagePath = path;
        }
    } else if (mTextRadio.getSelection()) {
        if (mValues.text.length() == 0) {
            error = "Enter text";
        }
    } else {
        assert mClipartRadio.getSelection();
        if (mValues.clipartName == null) {
            error = "Select clip art";
        }
    }

    setPageComplete(error == null);
    if (error != null) {
        setMessage(error, IMessageProvider.ERROR);
        //} else if (warning != null) {
        //    setMessage(warning, IMessageProvider.WARNING);
    } else {
        setErrorMessage(null);
        setMessage(null);
    }

    return error == null;
}

From source file:com.android.ide.eclipse.auidt.internal.wizards.newproject.ImportPage.java

License:Open Source License

private void validatePage() {
    IStatus status = null;/*from   w ww .java 2 s  . c o m*/

    // Validate project name -- unless we're creating a sample, in which case
    // the user will get a chance to pick the name on the Sample page
    if (mProjectPaths == null || mProjectPaths.isEmpty()) {
        status = new Status(IStatus.ERROR, AdtPlugin.PLUGIN_ID,
                "Select a directory to search for existing Android projects");
    } else if (mValues.importProjects == null || mValues.importProjects.isEmpty()) {
        status = new Status(IStatus.ERROR, AdtPlugin.PLUGIN_ID, "Select at least one project");
    } else {
        for (ImportedProject project : mValues.importProjects) {
            if (mCheckboxTableViewer.getGrayed(project)) {
                status = new Status(IStatus.ERROR, AdtPlugin.PLUGIN_ID, String.format(
                        "Cannot import %1$s because the project name is in use", project.getProjectName()));
                break;
            }
        }
    }

    // -- update UI & enable finish if there's no error
    setPageComplete(status == null || status.getSeverity() != IStatus.ERROR);
    if (status != null) {
        setMessage(status.getMessage(),
                status.getSeverity() == IStatus.ERROR ? IMessageProvider.ERROR : IMessageProvider.WARNING);
    } else {
        setErrorMessage(null);
        setMessage(null);
    }
}

From source file:com.android.ide.eclipse.auidt.internal.wizards.templates.ActivityPage.java

License:Open Source License

private void validatePage() {
    IStatus status = null;//from w  w  w .  j  a v  a  2s.c  o m

    if (mValues.createActivity) {
        if (mList.getSelectionCount() < 1) {
            status = new Status(IStatus.ERROR, AdtPlugin.PLUGIN_ID, "Select an activity type");
        } else {
            TemplateHandler templateHandler = mValues.activityValues.getTemplateHandler();
            status = templateHandler.validateTemplate(mValues.minSdkLevel);
        }
    }

    setPageComplete(status == null || status.getSeverity() != IStatus.ERROR);
    if (status != null) {
        setMessage(status.getMessage(),
                status.getSeverity() == IStatus.ERROR ? IMessageProvider.ERROR : IMessageProvider.WARNING);
    } else {
        setErrorMessage(null);
        setMessage(null);
    }
}

From source file:com.android.ide.eclipse.auidt.internal.wizards.templates.NewProjectPage.java

License:Open Source License

private void validatePage() {
    IStatus status = mValues.template.validateTemplate(mValues.minSdkLevel);
    if (status != null && !status.isOK()) {
        updateDecorator(mApplicationDec, null, true);
        updateDecorator(mPackageDec, null, true);
        updateDecorator(mProjectDec, null, true);
    } else {//w  w w  .  j  a  v  a2 s .  co m
        IStatus appStatus = validateAppName();
        if (appStatus != null && (status == null || appStatus.getSeverity() > status.getSeverity())) {
            status = appStatus;
        }

        IStatus projectStatus = validateProjectName();
        if (projectStatus != null && (status == null || projectStatus.getSeverity() > status.getSeverity())) {
            status = projectStatus;
        }

        IStatus packageStatus = validatePackageName();
        if (packageStatus != null && (status == null || packageStatus.getSeverity() > status.getSeverity())) {
            status = packageStatus;
        }

        IStatus locationStatus = validateProjectLocation();
        if (locationStatus != null && (status == null || locationStatus.getSeverity() > status.getSeverity())) {
            status = locationStatus;
        }

        if (status == null || status.getSeverity() != IStatus.ERROR) {
            if (mValues.target == null) {
                status = new Status(IStatus.WARNING, AdtPlugin.PLUGIN_ID,
                        "Select an Android build target version");
            }
        }

        if (status == null || status.getSeverity() != IStatus.ERROR) {
            if (mValues.minSdk == null || mValues.minSdk.isEmpty()) {
                status = new Status(IStatus.WARNING, AdtPlugin.PLUGIN_ID, "Select a minimum SDK version");
            } else {
                AndroidVersion version = mValues.target.getVersion();
                if (version.isPreview()) {
                    if (version.getCodename().equals(mValues.minSdk) == false) {
                        status = new Status(IStatus.ERROR, AdtPlugin.PLUGIN_ID,
                                "Preview platforms require the min SDK version to match their codenames.");
                    }
                } else if (mValues.target.getVersion().compareTo(mValues.minSdkLevel,
                        version.isPreview() ? mValues.minSdk : null) < 0) {
                    status = new Status(IStatus.WARNING, AdtPlugin.PLUGIN_ID,
                            "The minimum SDK version is higher than the build target version");
                }
            }
        }
    }

    setPageComplete(status == null || status.getSeverity() != IStatus.ERROR);
    if (status != null) {
        setMessage(status.getMessage(),
                status.getSeverity() == IStatus.ERROR ? IMessageProvider.ERROR : IMessageProvider.WARNING);
    } else {
        setErrorMessage(null);
        setMessage(null);
    }
}

From source file:com.android.ide.eclipse.auidt.internal.wizards.templates.NewTemplatePage.java

License:Open Source License

private void validatePage() {
    int currentMinSdk = getMinSdk();
    int minSdk = currentMinSdk;
    IStatus status = mValues.getTemplateHandler().validateTemplate(minSdk);

    if (status == null || status.isOK()) {
        if (mChooseProject && mValues.project == null) {
            status = new Status(IStatus.ERROR, AdtPlugin.PLUGIN_ID, "Please select an Android project.");
        }//from  www .  j  a va  2  s  . com
    }

    for (Parameter parameter : mParameters) {
        IInputValidator validator = parameter.getValidator(mValues.project);
        if (validator != null) {
            ControlDecoration decoration = mDecorations.get(parameter.id);
            String value = parameter.value == null ? "" : parameter.value.toString();
            String error = validator.isValid(value);
            if (error != null) {
                IStatus s = new Status(IStatus.ERROR, AdtPlugin.PLUGIN_ID, error);
                if (decoration != null) {
                    updateDecorator(decoration, s, parameter.help);
                }
                if (status == null || status.isOK()) {
                    status = s;
                }
            } else if (decoration != null) {
                updateDecorator(decoration, null, parameter.help);
            }
        }

        if (status == null || status.isOK()) {
            if (parameter.control instanceof Combo) {
                Combo combo = (Combo) parameter.control;
                Integer[] optionIds = (Integer[]) combo.getData(ATTR_MIN_API);
                int index = combo.getSelectionIndex();
                if (index != -1 && index < optionIds.length) {
                    Integer requiredMinSdk = optionIds[index];
                    if (requiredMinSdk > currentMinSdk) {
                        status = new Status(IStatus.ERROR, AdtPlugin.PLUGIN_ID,
                                String.format(
                                        "This template requires a minimum SDK version of at "
                                                + "least %1$d, and the current min version is %2$d",
                                        requiredMinSdk, currentMinSdk));
                    }
                }
            }
        }
    }

    setPageComplete(status == null || status.getSeverity() != IStatus.ERROR);
    if (status != null) {
        setMessage(status.getMessage(),
                status.getSeverity() == IStatus.ERROR ? IMessageProvider.ERROR : IMessageProvider.WARNING);
    } else {
        setErrorMessage(null);
        setMessage(null);
    }
}

From source file:com.android.ide.eclipse.editors.manifest.model.UiPackageAttributeNode.java

License:Open Source License

@Override
protected void onAddValidators(final Text text) {
    ModifyListener listener = new ModifyListener() {
        public void modifyText(ModifyEvent e) {
            String package_name = text.getText();
            if (package_name.indexOf('.') < 1) {
                getManagedForm().getMessageManager().addMessage(text,
                        "Package name should contain at least two identifiers.", null /* data */,
                        IMessageProvider.ERROR, text);
            } else {
                getManagedForm().getMessageManager().removeMessage(text, text);
            }/*w  w w . j  a v a 2 s .c  o  m*/
        }
    };

    text.addModifyListener(listener);

    // Make sure the validator removes its message(s) when the widget is disposed
    text.addDisposeListener(new DisposeListener() {
        public void widgetDisposed(DisposeEvent e) {
            getManagedForm().getMessageManager().removeMessage(text, text);
        }
    });

    // Finally call the validator once to make sure the initial value is processed
    listener.modifyText(null);
}

From source file:com.aptana.ide.security.internal.linux.StorageLoginDialog.java

License:Open Source License

protected boolean validatePassword() {
    String password1 = password.getText();
    if ((password1 == null) || (password1.length() == 0)) {
        setMessage(Messages.messageEmptyPassword, IMessageProvider.ERROR);
        return false;
    }//from  www . j a  va2s. c  o m
    if (confirm != null) {
        String password2 = confirm.getText();
        if (!password1.equals(password2)) {
            setMessage(Messages.messageNoMatch, IMessageProvider.WARNING);
            return false;
        }
    }
    setMessage("", IMessageProvider.NONE); //$NON-NLS-1$
    return true;
}