Search in sources :

Example 6 with SelectCellCommand

use of net.sourceforge.nattable.selection.command.SelectCellCommand in project translationstudio8 by heartsome.

the class XLIFFEditorImplWithNatTable method changeLayout.

public void changeLayout(boolean isHorizontalLayout) {
    // 同步布局状态
    this.isHorizontalLayout = isHorizontalLayout;
    // 如果当前的 table 已经存在,销毁后再重新创建。
    if (table != null && !table.isDisposed()) {
        table.dispose();
        for (Control control : parent.getChildren()) {
            control.dispose();
        }
    }
    // 构建 NatTable 的数据提供者
    bodyDataProvider = setupBodyDataProvider(isHorizontalLayout);
    // 构建 NatTable 列头的数据提供者
    DefaultColumnHeaderDataProvider colHeaderDataProvider = new DefaultColumnHeaderDataProvider(propertyNames, propertyToLabels);
    // 构建 NatTable 的 body layer stack
    bodyLayer = new BodyLayerStack(bodyDataProvider, isHorizontalLayout);
    // 构建 NatTable 的 column header layout stack
    ColumnHeaderLayerStack columnHeaderLayer = new ColumnHeaderLayerStack(colHeaderDataProvider);
    // 构建 NatTable 之下的 composite layer,不使用默认的 configuration(默认的 configuration 是在点击可编辑单元格时,直接进入编辑状态)。
    CompositeLayer compositeLayer = new CompositeLayer(1, 2);
    compositeLayer.setChildLayer(GridRegion.COLUMN_HEADER, columnHeaderLayer, 0, 0);
    compositeLayer.setChildLayer(GridRegion.BODY, bodyLayer, 0, 1);
    // 标识 BodyLayer 在 CompositeLayer 上的位置
    LayerUtil.setBodyLayerPosition(0, 1);
    /* 给 composite layer 添加编辑相关的命令和 handler */
    // 添加行背景色(奇数行和偶数行不同)
    addRowBackgroundColor(compositeLayer);
    // 构建 NatTable
    table = new NatTable(parent, compositeLayer, false);
    Language srcLang = LocaleService.getLanguageConfiger().getLanguageByCode(srcColumnName);
    Language tgtLang = LocaleService.getLanguageConfiger().getLanguageByCode(tgtColumnName);
    if (srcLang.isBidi() || tgtLang.isBidi()) {
        table.setOrientation(SWT.RIGHT_TO_LEFT);
    }
    // 去除默认绘画器
    table.removePaintListener(table);
    // 使用自定义绘画器,此绘画器,具有自动计算行高功能。
    table.addPaintListener(paintListenerWithAutoRowSize);
    Listener[] ls = table.getListeners(SWT.Resize);
    for (Listener l : ls) {
        table.removeListener(SWT.Resize, l);
    }
    table.addListener(SWT.Resize, resizeListenerWithColumnResize);
    table.addDisposeListener(new DisposeListener() {

        public void widgetDisposed(DisposeEvent e) {
            // ActiveCellEditor.commit(); // 关闭编辑时,先提交未提交的单元格,避免造成内容丢失。Bug #2685
            HsMultiActiveCellEditor.commit(true);
            table.removeListener(SWT.Resize, resizeListenerWithColumnResize);
            table.removePaintListener(paintListenerWithAutoRowSize);
        }
    });
    table.setLayoutData(new GridData(GridData.FILL_BOTH));
    // 给 NatTable 添加相应的配置
    DefaultNatTableStyleConfiguration configuration = new DefaultNatTableStyleConfiguration();
    configuration.hAlign = HorizontalAlignmentEnum.LEFT;
    table.addConfiguration(configuration);
    // To be changed 给NatTable添加选择列的功能 Add By Leakey
    /*
		 * ColumnGroupModel columnGroupModel = new ColumnGroupModel(); DisplayColumnChooserCommandHandler
		 * columnChooserCommandHandler = new DisplayColumnChooserCommandHandler( bodyLayer.getSelectionLayer(),
		 * bodyLayer.getColumnHideShowLayer(), columnHeaderLayer.getColumnHeaderLayer(),
		 * columnHeaderLayer.getColumnHeaderDataLayer(), columnHeaderLayer.getColumnGroupHeaderLayer(), columnGroupModel
		 * ); bodyLayer.registerCommandHandler(columnChooserCommandHandler);
		 */
    /*
		 * 不使用默认的表头菜单,使用自定义的菜单,因此自定义菜单在 corner 中添加了相应的菜单项,所以需要指定这些添加的 command 在哪一层进一处理
		 */
    // 表头中添加自定义菜单会引发一些不可预料的问题,故先去掉
    // table.addConfiguration(new HeaderMenuConfiguration(table));
    /*
		 * 增加表格的自定义右键菜单
		 */
    table.addConfiguration(new BodyMenuConfiguration(this));
    // 注册列头点击监听(处理排序)
    table.addConfiguration(new SingleClickSortConfiguration());
    /*
		 * 初始化“撤销/重做”历史
		 */
    initializeOperationHistory();
    table.setData(IUndoContext.class.getName(), undoContext);
    /* Weachy - 注册修改后保存内容并自适应大小的处理 handler(覆盖默认的handler:UpdateDataCommandHandler) */
    bodyLayer.getBodyDataLayer().registerCommandHandler(new UpdateDataAndAutoResizeCommandHandler(table, bodyLayer.getBodyDataLayer()));
    /* Weachy - 注册当前显示行的行高自适应处理 handler */
    compositeLayer.registerCommandHandler(new AutoResizeCurrentRowsCommandHandler(compositeLayer));
    /* Weachy - 移除系统默认的查找 handler,添加自定义的查找替换 handler */
    bodyLayer.getSelectionLayer().unregisterCommandHandler(SearchCommand.class);
    bodyLayer.getSelectionLayer().registerCommandHandler(new FindReplaceCommandHandler(bodyLayer.getSelectionLayer()));
    /*
		 * 下面给 NatTable 添加可编辑单元格的配置
		 */
    table.addConfiguration(editableGridConfiguration());
    // 添加标记的自定义显示样式
    IConfigRegistry configRegistry = new ConfigRegistry();
    /*
		 * 如果是水平布局,则使用 ColumnOverrideLabelAccumulator 实现指定列都使用相同的显示样式;否则使用 CellOverrideLabelAccumulator 实现根据显示的内容来显示样式。
		 */
    if (isHorizontalLayout) {
        // 第一步:创建一个标签累加器,给需要绘制会不同效果的 cells 添加自定义的标签。在这里是第三列的标签列。
        ColumnOverrideLabelAccumulator columnLabelAccumulator = new ColumnOverrideLabelAccumulator(bodyLayer);
        columnLabelAccumulator.registerColumnOverrides(0, "LINENUMBER_CELL_LABEL");
        columnLabelAccumulator.registerColumnOverrides(1, SOURCE_EDIT_CELL_LABEL);
        columnLabelAccumulator.registerColumnOverrides(2, FLAG_CELL_LABEL);
        columnLabelAccumulator.registerColumnOverrides(3, TARGET_EDIT_CELL_LABEL);
        // 第二步:注册这个标签累加器。
        bodyLayer.setConfigLabelAccumulator(columnLabelAccumulator);
        // 第三步:把自定义的 cell painter,cell style 与自定义的标签进行关联。
        addFlagLableToColumn(configRegistry);
        addLineNumberToColumn(configRegistry);
    } else {
        ColumnOverrideLabelAccumulator columnLabelAccumulator = new ColumnOverrideLabelAccumulator(bodyLayer);
        columnLabelAccumulator.registerColumnOverrides(0, "LINENUMBER_CELL_LABEL");
        columnLabelAccumulator.registerColumnOverrides(1, FLAG_CELL_LABEL);
        columnLabelAccumulator.registerColumnOverrides(VerticalNatTableConfig.TARGET_COL_INDEX, SOURCE_EDIT_CELL_LABEL);
        columnLabelAccumulator.registerColumnOverrides(VerticalNatTableConfig.TARGET_COL_INDEX, TARGET_EDIT_CELL_LABEL);
        bodyLayer.setConfigLabelAccumulator(columnLabelAccumulator);
        // CellOverrideLabelAccumulator<TransUnitDummy> cellLabelAccumulator = new
        // CellOverrideLabelAccumulator<TransUnitDummy>(
        // (IRowDataProvider) bodyDataProvider);
        // CellOverrideLabelAccumulator<TransUnitBean> cellLabelAccumulator = new
        // CellOverrideLabelAccumulator<TransUnitBean>(
        // (IRowDataProvider) bodyDataProvider);
        // cellLabelAccumulator.registerOverride("flag", VerticalNatTableConfig.SOURCE_COL_INDEX,
        // FOCUS_CELL_LABEL);
        //
        // bodyLayer.getBodyDataLayer().setConfigLabelAccumulator(cellLabelAccumulator);
        addFlagLableToColumn(configRegistry);
        addLineNumberToColumn(configRegistry);
    }
    table.setConfigRegistry(configRegistry);
    // configure manually
    table.configure();
    /* Weachy - 垂直布局下,注册使键盘方向键以 2 行为一个单位移动选中行的处理 handler(覆盖默认的handler:MoveRowSelectionCommandHandler) */
    if (!isHorizontalLayout) {
    // SelectionLayer selectionLayer = bodyLayer.getSelectionLayer();
    // selectionLayer.registerCommandHandler(new VerticalMoveRowSelectionCommandHandler(selectionLayer));
    }
    if (bodyLayer.selectionLayer.getRowCount() > 0) {
        // 默认选中第一行
        HsMultiActiveCellEditor.commit(true);
        bodyLayer.selectionLayer.doCommand(new SelectCellCommand(bodyLayer.getSelectionLayer(), getTgtColumnIndex(), isHorizontalLayout ? 0 : 1, false, false));
        HsMultiCellEditorControl.activeSourceAndTargetCell(this);
    }
    IWorkbenchPage page = getSite().getPage();
    IViewReference[] viewReferences = page.getViewReferences();
    IViewPart view;
    for (int i = 0; i < viewReferences.length; i++) {
        view = viewReferences[i].getView(false);
        if (view == null) {
            continue;
        }
        // 切换到其他视图,再切换回来,解决NatTable改变布局后其他视图无法监听到的问题。
        view.setFocus();
    // break;
    }
    // 改变布局方式后,把焦点给 NatTable
    table.setFocus();
    RowHeightCalculator rowHeightCalculator = new RowHeightCalculator(bodyLayer, table, 32);
    ILayer lay = bodyLayer.getViewportLayer();
    if (lay instanceof HorizontalViewportLayer) {
        ((HorizontalViewportLayer) bodyLayer.getViewportLayer()).setRowHeightCalculator(rowHeightCalculator);
    } else if (lay instanceof VerticalViewportLayer) {
        ((VerticalViewportLayer) bodyLayer.getViewportLayer()).setRowHeightCalculator(rowHeightCalculator);
    }
    parent.layout();
    NoteToolTip toolTip = new NoteToolTip(table);
    toolTip.setPopupDelay(10);
    toolTip.activate();
    toolTip.setShift(new Point(10, 10));
    StateToolTip stateTip = new StateToolTip(table);
    stateTip.setPopupDelay(10);
    stateTip.activate();
    stateTip.setShift(new Point(10, 10));
    NotSendToTmToolTip notSendToTMToolTip = new NotSendToTmToolTip(table);
    notSendToTMToolTip.setPopupDelay(10);
    notSendToTMToolTip.activate();
    notSendToTMToolTip.setShift(new Point(10, 10));
    HasQustionToolTip hasqustionTooltip = new HasQustionToolTip(table);
    hasqustionTooltip.setPopupDelay(10);
    hasqustionTooltip.activate();
    hasqustionTooltip.setShift(new Point(10, 10));
    // 在状态栏上显示当前文本段的信息。
    updateStatusLine();
}
Also used : DisposeListener(org.eclipse.swt.events.DisposeListener) IViewPart(org.eclipse.ui.IViewPart) PaintListener(org.eclipse.swt.events.PaintListener) IPropertyChangeListener(org.eclipse.jface.util.IPropertyChangeListener) DisposeListener(org.eclipse.swt.events.DisposeListener) Listener(org.eclipse.swt.widgets.Listener) IPropertyListener(org.eclipse.ui.IPropertyListener) VerifyListener(org.eclipse.swt.events.VerifyListener) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) FindReplaceCommandHandler(net.heartsome.cat.ts.ui.xliffeditor.nattable.search.command.FindReplaceCommandHandler) DisposeEvent(org.eclipse.swt.events.DisposeEvent) BodyMenuConfiguration(net.heartsome.cat.ts.ui.xliffeditor.nattable.menu.BodyMenuConfiguration) IUndoContext(org.eclipse.core.commands.operations.IUndoContext) IConfigRegistry(net.sourceforge.nattable.config.IConfigRegistry) ConfigRegistry(net.sourceforge.nattable.config.ConfigRegistry) Control(org.eclipse.swt.widgets.Control) Language(net.heartsome.cat.common.locale.Language) DefaultNatTableStyleConfiguration(net.sourceforge.nattable.config.DefaultNatTableStyleConfiguration) IViewReference(org.eclipse.ui.IViewReference) NatTable(net.sourceforge.nattable.NatTable) ColumnOverrideLabelAccumulator(net.sourceforge.nattable.layer.cell.ColumnOverrideLabelAccumulator) UpdateDataAndAutoResizeCommandHandler(net.heartsome.cat.ts.ui.xliffeditor.nattable.handler.UpdateDataAndAutoResizeCommandHandler) SelectCellCommand(net.sourceforge.nattable.selection.command.SelectCellCommand) ILayer(net.sourceforge.nattable.layer.ILayer) Point(org.eclipse.swt.graphics.Point) CompositeLayer(net.sourceforge.nattable.layer.CompositeLayer) Point(org.eclipse.swt.graphics.Point) RowHeightCalculator(net.heartsome.cat.ts.ui.xliffeditor.nattable.layer.RowHeightCalculator) VerticalViewportLayer(net.heartsome.cat.ts.ui.xliffeditor.nattable.layer.VerticalViewportLayer) HorizontalViewportLayer(net.heartsome.cat.ts.ui.xliffeditor.nattable.layer.HorizontalViewportLayer) SingleClickSortConfiguration(net.sourceforge.nattable.sort.config.SingleClickSortConfiguration) IConfigRegistry(net.sourceforge.nattable.config.IConfigRegistry) GridData(org.eclipse.swt.layout.GridData) IWorkbenchPage(org.eclipse.ui.IWorkbenchPage) DefaultColumnHeaderDataProvider(net.sourceforge.nattable.grid.data.DefaultColumnHeaderDataProvider) AutoResizeCurrentRowsCommandHandler(net.heartsome.cat.ts.ui.xliffeditor.nattable.handler.AutoResizeCurrentRowsCommandHandler)

