Java Code Examples for org.eclipse.core.databinding.validation.ValidationStatus#warning()
The following examples show how to use
org.eclipse.core.databinding.validation.ValidationStatus#warning() .
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: AggregationAndCompositionValidator.java From bonita-studio with GNU General Public License v2.0 | 6 votes |
@Override public IStatus validate(BusinessObject businessObject) { boolean usedInAggregation = modelObservable.getValue().getPackages().stream() .map(Package::getBusinessObjects) .flatMap(Collection::stream) .anyMatch(aBo -> areInRelation(aBo, businessObject, RelationType.AGGREGATION)); boolean usedInComposition = modelObservable.getValue().getPackages().stream() .map(Package::getBusinessObjects) .flatMap(Collection::stream) .anyMatch(aBo -> areInRelation(aBo, businessObject, RelationType.COMPOSITION)); return usedInAggregation && usedInComposition ? ValidationStatus .warning(String.format(Messages.boUsedInCompositionAndAggregation, businessObject.getSimpleName())) : ValidationStatus.ok(); }
Example 2
Source File: BusinessDataSelectedValidator.java From bonita-studio with GNU General Public License v2.0 | 6 votes |
@Override protected IStatus validate() { final Object selectedData = selectedDataObservable.getValue(); if (selectedData != null && selectedData instanceof BusinessObjectData) { final BusinessObjectData value = (BusinessObjectData) selectedData; return toBusinessObject(value).isPresent() ? Status.OK_STATUS : ValidationStatus.error(Messages.invalidBusinessDataSelected); } else { if (availableBusinessData.isEmpty()) { return Boolean.TRUE.equals(selectionTypeObservable.getValue()) ? ValidationStatus.warning(Messages.warningAddFromData_noDataAvailable) : Status.OK_STATUS; } else { return Boolean.TRUE.equals(selectionTypeObservable.getValue()) ? ValidationStatus.warning(Messages.warningAddFromData_noDataSelected) : Status.OK_STATUS; } } }
Example 3
Source File: SelectDataWizardPage.java From bonita-studio with GNU General Public License v2.0 | 6 votes |
protected IValidator createDefaultValueAlreadyDefinedValidator() { return new IValidator() { @Override public IStatus validate(final Object value) { if (value instanceof Document && contract.eContainer() instanceof Pool) { final Document document = (Document) value; return DocumentType.NONE.equals(document.getDocumentType()) ? Status.OK_STATUS : ValidationStatus .warning(Messages.bind(Messages.defaultValueAlreadyDefinedWarning, document.getName())); } return Status.OK_STATUS; } }; }
Example 4
Source File: EmptySelectionMultivalidator.java From bonita-studio with GNU General Public License v2.0 | 6 votes |
@Override protected IStatus validate() { if (selectedDataObservable.getValue() instanceof BusinessObjectData) { if (checkedElements.isEmpty()) { return ValidationStatus.error(Messages.atLeastOneAttributeShouldBeSelectedError); } else if(editModeObservable.getValue() == EditMode.CREATE){ final StringBuilder sb = new StringBuilder(); validateMandatoryFieldsNotSelected(sb, mappings, checkedElements); if (sb.length() > 0) { int lastIndexOf = sb.lastIndexOf(","); if (sb.indexOf(",") == lastIndexOf) { sb.replace(lastIndexOf, lastIndexOf + 1, ""); } final String message = container instanceof Task ? Messages.mandatoryFieldsNotSelectedStepWarning : Messages.mandatoryFieldsNotSelectedWarning; return ValidationStatus.warning(Messages.bind(message, sb.toString())); } } } return ValidationStatus.ok(); }
Example 5
Source File: ImportBosArchiveOperation.java From bonita-studio with GNU General Public License v2.0 | 6 votes |
protected void validateAllAfterImport(final IProgressMonitor monitor, ImportBosArchiveStatusBuilder statusBuilder) { if (progressDialog != null) { progressDialog.canBeSkipped(); } if (validate) { final List<BosImporterStatusProvider> validators = getValidators(); for (final BosImporterStatusProvider validator : validators) { try { validator.buildStatus(this, statusBuilder, monitor); } catch (final ValidationException e) { statusBuilder .addStatus(new Status(IStatus.ERROR, BosArchiveImporterPlugin.PLUGIN_ID, "Validation error", e)); } } } validationStatus = monitor.isCanceled() ? ValidationStatus.warning(org.bonitasoft.studio.importer.bos.i18n.Messages.skippedValidationMessage) : statusBuilder .done(); }
Example 6
Source File: OperationReturnTypesValidator.java From bonita-studio with GNU General Public License v2.0 | 6 votes |
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 7
Source File: NamespaceXMLFileValidator.java From bonita-studio with GNU General Public License v2.0 | 6 votes |
@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 8
Source File: DeployApplicationDescriptorOperation.java From bonita-studio with GNU General Public License v2.0 | 6 votes |
private Function<? super ImportError, ? extends IStatus> errorToStatus(String applicationDisplayName) { return s -> { switch (s.getType()) { case PROFILE: return ValidationStatus .warning(String.format(Messages.profileNotFound, applicationDisplayName, s.getName())); case LAYOUT: return ValidationStatus .warning(String.format(Messages.layoutNotFound, applicationDisplayName, s.getName())); case THEME: return ValidationStatus .warning(String.format(Messages.themeNotFound, applicationDisplayName, s.getName())); case APPLICATION_PAGE: return ValidationStatus.warning( String.format(Messages.appPageTokenNotFound, applicationDisplayName, s.getName())); case PAGE: return ValidationStatus.warning( String.format(Messages.applicationPageNotFound, applicationDisplayName, s.getName())); default: return ValidationStatus.error(s.getName()); } }; }
Example 9
Source File: OperationReturnTypesValidator.java From bonita-studio with GNU General Public License v2.0 | 5 votes |
protected IStatus validateXPathOperation(final Expression expression, final String expressionName, final Operation operation) { if (!ExpressionConstants.VARIABLE_TYPE.equals(dataExpression.getType())) { return ValidationStatus.error(Messages.bind(Messages.incompatibleExpressionTypeForOperator, typeLabelProvider.getText(dataExpression.getType()), operatorLabelProvider.getText(operation.getOperator()))); } if (dataExpression != null && dataExpression.getContent() != null && !dataExpression.getContent().isEmpty()) { if (!operation.getOperator().getInputTypes().isEmpty()) { final String typeName = operation.getOperator().getInputTypes().get(0); try { final Class<?> dataReturnTypeClass = Class.forName(typeName); final Class<?> expressionReturnTypeClass = Class.forName(expression.getReturnType()); if (!dataReturnTypeClass.isAssignableFrom(expressionReturnTypeClass)) { return ValidationStatus.warning(Messages.bind( Messages.invalidReturnTypeBetween, dataExpression.getName(), expressionName)); } } catch (final Exception e) { if (!operation.getOperator().getInputTypes().get(0).equals(expression.getReturnType())) { return ValidationStatus.warning(Messages.bind( Messages.invalidReturnTypeFor, expressionName)); } } } } return ValidationStatus.ok(); }
Example 10
Source File: OperationReturnTypesValidator.java From bonita-studio with GNU General Public License v2.0 | 5 votes |
protected IStatus validateJavaMethodOperation(final Expression expression, final String expressionName, final Operation operation) { if (!ExpressionConstants.VARIABLE_TYPE.equals(dataExpression.getType()) || !(!dataExpression.getReferencedElements().isEmpty() && dataExpression.getReferencedElements().get(0) instanceof JavaObjectData)) { return ValidationStatus.error(Messages.bind(Messages.incompatibleExpressionTypeForOperator, typeLabelProvider.getText(dataExpression.getType()), operatorLabelProvider.getText(operation.getOperator()))); } if (!operation.getOperator().getInputTypes().isEmpty()) { final String typeName = operation.getOperator().getInputTypes().get(0); try { final Class<?> dataReturnTypeClass = Class.forName(typeName); final Class<?> expressionReturnTypeClass = Class.forName(expression.getReturnType()); if (!dataReturnTypeClass.isAssignableFrom(expressionReturnTypeClass)) { return ValidationStatus.warning(Messages.bind( Messages.invalidReturnTypeBetween, dataExpression.getName(), expressionName)); } } catch (final Exception e) { if (!operation.getOperator().getInputTypes().get(0).equals(expression.getReturnType())) { return ValidationStatus.warning(Messages.bind( Messages.invalidReturnTypeFor, expressionName)); } } } if (isInvalidQueryExpression(operation)) { return ValidationStatus.error(Messages.cannotStoreBusinessObjectInProcessVariable); } return ValidationStatus.ok(); }
Example 11
Source File: ImportFileStoreConflictsValidator.java From bonita-studio with GNU General Public License v2.0 | 5 votes |
@Override protected IStatus doValidate(Optional<String> value) { if (value.isPresent()) { final File file = new File(value.get()); return repositoryStore.getChild(file.getName(), true) != null ? ValidationStatus.warning(Messages.importConflictWarning) : ValidationStatus.ok(); } return ValidationStatus.ok(); }
Example 12
Source File: RunConfigurationWizardPage.java From bonita-studio with GNU General Public License v2.0 | 5 votes |
protected IValidator<String> createUserNameValidator() { return name -> name == null || name.isEmpty() ? ValidationStatus.warning(Messages.usernameIsMissingForConfiguration) : users != null && !users.contains(name) ? ValidationStatus.error(String.format(Messages.unknownUser, name)) : ValidationStatus.ok(); }
Example 13
Source File: MessageContentExpressionValidator.java From bonita-studio with GNU General Public License v2.0 | 5 votes |
@Override public IStatus validate(final Object value) { if ( messageEvent !=null){ final String expr = value.toString(); if(expr == null || expr.isEmpty()){ return ValidationStatus.ok(); } final MessageFlow incomingMessag = messageEvent.getIncomingMessag(); TableExpression throwMessageContent=null; if(incomingMessag != null){ final Message message = ModelHelper.findEvent(messageEvent, incomingMessag.getName()); if(message != null){ throwMessageContent = message.getMessageContent(); boolean isExisting =false; for (final ListExpression row : throwMessageContent.getExpressions()) { final List<org.bonitasoft.studio.model.expression.Expression> col = row.getExpressions() ; if (col.size()==2){ if (expr.equals(col.get(0).getName())){ isExisting =true; break; } } } if (!isExisting){ return ValidationStatus.warning(Messages.bind(Messages.messageContentIdExistenceWarning,expr,message.getName())); } } } } else { return ValidationStatus.warning(Messages.NoIncomingMessageWarning); } return ValidationStatus.OK_STATUS; }
Example 14
Source File: BonitaStatusCodeAggregator.java From bonita-studio with GNU General Public License v2.0 | 5 votes |
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 15
Source File: TransientDataValidator.java From bonita-studio with GNU General Public License v2.0 | 5 votes |
@Override public IStatus validate(final Object value) { if (!inputExpression.getReferencedElements().isEmpty()) { final EObject data = inputExpression.getReferencedElements().get(0); if (data instanceof Data) { if (((Data) data).isTransient()) { return ValidationStatus.warning(Messages.transientDataWarning); } } } return ValidationStatus.ok(); }
Example 16
Source File: ConstraintExpressionEditorValidator.java From bonita-studio with GNU General Public License v2.0 | 5 votes |
@Override protected IStatus validate() { final String text = (String) expressionObservable.getValue(); if (Strings.isNullOrEmpty(text)) { return ValidationStatus.error(Messages.emptyExpressionContent); } if (dependenciesObservable.isEmpty()) { return ValidationStatus.warning(Messages.noContractInputReferencedInExpression); } return ValidationStatus.ok(); }
Example 17
Source File: StringValidator.java From bonita-studio with GNU General Public License v2.0 | 5 votes |
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 18
Source File: AvailableDataValidator.java From bonita-studio with GNU General Public License v2.0 | 5 votes |
@Override protected IStatus validate() { if (availableBusinessData.isEmpty() && availableDocuments.isEmpty()) { return ValidationStatus.warning(Messages.warningAddFromData_noDataAvailable); } final Object selectedData = selectedDataObservable.getValue(); if (selectedData != null && selectedData instanceof BusinessObjectData) { final BusinessObjectData value = (BusinessObjectData) selectedData; return toBusinessObject(value).isPresent() ? Status.OK_STATUS : ValidationStatus.error(Messages.invalidBusinessDataSelected); } return Status.OK_STATUS; }
Example 19
Source File: OperationReturnTypesValidator.java From bonita-studio with GNU General Public License v2.0 | 4 votes |
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 20
Source File: FieldNameValidator.java From bonita-studio with GNU General Public License v2.0 | 4 votes |
private IStatus validateFirstCharacter(String name) { return !Objects.equals(name.substring(0, 1), name.substring(0, 1).toLowerCase()) ? ValidationStatus.warning(Messages.fieldNameShouldStartsWithLowercase) : ValidationStatus.ok(); }