/** 添加帮助按钮,备注,这里的配置与其他的不一样 robert 2012-09-06 */
 protected Control createHelpToolItem(Composite parent) {
   // ROBERTHELP xml 转换器配置
   String language = CommonFunction.getSystemLanguage();
   final String helpUrl =
       MessageFormat.format(
           "/net.heartsome.cat.ts.ui.help/html/{0}/ch08.html#configure-xml-converter", language);
   Image helpImage = JFaceResources.getImage(DLG_IMG_HELP);
   ToolBar toolBar = new ToolBar(parent, SWT.FLAT | SWT.NO_FOCUS);
   toolBar.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING));
   final Cursor cursor = new Cursor(parent.getDisplay(), SWT.CURSOR_HAND);
   toolBar.setCursor(cursor);
   toolBar.addDisposeListener(
       new DisposeListener() {
         public void widgetDisposed(DisposeEvent e) {
           cursor.dispose();
         }
       });
   ToolItem helpItem = new ToolItem(toolBar, SWT.NONE);
   helpItem.setImage(helpImage);
   helpItem.setToolTipText(JFaceResources.getString("helpToolTip")); // $NON-NLS-1$
   helpItem.addSelectionListener(
       new SelectionAdapter() {
         public void widgetSelected(SelectionEvent e) {
           PlatformUI.getWorkbench().getHelpSystem().displayHelpResource(helpUrl);
         }
       });
   return toolBar;
 }
Пример #2
0
    /**
     * 创建所有批注节点
     *
     * @throws Exception
     */
    private void createComments() throws Exception {
      String xpath = "";
      // 先生成全局批注的定义节点
      if (fileCommentsList.size() > 0) {
        String fileCommentId = CommonFunction.createUUID();
        String fileCommentStr = "<sdl:cmt id=\"" + fileCommentId + "\" />";
        xpath = "/xliff/file/header";
        outputAP.selectXPath(xpath);
        while (outputAP.evalXPath() != -1) {
          outputXM.insertBeforeTail(fileCommentStr.getBytes("utf-8"));
          commentMap.put(fileCommentId, fileCommentsList);
        }
      }

      // 开始生成Comments节点
      if (commentMap.size() == 0) {
        return;
      }
      xpath = "/xliff/doc-info";
      outputAP.selectXPath(xpath);
      if (outputAP.evalXPath() != -1) {
        StringBuffer commentSB = new StringBuffer();
        commentSB.append("<cmt-defs>");
        for (Entry<String, List<CommentBean>> entry : commentMap.entrySet()) {
          String id = entry.getKey();
          commentSB.append("<cmt-def id=\"" + id + "\">");
          commentSB.append("<Comments xmlns=\"\">");
          for (CommentBean bean : entry.getValue()) {
            commentSB.append(
                "<Comment severity=\""
                    + bean.getSeverity()
                    + "\" "
                    + "user=\""
                    + bean.getUser()
                    + "\" date=\""
                    + bean.getDate()
                    + "\" version=\"1.0\">"
                    + bean.getCommentText()
                    + "</Comment>");
          }
          commentSB.append("</Comments>");
          commentSB.append("</cmt-def>");
        }
        commentSB.append("</cmt-defs>");

        outputXM.insertBeforeTail(commentSB.toString().getBytes("utf-8"));
      }
    }
  @Override
  public boolean performOk() {
    if (!isInit) {
      return true;
    }

    if (btnCheckUpdateWithStartup.getSelection()) {
      preferenceStore.setValue(
          IPreferenceConstants.SYSTEM_AUTO_UPDATE,
          IPreferenceConstants.SYSTEM_CHECK_UPDATE_WITH_STARTUP);
    } else if (btnCheckUpdateWithMonthly.getSelection()) {
      preferenceStore.setValue(
          IPreferenceConstants.SYSTEM_AUTO_UPDATE,
          IPreferenceConstants.SYSTEM_CHECK_UPDATE_WITH_MONTHLY);
      preferenceStore.setValue(
          IPreferenceConstants.SYSTEM_CHECK_UPDATE_WITH_MONTHLY_DATE, selectDateSpi.getSelection());
    } else if (btnCheckUpdateWithWeekly.getSelection()) {
      preferenceStore.setValue(
          IPreferenceConstants.SYSTEM_AUTO_UPDATE,
          IPreferenceConstants.SYSTEM_CHECK_UPDATE_WITH_WEEKLY);
      preferenceStore.setValue(
          IPreferenceConstants.SYSTEM_CHECK_UPDATE_WITH_WEEKLY_DATE,
          cmbSelectWeek.getSelectionIndex() + 1);
    } else if (btnCheckUpdateWithNever.getSelection()) {
      preferenceStore.setValue(
          IPreferenceConstants.SYSTEM_AUTO_UPDATE,
          IPreferenceConstants.SYSTEM_CHECK_UPDATE_WITH_NEVER);
    }

    preferenceStore.setValue(
        IPreferenceConstants.SYSTEM_USER,
        txtSystemUser.getText() == null ? "" : txtSystemUser.getText());
    // 将用户保存到平台首选项中
    PlatformUI.getPreferenceStore()
        .setValue(
            IPreferenceConstants.SYSTEM_USER,
            preferenceStore.getString(IPreferenceConstants.SYSTEM_USER));
    if (btnLanguageWithEN.getSelection()) {
      preferenceStore.setValue(
          IPreferenceConstants.SYSTEM_LANGUAGE, IPreferenceConstants.SYSTEM_LANGUAGE_WITH_EN);
      CommonFunction.setSystemLanguage("en");
      if (initLang != IPreferenceConstants.SYSTEM_LANGUAGE_WITH_EN) {
        changeLocale("en");
        if (MessageDialog.openConfirm(
            getShell(),
            Messages.getString("preferencepage.SystemPreferencePage.msgTitle"),
            Messages.getString("preferencepage.SystemPreferencePage.msgInfo"))) {
          PlatformUI.getWorkbench().restart();
        }
      }
    } else if (btnLanguageWithZHCN.getSelection()) {
      preferenceStore.setValue(
          IPreferenceConstants.SYSTEM_LANGUAGE, IPreferenceConstants.SYSTEM_LANGUAGE_WITH_ZH_CN);
      CommonFunction.setSystemLanguage("zh");
      if (initLang != IPreferenceConstants.SYSTEM_LANGUAGE_WITH_ZH_CN) {
        changeLocale("zh");
        if (MessageDialog.openConfirm(
            getShell(),
            Messages.getString("preferencepage.SystemPreferencePage.msgTitle"),
            Messages.getString("preferencepage.SystemPreferencePage.msgInfo"))) {
          PlatformUI.getWorkbench().restart();
        }
      }
    }

    FontData[] fontData = editorFontSetting.getFontSetingFont();
    JFaceResources.getFontRegistry().put(Constants.XLIFF_EDITOR_TEXT_FONT, fontData);
    preferenceStore.setValue(IPreferenceConstants.XLIFF_EDITOR_FONT_NAME, fontData[0].getName());
    preferenceStore.setValue(IPreferenceConstants.XLIFF_EDITOR_FONT_SIZE, fontData[0].getHeight());

    fontData = matchViewFontSetting.getFontSetingFont();
    JFaceResources.getFontRegistry().put(Constants.MATCH_VIEWER_TEXT_FONT, fontData);
    preferenceStore.setValue(IPreferenceConstants.MATCH_VIEW_FONT_NAME, fontData[0].getName());
    preferenceStore.setValue(IPreferenceConstants.MATCH_VIEW_FONT_SIZE, fontData[0].getHeight());

    return true;
  }