Example 7 with SelectCellCommand

use of net.sourceforge.nattable.selection.command.SelectCellCommand in project translationstudio8 by heartsome.

the class XLIFFEditorImplWithNatTable method jumpToRow.

/**
	 * 跳转到指定行的文本段
	 * @param rowPosition
	 *            行号,从0开始 ;
	 */
public void jumpToRow(int rowPosition) {
    if (rowPosition < 0) {
        return;
    }
    int[] selectedRows = getSelectedRows();
    if (selectedRows.length == 1 && selectedRows[0] == rowPosition) {
        // 如果已经选中此行
        return;
    }
    // TODO 已在 target 内容修改的时候判断并将 state 属性值做修改,此处理论上无需再做处理。
    // updateCurrentSegmentTranslateProp(); // 若当前目标文本段内容不为空,则自动将其 state 属性值设为“translated”
    int maxRowNum = handler.countEditableTransUnit() - 1;
    rowPosition = rowPosition > maxRowNum ? maxRowNum : rowPosition;
    if (!isHorizontalLayout) {
        // 处理垂直布局下的行号
        rowPosition = rowPosition * VerticalNatTableConfig.ROW_SPAN;
    }
    ViewportLayer viewportLayer = bodyLayer.getViewportLayer();
    // 先记录下可见区域的范围
    HsMultiActiveCellEditor.commit(true);
    viewportLayer.doCommand(new SelectCellCommand(bodyLayer.getSelectionLayer(), getTgtColumnIndex(), rowPosition, false, false));
    HsMultiCellEditorControl.activeSourceAndTargetCell(this);
}
Also used : SelectCellCommand(net.sourceforge.nattable.selection.command.SelectCellCommand) HorizontalViewportLayer(net.heartsome.cat.ts.ui.xliffeditor.nattable.layer.HorizontalViewportLayer) ViewportLayer(net.sourceforge.nattable.viewport.ViewportLayer) VerticalViewportLayer(net.heartsome.cat.ts.ui.xliffeditor.nattable.layer.VerticalViewportLayer) Point(org.eclipse.swt.graphics.Point)

