Search in sources :

Example 16 with NatTable

use of net.sourceforge.nattable.NatTable in project translationstudio8 by heartsome.

the class NatEventData method createInstanceFromEvent.

public static NatEventData createInstanceFromEvent(MouseEvent event) {
    NatTable natTable = (NatTable) event.widget;
    int columnPosition = natTable.getColumnPositionByX(event.x);
    int rowPosition = natTable.getRowPositionByY(event.y);
    return new NatEventData(natTable, natTable.getRegionLabelsByXY(event.x, event.y), columnPosition, rowPosition, event.data);
}
Also used : NatTable(net.sourceforge.nattable.NatTable)

Example 17 with NatTable

use of net.sourceforge.nattable.NatTable in project translationstudio8 by heartsome.

the class MenuItemProviders method renameColumnMenuItemProvider.

public static IMenuItemProvider renameColumnMenuItemProvider(final String label) {
    return new IMenuItemProvider() {

        public void addMenuItem(final NatTable natTable, final Menu popupMenu) {
            MenuItem menuItem = new MenuItem(popupMenu, SWT.PUSH);
            menuItem.setText(label);
            menuItem.setEnabled(true);
            menuItem.addSelectionListener(new SelectionAdapter() {

                @Override
                public void widgetSelected(SelectionEvent event) {
                    natTable.doCommand(new DisplayColumnRenameDialogCommand(natTable, getNatEventData(event).getColumnPosition()));
                }
            });
        }
    };
}
Also used : DisplayColumnRenameDialogCommand(net.sourceforge.nattable.columnRename.DisplayColumnRenameDialogCommand) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) SelectionEvent(org.eclipse.swt.events.SelectionEvent) NatTable(net.sourceforge.nattable.NatTable) MenuItem(org.eclipse.swt.widgets.MenuItem) Menu(org.eclipse.swt.widgets.Menu)

Example 18 with NatTable

use of net.sourceforge.nattable.NatTable in project translationstudio8 by heartsome.

the class MenuItemProviders method autoResizeAllSelectedColumnMenuItemProvider.

public static IMenuItemProvider autoResizeAllSelectedColumnMenuItemProvider() {
    return new IMenuItemProvider() {

        public void addMenuItem(final NatTable natTable, final Menu popupMenu) {
            MenuItem autoResizeColumns = new MenuItem(popupMenu, SWT.PUSH);
            autoResizeColumns.setText("Auto resize all selected columns");
            autoResizeColumns.setEnabled(true);
            autoResizeColumns.addSelectionListener(new SelectionAdapter() {

                @Override
                public void widgetSelected(SelectionEvent event) {
                    int columnPosition = getNatEventData(event).getColumnPosition();
                    natTable.doCommand(new InitializeAutoResizeColumnsCommand(natTable, columnPosition, natTable.getConfigRegistry(), new GC(natTable)));
                }
            });
        }
    };
}
Also used : SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) InitializeAutoResizeColumnsCommand(net.sourceforge.nattable.resize.command.InitializeAutoResizeColumnsCommand) SelectionEvent(org.eclipse.swt.events.SelectionEvent) NatTable(net.sourceforge.nattable.NatTable) MenuItem(org.eclipse.swt.widgets.MenuItem) Menu(org.eclipse.swt.widgets.Menu) GC(org.eclipse.swt.graphics.GC)

Example 19 with NatTable

use of net.sourceforge.nattable.NatTable in project translationstudio8 by heartsome.

the class HsMultiCellEditorControl method activeSourceAndTargetCell.

