Search in sources :

Example 1 with AddTermToTBDialog

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;
}
Also used : IFile(org.eclipse.core.resources.IFile) FileEditorInput(org.eclipse.ui.part.FileEditorInput) AddTermToTBDialog(net.heartsome.cat.ts.ui.term.dialog.AddTermToTBDialog) IEditorPart(org.eclipse.ui.IEditorPart) IXliffEditor(net.heartsome.cat.ts.ui.editors.IXliffEditor)

Example 2 with AddTermToTBDialog

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();
    }
}
Also used : IFile(org.eclipse.core.resources.IFile) FileEditorInput(org.eclipse.ui.part.FileEditorInput) AddTermToTBDialog(net.heartsome.cat.ts.ui.term.dialog.AddTermToTBDialog) IEditorPart(org.eclipse.ui.IEditorPart) IXliffEditor(net.heartsome.cat.ts.ui.editors.IXliffEditor)

Example 3 with AddTermToTBDialog

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);
        }
    }
}
Also used : GridItem(org.eclipse.nebula.widgets.grid.GridItem) SQLException(java.sql.SQLException) DBOperator(net.heartsome.cat.database.DBOperator) AddTermToTBDialog(net.heartsome.cat.ts.ui.term.dialog.AddTermToTBDialog) IProject(org.eclipse.core.resources.IProject) CoreException(org.eclipse.core.runtime.CoreException) SQLException(java.sql.SQLException)

Aggregations

AddTermToTBDialog (net.heartsome.cat.ts.ui.term.dialog.AddTermToTBDialog)3 IXliffEditor (net.heartsome.cat.ts.ui.editors.IXliffEditor)2 IFile (org.eclipse.core.resources.IFile)2 IEditorPart (org.eclipse.ui.IEditorPart)2 FileEditorInput (org.eclipse.ui.part.FileEditorInput)2 SQLException (java.sql.SQLException)1 DBOperator (net.heartsome.cat.database.DBOperator)1 IProject (org.eclipse.core.resources.IProject)1 CoreException (org.eclipse.core.runtime.CoreException)1 GridItem (org.eclipse.nebula.widgets.grid.GridItem)1