コード例 #1
0
  /** 加载文件数据。 */
  private void loadFiles() {
    for (int i = 0; i < conversionConfigBeans.size(); i++) {
      ConversionConfigBean bean = conversionConfigBeans.get(i);

      String source = bean.getSource();
      String sourceLocalPath = ConverterUtil.toLocalPath(source);
      // 自动识别文件类型
      String format = FileFormatUtils.detectFormat(sourceLocalPath);
      if (format == null) {
        format = ""; // $NON-NLS-1$
      }
      // 自动分析源文件编码
      String srcEncValue = EncodingResolver.getEncoding(sourceLocalPath, format);
      if (srcEncValue == null) {
        srcEncValue = ""; // $NON-NLS-1$
      }

      // XLIFF 文件路径
      String xliff = ""; // $NON-NLS-1$
      // 骨架文件路径
      String skeleton = ""; // $NON-NLS-1$
      try {
        ConversionResource resource =
            new ConversionResource(Converter.DIRECTION_POSITIVE, sourceLocalPath);
        xliff = resource.getXliffPath();
        skeleton = resource.getSkeletonPath();
      } catch (CoreException e) {
        e.printStackTrace();
      }

      if (!"".equals(format)) { // $NON-NLS-1$
        String name = getSelectedFormat(format);
        if (name != null && !"".equals(name)) { // $NON-NLS-1$
          converterViewModels.get(i).setSelectedType(name); // 添加类型
        }
      }
      bean.setFileType(format);
      bean.setSrcEncoding(srcEncValue);
      bean.setTarget(xliff);
      bean.setSkeleton(ConverterUtil.toLocalPath(skeleton));
    }
  }
コード例 #2
0
 /** 对 UI 和 View Model 进行绑定 ; */
 private void bindValue() {
   DataBindingContext dbc = new DataBindingContext();
   ConverterUtil.bindValue(dbc, supportList, converterViewModel);
 }