热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

org.eclipse.core.databinding.UpdateValueStrategy类的使用及代码示例

本文整理了Java中org.eclipse.core.databinding.UpdateValueStrategy类的一些代码示例,展示了UpdateVa

本文整理了Java中org.eclipse.core.databinding.UpdateValueStrategy类的一些代码示例,展示了UpdateValueStrategy类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。UpdateValueStrategy类的具体详情如下:
包路径:org.eclipse.core.databinding.UpdateValueStrategy
类名称:UpdateValueStrategy

UpdateValueStrategy介绍

[英]Customizes a Binding between two IObservableValue. The following behaviors can be customized via the strategy:

  • Validation
  • Conversion
  • Automatic processing

The update phases are:

  1. Validate after get - #validateAfterGet(Object)
  2. Conversion - #convert(Object)
  3. Validate after conversion - #validateAfterConvert(Object)
  4. Validate before set - #validateBeforeSet(Object)
  5. Value set - #doSet(IObservableValue,Object)

Validation:
IValidator validate the value at multiple phases in the update process. Statuses returned from validators are aggregated into a MultiStatus until a status of ERROR or CANCEL is encountered. Either of these statuses will abort the update process. These statuses are available as the Binding#getValidationStatus().

Conversion:
A IConverter will convert the value from the type of the source observable into the type of the destination. The strategy has the ability to default converters for common scenarios.

