Java Code Examples for org.eclipse.core.databinding.validation.ValidationStatus#info()

The following examples show how to use org.eclipse.core.databinding.validation.ValidationStatus#info() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AppEngineDeployPreferencesPanel.java    From google-cloud-eclipse with Apache License 2.0 6 votes vote down vote up
@Override
protected IStatus validate() {
  // this access is recorded and ensures that changes are tracked, don't move it inside the if
  Collection<?> projects = (Collection<?>) projectInput.getValue();
  // this access is recorded and ensures that changes are tracked, don't move it inside the if
  Object selectedProject = projectSelection.getValue();
  if (projects.isEmpty()) {
    if (requireValues) {
      return ValidationStatus.error(Messages.getString("projectselector.no.projects")); //$NON-NLS-1$
    } else {
      return ValidationStatus.info(Messages.getString("projectselector.no.projects")); //$NON-NLS-1$
    }
  }
  if (requireValues) {
    if (selectedProject == null) {
      return ValidationStatus.error(Messages.getString("projectselector.project.not.selected")); //$NON-NLS-1$
    }
  }
  if (selectedProject != null && project != null) {
    return ValidationStatus.info(Messages.getString("deploy.project.summary", project.getName(),
        ((GcpProject) selectedProject).getName()));
  }
  return ValidationStatus.ok();
}
 
Example 2
Source File: OrganizationFileStore.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
@Override
public IStatus deploy(APISession session, Map<String, Object> options, IProgressMonitor monitor) {
    final String activeOrganization = activeOrganizationProvider.getActiveOrganization();
    Organization organization = getContent();
    PublishOrganizationOperation operation = Objects.equals(organization.getName(), activeOrganization)
            ? new UpdateOrganizationOperation(organization)
            : new CleanPublishOrganizationOperation(organization);
    if(!PlatformUtil.isACommunityBonitaProduct()) {
        operation.doNotApplyAllProfileToUsers();
    }
    operation.setSession(session);
    try {
        operation.run(monitor);
        String defaultUsername = String.valueOf(options.get(DeployOptions.DEFAULT_USERNAME));
        updateDefaultUserPreference(organization, defaultUsername);
        return ValidationStatus.info(String.format(org.bonitasoft.studio.actors.i18n.Messages.organizationDeployed,
                organization.getName()));
    } catch (InvocationTargetException | InterruptedException e) {
        BonitaStudioLog.error(e);
        return new Status(IStatus.ERROR, ActorsPlugin.PLUGIN_ID, "An error occured while depoying the Organization", e);
    }
}
 
Example 3
Source File: NamespaceXMLFileValidator.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
@Override
public IStatus validate(Object value) {
    try {
        File file = new File((String) value);
        DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
        dbf.setNamespaceAware(true);
        Document document = dbf.newDocumentBuilder().parse(file);
        Element documentElement = document.getDocumentElement();
        if (!isValid(documentElement)) {
            switch (severity) {
                case IStatus.ERROR:
                    return ValidationStatus.error(message);
                case IStatus.WARNING:
                    return ValidationStatus.warning(message);
                default:
                    return ValidationStatus.info(message);
            }
        }
    } catch (SAXException | IOException | ParserConfigurationException e) {
        throw new RuntimeException(e);
    }

    return ValidationStatus.ok();
}
 
Example 4
Source File: OperationReturnTypesValidator.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
protected IStatus validateSetDocumentOperation(final Expression expression, final Operation operation) {
    final boolean isTask = operation.eContainer() instanceof Task;
    final Expression storageExpression = operation.getLeftOperand();
    if (!String.class.getName().equals(storageExpression.getReturnType())) {
        return ValidationStatus.error(Messages.bind(Messages.incompatibleStorageReturnType, storageExpression.getName(),
                operatorLabelProvider.getText(operation.getOperator())));
    }
    if (expression != null && expression.getContent() != null && !expression.getContent().isEmpty()) {
        final String typeName = storageExpression.getReturnType();
        final String actionExpressionReturnType = expression.getReturnType();
        if (!((DocumentValue.class.getName().equals(actionExpressionReturnType)
                || FileInputValue.class.getName().equals(actionExpressionReturnType))
                && typeName.equals(String.class.getName()))) {
            return isTask
                    ? ValidationStatus
                            .warning(Messages.incompatibleType + " " + Messages.messageOperationWithDocumentInTask)
                    : ValidationStatus
                            .warning(Messages.incompatibleType + " " + Messages.messageOperationWithDocumentInForm);
        } else {
            return ValidationStatus.ok();
        }
    } else {
        return isTask ? ValidationStatus.info(Messages.messageOperationWithDocumentInTask) : ValidationStatus
                .info(Messages.messageOperationWithDocumentInForm);
    }
}
 