Example 8 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) {
    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;
    natTable.doCommand(new SelectCellCommand(natTable, columnPosition, rowPosition, withShiftMask, withCtrlMask));
    natTable.doCommand(new EditCellCommand(natTable, natTable.getConfigRegistry(), natTable.getCellByPosition(columnPosition, rowPosition)));
}
Also used : SelectCellCommand(net.sourceforge.nattable.selection.command.SelectCellCommand) EditCellCommand(net.sourceforge.nattable.edit.command.EditCellCommand)

Example 9 with SelectCellCommand

use of net.sourceforge.nattable.selection.command.SelectCellCommand in project translationstudio8 by heartsome.

the class KeyEditAction method run.

public void run(NatTable natTable, KeyEvent event) {
    Character character = null;
    if (LetterOrDigitKeyEventMatcher.isLetterOrDigit(event.character) || event.character == ' ') {
        character = Character.valueOf(event.character);
    }
    if (character != null) {
        int[] selectedRowIndexs = XLIFFEditorImplWithNatTable.getCurrent().getSelectedRows();
        if (selectedRowIndexs.length == 0) {
            return;
        }
        Arrays.sort(selectedRowIndexs);
        int rowIndex = selectedRowIndexs[selectedRowIndexs.length - 1];
        ViewportLayer viewportLayer = LayerUtil.getLayer(natTable, ViewportLayer.class);
        SelectionLayer selectionLayer = LayerUtil.getLayer(natTable, SelectionLayer.class);
        // 先记录下可见区域的范围
        int originRowPosition = viewportLayer.getOriginRowPosition();
        // 总行数
        int rowCount = viewportLayer.getRowCount();
        XLIFFEditorImplWithNatTable editor = XLIFFEditorImplWithNatTable.getCurrent();
        if (!editor.isHorizontalLayout()) {
            rowIndex = rowIndex * 2;
        }
        if (rowIndex < originRowPosition || rowIndex > originRowPosition + rowCount || HsMultiActiveCellEditor.getTargetEditor() == null) {
            HsMultiActiveCellEditor.commit(true);
            PositionCoordinate p = selectionLayer.getLastSelectedCellPosition();
            if (!editor.isHorizontalLayout()) {
                natTable.doCommand(new SelectCellCommand(selectionLayer, editor.getTgtColumnIndex(), p.rowPosition / 2 * 2, false, false));
            } else {
                if (p.columnPosition != editor.getSrcColumnIndex() && p.columnPosition != editor.getTgtColumnIndex()) {
                    p.columnPosition = editor.getTgtColumnIndex();
                }
                natTable.doCommand(new SelectCellCommand(selectionLayer, p.columnPosition, p.rowPosition, false, false));
            }
            HsMultiCellEditorControl.activeSourceAndTargetCell(editor);
            StyledTextCellEditor cellEditor = HsMultiActiveCellEditor.getFocusCellEditor();
            if (cellEditor != null && cellEditor.getCellType().equals(NatTableConstant.TARGET)) {
                cellEditor.insertCanonicalValue(character);
            }
        }
    } else if ((event.character == SWT.CR) && event.stateMask == SWT.NONE) {
        HsMultiActiveCellEditor.commit(true);
        SelectionLayer selectionLayer = LayerUtil.getLayer(natTable, SelectionLayer.class);
        PositionCoordinate p = selectionLayer.getLastSelectedCellPosition();
        XLIFFEditorImplWithNatTable editor = XLIFFEditorImplWithNatTable.getCurrent();
        if (!editor.isHorizontalLayout()) {
            natTable.doCommand(new SelectCellCommand(selectionLayer, editor.getTgtColumnIndex(), p.rowPosition / 2 * 2, false, false));
        } else {
            if (p.columnPosition != editor.getSrcColumnIndex() && p.columnPosition != editor.getTgtColumnIndex()) {
                p.columnPosition = editor.getTgtColumnIndex();
            }
            natTable.doCommand(new SelectCellCommand(selectionLayer, p.columnPosition, p.rowPosition, false, false));
        }
        HsMultiCellEditorControl.activeSourceAndTargetCell(editor);
    }
}
Also used : XLIFFEditorImplWithNatTable(net.heartsome.cat.ts.ui.xliffeditor.nattable.editor.XLIFFEditorImplWithNatTable) SelectionLayer(net.sourceforge.nattable.selection.SelectionLayer) SelectCellCommand(net.sourceforge.nattable.selection.command.SelectCellCommand) PositionCoordinate(net.sourceforge.nattable.coordinate.PositionCoordinate) ViewportLayer(net.sourceforge.nattable.viewport.ViewportLayer) StyledTextCellEditor(net.heartsome.cat.ts.ui.xliffeditor.nattable.editor.StyledTextCellEditor)

Example 10 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