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.andmore.internal.wizards.newproject.ProjectNamePage.java

License:Open Source License

private void validatePage() {
    IStatus status = null;//www. j av a  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 (mValues.mode != Mode.SAMPLE) {
        status = validateProjectName(mValues.projectName);
    }

    if (status == null || status.getSeverity() != IStatus.ERROR) {
        IStatus validLocation = validateLocation();
        if (validLocation != null) {
            status = validLocation;
        }
    }

    if (!mCheckedSdkUptodate) {
        // Ensure that we have a recent enough version of the Tools that the right templates
        // are available
        File file = new File(AndmoreAndroidPlugin.getOsSdkFolder(),
                OS_SDK_TOOLS_LIB_FOLDER + File.separator + FN_PROJECT_PROGUARD_FILE);
        if (!file.exists()) {
            status = new Status(IStatus.ERROR, AndmoreAndroidPlugin.PLUGIN_ID,
                    String.format("You do not have the latest version of the "
                            + "SDK Tools installed: Please update. (Missing %1$s)", file.getPath()));
        } else {
            mCheckedSdkUptodate = true;
        }
    }

    // -- 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:org.eclipse.andmore.internal.wizards.newproject.SampleSelectionPage.java

License:Open Source License

private void validatePage() {
    IStatus status = null;//w  ww .  j a  v  a  2 s .  c  om
    if (mValues.samples == null || mValues.samples.size() == 0) {
        status = new Status(IStatus.ERROR, AndmoreAndroidPlugin.PLUGIN_ID,
                "The chosen SDK does not contain any samples");
    } else if (mValues.chosenSample == null) {
        status = new Status(IStatus.ERROR, AndmoreAndroidPlugin.PLUGIN_ID, "Choose a sample");
    } else if (!mValues.chosenSample.exists()) {
        status = new Status(IStatus.ERROR, AndmoreAndroidPlugin.PLUGIN_ID,
                String.format("Sample does not exist: %1$s", mValues.chosenSample.getPath()));
    } else {
        status = ProjectNamePage.validateProjectName(mValues.projectName);
    }

    // -- 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:org.eclipse.andmore.internal.wizards.newproject.SdkSelectionPage.java

License:Open Source License

private void validatePage() {
    String error = null;//ww w  .ja  va2  s. c  om

    if (AndmoreAndroidPlugin.getDefault().getSdkLoadStatus() == LoadStatus.LOADING) {
        error = "The SDK is still loading; please wait.";
    }

    if (error == null && mValues.target == null) {
        error = "An SDK Target must be specified.";
    }

    if (error == null && mValues.mode == Mode.SAMPLE) {
        // Make sure this SDK target contains samples
        if (mValues.samples == null || mValues.samples.size() == 0) {
            error = "This target has no samples. Please select another target.";
        }
    }

    // -- update UI & enable finish if there's no error
    setPageComplete(error == null);
    if (error != null) {
        setMessage(error, IMessageProvider.ERROR);
    } else {
        setErrorMessage(null);
        setMessage(null);
    }
}

From source file:org.eclipse.andmore.internal.wizards.templates.ActivityPage.java

License:Open Source License

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

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

    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:org.eclipse.andmore.internal.wizards.templates.InstallDependencyPage.java

License:Open Source License

private void validatePage() {
    if (mTemplate == null) {
        return;/* www .  ja v  a2s.c o m*/
    }

    IStatus status = null;

    List<Pair<String, Integer>> dependencies = mTemplate.getDependencies();
    if (dependencies.size() > 1
            || dependencies.size() == 1 && !dependencies.get(0).getFirst().equals(SUPPORT_LIBRARY_NAME)) {
        status = new Status(IStatus.WARNING, AndmoreAndroidPlugin.PLUGIN_ID,
                "Unsupported template dependency: Upgrade your Android Eclipse plugin");
    }

    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:org.eclipse.andmore.internal.wizards.templates.NewProjectPage.java

License:Open Source License

private void validatePage() {
    IStatus status = mValues.template.validateTemplate(mValues.minSdkLevel, mValues.getBuildApi());
    if (status != null && !status.isOK()) {
        updateDecorator(mApplicationDec, null, true);
        updateDecorator(mPackageDec, null, true);
        updateDecorator(mProjectDec, null, true);
        updateDecorator(mThemeDec, null, true);
        /* These never get marked with errors:
        updateDecorator(mBuildTargetDec, null, true);
        updateDecorator(mMinSdkDec, null, true);
        updateDecorator(mTargetSdkDec, null, true);
        *///  w w w  .j  av  a  2 s.  co m
    } else {
        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 = ProjectContentsPage.validateLocationInWorkspace(mValues);
        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, AndmoreAndroidPlugin.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, AndmoreAndroidPlugin.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, AndmoreAndroidPlugin.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, AndmoreAndroidPlugin.PLUGIN_ID,
                            "The minimum SDK version is higher than the build target version");
                }
                if (status == null || status.getSeverity() != IStatus.ERROR) {
                    if (mValues.targetSdkLevel < mValues.minSdkLevel) {
                        status = new Status(IStatus.ERROR, AndmoreAndroidPlugin.PLUGIN_ID,
                                "The target SDK version should be at least as high as the minimum SDK version");
                    }
                }
            }
        }

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

    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:org.eclipse.andmore.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, AndmoreAndroidPlugin.PLUGIN_ID,
                    "Please select an Android project.");
        }/*  w ww  .  j a  v a  2  s.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, AndmoreAndroidPlugin.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:org.eclipse.babel.editor.wizards.internal.ResourceBundleNewWizardPage.java

License:Open Source License

/**
 * Ensures that both text fields and the Locale field are set.
 *///from   www  .j  a v  a2s. c o m
