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


Java Converter类代码示例

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


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

示例1: setupAccountEmailDataBinding

import org.eclipse.core.databinding.conversion.Converter; //导入依赖的package包/类
private void setupAccountEmailDataBinding() {
  AccountSelectorObservableValue accountSelectorObservableValue =
      new AccountSelectorObservableValue(accountSelector);
  UpdateValueStrategy modelToTarget =
      new UpdateValueStrategy().setConverter(new Converter(String.class, String.class) {
        @Override
        public Object convert(Object savedEmail) {
          Preconditions.checkArgument(savedEmail instanceof String);
          if (accountSelector.isEmailAvailable((String) savedEmail)) {
            return savedEmail;
          } else if (requireValues && accountSelector.getAccountCount() == 1) {
            return accountSelector.getFirstEmail();
          } else {
            return null;
          }
        }
      });

  final IObservableValue accountEmailModel = PojoProperties.value("accountEmail").observe(model);

  Binding binding = bindingContext.bindValue(accountSelectorObservableValue, accountEmailModel,
      new UpdateValueStrategy(), modelToTarget);
  /*
   * Trigger an explicit target -> model update for the auto-select-single-account case. When the
   * model has a null account but there is exactly 1 login account, then the AccountSelector
   * automatically selects that account. That change means the AccountSelector is at odds with the
   * model.
   */
  binding.updateTargetToModel();
  bindingContext.addValidationStatusProvider(new AccountSelectorValidator(
      requireValues, accountSelector, accountSelectorObservableValue));
}
 
开发者ID:GoogleCloudPlatform,项目名称:google-cloud-eclipse,代码行数:33,代码来源:AppEngineDeployPreferencesPanel.java


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