/**
  * 当一个文本段初次获取焦点时,实时进行拼写检查,<div style='color:red'>该方法与{@link tgtTextRealTimeSpellCheck} 类似</div>
  */
 private static void tgtTextFirstRealTimeSpellCheck(
     final String tgtLang, HsMultiCellEditor targetEditor) {
   final StyledTextCellEditor tgtEditor = targetEditor.getCellEditor();
   final StyledText text = tgtEditor.getSegmentViewer().getTextWidget();
   if (tgtLang == null) {
     return;
   }
   String tgtText = text.getText();
   if (tgtText == null || "".equals(tgtText.trim())) {
     return;
   }
   List<SingleWord> errorWordList = new LinkedList<SingleWord>();
   errorWordList = spellTrigger.getErrorWords(tgtText, tgtLang);
   if (errorWordList != null && errorWordList.size() > 0) {
     targetEditor.highLightedErrorWord(tgtText, errorWordList);
   } else {
     targetEditor.refreshErrorWordsStyle(null);
   }
 }
  public static void activeSourceAndTargetCell(XLIFFEditorImplWithNatTable xliffEditor) {
    if (xliffEditor == null) {
      return;
    }
    int[] selectedRowIndexs = xliffEditor.getSelectedRows();
    if (selectedRowIndexs.length == 0) {
      return;
    }
    Arrays.sort(selectedRowIndexs);
    int rowIndex = selectedRowIndexs[selectedRowIndexs.length - 1];
    if (!xliffEditor.isHorizontalLayout()) {
      rowIndex = rowIndex * 2; // source index
    }

    NatTable natTable = xliffEditor.getTable();
    IConfigRegistry configRegistry = natTable.getConfigRegistry();
    ViewportLayer vLayer = LayerUtil.getLayer(natTable, ViewportLayer.class);
    int rowPosition = vLayer.getRowPositionByIndex(rowIndex);
    rowPosition += 1;
    if (rowPosition < 1) {
      return;
    }

    int columnIndex = xliffEditor.getSrcColumnIndex();
    HsMultiCellEditor srcCellEditor =
        activeCell(
            vLayer,
            xliffEditor,
            configRegistry,
            columnIndex,
            rowIndex,
            rowPosition,
            NatTableConstant.SOURCE);
    if (srcCellEditor == null) {
      return;
    }

    if (!xliffEditor.isHorizontalLayout()) {
      rowIndex = rowIndex + 1; // target
      rowPosition = vLayer.getRowPositionByIndex(rowIndex);
      rowPosition += 1;
      if (rowPosition < 1) {
        return;
      }
    }
    columnIndex = xliffEditor.getTgtColumnIndex();
    HsMultiCellEditor tgtCellEditor =
        activeCell(
            vLayer,
            xliffEditor,
            configRegistry,
            columnIndex,
            rowIndex,
            rowPosition,
            NatTableConstant.TARGET);
    if (tgtCellEditor == null) {
      return;
    }
    HsMultiActiveCellEditor.activateCellEditors(srcCellEditor, tgtCellEditor, natTable);

    // 目标文本段一进入焦点就进行一次拼写检查 robert 2013-01-22
    // UNDO 这里错误单词提示并没有修改颜色。
    String tgtLang = xliffEditor.getTgtColumnName();
    spellTrigger = RealTimeSpellCheckTrigger.getInstance();
    if (spellTrigger != null && spellTrigger.checkSpellAvailable(tgtLang)) {
      tgtTextFirstRealTimeSpellCheck(tgtLang, tgtCellEditor);
      tgtTextRealTimeSpellCheck(tgtLang, tgtCellEditor);
    }
    List<String> terms = xliffEditor.getTermsCache().get(selectedRowIndexs[0]);
    if (terms != null && terms.size() > 0) {
      srcCellEditor.highlightedTerms(terms);
    }
  }