protected void dialogChanged() {
    String container = getContainerName();
    String fileName = getFileName();

    if (container.length() == 0) {
        updateStatus(Messages.editor_wiz_error_container, IMessageProvider.ERROR);
        return;
    }
    if (fileName.length() == 0) {
        updateStatus(Messages.editor_wiz_error_bundleName, IMessageProvider.ERROR);
        return;
    }
    int dotLoc = fileName.lastIndexOf('.');
    if (dotLoc != -1) {
        updateStatus(Messages.editor_wiz_error_extension, IMessageProvider.ERROR);
        return;
    }
    // check if at least one Locale has been added to th list
    if (bundleLocalesList.getItemCount() <= 0) {
        updateStatus(Messages.editor_wiz_error_noLocale, IMessageProvider.ERROR);
        return;
    }
    // check if the container field contains a valid path
    // meaning: Project exists, at least one segment, valid path
    Path pathContainer = new Path(container);
    if (!pathContainer.isValidPath(container)) {
        updateStatus(Messages.editor_wiz_error_invalidpath, IMessageProvider.ERROR);
        return;
    }

    if (pathContainer.segmentCount() < 1) {
        updateStatus(Messages.editor_wiz_error_invalidpath, IMessageProvider.ERROR);
        return;
    }

    if (!projectExists(pathContainer.segment(0))) {
        String errormessage = Messages.editor_wiz_error_projectnotexist;
        errormessage = String.format(errormessage, pathContainer.segment(0));
        updateStatus(errormessage, IMessageProvider.ERROR);
        return;
    }

    updateStatus(null, IMessageProvider.NONE);
}

From source file:org.eclipse.babel.editor.wizards.internal.ResourceBundleNewWizardPage.java

License:Open Source License

protected void updateStatus(String message, int messageType) {
    setMessage(message, messageType);
    setPageComplete(messageType != IMessageProvider.ERROR);
}

From source file:org.eclipse.be.build.ui.wizards.StatusPage.java

License:Open Source License

protected void setHeaderForError() {
    setTitle("Error");
    setMessage(getStatusMessage(), IMessageProvider.ERROR);
}