public static void activeSourceAndTargetCell(XLIFFEditorImplWithNatTable xliffEditor) {
    if (xliffEditor == null) {
        return;
    }
    int[] selectedRowIndexs = xliffEditor.getSelectedRows();
    if (selectedRowIndexs.length == 0) {
        return;
    }
    Arrays.sort(selectedRowIndexs);
    int rowIndex = selectedRowIndexs[selectedRowIndexs.length - 1];
    if (!xliffEditor.isHorizontalLayout()) {
        // source index
        rowIndex = rowIndex * 2;
    }
    NatTable natTable = xliffEditor.getTable();
    IConfigRegistry configRegistry = natTable.getConfigRegistry();
    ViewportLayer vLayer = LayerUtil.getLayer(natTable, ViewportLayer.class);
    int rowPosition = vLayer.getRowPositionByIndex(rowIndex);
    rowPosition += 1;
    if (rowPosition < 1) {
        return;
    }
    int columnIndex = xliffEditor.getSrcColumnIndex();
    HsMultiCellEditor srcCellEditor = activeCell(vLayer, xliffEditor, configRegistry, columnIndex, rowIndex, rowPosition, NatTableConstant.SOURCE);
    if (srcCellEditor == null) {
        return;
    }
    if (!xliffEditor.isHorizontalLayout()) {
        // target
        rowIndex = rowIndex + 1;
        rowPosition = vLayer.getRowPositionByIndex(rowIndex);
        rowPosition += 1;
        if (rowPosition < 1) {
            return;
        }
    }
    columnIndex = xliffEditor.getTgtColumnIndex();
    HsMultiCellEditor tgtCellEditor = activeCell(vLayer, xliffEditor, configRegistry, columnIndex, rowIndex, rowPosition, NatTableConstant.TARGET);
    if (tgtCellEditor == null) {
        return;
    }
    HsMultiActiveCellEditor.activateCellEditors(srcCellEditor, tgtCellEditor, natTable);
    // 目标文本段一进入焦点就进行一次拼写检查 robert 2013-01-22
    // UNDO 这里错误单词提示并没有修改颜色。
    String tgtLang = xliffEditor.getTgtColumnName();
    spellTrigger = RealTimeSpellCheckTrigger.getInstance();
    if (spellTrigger != null && spellTrigger.checkSpellAvailable(tgtLang)) {
        tgtTextFirstRealTimeSpellCheck(tgtLang, tgtCellEditor);
        tgtTextRealTimeSpellCheck(tgtLang, tgtCellEditor);
    }
    List<String> terms = xliffEditor.getTermsCache().get(selectedRowIndexs[0]);
    if (terms != null && terms.size() > 0) {
        srcCellEditor.highlightedTerms(terms);
    }
}
Also used : IConfigRegistry(net.sourceforge.nattable.config.IConfigRegistry) NatTable(net.sourceforge.nattable.NatTable) ViewportLayer(net.sourceforge.nattable.viewport.ViewportLayer)

Aggregations

NatTable (net.sourceforge.nattable.NatTable)19 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)14 SelectionEvent (org.eclipse.swt.events.SelectionEvent)14 Menu (org.eclipse.swt.widgets.Menu)14 MenuItem (org.eclipse.swt.widgets.MenuItem)14 GC (org.eclipse.swt.graphics.GC)3 IConfigRegistry (net.sourceforge.nattable.config.IConfigRegistry)2 ILayer (net.sourceforge.nattable.layer.ILayer)2 InitializeAutoResizeColumnsCommand (net.sourceforge.nattable.resize.command.InitializeAutoResizeColumnsCommand)2 Point (org.eclipse.swt.graphics.Point)2 Language (net.heartsome.cat.common.locale.Language)1 XLIFFEditorImplWithNatTable (net.heartsome.cat.ts.ui.xliffeditor.nattable.editor.XLIFFEditorImplWithNatTable)1 AutoResizeCurrentRowsCommandHandler (net.heartsome.cat.ts.ui.xliffeditor.nattable.handler.AutoResizeCurrentRowsCommandHandler)1 UpdateDataAndAutoResizeCommandHandler (net.heartsome.cat.ts.ui.xliffeditor.nattable.handler.UpdateDataAndAutoResizeCommandHandler)1 HorizontalViewportLayer (net.heartsome.cat.ts.ui.xliffeditor.nattable.layer.HorizontalViewportLayer)1 RowHeightCalculator (net.heartsome.cat.ts.ui.xliffeditor.nattable.layer.RowHeightCalculator)1 VerticalViewportLayer (net.heartsome.cat.ts.ui.xliffeditor.nattable.layer.VerticalViewportLayer)1 BodyMenuConfiguration (net.heartsome.cat.ts.ui.xliffeditor.nattable.menu.BodyMenuConfiguration)1 FindReplaceCommandHandler (net.heartsome.cat.ts.ui.xliffeditor.nattable.search.command.FindReplaceCommandHandler)1 ActiveCellRegion (net.heartsome.cat.ts.ui.xliffeditor.nattable.search.coordinate.ActiveCellRegion)1