Search in sources :

Example 11 with SelectCellCommand

use of net.sourceforge.nattable.selection.command.SelectCellCommand 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

SelectCellCommand (net.sourceforge.nattable.selection.command.SelectCellCommand)11 XLIFFEditorImplWithNatTable (net.heartsome.cat.ts.ui.xliffeditor.nattable.editor.XLIFFEditorImplWithNatTable)4 StyledTextCellEditor (net.heartsome.cat.ts.ui.xliffeditor.nattable.editor.StyledTextCellEditor)3 PositionCoordinate (net.sourceforge.nattable.coordinate.PositionCoordinate)3 ViewportLayer (net.sourceforge.nattable.viewport.ViewportLayer)3 Point (org.eclipse.swt.graphics.Point)3 HorizontalViewportLayer (net.heartsome.cat.ts.ui.xliffeditor.nattable.layer.HorizontalViewportLayer)2 VerticalViewportLayer (net.heartsome.cat.ts.ui.xliffeditor.nattable.layer.VerticalViewportLayer)2 SelectionLayer (net.sourceforge.nattable.selection.SelectionLayer)2 NavException (com.ximpleware.NavException)1 XPathEvalException (com.ximpleware.XPathEvalException)1 XPathParseException (com.ximpleware.XPathParseException)1 Language (net.heartsome.cat.common.locale.Language)1 NoteBean (net.heartsome.cat.ts.core.bean.NoteBean)1 ISegmentViewer (net.heartsome.cat.ts.ui.innertag.ISegmentViewer)1 UpdateDataBean (net.heartsome.cat.ts.ui.xliffeditor.nattable.UpdateDataBean)1 CustomFilterDialog (net.heartsome.cat.ts.ui.xliffeditor.nattable.dialog.CustomFilterDialog)1 UpdateNoteDialog (net.heartsome.cat.ts.ui.xliffeditor.nattable.dialog.UpdateNoteDialog)1 AutoResizeCurrentRowsCommand (net.heartsome.cat.ts.ui.xliffeditor.nattable.handler.AutoResizeCurrentRowsCommand)1 AutoResizeCurrentRowsCommandHandler (net.heartsome.cat.ts.ui.xliffeditor.nattable.handler.AutoResizeCurrentRowsCommandHandler)1