Automatic processing:
The processing to perform when the source observable changes. This behavior is configured via policies provided on construction of the strategy (e.g. #POLICY_NEVER, #POLICY_CONVERT, #POLICY_ON_REQUEST, #POLICY_UPDATE).
[中]自定义两个IObservableValue之间的绑定。可以通过该策略定制以下行为:
*验证
*转换
*自动处理
更新阶段包括:
1.获取后验证-#获取后验证(对象)
1.转换-#转换(对象)
1.转换后验证-#转换后验证(对象)
1.设置前验证-#验证前设置(对象)
1.值集-#doSet(IObservableValue,对象)
验证:
IValidator在更新过程的多个阶段验证该值。从验证器返回的状态被聚合为MultiStatus,直到遇到ERRORCANCEL状态。这两种状态都将中止更新过程。这些状态可用作绑定#getValidationStatus()。
转换:
IConverter会将可观测的源类型的值转换为目标类型的值。该策略能够为常见场景设置默认转换器。
自动处理:
当观察到的源发生变化时要执行的处理。此行为通过策略构建时提供的策略进行配置(例如#POLICY_NEVER、#POLICY_CONVERT、#POLICY_on_REQUEST、#POLICY_UPDATE)。

代码示例

代码示例来源:origin: org.eclipse.platform/org.eclipse.core.databinding

/**
* Create an {@link UpdateValueStrategy} with a converter
*
* @param converter
* the converter
* @return the update value strategy
* @since 1.6
*/
public static UpdateValueStrategy create(IConverter converter) {
return new UpdateValueStrategy().setConverter(converter);
}
}

代码示例来源:origin: org.eclipse.platform/org.eclipse.core.databinding

/**
* Tries to create a validator that can validate values of type fromType.
* Returns null if no validator could be created. Either toType
* or modelDescription can be null, but not both.
*
* @param fromType
* @param toType
* @return an IValidator, or null if unsuccessful
*/
protected IValidator createValidator(Object fromType, Object toType) {
if (fromType == null || toType == null) {
return value -> Status.OK_STATUS;
}
return findValidator(fromType, toType);
}

代码示例来源:origin: org.eclipse.fx/org.eclipse.core.databinding

protected void postInit() {
if (modelToTarget.getUpdatePolicy() == UpdateValueStrategy.POLICY_UPDATE) {
updateModelToTarget();
} else if (modelToTarget.getUpdatePolicy() == UpdateValueStrategy.POLICY_CONVERT) {
validateModelToTarget();
}
if (targetToModel.getUpdatePolicy() == UpdateValueStrategy.POLICY_UPDATE
|| targetToModel.getUpdatePolicy() == UpdateValueStrategy.POLICY_CONVERT) {
validateTargetToModel();
}
}

代码示例来源:origin: org.eclipse.mylyn.commons.repositories/ui

protected UpdateValueStrategy getUrlUpdateValueStrategy() {
return new UpdateValueStrategy().setAfterConvertValidator(new UrlValidator());
}

代码示例来源:origin: org.eclipse.platform/org.eclipse.core.databinding

/**
* Returns an update value strategy to be used for copying values from the
* from value to the to value. Clients may override.
*
* @param fromValue
* @param toValue
* @return a update value strategy
*/
protected UpdateValueStrategy createModelToTargetUpdateValueStrategy(
IObservableValue fromValue, IObservableValue toValue) {
return new UpdateValueStrategy<>();
}

代码示例来源:origin: at.bestsolution.efxclipse.eclipse/org.eclipse.core.databinding

if (provideDefaults && sourceType != null && destinationType != null) {
if (cOnverter== null) {
IConverter cOnverter= createConverter(sourceType,
destinationType);
defaultedCOnverter= (converter != null);
setConverter(converter);
afterGetValidator = createValidator(sourceType, destinationType);
checkAssignable(converter.getFromType(), sourceType,
"converter does not convert from type " + sourceType); //$NON-NLS-1$
checkAssignable(destinationType, converter.getToType(),
"converter does not convert to type " + destinationType); //$NON-NLS-1$

代码示例来源:origin: org.eclipse.platform/org.eclipse.core.databinding

final boolean explicit, final boolean validateOnly) {
final int policy = updateValueStrategy.getUpdatePolicy();
if (policy == UpdateValueStrategy.POLICY_NEVER)
return;
IStatus status = updateValueStrategy.validateAfterGet(value);
if (!mergeStatus(multiStatus, status))
return;
final D2 cOnvertedValue= updateValueStrategy.convert(value);
status = updateValueStrategy.validateAfterConvert(convertedValue);
if (!mergeStatus(multiStatus, status))
return;
status = updateValueStrategy.validateBeforeSet(convertedValue);
if (!mergeStatus(multiStatus, status))
return;
IStatus setterStatus = updateValueStrategy.doSet(destination, convertedValue);

代码示例来源:origin: at.bestsolution.efxclipse.eclipse/org.eclipse.core.databinding

.validateAfterGet(value);
if (!mergeStatus(multiStatus, status))
return;
.convert(value);
.validateAfterConvert(convertedValue);
if (!mergeStatus(multiStatus, status))
return;
.validateBeforeSet(convertedValue);
if (!mergeStatus(multiStatus, status))
return;

代码示例来源:origin: org.eclipse.emf/databinding

return super.createConverter(fromType, toType);

代码示例来源:origin: at.bestsolution.efxclipse.eclipse/org.eclipse.core.databinding

UpdateValueStrategy modelToTargetStrategy = modelToTarget != null ? modelToTarget
: createModelToTargetUpdateValueStrategy(modelObservableValue, targetObservableValue);
targetToModelStrategy.fillDefaults(targetObservableValue, modelObservableValue);
modelToTargetStrategy.fillDefaults(modelObservableValue, targetObservableValue);
ValueBinding result = new ValueBinding(targetObservableValue,
modelObservableValue, targetToModelStrategy,

代码示例来源:origin: org.eclipse.platform/org.eclipse.core.databinding

/**
* Returns an update value strategy to be used for copying values from the
* from value to the to value. Clients may override.
*
* @param fromValue
* @param toValue
* @return a update value strategy
*/
protected UpdateValueStrategy createTargetToModelUpdateValueStrategy(
IObservableValue fromValue, IObservableValue toValue) {
return new UpdateValueStrategy<>();
}

代码示例来源:origin: org.eclipse.platform/org.eclipse.core.databinding

if (cOnverter== null) {
@SuppressWarnings("unchecked")
IConverter cOnverter= (IConverter) createConverter(sourceType, destinationType);
defaultedCOnverter= (converter != null);
setConverter(converter);
afterGetValidator = createValidator(sourceType, destinationType);
checkAssignable(converter.getFromType(), sourceType,
"converter does not convert from type " + sourceType); //$NON-NLS-1$
checkAssignable(destinationType, converter.getToType(),
"converter does not convert to type " + destinationType); //$NON-NLS-1$

代码示例来源:origin: org.eclipse.fx/org.eclipse.core.databinding

.validateAfterGet(value);
if (!mergeStatus(multiStatus, status))
return;
.convert(value);
.validateAfterConvert(convertedValue);
if (!mergeStatus(multiStatus, status))
return;
.validateBeforeSet(convertedValue);
if (!mergeStatus(multiStatus, status))
return;

代码示例来源:origin: org.eclipse.emf/org.eclipse.emf.databinding

return super.createConverter(fromType, toType);

代码示例来源:origin: org.eclipse.fx/org.eclipse.core.databinding

UpdateValueStrategy modelToTargetStrategy = modelToTarget != null ? modelToTarget
: createModelToTargetUpdateValueStrategy(modelObservableValue, targetObservableValue);
targetToModelStrategy.fillDefaults(targetObservableValue, modelObservableValue);
modelToTargetStrategy.fillDefaults(modelObservableValue, targetObservableValue);
ValueBinding result = new ValueBinding(targetObservableValue,
modelObservableValue, targetToModelStrategy,

代码示例来源:origin: at.bestsolution.efxclipse.eclipse/org.eclipse.core.databinding

/**
* Create an {@link UpdateValueStrategy} with a converter
*
* @param converter
* the converter
* @return the update value strategy
* @since 1.6
*/
public static UpdateValueStrategy create(IConverter converter) {
return new UpdateValueStrategy().setConverter(converter);
}
}

代码示例来源:origin: at.bestsolution.efxclipse.eclipse/org.eclipse.core.databinding

/**
* Returns an update value strategy to be used for copying values from the
* from value to the to value. Clients may override.
*
* @param fromValue
* @param toValue
* @return a update value strategy
*/
protected UpdateValueStrategy createModelToTargetUpdateValueStrategy(
IObservableValue fromValue, IObservableValue toValue) {
return new UpdateValueStrategy();
}

代码示例来源:origin: org.eclipse.fx/org.eclipse.core.databinding

if (provideDefaults && sourceType != null && destinationType != null) {
if (cOnverter== null) {
IConverter cOnverter= createConverter(sourceType,
destinationType);
defaultedCOnverter= (converter != null);
setConverter(converter);
afterGetValidator = createValidator(sourceType, destinationType);
checkAssignable(converter.getFromType(), sourceType,
"converter does not convert from type " + sourceType); //$NON-NLS-1$
checkAssignable(destinationType, converter.getToType(),
"converter does not convert to type " + destinationType); //$NON-NLS-1$

代码示例来源:origin: at.bestsolution.efxclipse.eclipse/org.eclipse.emf.databinding

return super.createConverter(fromType, toType);

代码示例来源:origin: at.bestsolution.efxclipse.eclipse/org.eclipse.core.databinding

@Override
protected void postInit() {
if (modelToTarget.getUpdatePolicy() == UpdateValueStrategy.POLICY_UPDATE) {
updateModelToTarget();
} else if (modelToTarget.getUpdatePolicy() == UpdateValueStrategy.POLICY_CONVERT) {
validateModelToTarget();
}
if (targetToModel.getUpdatePolicy() == UpdateValueStrategy.POLICY_UPDATE
|| targetToModel.getUpdatePolicy() == UpdateValueStrategy.POLICY_CONVERT) {
validateTargetToModel();
}
}

推荐阅读
author-avatar
彭雅静政颖
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有