public Object execute(ExecutionEvent event) throws ExecutionException {
    IEditorPart editor = HandlerUtil.getActiveEditor(event);
    if (editor instanceof IXliffEditor) {
      IXliffEditor xliffEditor = (IXliffEditor) editor;
      IFile file = ((FileEditorInput) editor.getEditorInput()).getFile();
      //			ProjectConfiger projectConfig =
      // ProjectConfigerFactory.getProjectConfiger(file.getProject());
      //			List<DatabaseModelBean> lstDatabase = projectConfig.getTermBaseDbs(true);
      TbImporter.getInstance().setProject(file.getProject());
      if (!TbImporter.getInstance().checkImporter()) {
        MessageDialog.openInformation(
            HandlerUtil.getActiveShell(event),
            Messages.getString("handler.AddTermToTBHandler.msgTitle"),
            Messages.getString("handler.AddTermToTBHandler.msg"));
        return null;
      }

      StringBuffer srcTerm = new StringBuffer();
      StringBuffer tgtTerm = new StringBuffer();
      String srcAllText =
          xliffEditor.getRowTransUnitBean(xliffEditor.getSelectedRows()[0]).getSrcText();
      xliffEditor.getSelectSrcOrTgtPureText(srcTerm, tgtTerm);

      AddTermToTBDialog dialog =
          AddTermToTBDialog.getInstance(
              editor.getSite().getShell(),
              srcTerm.toString().trim(),
              tgtTerm.toString().trim(),
              AddTermToTBDialog.ADD_TYPE);
      dialog.setProject(file.getProject());
      dialog.setSrcLang(xliffEditor.getSrcColumnName());
      dialog.setTgtLang(xliffEditor.getTgtColumnName());
      dialog.setSrcAllText(srcAllText);
      dialog.open();
    }
    return null;
  }
예제 #2
0
 public void releaseResource() {
   importer.setProject(null);
   TbImporter.getInstance().setProject(null);
 }