Search in sources :

Example 11 with XLIFFEditorImplWithNatTable

use of net.heartsome.cat.ts.ui.xliffeditor.nattable.editor.XLIFFEditorImplWithNatTable in project translationstudio8 by heartsome.

the class ShowNextNoteHandler method execute.

public Object execute(ExecutionEvent event) throws ExecutionException {
    IEditorPart editor = HandlerUtil.getActiveEditor(event);
    if (!(editor instanceof XLIFFEditorImplWithNatTable)) {
        return null;
    }
    XLIFFEditorImplWithNatTable xliffEditor = (XLIFFEditorImplWithNatTable) editor;
    int[] selectedRows = xliffEditor.getSelectedRows();
    if (selectedRows.length < 1) {
        return null;
    }
    Arrays.sort(selectedRows);
    int lastSelectedRow = selectedRows[selectedRows.length - 1];
    XLFHandler handler = xliffEditor.getXLFHandler();
    int row = handler.getNextNoteSegmentIndex(lastSelectedRow);
    if (row != -1) {
        xliffEditor.jumpToRow(row);
    } else {
        IWorkbenchWindow window = HandlerUtil.getActiveWorkbenchWindowChecked(event);
        MessageDialog.openWarning(window.getShell(), "", "不存在下一个带批注的文本段。");
    }
    return null;
}
Also used : IWorkbenchWindow(org.eclipse.ui.IWorkbenchWindow) XLIFFEditorImplWithNatTable(net.heartsome.cat.ts.ui.xliffeditor.nattable.editor.XLIFFEditorImplWithNatTable) IEditorPart(org.eclipse.ui.IEditorPart) XLFHandler(net.heartsome.cat.ts.core.file.XLFHandler)

Example 12 with XLIFFEditorImplWithNatTable

use of net.heartsome.cat.ts.ui.xliffeditor.nattable.editor.XLIFFEditorImplWithNatTable in project translationstudio8 by heartsome.

the class ShowNextSegmentHandler method execute.

public Object execute(ExecutionEvent event) throws ExecutionException {
    IEditorPart editor = HandlerUtil.getActiveEditor(event);
    if (!(editor instanceof XLIFFEditorImplWithNatTable)) {
        return null;
    }
    XLIFFEditorImplWithNatTable xliffEditor = (XLIFFEditorImplWithNatTable) editor;
    int[] selectedRows = xliffEditor.getSelectedRows();
    if (selectedRows.length < 1) {
        return null;
    }
    Arrays.sort(selectedRows);
    int lastSelectedRow = selectedRows[selectedRows.length - 1];
    XLFHandler handler = xliffEditor.getXLFHandler();
    int lastRow = handler.countEditableTransUnit() - 1;
    if (lastSelectedRow == lastRow) {
        lastSelectedRow = lastRow - 1;
    }
    xliffEditor.jumpToRow(lastSelectedRow + 1);
    return null;
}
Also used : XLIFFEditorImplWithNatTable(net.heartsome.cat.ts.ui.xliffeditor.nattable.editor.XLIFFEditorImplWithNatTable) IEditorPart(org.eclipse.ui.IEditorPart) XLFHandler(net.heartsome.cat.ts.core.file.XLFHandler)

Example 13 with XLIFFEditorImplWithNatTable

use of net.heartsome.cat.ts.ui.xliffeditor.nattable.editor.XLIFFEditorImplWithNatTable in project translationstudio8 by heartsome.

the class ShowNextUnapprovedHandler method execute.

public Object execute(ExecutionEvent event) throws ExecutionException {
    IEditorPart editor = HandlerUtil.getActiveEditor(event);
    if (!(editor instanceof XLIFFEditorImplWithNatTable)) {
        return null;
    }
    XLIFFEditorImplWithNatTable xliffEditor = (XLIFFEditorImplWithNatTable) editor;
    int[] selectedRows = xliffEditor.getSelectedRows();
    if (selectedRows.length < 1) {
        return null;
    }
    Arrays.sort(selectedRows);
    int lastSelectedRow = selectedRows[selectedRows.length - 1];
    XLFHandler handler = xliffEditor.getXLFHandler();
    int row = handler.getNextUnapprovedSegmentIndex(lastSelectedRow);
    if (row != -1) {
        xliffEditor.jumpToRow(row);
    } else {
        IWorkbenchWindow window = HandlerUtil.getActiveWorkbenchWindowChecked(event);
        MessageDialog.openWarning(window.getShell(), "", "不存在下一个未批准文本段。");
    }
    return null;
}
Also used : IWorkbenchWindow(org.eclipse.ui.IWorkbenchWindow) XLIFFEditorImplWithNatTable(net.heartsome.cat.ts.ui.xliffeditor.nattable.editor.XLIFFEditorImplWithNatTable) IEditorPart(org.eclipse.ui.IEditorPart) XLFHandler(net.heartsome.cat.ts.core.file.XLFHandler)

