Package com.volantis.mcs.eclipse.validation

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


                final IFile file = ResourcesPlugin.getWorkspace().getRoot().
                        getFile(filePath);

                // Ensure that the specified file can be written to.
                ValidationStatus status = ValidationUtils.checkFile(file.
                        getLocation().toFile().getAbsolutePath(),
                        ValidationUtils.FILE_CAN_WRITE);

                if (!status.isOK()) {
                    String title = EditorMessages.getString("Editor.error." +
                            "saveas.problems.title");
                    ErrorDialog.openError(shell, title, null, status);
                } else {
                    SaveCommandFactory factory =
View Full Code Here


        device = null;
        fallbackDevice = null;
        updateValues();

        // Default status is valid.
        ValidationStatus status = VALID_STATUS;
        String supplementaryArgs[] = {
            DevicesMessages.getString(RESOURCE_PREFIX + "newDevice.text")
        };
        validationMessageBuilder.setSupplementaryFormatArgs(supplementaryArgs);

        status = DEVICE_NAME_VALIDATOR.validate(getDevice(),
                validationMessageBuilder);

        // Ensure the fallback device has been selected.
        if ((status.getSeverity() == Status.OK) &&
                deviceFallbackTree.getSelectionCount() <= 0) {
            String message = DevicesMessages.getString(RESOURCE_PREFIX +
                    "error.fallbackDeviceIsMandatory");
            status = new ValidationStatus(4, message);
        }

        // If the status is OK then check to see if we have any duplicate names.
        if (status.getSeverity() == Status.OK) {
            visitor.reset();
            walker.visit(root, visitor);
            if (visitor.isDuplicate()) {
                String message = DevicesMessages.getString(RESOURCE_PREFIX +
                        "error.duplicateDeviceName");
                String args[] = {
                    getDevice()
                };
                MessageFormat format = new MessageFormat(message);
                message = format.format(args);
                status = new ValidationStatus(Status.ERROR, message);
            }
        }

        if (status.getSeverity() == Status.ERROR) {
            setErrorMessage(status.getMessage());
        } else if (status.getSeverity() == Status.WARNING) {
            setErrorMessage(null);
            setMessage(status.getMessage());
        } else {
            setErrorMessage(null);
            if(context.isAdminProject()) {
                setMessage(DevicesMessages.getString(RESOURCE_PREFIX +
                            "info.admin"));
            } else {
                setMessage(DevicesMessages.getString(RESOURCE_PREFIX +
                            "info.custom"));
            }
        }
        valid = status.getSeverity() == Status.OK;
        return valid;
    }
View Full Code Here

    /**
     * Validates the selector and list items. Error messages from
     * the selector validation take precedence.
     */
    protected void validateDialog() {
        ValidationStatus status = listBuilder.validate();
        if (status.isOK()) {
            //Clear error message
            setErrorMessage(null);
        } else if (status.getSeverity() == ValidationStatus.ERROR) {
            setErrorMessage(status.getMessage());
        }
    }
View Full Code Here

     * @todo If this logic changes, you may also need to change the
     * validatePage method in MCSProjectproperties.
     */
    public boolean validatePage() {
        boolean valid = true;
        ValidationStatus status = null;

        if (origPolicySource != null &&
                !origPolicySource.equals(policySource.getText())) {
            valid = false;
            String message = WizardMessages.getString(RESOURCE_PREFIX +
                    "policySourceConflict.message");
            status = new ValidationStatus(Status.ERROR, message);
        } else {
            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(), DialogPage.INFORMATION);
        } 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);
            }
            if (valid) {
View Full Code Here

     * Validates the ValidatedTextControl and list in that order. Validation
     * stops when the first error is encountered.
     * @return the validation status
     */
    public ValidationStatus validate() {
        ValidationStatus status = textControl.validate();
        if (status.isOK() && listValidator != null) {
            status = validateListItems();
        }
        return status;
    }
View Full Code Here

    /**
     * Validates the items in the list. Validation stops at the first error.
     * @return the validation status
     */
    private ValidationStatus validateListItems() {
        ValidationStatus status = OK_STATUS;
        String[] items = list.getItems();
        for (int i = 0; i < items.length && status.isOK(); i++) {
            status = listValidator.validate(items[i]);
        }
        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

     * @return the independent validator to use
     */
    private static IndependentValidator createTimeListValidator() {
        Validator validator = new Validator() {
            private final ValidationStatus OK_STATUS =
                    new ValidationStatus(ValidationStatus.OK, "");

            public ValidationStatus validate(Object object,
                                             ValidationMessageBuilder builder) {
                ValidationStatus status = OK_STATUS;
                String item = (String) object;
                StringReader reader = new StringReader(item);
                String errorMessage = null;
                TimerParser timerParser = new TimerParser(reader);
                try {
                    timerParser.parse();
                } catch (Throwable e) {
                    errorMessage = builder.
                            buildValidationMessage("invalidTime",
                                                   null, new String[]{item});
                }
                if ("00:00:00".equals(item)) {
                    errorMessage = builder.
                            buildValidationMessage("zeroTime",
                                                   null, null);
                }
                if (errorMessage != null) {
                    status = new ValidationStatus(ValidationStatus.ERROR,
                                                  errorMessage);
                }
                return status;
            }
        };
View Full Code Here

    /**
     * Validates the selector and list items. Error messages from the selector
     * validation take precedence.
     */
    private void validateDialog() {
        ValidationStatus status = OK_STATUS;
        for (int i = 0; status.isOK() && (i < currentSelection.length); i++) {
            status = charsetValidator.validate(currentSelection[i],
                                               messageBuilder);
        }
        if (status.isOK()) {
            // Doesn't matter if is row or columnStyleClasses attribute as
            // long as the validation for its value happens we're OK.
            styleClassElement.setAttribute("rowStyleClasses", getStyles());

            validator.validate(styleClassElement);

            // if the element is invalid then we need to return an ERROR
            // validation status.
            if (errorReporter.getErrorMessage() != null) {
                status = new ValidationStatus(ValidationStatus.ERROR,
                                              errorReporter.getErrorMessage());
            }
        }
        if (status.isOK()) {
            // Clear error message
            setErrorMessage(null);
        } else if (status.getSeverity() == ValidationStatus.ERROR) {
            setErrorMessage(status.getMessage());
        }
    }
View Full Code Here

     * Validates the selector and list items. Error messages from
     * the selector validation take precedence.
     */
    protected void validateDialog() {
        if (validator != null) {
            ValidationStatus status = validator.validate(listBuilder.getItems());
            if (status.isOK()) {
                //Clear error message
                setErrorMessage(null);
            } else if (status.getSeverity() == ValidationStatus.ERROR) {
                setErrorMessage(status.getMessage());
            }
        }
    }
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.