Search in sources :

Example 36 with IEditorPart

use of org.eclipse.ui.IEditorPart 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 37 with IEditorPart

use of org.eclipse.ui.IEditorPart 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 38 with IEditorPart

use of org.eclipse.ui.IEditorPart in project translationstudio8 by heartsome.

the class ColorConfigLoader method loadColor.

private void loadColor() {
    Device device = Activator.getDefault().getWorkbench().getDisplay();
    if (pfStore == null) {
        pfStore = Activator.getDefault().getPreferenceStore();
        pfStore.addPropertyChangeListener(this);
    }
    colorConfigBean.release();
    colorConfigBean.setPtColor(getColor(device, IColorPreferenceConstant.PT_COLOR));
    colorConfigBean.setQtColor(getColor(device, IColorPreferenceConstant.QT_COLOR));
    colorConfigBean.setMtColor(getColor(device, IColorPreferenceConstant.MT_COLOR));
    colorConfigBean.setTm101Color(getColor(device, IColorPreferenceConstant.TM_MATCH101_COLOR));
    colorConfigBean.setTm100Color(getColor(device, IColorPreferenceConstant.TM_MATCH100_COLOR));
    colorConfigBean.setTm90Color(getColor(device, IColorPreferenceConstant.TM_MATCH90_COLOR));
    colorConfigBean.setTm80Color(getColor(device, IColorPreferenceConstant.TM_MATCH80_COLOR));
    colorConfigBean.setTm70Color(getColor(device, IColorPreferenceConstant.TM_MATCH70_COLOR));
    colorConfigBean.setTm0Color(getColor(device, IColorPreferenceConstant.TM_MATCH0_COLOR));
    colorConfigBean.setSrcDiffFgColor(getColor(device, IColorPreferenceConstant.DIFFERENCE_FG_COLOR));
    colorConfigBean.setSrcDiffBgColor(getColor(device, IColorPreferenceConstant.DIFFERENCE_BG_COLOR));
    colorConfigBean.setTagFgColor(getColor(device, IColorPreferenceConstant.TAG_FG_COLOR));
    colorConfigBean.setTagBgColor(getColor(device, IColorPreferenceConstant.TAG_BG_COLOR));
    colorConfigBean.setWrongTagColor(getColor(device, IColorPreferenceConstant.WRONG_TAG_COLOR));
    colorConfigBean.setErrorWordColor(getColor(device, IColorPreferenceConstant.WRONG_TAG_COLOR));
    String strColor = colorConfigBean.toString();
    IXliffEditor xliffEditor = null;
    IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
    if (window != null) {
        IWorkbenchPage page = window.getActivePage();
        if (page != null) {
            IEditorPart editor = page.getActiveEditor();
            if (editor != null && editor instanceof IXliffEditor) {
                xliffEditor = (IXliffEditor) editor;
            }
        }
    }
    if (strCurColor != null && !strCurColor.equals(strColor)) {
        // 更改颜色设置后刷新界面
        if (xliffEditor != null) {
            xliffEditor.autoResize();
            xliffEditor.refresh();
        }
        if (window != null) {
            IWorkbenchPage page = window.getActivePage();
            if (page != null) {
                IViewPart viewPart = page.findView("net.heartsome.cat.ts.ui.translation.view.matchview");
                if (viewPart != null) {
                    IMatchViewPart part = (IMatchViewPart) viewPart;
                    part.refreshTable();
                }
            }
        }
        strCurColor = strColor;
    }
    Color highlightedTermColor = colorConfigBean.getHighlightedTermColor();
    RGB newRgb = StringConverter.asRGB(pfStore.getString(IColorPreferenceConstant.HIGHLIGHTED_TERM_COLOR));
    if (highlightedTermColor == null || highlightedTermColor.isDisposed()) {
        highlightedTermColor = new Color(device, newRgb);
    } else if (!highlightedTermColor.getRGB().equals(newRgb)) {
        highlightedTermColor.dispose();
        highlightedTermColor = new Color(device, newRgb);
        // had changed
        if (xliffEditor != null) {
            // 刷新
            xliffEditor.highlightedTerms(0, null);
        }
    }
    colorConfigBean.setHighlightedTermColor(highlightedTermColor);
}
Also used : IWorkbenchWindow(org.eclipse.ui.IWorkbenchWindow) IViewPart(org.eclipse.ui.IViewPart) Device(org.eclipse.swt.graphics.Device) Color(org.eclipse.swt.graphics.Color) IWorkbenchPage(org.eclipse.ui.IWorkbenchPage) IEditorPart(org.eclipse.ui.IEditorPart) RGB(org.eclipse.swt.graphics.RGB) IXliffEditor(net.heartsome.cat.ts.ui.editors.IXliffEditor) IMatchViewPart(net.heartsome.cat.ts.ui.view.IMatchViewPart)

Example 39 with IEditorPart

use of org.eclipse.ui.IEditorPart in project translationstudio8 by heartsome.

the class NotSendToTMHandler method execute.

