Package com.volantis.mcs.eclipse.validation

Examples of com.volantis.mcs.eclipse.validation.ValidationStatus


     * validatePage method in MCSProjectPropertiesPage.
     */
    protected boolean validatePage() {
        boolean valid = true;

        ValidationStatus status = REPOSITORY_NAME_VALIDATOR.validate(
                fileSelector.getValue(), messageBuilder);

        if (status.getSeverity() == Status.ERROR) {
            setErrorMessage(status.getMessage());
            valid = false;
        } else if (status.getSeverity() == Status.INFO) {
            setErrorMessage(null);
            setMessage(status.getMessage());
        } else {
            status = PROJECT_CONTAINER_NAME_VALIDATOR.validate(
                    policySource.getText().trim(), messageBuilder);
            if (status.getSeverity() == Status.ERROR) {
                setErrorMessage(status.getMessage());
                valid = false;
            } else if (status.getSeverity() == Status.INFO) {
                setErrorMessage(null);
                setMessage(status.getMessage(), DialogPage.INFORMATION);
            } else {
                setErrorMessage(null);
                setMessage(null);
            }
        }
View Full Code Here


    public boolean hasValidDeviceRepository() {
        boolean result = false;
        // check the device repository name
        String deviceRepositoryName = getDeviceRepositoryName(iProject);
        if (deviceRepositoryName != null) {
            ValidationStatus status = REPOSITORY_NAME_VALIDATOR.validate(
                    deviceRepositoryName, messageBuilder);
            if (status.getSeverity() == ValidationStatus.OK) {
                // check the policy source path
                StringBuffer fullPolicyPathName = new StringBuffer(
                        getProject().getLocation().toOSString());
                fullPolicyPathName.append(File.separatorChar).
                        append(getPolicySourcePath());
View Full Code Here

    /**
     * Validates the control's contents.
     * @return the validation status
     */
    public ValidationStatus validate() {
        ValidationStatus status = OK_STATUS;
        String errorMessage = null;
        String hoursText = hoursTextField.getText().trim();
        String minutesText = minutesTextField.getText().trim();
        String secondsText = secondsTextField.getText().trim();

        // Only process the time if a time has been entered.
        if (hoursText.length() > 0 ||
                minutesText.length() > 0 ||
                secondsText.length() > 0) {
            hoursText = hoursText.length() == 0 ? TWO_LEADING_ZEROES : hoursText;
            minutesText =
                    minutesText.length() == 0 ? TWO_LEADING_ZEROES : minutesText;
            secondsText =
                    secondsText.length() == 0 ? TWO_LEADING_ZEROES : secondsText;
            status = hoursValidator.validate(hoursText);
            if (status.isOK()) {
                status = minutesValidator.validate(minutesText);
                if (status.isOK()) {
                    status = secondsValidator.validate(secondsText);
                    if (!status.isOK()) {
                        errorMessage = validationMessageBuilder.
                                buildValidationMessage("invalidSecond",
                                        null, new String[]{secondsText});
                    }
                } else {
                    errorMessage = validationMessageBuilder.
                            buildValidationMessage("invalidMinute",
                                    null, new String[]{minutesText});
                }
            } else {
                errorMessage = validationMessageBuilder.
                        buildValidationMessage("invalidHour",
                                null, new String[]{hoursText});
            }
            if (status.isOK() && !(isNonZero(hoursText) ||
                    isNonZero(minutesText) ||
                    isNonZero(secondsText))) {
                errorMessage = validationMessageBuilder.
                        buildValidationMessage("zeroTime", null, null);
            }
            if (errorMessage != null) {
                status =new ValidationStatus(ValidationStatus.ERROR, errorMessage);
            }
        }
        return status;
    }
View Full Code Here

     * @return true if the page is valid; false otherwise
     */
    private boolean validatePage() {
        boolean isOK = true;
        final String policyName = policyText.getText();
        ValidationStatus status = POLICY_NAME_VALIDATOR.validate(
                policyName, messageBuilder);

        if (status.isOK()) {
            // Policy name has passed the schema constraints so now check for
            // duplicates.
            if (deviceRAM.policyExists(policyName)) {
                String errorMsg =
                        DUPLICATE_POLICY_FORMAT.format(new Object[]{policyName});
                setErrorMessage(errorMsg);
                isOK = false;
            } else {
                // Clear the error message
                setErrorMessage(null);
                // set the description back to the default
                setMessage(PAGE_DESCRIPTION);
            }
        } else if (status.getSeverity() == ValidationStatus.INFO) {
            setMessage(status.getMessage());
            isOK = false;
        } else if (status.getSeverity() == ValidationStatus.ERROR) {
            // Set the error message
            setErrorMessage(status.getMessage());
            isOK = false;
        }

        return isOK;
    }
View Full Code Here

        ValidationMessageBuilder builder = new ValidationMessageBuilder(BUNDLE,
                MESSAGE_KEY_MAPPINGS, new Object[]{resource.getName()});

        // Perform the validation and store the result of the validation.
        ValidationStatus status =
                policyNameValidator.validate(resource.getName(), builder);

        if (status.getSeverity() == ValidationStatus.ERROR) {
            valid = false;
        } else if (status.getSeverity() == ValidationStatus.WARNING) {
            valid = false;
        }
        if (!valid) {
            try {
                IMarker marker = resource.createMarker(IMarker.PROBLEM);
                marker.setAttribute(IMarker.MESSAGE, status.getMessage());
                marker.setAttribute(IMarker.SEVERITY, IMarker.SEVERITY_ERROR);
            } catch (CoreException e) {
                e.printStackTrace();
                EclipseCommonPlugin.handleError(ControlsPlugin.getDefault(), e);
            }
View Full Code Here

     */
    protected boolean validatePage() {
        // check cached variable
        if (!isValidated) {
            String[] attributeNames = attrsComposite.getAttributeNames();
            ValidationStatus status = null;
            boolean valid = true;
            for (int i = 0; i < attributeNames.length && valid; i++) {
                String attrName = attributeNames[i];
                String value = attrsComposite.getAttributeValue(attrName);
                Validator validator =
                        attrsComposite.getAttributeValidator(attrName);
                if (value != null && validator != null) {
                    status = validateAttribute(attrName, value, validator);
                    valid = status.getSeverity() == IStatus.OK;
                }
            }

            if (valid) {
                setErrorMessage(null);
                setMessage(null);
            } else {
                // status should be IStatus.ERROR since there should never be
                // another type if we are here i.e. INFOs are not expected.
                setErrorMessage(status.getMessage());
            }
            isValidated = valid;
        }
        return isValidated;
    }
View Full Code Here

        supplementaryFormatArgs[0] = localName;
        ValidationMessageBuilder messageBuilder =
                new ValidationMessageBuilder(WizardMessages.
                getResourceBundle(), MESSAGE_KEY_MAPPINGS,
                        supplementaryFormatArgs);
        ValidationStatus status = validator.validate(value, messageBuilder);

        return status;
    }
View Full Code Here

        return valid;
    }

    // javadoc inherited
    public ValidationStatus validate() {
        ValidationStatus status = null;
        if (!isValueValid()) {
            formatArgs[0] = getValue();
            if (messageFormat == null) {
                messageFormat = new MessageFormat(pattern);
            }
            status = new ValidationStatus(ValidationStatus.WARNING,
                    messageFormat.format(formatArgs));
        }
        return status;
    }
View Full Code Here

        if (!resourceGroup.areAllValuesValid()) {
            setErrorMessage(resourceGroup.getProblemMessage());
            valid = false;
        } else {
            ValidationStatus status =
                    VALIDATOR.validate(getPolicyName(), messageBuilder);

            if (status.getSeverity() == Status.ERROR) {
                setErrorMessage(status.getMessage());
                valid = false;
            } else if (status.getSeverity() == Status.INFO) {
                setErrorMessage(null);
                setMessage(status.getMessage());
                valid = false;
            } else {
                // Attempt to reduce garbage by using a StringBuffer and storing
                // the result of  the toString in a variable. Also the check for
                // policy existence is performed after other validation succeeds
View Full Code Here

TOP

Related Classes of com.volantis.mcs.eclipse.validation.ValidationStatus

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.