use of net.heartsome.cat.ts.ui.term.dialog.AddTermToTBDialog in project translationstudio8 by heartsome.
the class AddTermToTBHandler method execute.
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;
}
use of net.heartsome.cat.ts.ui.term.dialog.AddTermToTBDialog in project translationstudio8 by heartsome.
the class TermViewerBodyMenu method addTerm.
void addTerm() {
IEditorPart editor = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor();
if (editor instanceof IXliffEditor) {
IXliffEditor xliffEditor = (IXliffEditor) editor;
IFile file = ((FileEditorInput) editor.getEditorInput()).getFile();
TbImporter.getInstance().setProject(file.getProject());
if (!TbImporter.getInstance().checkImporter()) {
MessageDialog.openInformation(editor.getSite().getShell(), Messages.getString("handler.AddTermToTBHandler.msgTitle"), Messages.getString("handler.AddTermToTBHandler.msg"));
return;
}
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();
}
}
use of net.heartsome.cat.ts.ui.term.dialog.AddTermToTBDialog in project translationstudio8 by heartsome.
the class TermViewerBodyMenu method editTerm.
void editTerm() {
IProject curentProject = getCurentProject();
DBOperator dbOperator = getDbOperator(curentProject);
try {
if (dbOperator.getConnection() == null) {
dbOperator.start();
}
GridItem selectItem = getSelectItem();
String srcTerm = selectItem.getText(1);
String tgtTerm = selectItem.getText(2);
String properValue = selectItem.getText(3);
AddTermToTBDialog dialog = AddTermToTBDialog.getInstance(this.termView.getSite().getShell(), srcTerm.toString().trim(), tgtTerm.toString().trim(), AddTermToTBDialog.EDIT_TYPE);
dialog.setProject(curentProject);
dialog.setSrcLang(getSrcLang());
dialog.setTgtLang(getTgtLang());
dialog.setPropertyValue(properValue);
dialog.setDbOperator(dbOperator);
Object id = selectItem.getData("DBID");
int open = dialog.open();
if (Dialog.OK == open) {
if (id instanceof String) {
String termId = (String) id;
dbOperator.beginTransaction();
dbOperator.deleteTermEntry(termId, getSrcLang(), getTgtLang());
}
dbOperator.commit();
}
} catch (Exception e) {
MessageDialog.openInformation(this.termView.getSite().getShell(), Messages.getString("view.TerminologyViewPart.action.msg"), Messages.getString("view.TerminologyViewPart.action.editFailed"));
try {
dbOperator.rollBack();
} catch (SQLException e1) {
logger.error("RollBack error", e);
}
logger.error("", e);
} finally {
try {
dbOperator.end();
} catch (SQLException e) {
logger.error("", e);
}
}
}
Aggregations