当前位置: 首页>>代码示例>>Java>>正文


Java ValidationStatus类代码示例

本文整理汇总了Java中org.eclipse.core.databinding.validation.ValidationStatus的典型用法代码示例。如果您正苦于以下问题:Java ValidationStatus类的具体用法?Java ValidationStatus怎么用?Java ValidationStatus使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


ValidationStatus类属于org.eclipse.core.databinding.validation包,在下文中一共展示了ValidationStatus类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: validate

import org.eclipse.core.databinding.validation.ValidationStatus; //导入依赖的package包/类
@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$
    }
  }
  return ValidationStatus.ok();
}
 
开发者ID:GoogleCloudPlatform,项目名称:google-cloud-eclipse,代码行数:21,代码来源:AppEngineDeployPreferencesPanel.java

示例2: validate

import org.eclipse.core.databinding.validation.ValidationStatus; //导入依赖的package包/类
@Override
protected IStatus validate() {
  String pathValue = deployArtifactPath.getValue().toString();
  if (pathValue.isEmpty()) {
    return ValidationStatus.error(Messages.getString("error.deploy.artifact.empty"));
  } else if (!pathValue.endsWith(".war") && !pathValue.endsWith(".jar")) {
    return ValidationStatus.error(Messages.getString("error.deploy.artifact.invalid.extension"));
  }

  File deployArtifact = new File((String) deployArtifactPath.getValue());
  if (!deployArtifact.isAbsolute()) {
    deployArtifact = new File(basePath + "/" + deployArtifact);
  }

  if (!deployArtifact.exists()) {
    return ValidationStatus.error(
        Messages.getString("error.deploy.artifact.non.existing", deployArtifact));
  } else if (!deployArtifact.isFile()) {
    return ValidationStatus.error(Messages.getString("error.not.a.file", deployArtifact));
  }
  return Status.OK_STATUS;
}
 
开发者ID:GoogleCloudPlatform,项目名称:google-cloud-eclipse,代码行数:23,代码来源:DeployArtifactValidator.java

示例3: validate

import org.eclipse.core.databinding.validation.ValidationStatus; //导入依赖的package包/类
@Override
protected IStatus validate() {
  if (appYamlPath.getValue().toString().isEmpty()) {
    return ValidationStatus.error(Messages.getString("error.app.yaml.empty"));
  }

  File appYaml = new File((String) appYamlPath.getValue());
  if (!appYaml.isAbsolute()) {
    appYaml = new File(basePath + "/" + appYaml);
  }

  // appengine-plugins-core does not yet support other file names.
  if (!"app.yaml".equals(appYaml.getName())) {
    return ValidationStatus.error(Messages.getString("error.app.yaml.invalid.name", appYaml));
  } else if (!appYaml.exists()) {
    return ValidationStatus.error(Messages.getString("error.app.yaml.non.existing"));
  } else if (!appYaml.isFile()) {
    return ValidationStatus.error(Messages.getString("error.not.a.file", appYaml));
  } else {
    return validateRuntime(appYaml);
  }
}
 
开发者ID:GoogleCloudPlatform,项目名称:google-cloud-eclipse,代码行数:23,代码来源:AppYamlValidator.java

示例4: validate

