Java Code Examples for org.eclipse.core.databinding.validation.ValidationStatus#error()
The following examples show how to use
org.eclipse.core.databinding.validation.ValidationStatus#error() .
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: ProjectVersionValidator.java From google-cloud-eclipse with Apache License 2.0 | 6 votes |
/** * @param input the prospective version string * @return OK status if valid, or an ERROR status with a description why invalid */ @Override public IStatus validate(Object input) { // https://cloud.google.com/appengine/docs/java/config/appref // "The version specifier can contain lowercase letters, digits, and hyphens. // It cannot begin with the prefix ah- and the names default and latest are // reserved and cannot be used." if (!(input instanceof String)) { return ValidationStatus.error(Messages.getString("version.invalid")); //$NON-NLS-1$ } String value = (String) input; if (value.isEmpty()) { return ValidationStatus.ok(); } else if (APPENGINE_PROJECT_VERSION_PATTERN.matcher(value).matches()) { if (value.startsWith(RESERVED_PREFIX) || RESERVED_VALUES.contains(value)) { return ValidationStatus.error(Messages.getString("version.reserved")); //$NON-NLS-1$ } return ValidationStatus.ok(); } else { return ValidationStatus.error(Messages.getString("version.invalid")); //$NON-NLS-1$ } }
Example 2
Source File: BusinessObjectNameValidator.java From bonita-studio with GNU General Public License v2.0 | 6 votes |
@Override public IStatus validate(BusinessObject businessObject) { String name = businessObject.getSimpleName(); if (name == null || name.isEmpty()) { return ValidationStatus.error(Messages.boNameRequired); } MultiStatus status = new MultiStatus(BusinessObjectPlugin.PLUGIN_ID, 0, "", null); status.add(validateNameLength(name)); status.add(validateUniqueness((businessObject), name)); status.add(validateWhiteSpaceCharacter(name)); status.add(validateUnderscoreCharacter(name)); status.add(validateSqlValidity(name)); status.add(validateJavaConvention(name)); return status; }
Example 3
Source File: DiagramUnicityValidator.java From bonita-studio with GNU General Public License v2.0 | 6 votes |
@Override protected IStatus validate() { final String name = (String) nameObservable.getValue(); final String version = (String) versionObservable.getValue(); final String newDiagramFilename = NamingUtils.toDiagramFilename(name, version); if (existingFileNames.contains(newDiagramFilename) && nameOrVersionHasChanged(name, version)) { return ValidationStatus.error(Messages.bind(Messages.diagramAlreadyExists, Messages.diagram.toLowerCase())); } for (final String existingFileName : existingFileNames) { if (!NamingUtils.toDiagramFilename(diagram.getName(), diagram.getVersion()).equals(newDiagramFilename) && existingFileName.toLowerCase().equals(newDiagramFilename.toLowerCase())) { return ValidationStatus.error(Messages.bind(Messages.differentCaseSameNameError, Messages.diagram.toLowerCase())); } } return ValidationStatus.ok(); }
Example 4
Source File: ConverterViewModel.java From translationstudio8 with GNU General Public License v2.0 | 6 votes |
/** * 验证 XLIFF 文件中的 file 节点 * @param handler * XLFHandler 实例 * @param xliffPath * XLIFF 文件路径 * @param type * 文件类型,(Converter.getType() 的值,XLIIF 文件 file 节点的 datatype 属性值) * @return ; */ private IStatus validateFileNodeInXliff(XLFHandler handler, String xliffPath, String type) { handler.reset(); // 重置,以便重新使用。 Map<String, Object> resultMap = handler.openFile(xliffPath); if (resultMap == null || Constant.RETURNVALUE_RESULT_SUCCESSFUL != (Integer) resultMap.get(Constant.RETURNVALUE_RESULT)) { // 打开文件失败。 return ValidationStatus.error(Messages.getString("model.ConverterViewModel.msg4")); //$NON-NLS-1$ } try { int fileCount = handler.getFileCountInXliff(xliffPath); if (fileCount < 1) { // 不存在 file 节点。提示为不合法的 XLIFF return ValidationStatus.error(Messages.getString("model.ConverterViewModel.msg4")); //$NON-NLS-1$ } else if (fileCount > 1) { // 多个 file 节点,提示分割。 if (ConverterUtils.isOpenOfficeOrMSOffice2007(type)) { // 验证源文件是 OpenOffice 和 MSOffice 2007 的XLIFF 的 file 节点信息是否完整 return validateOpenOfficeOrMSOffice2007(handler, xliffPath); } return ValidationStatus.error(Messages.getString("model.ConverterViewModel.msg5")); //$NON-NLS-1$ } else { // 只有一个 file 节点 return Status.OK_STATUS; } } catch (Exception e) { // 当前打开了多个 XLIFF 文件,参看 XLFHandler.getFileCountInXliff() 方法 return ValidationStatus.error(Messages.getString("model.ConverterViewModel.msg5")); //$NON-NLS-1$ } }
Example 5
Source File: ExpressionViewerValidator.java From bonita-studio with GNU General Public License v2.0 | 6 votes |
protected IStatus updateMessage(final IStatus status) { String message = status.getMessage(); if (!status.isOK()) { if (status instanceof MultiStatus) { final StringBuilder sb = new StringBuilder(); for (final IStatus statusChild : status.getChildren()) { sb.append(statusChild.getMessage()); sb.append("\n"); } if (sb.length() > 0) { sb.delete(sb.length() - 1, sb.length()); } message = sb.toString(); return ValidationStatus.error(message); } } return status; }
Example 6
Source File: ProcessesNameVersionUnicityValidator.java From bonita-studio with GNU General Public License v2.0 | 6 votes |
@Override protected IStatus validate() { final String poolName = (String) nameObservable.getValue(); final String poolVersion = (String) versionObservable.getValue(); processeIdentifiers.remove(new Identifier(process.getName(), process.getVersion())); for (final ProcessesNameVersion poolNameAndVersion : processesNameVersion) { if (!process.equals(poolNameAndVersion.getAbstractProcess())) { processeIdentifiers.add(new Identifier(poolNameAndVersion.getNewName(), poolNameAndVersion.getNewVersion())); } } if (processeIdentifiers.contains(new Identifier(poolName, poolVersion))) { return ValidationStatus.error(Messages.bind(Messages.differentCaseSameNameError, Messages.Pool_title.toLowerCase())); } return ValidationStatus.ok(); }
Example 7
Source File: ConverterViewModel.java From tmxeditor8 with GNU General Public License v2.0 | 6 votes |
/** * 验证 XLIFF 文件中的 file 节点 * @param handler * XLFHandler 实例 * @param xliffPath * XLIFF 文件路径 * @param type * 文件类型,(Converter.getType() 的值,XLIIF 文件 file 节点的 datatype 属性值) * @return ; */ private IStatus validateFileNodeInXliff(XLFHandler handler, String xliffPath, String type) { handler.reset(); // 重置,以便重新使用。 Map<String, Object> resultMap = handler.openFile(xliffPath); if (resultMap == null || Constant.RETURNVALUE_RESULT_SUCCESSFUL != (Integer) resultMap.get(Constant.RETURNVALUE_RESULT)) { // 打开文件失败。 return ValidationStatus.error(Messages.getString("model.ConverterViewModel.msg4")); //$NON-NLS-1$ } try { int fileCount = handler.getFileCountInXliff(xliffPath); if (fileCount < 1) { // 不存在 file 节点。提示为不合法的 XLIFF return ValidationStatus.error(Messages.getString("model.ConverterViewModel.msg4")); //$NON-NLS-1$ } else if (fileCount > 1) { // 多个 file 节点,提示分割。 if (ConverterUtils.isOpenOfficeOrMSOffice2007(type)) { // 验证源文件是 OpenOffice 和 MSOffice 2007 的XLIFF 的 file 节点信息是否完整 return validateOpenOfficeOrMSOffice2007(handler, xliffPath); } return ValidationStatus.error(Messages.getString("model.ConverterViewModel.msg5")); //$NON-NLS-1$ } else { // 只有一个 file 节点 return Status.OK_STATUS; } } catch (Exception e) { // 当前打开了多个 XLIFF 文件,参看 XLFHandler.getFileCountInXliff() 方法 return ValidationStatus.error(Messages.getString("model.ConverterViewModel.msg5")); //$NON-NLS-1$ } }
Example 8
Source File: InputLengthValidator.java From bonita-studio with GNU General Public License v2.0 | 5 votes |
@Override public IStatus validate(final Object input) { if(input != null && input.toString().trim().length() < minChar){ return ValidationStatus.error(Messages.bind(Messages.fieldIsTooShort,inputName,minChar)) ; } if (input != null && input.toString().length() > maxChar) { return ValidationStatus.error(Messages.bind(Messages.fieldIsTooLong,inputName,maxChar)) ; } return ValidationStatus.ok() ; }
Example 9
Source File: DocumentWizardPage.java From bonita-studio with GNU General Public License v2.0 | 5 votes |
protected IStatus validateInternalDocumentId(final Object value) { if (!document.isMultiple() && DocumentType.INTERNAL.equals(document.getDocumentType()) && (value == null || ((String) value).isEmpty())) { return ValidationStatus.error(Messages.error_documentDefaultIDEmpty); } return ValidationStatus.ok(); }
Example 10
Source File: QueryNameValidator.java From bonita-studio with GNU General Public License v2.0 | 5 votes |
private IStatus validateUniqueness(Query query) { return boSelectedObservable.getValue().getQueries().stream() .filter(aQuery -> !Objects.equals(aQuery, query)) .map(Query::getName) .anyMatch(query.getName()::equals) ? ValidationStatus.error(Messages.queryNameAlreadyExists) : ValidationStatus.ok(); }
Example 11
Source File: ConverterViewModel.java From translationstudio8 with GNU General Public License v2.0 | 5 votes |
/** * 验证源文件是 OpenOffice 和 MSOffice 2007 的XLIFF 的 file 节点信息是否完整 * @param handler * @param path * @return ; */ private IStatus validateOpenOfficeOrMSOffice2007(XLFHandler handler, String path) { if (!handler.validateMultiFileNodes(path)) { return ValidationStatus.error(Messages.getString("model.ConverterViewModel.msg7")); } return Status.OK_STATUS; }
Example 12
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 13
Source File: FieldNameValidator.java From bonita-studio with GNU General Public License v2.0 | 5 votes |
private IStatus validateReservedFieldNames(String name) { if (name.equalsIgnoreCase(org.bonitasoft.engine.bdm.model.field.Field.PERSISTENCE_ID)) { return ValidationStatus.error( Messages.bind(Messages.reservedKeyWord, org.bonitasoft.engine.bdm.model.field.Field.PERSISTENCE_ID)); } else if (name.equalsIgnoreCase(org.bonitasoft.engine.bdm.model.field.Field.PERSISTENCE_VERSION)) { return ValidationStatus.error(Messages.bind(Messages.reservedKeyWord, org.bonitasoft.engine.bdm.model.field.Field.PERSISTENCE_VERSION)); } return ValidationStatus.ok(); }
Example 14
Source File: SelectGroupMappingWizardPage.java From bonita-studio with GNU General Public License v2.0 | 4 votes |
@Override public void createControl(Composite parent) { super.createControl(parent) ; final Composite mainComposite = (Composite) getControl(); final Composite viewersComposite = new Composite(mainComposite, SWT.NONE) ; viewersComposite.setLayoutData(GridDataFactory.fillDefaults().grab(true, true).span(2, 1).hint(SWT.DEFAULT,250).create()) ; viewersComposite.setLayout(GridLayoutFactory.swtDefaults().numColumns(1).margins(0, 0).extendedMargins(0, 0, 10, 0).equalWidth(false).create()) ; availableGroupViewer = CheckboxTableViewer.newCheckList(viewersComposite, SWT.BORDER | SWT.FULL_SELECTION | SWT.V_SCROLL) ; availableGroupViewer.getTable().setLayoutData(GridDataFactory.fillDefaults().grab(true,true).create()) ; availableGroupViewer.getTable().setHeaderVisible(true) ; availableGroupViewer.setContentProvider(new ArrayContentProvider()) ; final TableLayout layout = new TableLayout() ; layout.addColumnData(new ColumnWeightData(100)); availableGroupViewer.getTable().setLayout(layout) ; final TableViewerColumn columnViewer = new TableViewerColumn(availableGroupViewer, SWT.NONE) ; final TableColumn usernameColumn = columnViewer.getColumn() ; usernameColumn.setText(Messages.groupName); columnViewer.setLabelProvider(new ColumnLabelProvider()); final TableColumnSorter sorter = new TableColumnSorter(availableGroupViewer) ; sorter.setColumn(usernameColumn) ; availableGroupViewer.setInput(availableGroups) ; availableGroupViewer.setCheckedElements(selectedGroups.toArray()); context = new DataBindingContext(); final IObservableSet checkedElementsObservable = ViewersObservables.observeCheckedElements(availableGroupViewer, String.class) ; final MultiValidator notEmptyValidator = new MultiValidator() { @Override protected IStatus validate() { if(groupSelectionIsValid(checkedElementsObservable)){ return ValidationStatus.ok(); } return ValidationStatus.error(Messages.errorSelectionGroups); } } ; context.addValidationStatusProvider(notEmptyValidator); context.bindSet(checkedElementsObservable, PojoObservables.observeSet(this, "selectedGroups")); WizardPageSupport.create(this, context); setControl(mainComposite); }
Example 15
Source File: TermDbManagerDialog.java From tmxeditor8 with GNU General Public License v2.0 | 4 votes |
/** * 输入验证器 ; */ private IStatus validator() { String instance = currServer.getInstance(); String host = currServer.getHost(); String port = currServer.getPort(); String location = currServer.getItlDBLocation(); String username = currServer.getUserName(); MetaData dbMetaData = dbMetaDataMap.get(currServer.getDbType()); if (dbMetaData.dataPathSupported()) { File f = new File(location); if (location == null || location.trim().length() == 0) { if (dbMetaData.getDbType().equals(Constants.DBTYPE_INTERNALDB)) { return ValidationStatus.error(Messages.getString("dialog.TermDbManagerDialog.msg5")); } else if (dbMetaData.getDbType().equals(Constants.DBTYPE_SQLITE)) { return ValidationStatus.error(Messages.getString("dialog.TermDbManagerDialog.msg11")); } } else if (!f.exists()) { return ValidationStatus.error(Messages.getString("dialog.TermDbManagerDialog.msg12")); } } if (dbMetaData.serverNameSupported()) { if (host == null || host.trim().length() == 0) { return ValidationStatus.error(Messages.getString("dialog.TermDbManagerDialog.msg6")); } } if (dbMetaData.portSupported()) { if (port == null || port.trim().length() == 0) { return ValidationStatus.error(Messages.getString("dialog.TermDbManagerDialog.msg7")); } } if (dbMetaData.userNameSupported()) { if (username == null || username.trim().length() == 0) { return ValidationStatus.error(Messages.getString("dialog.TermDbManagerDialog.msg8")); } } if (dbMetaData.instanceSupported()) { if (instance == null || instance.trim().length() == 0) { return ValidationStatus.error(Messages.getString("dialog.TermDbManagerDialog.msg9")); } } return ValidationStatus.ok(); }
Example 16
Source File: BusinessObjectNameValidator.java From bonita-studio with GNU General Public License v2.0 | 4 votes |
private IStatus validateUnderscoreCharacter(String name) { return name.contains("_") ? ValidationStatus.error(Messages.errorMessageNoUnderscoreInBoNames) : ValidationStatus.ok(); }
Example 17
Source File: NewTmDbBaseInfoPage.java From translationstudio8 with GNU General Public License v2.0 | 4 votes |
/** * 输入验证器 ; */ private IStatus validator() { if (dbOp == null) { return ValidationStatus.error(Messages.getString("wizard.NewTmDbBaseInfoPage.msg1")); } // String dbName = dbModel.getDbName(); String instance = dbModel.getInstance(); String host = dbModel.getHost(); String port = dbModel.getPort(); String location = dbModel.getItlDBLocation(); String username = dbModel.getUserName(); String password = dbModel.getPassword(); if (dbName == null || dbName.trim().length() == 0) { return ValidationStatus.error(Messages.getString("wizard.NewTmDbBaseInfoPage.msg2")); } String vRs = DbValidator.valiateDbName(dbName); if (vRs != null) { return ValidationStatus.error(vRs); } if (dbMetaData.instanceSupported()) { if (instance == null || instance.trim().length() == 0) { return ValidationStatus.error(Messages.getString("wizard.NewTmDbBaseInfoPage.instancemsg")); } dbMetaData.setInstance(instance == null ? "" : instance); } if (dbMetaData.dataPathSupported()) { if (location == null || location.trim().length() == 0) { return ValidationStatus.error(Messages.getString("wizard.NewTmDbBaseInfoPage.msg3")); } File f = new File(location); if (!f.isDirectory() || !f.exists()) { return ValidationStatus.error(Messages.getString("wizard.NewTmDbBaseInfoPage.msg11")); } } if (dbMetaData.serverNameSupported()) { if (host == null || host.trim().length() == 0) { return ValidationStatus.error(Messages.getString("wizard.NewTmDbBaseInfoPage.msg4")); } } if (dbMetaData.portSupported()) { if (port == null || !port.matches("[0-9]+")) { return ValidationStatus.error(Messages.getString("wizard.NewTmDbBaseInfoPage.msg5")); } } if (dbMetaData.userNameSupported()) { if (username == null || username.trim().length() == 0) { return ValidationStatus.error(Messages.getString("wizard.NewTmDbBaseInfoPage.msg6")); } } dbMetaData.setDatabaseName(dbName == null ? "" : dbName); dbMetaData.setDataPath(location == null ? "" : location); dbMetaData.setServerName(host == null ? "" : host); dbMetaData.setPort(port == null ? "" : port); dbMetaData.setUserName(username == null ? "" : username); dbMetaData.setPassword(password == null ? "" : password); // 密码可以为空 return ValidationStatus.ok(); }
Example 18
Source File: BusinessObjectNameValidator.java From bonita-studio with GNU General Public License v2.0 | 4 votes |
private IStatus validateWhiteSpaceCharacter(String name) { return name.contains(" ") ? ValidationStatus.error(Messages.errorMessageNoWhitespaceInDataTypeNames) : ValidationStatus.ok(); }
Example 19
Source File: RepositoryNameValidator.java From bonita-studio with GNU General Public License v2.0 | 4 votes |
@Override public IStatus validate(Object value) { final String errorMessage = isValid((String) value); return errorMessage == null ? ValidationStatus.ok() : ValidationStatus.error(errorMessage); }
Example 20
Source File: TmDbManagerDialog.java From tmxeditor8 with GNU General Public License v2.0 | 4 votes |
/** * 输入验证器 ; */ private IStatus validator() { String instance = currServer.getInstance(); String host = currServer.getHost(); String port = currServer.getPort(); String location = currServer.getItlDBLocation(); String username = currServer.getUserName(); MetaData dbMetaData = dbMetaDataMap.get(currServer.getDbType()); if (dbMetaData.dataPathSupported()) { File f = new File(location); if (location == null || location.trim().length() == 0) { if (dbMetaData.getDbType().equals(Constants.DBTYPE_INTERNALDB)) { return ValidationStatus.error(Messages.getString("dialog.TmDbManagerDialog.msg5")); } else if (dbMetaData.getDbType().equals(Constants.DBTYPE_SQLITE)) { return ValidationStatus.error(Messages.getString("dialog.TmDbManagerDialog.msg11")); } } else if (!f.exists()) { return ValidationStatus.error(Messages.getString("dialog.TmDbManagerDialog.msg12")); } } if (dbMetaData.serverNameSupported()) { if (host == null || host.trim().length() == 0) { return ValidationStatus.error(Messages.getString("dialog.TmDbManagerDialog.msg6")); } } if (dbMetaData.portSupported()) { if (port == null || port.trim().length() == 0) { return ValidationStatus.error(Messages.getString("dialog.TmDbManagerDialog.msg7")); } } if (dbMetaData.userNameSupported()) { if (username == null || username.trim().length() == 0) { return ValidationStatus.error(Messages.getString("dialog.TmDbManagerDialog.msg8")); } } if (dbMetaData.instanceSupported()) { if (instance == null || instance.trim().length() == 0) { return ValidationStatus.error(Messages.getString("dialog.TmDbManagerDialog.msg9")); } } return ValidationStatus.ok(); }