public Object execute(ExecutionEvent event) throws ExecutionException {
    IEditorPart editor = HandlerUtil.getActiveEditor(event);
    if (editor instanceof XLIFFEditorImplWithNatTable) {
        XLIFFEditorImplWithNatTable xliffEditor = (XLIFFEditorImplWithNatTable) editor;
        List<String> selectedRowIds = xliffEditor.getSelectedRowIds();
        if (selectedRowIds != null && selectedRowIds.size() > 0) {
            boolean isSendtoTm = true;
            XLFHandler handler = xliffEditor.getXLFHandler();
            for (String rowId : selectedRowIds) {
                if (!handler.isSendToTM(rowId) && isSendtoTm) {
                    isSendtoTm = false;
                    break;
                }
            }
            NattableUtil util = NattableUtil.getInstance(xliffEditor);
            util.changeSendToTmState(selectedRowIds, isSendtoTm ? "yes" : "no");
        }
    }
    return null;
}
Also used : XLIFFEditorImplWithNatTable(net.heartsome.cat.ts.ui.xliffeditor.nattable.editor.XLIFFEditorImplWithNatTable) NattableUtil(net.heartsome.cat.ts.ui.xliffeditor.nattable.utils.NattableUtil) IEditorPart(org.eclipse.ui.IEditorPart) XLFHandler(net.heartsome.cat.ts.core.file.XLFHandler)

Example 40 with IEditorPart

use of org.eclipse.ui.IEditorPart in project translationstudio8 by heartsome.

the class SplitPointSettingHandler method execute.

public Object execute(ExecutionEvent event) throws ExecutionException {
    IEditorPart editor = HandlerUtil.getActiveEditor(event);
    if (editor instanceof XLIFFEditorImplWithNatTable) {
        XLIFFEditorImplWithNatTable xliffEditor = (XLIFFEditorImplWithNatTable) editor;
        if (xliffEditor.isMultiFile()) {
            MessageDialog.openInformation(HandlerUtil.getActiveShell(event), Messages.getString("menu.BodyMenuConfiguration.msgTitle"), Messages.getString("menu.BodyMenuConfiguration.msg7"));
            return null;
        }
        List<String> selectedRowIds = xliffEditor.getSelectedRowIds();
        boolean isSplitPointExist = false;
        if (selectedRowIds != null && selectedRowIds.size() > 0) {
            for (String rowId : selectedRowIds) {
                if (xliffEditor.getSplitXliffPoints().contains(rowId)) {
                    isSplitPointExist = true;
                } else {
                    isSplitPointExist = false;
                    break;
                }
            }
            if (!isSplitPointExist) {
                String xlfPath = ((FileEditorInput) xliffEditor.getEditorInput()).getFile().getLocation().toOSString();
                for (String rowId : selectedRowIds) {
                    //						String firstTURowId = xliffEditor.getXLFHandler().getRowIdByXpath(xlfPath,
                    //								"/xliff/file[1]/body/descendant::trans-unit[1]");
                    //						if (firstTURowId != null && firstTURowId.equals(rowId)) {
                    //							MessageDialog.openInformation(HandlerUtil.getActiveShell(event),
                    //									Messages.getString("menu.BodyMenuConfiguration.msgTitle"),
                    //									Messages.getString("menu.BodyMenuConfiguration.msg8"));
                    //							continue;
                    //						}
                    String lastTURowid = xliffEditor.getXLFHandler().getRowIdByXpath(xlfPath, "/xliff/file[last()]/body/descendant::trans-unit[last()]");
                    if (lastTURowid != null && lastTURowid.equals(rowId)) {
                        MessageDialog.openInformation(HandlerUtil.getActiveShell(event), Messages.getString("menu.BodyMenuConfiguration.msgTitle"), Messages.getString("menu.BodyMenuConfiguration.msg9"));
                        continue;
                    }
                    if (!xliffEditor.getSplitXliffPoints().contains(rowId)) {
                        // 将切割点的序列号添加到List中
                        xliffEditor.getSplitXliffPoints().add(rowId);
                        xliffEditor.getTable().redraw();
                    }
                }
            } else {
                for (String rowId : selectedRowIds) {
                    if (xliffEditor.getSplitXliffPoints().contains(rowId)) {
                        // 删除切割点
                        int index = xliffEditor.getSplitXliffPoints().indexOf(rowId);
                        xliffEditor.getSplitXliffPoints().remove(index);
                        xliffEditor.getTable().redraw();
                    }
                }
            }
        }
    }
    return null;
}
Also used : XLIFFEditorImplWithNatTable(net.heartsome.cat.ts.ui.xliffeditor.nattable.editor.XLIFFEditorImplWithNatTable) FileEditorInput(org.eclipse.ui.part.FileEditorInput) IEditorPart(org.eclipse.ui.IEditorPart)

Aggregations

IEditorPart (org.eclipse.ui.IEditorPart)401 IWorkbenchWindow (org.eclipse.ui.IWorkbenchWindow)137 IWorkbenchPage (org.eclipse.ui.IWorkbenchPage)127 PartInitException (org.eclipse.ui.PartInitException)73 IFile (org.eclipse.core.resources.IFile)58 XLIFFEditorImplWithNatTable (net.heartsome.cat.ts.ui.xliffeditor.nattable.editor.XLIFFEditorImplWithNatTable)53 IEditorReference (org.eclipse.ui.IEditorReference)52 XLFHandler (net.heartsome.cat.ts.core.file.XLFHandler)45 ArrayList (java.util.ArrayList)43 QueryEditorPart (com.cubrid.common.ui.query.editor.QueryEditorPart)41 IEditorInput (org.eclipse.ui.IEditorInput)37 IViewPart (org.eclipse.ui.IViewPart)34 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)33 Test (org.junit.Test)31 ISelection (org.eclipse.jface.viewers.ISelection)30 FileEditorInput (org.eclipse.ui.part.FileEditorInput)29 ITextEditor (org.eclipse.ui.texteditor.ITextEditor)27 IWorkbenchPart (org.eclipse.ui.IWorkbenchPart)26 AbstractMultiPageTalendEditor (org.talend.designer.core.ui.AbstractMultiPageTalendEditor)26 IXliffEditor (net.heartsome.cat.ts.ui.editors.IXliffEditor)24