Example 5
Source File: BusinessObjectModelFileStore.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
@Override
public IStatus deploy(APISession session, Map<String, Object> options, IProgressMonitor monitor) {
    GenerateBDMOperation generateBDMOperation = new GenerateBDMOperation(this);
    Object cleanBDM = options.containsKey(DeployOptions.CLEAN_BDM) ? options.get(DeployOptions.CLEAN_BDM) : false;
    if (!(cleanBDM instanceof Boolean)) {
        return new Status(IStatus.ERROR,
                BusinessObjectPlugin.PLUGIN_ID,
                String.format("Invalid option type for %s. Expected a Boolean value but found a %s",
                        DeployOptions.CLEAN_BDM, cleanBDM.getClass()));
    }
    DeployBDMOperation deployBDMOperation = new DeployBDMOperation(this, (boolean) cleanBDM).reuseSession(session);
    try {
        generateBDMOperation.run(monitor);
        deployBDMOperation.run(monitor);
    } catch (InvocationTargetException | InterruptedException e) {
        BonitaStudioLog.error(e);
        return new Status(IStatus.ERROR, BusinessObjectPlugin.PLUGIN_ID, "An error occured while depoying the BDM",
                e);
    }
    updateDeployRequiredState();
    return ValidationStatus.info(Messages.businessDataModelDeployed);
}
 
Example 6
Source File: StringValidator.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
protected IStatus createFailureStatus(String message) {
    switch (severity) {
        case IStatus.WARNING:
            return ValidationStatus.warning(message);
        case IStatus.CANCEL:
            return ValidationStatus.cancel(message);
        case IStatus.INFO:
            return ValidationStatus.info(message);
        case IStatus.ERROR:
        default:
            return ValidationStatus.error(message);
    }
}
 
Example 7
Source File: BonitaStatusCodeAggregator.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
public IStatus createAggregatedStatus() {
    String message = occurrence > 1
            ? String.format("%s (%s %s)", status.getMessage(), occurrence, Messages.occurrences)
            : status.getMessage();
    switch (status.getSeverity()) {
        case IStatus.OK:
        case IStatus.INFO:
            return ValidationStatus.info(message);
        case IStatus.WARNING:
            return ValidationStatus.warning(message);
        default:
            return ValidationStatus.error(message);
    }
}
 
Example 8
Source File: ImportArchiveModel.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
private IStatus createDefaultStatus(BosArchive bosArchive) {
    StringBuilder message = new StringBuilder(String.format("%s %s (%s)",
            Messages.bosArchiveName,
            bosArchive.getFileName(),
            bosArchive.getVersion()));
    return ValidationStatus.info(message.toString());
}
 
Example 9
Source File: OperationReturnTypesValidator.java    From bonita-studio with GNU General Public License v2.0 4 votes vote down vote up
protected IStatus validateSetListDocumentOperation(final Expression expression, final Operation operation) {
    final boolean isTask = operation.eContainer() instanceof Task;
    final String listClass = List.class.getName();
    final Expression storageExpression = operation.getLeftOperand();
    if (!listClass.equals(storageExpression.getReturnType())) {
        return ValidationStatus.error(Messages.bind(Messages.incompatibleStorageReturnType, storageExpression.getName(),
                operatorLabelProvider.getText(operation.getOperator())));
    }

    if (expression != null && expression.getContent() != null && !expression.getContent().isEmpty()) {
        final String dataReturnType = storageExpression.getReturnType();
        final String returnType = expression.getReturnType();
        try {
            final boolean isListType = listClass.equals(returnType)
                    || List.class.isAssignableFrom(Class.forName(returnType));
            if (!isListType && listClass.equals(dataReturnType)) {

                if (isTask) {
                    return ValidationStatus
                            .warning(Messages.incompatibleType + " " + Messages.messageOperationWithListDocumentInTask);
                } else {
                    if (PlatformUtil.isACommunityBonitaProduct()) {
                        return ValidationStatus.warning(Messages.incompatibleType + " "
                                + Messages.messageOperationWithListDocumentInFormInCommunity);
                    } else {
                        return ValidationStatus.warning(
                                Messages.incompatibleType + " " + Messages.messageOperationWithListDocumentInForm);
                    }
                }
            } else {
                return ValidationStatus.ok();
            }
        } catch (final ClassNotFoundException e) {
            return ValidationStatus.warning(Messages.bind(
                    Messages.invalidReturnTypeFor,
                    expression.getName()));
        }

    } else {
        if (isTask) {
            return ValidationStatus.info(Messages.messageOperationWithListDocumentInTask);
        } else {
            return ValidationStatus.info(Messages.messageOperationWithListDocumentInForm);
        }
    }
}
 
Example 10
Source File: ExpressionViewer.java    From bonita-studio with GNU General Public License v2.0 4 votes vote down vote up
public void setMessage(String message) {
    this.defaultStatus = ValidationStatus.info(message);
    this.status = defaultStatus;
    refreshMessageDecoration();
}
 
Example 11
Source File: ExpressionViewer.java    From bonita-studio with GNU General Public License v2.0 4 votes vote down vote up
public void resetStatus() {
    this.status = ValidationStatus.info("");
}