import org.eclipse.core.databinding.validation.ValidationStatus; //导入依赖的package包/类
/**
 * @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$
  }
}
 
开发者ID:GoogleCloudPlatform,项目名称:google-cloud-eclipse,代码行数:26,代码来源:ProjectVersionValidator.java

示例5: validate

import org.eclipse.core.databinding.validation.ValidationStatus; //导入依赖的package包/类
@Override
public IStatus validate(Object value) {
	if (value instanceof String && !"".equals(value)) {
		Matcher m = pattern.matcher((CharSequence) value);
		if (m.find()) {
			return ValidationStatus.ok();
		}
		else {
			return ValidationStatus.error(errorMessage + patternString);
		}
	}
	if (force)
	{
		return ValidationStatus.error(errorMessage + patternString);
	}
		return ValidationStatus.ok();
}
 
开发者ID:cplutte,项目名称:bts,代码行数:18,代码来源:StringRegexValidator.java

示例6: validate

import org.eclipse.core.databinding.validation.ValidationStatus; //导入依赖的package包/类
public IStatus validate(Object value) {
	if (value instanceof String) {
		String text = (String) value;
		if (text.trim().length() == 0) {
			controlDecoration.show();
			okButton.setEnabled(false);
			return ValidationStatus.error(errorText);
		}
		for (String t : themes) {
			if (t.equals(value)) {
				controlDecoration.show();
				okButton.setEnabled(false);
				return ValidationStatus.error(errorText);
			}
		}
	}
	okButton.setEnabled(true);
	controlDecoration.hide();
	return Status.OK_STATUS;
}
 
开发者ID:OpenSoftwareSolutions,项目名称:PDFReporter-Studio,代码行数:21,代码来源:ThemesPreferencePage.java

示例7: validate

import org.eclipse.core.databinding.validation.ValidationStatus; //导入依赖的package包/类
public IStatus validate(Object value) {
	String v = (String) value;
	if (value == null || v.isEmpty())
		return ValidationStatus.error(Messages.IDStringValidator_EmptyError);
	if (v.length() > 100)
		return ValidationStatus.error("ID size between 0 and 100");
	for (char c : v.toCharArray()) {
		if (Character.isLetterOrDigit(c))
			continue;
		boolean isAllowed = false;
		for (char a : allowed) {
			if (c == a) {
				isAllowed = true;
				break;
			}
		}
		if (!isAllowed)
			return ValidationStatus.error(Messages.IDStringValidator_InvalidChars);
	}
	return Status.OK_STATUS;
}
 
开发者ID:OpenSoftwareSolutions,项目名称:PDFReporter-Studio,代码行数:22,代码来源:IDStringValidator.java

示例8: validate

import org.eclipse.core.databinding.validation.ValidationStatus; //导入依赖的package包/类
@Override
public IStatus validate(Object value) {
	if (value == null) {
		controlDecoration.hide();
		return Status.OK_STATUS;
	} else if (value instanceof String) {
		String text = (String) value;
		if (text.length() == 0 || SVNR.validateSVNumber(text)) {
			controlDecoration.hide();
			return Status.OK_STATUS;
		}
	}
	controlDecoration.show();
	return ValidationStatus.error(errorText);

}
 
开发者ID:MEDEVIT,项目名称:ecard,代码行数:17,代码来源:SVNRValidator.java

示例9: validateXliffFile

import org.eclipse.core.databinding.validation.ValidationStatus; //导入依赖的package包/类
/**
 * 验证 xliff 所需要转换的 xliff 文件
 * @param xliffPath
 *            xliff 文件路径
 * @param monitor
 * @return ;
 */
public IStatus validateXliffFile(String xliffPath, XLFHandler handler, IProgressMonitor monitor) {
	IStatus result = new ReverseConversionValidateWithLibrary3().validate(xliffPath, configBean, monitor);
	if (!result.isOK()) {
		return result;
	}
	// 验证是否存在 xliff 对应的源文件类型的转换器实现
	String fileType = configBean.getFileType();
	Converter converter = getConverter(fileType);
	if (converter != null) {
		result = validateFileNodeInXliff(handler, xliffPath, converter.getType()); // 验证 XLIFF 文件的 file 节点
		if (!result.isOK()) {
			return result;
		}

		result = validIsSplitedXliff(handler, xliffPath);
		if (!result.isOK()) {
			return result;
		}
		setSelectedType(fileType);
		result = Status.OK_STATUS;
	} else {
		result = ValidationStatus.error(Messages.getString("model.ConverterViewModel.msg3") + fileType);
	}
	return result;
}
 
开发者ID:heartsome,项目名称:translationstudio8,代码行数:33,代码来源:ConverterViewModel.java

示例10: validateFileNodeInXliff

import org.eclipse.core.databinding.validation.ValidationStatus; //导入依赖的package包/类
/**
 * 验证 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$
	}
}
 
开发者ID:heartsome,项目名称:translationstudio8,代码行数:36,代码来源:ConverterViewModel.java

示例11: validateReverseConversion

import org.eclipse.core.databinding.validation.ValidationStatus; //导入依赖的package包/类
/**
 * 逆向转换验证
 * @return ;
 */
public IStatus validateReverseConversion() {
	if (target == null || target.trim().equals("")) {
		return ValidationStatus.error(Messages.getString("model.ConversionConfigBean.msg9"));
	} else {
		if (!replaceTarget) { // 如果未选择覆盖,判断并提示目标文件是否存在
			String localTarget = ConverterUtil.toLocalPath(target);
			File file = new File(localTarget);
			if (file.exists()) {
				return ValidationStatus.error(Messages.getString("model.ConversionConfigBean.msg10"));
			}
		}
	}
	if (targetEncoding == null || targetEncoding.trim().equals("")) {
		return ValidationStatus.error(Messages.getString("model.ConversionConfigBean.msg11"));
	}
	return Status.OK_STATUS;
}
 
