Search in sources :

Example 1 with UpdateNoteDialog

use of net.heartsome.cat.ts.ui.xliffeditor.nattable.dialog.UpdateNoteDialog in project translationstudio8 by heartsome.

the class EditSelectionSegmentNotesHandler method execute.

public Object execute(ExecutionEvent event) throws ExecutionException {
    IEditorPart editorPart = HandlerUtil.getActiveEditor(event);
    if (editorPart instanceof XLIFFEditorImplWithNatTable) {
        XLIFFEditorImplWithNatTable xliffEditor = (XLIFFEditorImplWithNatTable) editorPart;
        if (xliffEditor.getSelectedRows().length == 0) {
            return null;
        }
        if (xliffEditor.getSelectedRows().length > 1) {
            MessageDialog.openInformation(xliffEditor.getSite().getShell(), Messages.getString("menu.BodyMenuConfiguration.msgTitle"), Messages.getString("menu.BodyMenuConfiguration.msg5"));
            return null;
        }
        UpdateNoteDialog dialog = new UpdateNoteDialog(xliffEditor.getSite().getShell(), xliffEditor, xliffEditor.getSelectedRows()[0]);
        dialog.open();
    }
    return null;
}
Also used : XLIFFEditorImplWithNatTable(net.heartsome.cat.ts.ui.xliffeditor.nattable.editor.XLIFFEditorImplWithNatTable) IEditorPart(org.eclipse.ui.IEditorPart) UpdateNoteDialog(net.heartsome.cat.ts.ui.xliffeditor.nattable.dialog.UpdateNoteDialog)

Example 2 with UpdateNoteDialog

use of net.heartsome.cat.ts.ui.xliffeditor.nattable.dialog.UpdateNoteDialog in project translationstudio8 by heartsome.

the class MouseEditAction method run.

public void run(NatTable natTable, MouseEvent event) {
    XLIFFEditorImplWithNatTable xliffEditor = XLIFFEditorImplWithNatTable.getCurrent();
    if (xliffEditor == null) {
        return;
    }
    int columnPosition = natTable.getColumnPositionByX(event.x);
    int rowPosition = natTable.getRowPositionByY(event.y);
    boolean withShiftMask = (event.stateMask & SWT.SHIFT) != 0;
    boolean withCtrlMask = (event.stateMask & SWT.CTRL) != 0;
    if (!xliffEditor.isHorizontalLayout() && rowPosition != HsMultiActiveCellEditor.targetRowPosition && (rowPosition != HsMultiActiveCellEditor.sourceRowPosition || columnPosition != xliffEditor.getSrcColumnIndex())) {
        HsMultiActiveCellEditor.commit(true);
        natTable.doCommand(new SelectCellCommand(natTable, columnPosition, rowPosition, withShiftMask, withCtrlMask));
        if (columnPosition == xliffEditor.getTgtColumnIndex()) {
            HsMultiCellEditorControl.activeSourceAndTargetCell(xliffEditor);
        }
    } else if (rowPosition != HsMultiActiveCellEditor.targetRowPosition || columnPosition != xliffEditor.getSrcColumnIndex() || columnPosition != xliffEditor.getTgtColumnIndex()) {
        HsMultiActiveCellEditor.commit(true);
        natTable.doCommand(new SelectCellCommand(natTable, columnPosition, rowPosition, withShiftMask, withCtrlMask));
        if (columnPosition == xliffEditor.getSrcColumnIndex() || columnPosition == xliffEditor.getTgtColumnIndex()) {
            HsMultiCellEditorControl.activeSourceAndTargetCell(xliffEditor);
        }
    }
    // 点击批注图片时打开编辑批注对话框
    Image image = XliffEditorGUIHelper.getImage(ImageName.HAS_NOTE);
    // int columnPosition = natTable.getColumnPositionByX(event.x);
    // int rowPosition = natTable.getRowPositionByY(event.y);
    LayerCell cell = natTable.getCellByPosition(columnPosition, rowPosition);
    Rectangle imageBounds = image.getBounds();
    if (cell == null) {
        return;
    }
    Rectangle cellBounds = cell.getBounds();
    int x = cellBounds.x + imageBounds.width * 3 + 20;
    int y = cellBounds.y + CellStyleUtil.getVerticalAlignmentPadding(CellStyleUtil.getCellStyle(cell, natTable.getConfigRegistry()), cellBounds, imageBounds.height);
    if (columnPosition == xliffEditor.getStatusColumnIndex() && event.x >= x && event.x <= (x + imageBounds.width) && event.y >= y && event.y <= (y + imageBounds.height)) {
        if ((xliffEditor.isHorizontalLayout() && columnPosition == 2) || (!xliffEditor.isHorizontalLayout() && columnPosition == 1)) {
            Vector<NoteBean> noteBeans = null;
            try {
                int rowIndex = natTable.getRowIndexByPosition(rowPosition);
                if (!xliffEditor.isHorizontalLayout()) {
                    rowIndex = rowIndex / VerticalNatTableConfig.ROW_SPAN;
                }
                noteBeans = xliffEditor.getXLFHandler().getNotes(xliffEditor.getXLFHandler().getRowId(rowIndex));
                if (noteBeans != null && noteBeans.size() > 0) {
                    UpdateNoteDialog dialog = new UpdateNoteDialog(xliffEditor.getSite().getShell(), xliffEditor, rowIndex);
                    dialog.open();
                }
            } catch (NavException e) {
                e.printStackTrace();
            } catch (XPathParseException e) {
                e.printStackTrace();
            } catch (XPathEvalException e) {
                e.printStackTrace();
            }
        }
    }
}
Also used : XLIFFEditorImplWithNatTable(net.heartsome.cat.ts.ui.xliffeditor.nattable.editor.XLIFFEditorImplWithNatTable) SelectCellCommand(net.sourceforge.nattable.selection.command.SelectCellCommand) LayerCell(net.sourceforge.nattable.layer.cell.LayerCell) Rectangle(org.eclipse.swt.graphics.Rectangle) NavException(com.ximpleware.NavException) XPathEvalException(com.ximpleware.XPathEvalException) Image(org.eclipse.swt.graphics.Image) XPathParseException(com.ximpleware.XPathParseException) NoteBean(net.heartsome.cat.ts.core.bean.NoteBean) UpdateNoteDialog(net.heartsome.cat.ts.ui.xliffeditor.nattable.dialog.UpdateNoteDialog)

Aggregations

UpdateNoteDialog (net.heartsome.cat.ts.ui.xliffeditor.nattable.dialog.UpdateNoteDialog)2 XLIFFEditorImplWithNatTable (net.heartsome.cat.ts.ui.xliffeditor.nattable.editor.XLIFFEditorImplWithNatTable)2 NavException (com.ximpleware.NavException)1 XPathEvalException (com.ximpleware.XPathEvalException)1 XPathParseException (com.ximpleware.XPathParseException)1 NoteBean (net.heartsome.cat.ts.core.bean.NoteBean)1 LayerCell (net.sourceforge.nattable.layer.cell.LayerCell)1 SelectCellCommand (net.sourceforge.nattable.selection.command.SelectCellCommand)1 Image (org.eclipse.swt.graphics.Image)1 Rectangle (org.eclipse.swt.graphics.Rectangle)1 IEditorPart (org.eclipse.ui.IEditorPart)1