Example 14 with XLIFFEditorImplWithNatTable

use of net.heartsome.cat.ts.ui.xliffeditor.nattable.editor.XLIFFEditorImplWithNatTable in project translationstudio8 by heartsome.

the class ShowNextUntranslatableHandler method execute.

public Object execute(ExecutionEvent event) throws ExecutionException {
    IEditorPart editor = HandlerUtil.getActiveEditor(event);
    if (!(editor instanceof XLIFFEditorImplWithNatTable)) {
        return null;
    }
    XLIFFEditorImplWithNatTable xliffEditor = (XLIFFEditorImplWithNatTable) editor;
    int[] selectedRows = xliffEditor.getSelectedRows();
    if (selectedRows.length < 1) {
        return null;
    }
    Arrays.sort(selectedRows);
    int lastSelectedRow = selectedRows[selectedRows.length - 1];
    XLFHandler handler = xliffEditor.getXLFHandler();
    int row = handler.getNextUntranslatableSegmentIndex(lastSelectedRow);
    if (row != -1) {
        xliffEditor.jumpToRow(row);
    } else {
        IWorkbenchWindow window = HandlerUtil.getActiveWorkbenchWindowChecked(event);
        MessageDialog.openWarning(window.getShell(), "", "不存在下一不可翻译文本段。");
    }
    return null;
}
Also used : IWorkbenchWindow(org.eclipse.ui.IWorkbenchWindow) XLIFFEditorImplWithNatTable(net.heartsome.cat.ts.ui.xliffeditor.nattable.editor.XLIFFEditorImplWithNatTable) IEditorPart(org.eclipse.ui.IEditorPart) XLFHandler(net.heartsome.cat.ts.core.file.XLFHandler)

Example 15 with XLIFFEditorImplWithNatTable

use of net.heartsome.cat.ts.ui.xliffeditor.nattable.editor.XLIFFEditorImplWithNatTable in project translationstudio8 by heartsome.

the class ShowNextUntranslatedHandler method execute.

public Object execute(ExecutionEvent event) throws ExecutionException {
    IEditorPart editor = HandlerUtil.getActiveEditor(event);
    if (!(editor instanceof XLIFFEditorImplWithNatTable)) {
        return null;
    }
    XLIFFEditorImplWithNatTable xliffEditor = (XLIFFEditorImplWithNatTable) editor;
    int[] selectedRows = xliffEditor.getSelectedRows();
    if (selectedRows.length < 1) {
        return null;
    }
    Arrays.sort(selectedRows);
    int lastSelectedRow = selectedRows[selectedRows.length - 1];
    XLFHandler handler = xliffEditor.getXLFHandler();
    int row = handler.getNextUntranslatedSegmentIndex(lastSelectedRow);
    if (row != -1) {
        xliffEditor.jumpToRow(row);
    } else {
        IWorkbenchWindow window = HandlerUtil.getActiveWorkbenchWindowChecked(event);
        MessageDialog.openWarning(window.getShell(), "", "不存在下一未翻译文本段。");
    }
    return null;
}
Also used : IWorkbenchWindow(org.eclipse.ui.IWorkbenchWindow) XLIFFEditorImplWithNatTable(net.heartsome.cat.ts.ui.xliffeditor.nattable.editor.XLIFFEditorImplWithNatTable) IEditorPart(org.eclipse.ui.IEditorPart) XLFHandler(net.heartsome.cat.ts.core.file.XLFHandler)

Aggregations

XLIFFEditorImplWithNatTable (net.heartsome.cat.ts.ui.xliffeditor.nattable.editor.XLIFFEditorImplWithNatTable)71 IEditorPart (org.eclipse.ui.IEditorPart)53 XLFHandler (net.heartsome.cat.ts.core.file.XLFHandler)36 IWorkbenchWindow (org.eclipse.ui.IWorkbenchWindow)27 ArrayList (java.util.ArrayList)16 IFile (org.eclipse.core.resources.IFile)13 FileEditorInput (org.eclipse.ui.part.FileEditorInput)11 StyledTextCellEditor (net.heartsome.cat.ts.ui.xliffeditor.nattable.editor.StyledTextCellEditor)9 Shell (org.eclipse.swt.widgets.Shell)9 NattableUtil (net.heartsome.cat.ts.ui.xliffeditor.nattable.utils.NattableUtil)8 StructuredSelection (org.eclipse.jface.viewers.StructuredSelection)8 IViewPart (org.eclipse.ui.IViewPart)8 IWorkbenchPage (org.eclipse.ui.IWorkbenchPage)8 ExecutionException (org.eclipse.core.commands.ExecutionException)7 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)7 IEditorReference (org.eclipse.ui.IEditorReference)7 HashMap (java.util.HashMap)6 IEditorInput (org.eclipse.ui.IEditorInput)6 ISelection (org.eclipse.jface.viewers.ISelection)5 IWorkbenchPart (org.eclipse.ui.IWorkbenchPart)5