开发者ID:heartsome,项目名称:translationstudio8,代码行数:22,代码来源:ConversionConfigBean.java

示例12: validateXliffFile

import org.eclipse.core.databinding.validation.ValidationStatus; //导入依赖的package包/类
/**
 * 验证 xliff 所需要转换的 xliff 文件
 * @param xliffPath
 *            xliff 文件路径
 * @param monitor
 * @return ;
 */
public IStatus validateXliffFile(String xliffPath, XLFHandler handler, IProgressMonitor monitor) {
	IStatus result = new ReverseConversionValidateWithLibrary3().validate(xliffPath, configBean, monitor);
	if (!result.isOK()) {
		return result;
	}
	// 验证是否存在 xliff 对应的源文件类型的转换器实现
	String fileType = configBean.getFileType();
	Converter converter = getConverter(fileType);
	if (converter != null) {
		result = validateFileNodeInXliff(handler, xliffPath, converter.getType()); // 验证 XLIFF 文件的 file 节点
		if (!result.isOK()) {
			return result;
		}

		setSelectedType(fileType);
		result = Status.OK_STATUS;
	} else {
		result = ValidationStatus.error("xliff 对应的源文件类型的转换器不存在:" + fileType);
	}
	return result;
}
 
开发者ID:heartsome,项目名称:translationstudio8,代码行数:29,代码来源:ConverterViewModel.java

示例13: validateFileNodeInXliff

import org.eclipse.core.databinding.validation.ValidationStatus; //导入依赖的package包/类
/**
 * 验证 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("ConverterViewModel.0")); //$NON-NLS-1$
	}
	try {
		int fileCount = handler.getFileCountInXliff(xliffPath);
		if (fileCount < 1) { // 不存在 file 节点。提示为不合法的 XLIFF
			return ValidationStatus.error(Messages.getString("ConverterViewModel.0")); //$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("ConverterViewModel.1")); //$NON-NLS-1$
		} else { // 只有一个 file 节点
			return Status.OK_STATUS;
		}
	} catch (Exception e) { // 当前打开了多个 XLIFF 文件,参看 XLFHandler.getFileCountInXliff() 方法
		return ValidationStatus.error(Messages.getString("ConverterViewModel.1")); //$NON-NLS-1$
	}
}
 
开发者ID:heartsome,项目名称:translationstudio8,代码行数:36,代码来源:ConverterViewModel.java

示例14: validateReverseConversion

import org.eclipse.core.databinding.validation.ValidationStatus; //导入依赖的package包/类
/**
 * 逆向转换验证
 * @return ;
 */
public IStatus validateReverseConversion() {
	if (target == null || target.trim().equals("")) {
		return ValidationStatus.error("请选择已转换的文件。");
	} else {
		if (!replaceTarget) { // 如果未选择覆盖,判断并提示目标文件是否存在
			String localTarget = ConverterUtil.toLocalPath(target);
			File file = new File(localTarget);
			if (file.exists()) {
				return ValidationStatus.error("已转换的文件已存在。");
			}
		}
	}
	if (targetEncoding == null || targetEncoding.trim().equals("")) {
		return ValidationStatus.error("请选择已转换文件的编码。");
	}
	return Status.OK_STATUS;
}
 
开发者ID:heartsome,项目名称:translationstudio8,代码行数:22,代码来源:ConversionConfigBean.java

示例15: validate

import org.eclipse.core.databinding.validation.ValidationStatus; //导入依赖的package包/类
public IStatus validate(Object value)
{
  if (value instanceof String)
  {
    String s = (String) value;
    
    try
    {
      Long.parseLong(s);

      decoration.hide();
      return Status.OK_STATUS;
    }
    catch(Exception e)
    {
      decoration.show();        
      
      return ValidationStatus.error(message);
    }
  }
  else
  {
    throw new ConfigurationException("Not supposed to be called for non-strings.");
  }
}
 
开发者ID:terraframe,项目名称:Runway-SDK,代码行数:26,代码来源:IntegerValidator.java


注:本文中的org.eclipse.core.databinding.validation.ValidationStatus类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。