Пример #4
0
    /**
     * 替换掉骨架文件中的占位符
     *
     * @param segId
     * @param srcBean
     * @param tgtbeBean
     */
    private void replaceSegment(String segId, TuMrkBean srcBean, TuMrkBean tgtbeBean)
        throws Exception {
      String segStr = "%%%" + segId + "%%%";
      String srcXpath = "/xliff/file/body//trans-unit/seg-source//mrk[text()='" + segStr + "']";
      // 先处理源文
      outputAP.selectXPath(srcXpath);
      if (outputAP.evalXPath() != -1) {
        int textIdx = outputVN.getText();
        outputXM.updateToken(textIdx, srcBean.getContent().getBytes("utf-8"));
      }
      // 处理译文
      String tgtXpath = "/xliff/file/body//trans-unit/target//mrk[text()='" + segStr + "']";
      outputAP.selectXPath(tgtXpath);
      if (outputAP.evalXPath() != -1) {
        String content = tgtbeBean.getContent();
        if (tgtbeBean.getCommentList().size() > 0) {
          String uuId = CommonFunction.createUUID();
          commentMap.put(uuId, tgtbeBean.getCommentList());
          content =
              "<mrk mtype=\"x-sdl-comment\" sdl:cid=\""
                  + uuId
                  + "\">"
                  + tgtbeBean.getContent()
                  + "</mrk>";
        }
        int textIdx = outputVN.getText();
        outputXM.updateToken(textIdx, content.getBytes("utf-8"));

        // 开始处理状态
        int attrIdx = -1;
        if ((attrIdx = outputVN.getAttrVal("mid")) != -1) {
          boolean needLocked = false;
          String mid = outputVN.toString(attrIdx);
          // 下面根据mid找到对应的sdl:seg节点,这个节点里面存放的有每个文本段的状态
          String xpath = "ancestor::trans-unit/sdl:seg-defs/sdl:seg[@id='" + mid + "']";
          outputAP.selectXPath(xpath);
          if (outputAP.evalXPath() != -1) {
            // 先判断是否锁定
            if (tgtbeBean.isLocked()) {
              if ((attrIdx = outputVN.getAttrVal("locked")) != -1) {
                if (!"true".equals(outputVN.toString(attrIdx))) {
                  outputXM.updateToken(attrIdx, "true");
                }
              } else {
                needLocked = true;
              }
            } else {
              if ((attrIdx = outputVN.getAttrVal("locked")) != -1) {
                if ("true".equals(outputVN.toString(attrIdx))) {
                  outputXM.updateToken(attrIdx, "false");
                }
              }
            }

            // 下面根据R8的状态。修改sdl的状态。
            String conf = "";
            String status = tgtbeBean.getStatus();
            if ("new".equals(status)) {
              conf = "Draft";
            } else if ("translated".equals(status)) {
              conf = "Translated";
            } else if ("approved".equals(status)) {
              conf = "ApprovedTranslation";
            } else if ("signed-off".equals(status)) {
              conf = "ApprovedSignOff";
            }

            if ("".equals(conf)) {
              if ((attrIdx = outputVN.getAttrVal("conf")) != -1) {
                outputXM.updateToken(attrIdx, "");
              }
            } else {
              if ((attrIdx = outputVN.getAttrVal("conf")) != -1) {
                if (!conf.equals(outputVN.toString(attrIdx))) {
                  outputXM.updateToken(attrIdx, conf);
                }
              } else {
                String attributeStr = "";
                if (needLocked) {
                  attributeStr = " locked=\"true\" ";
                }
                attributeStr += " conf=\"" + conf + "\" ";
                outputXM.insertAttribute(attributeStr.getBytes("utf-8"));
                needLocked = false;
              }
            }

            if (needLocked) {
              outputXM.insertAttribute(" locked=\"true\" ".getBytes("utf-8"));
            }
          }
        }
      }
    }