Search in sources :

Example 1 with NatTable

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

the class HsMultiCellEditorControl method activeCell.

private static HsMultiCellEditor activeCell(ViewportLayer vLayer, XLIFFEditorImplWithNatTable xliffEditor, IConfigRegistry configRegistry, int columnIndex, int rowIndex, int rowPosition, String cellType) {
    NatTable natTable = xliffEditor.getTable();
    int columnPosition = vLayer.getColumnPositionByIndex(columnIndex);
    LayerCell cell = natTable.getCellByPosition(columnPosition, rowPosition);
    if (cell == null) {
        return null;
    }
    Rectangle cellBounds = cell.getBounds();
    List<String> configLabels = cell.getConfigLabels().getLabels();
    if (!xliffEditor.isHorizontalLayout()) {
        if (cellType.equals(NatTableConstant.SOURCE)) {
            configLabels.remove(XLIFFEditorImplWithNatTable.TARGET_EDIT_CELL_LABEL);
        } else if (cellType.equals(NatTableConstant.TARGET)) {
            configLabels.remove(XLIFFEditorImplWithNatTable.SOURCE_EDIT_CELL_LABEL);
        }
    }
    ILayer layer = cell.getLayer();
    Object originalCanonicalValue = cell.getDataValue();
    IDisplayConverter displayConverter = configRegistry.getConfigAttribute(CellConfigAttributes.DISPLAY_CONVERTER, DisplayMode.EDIT, configLabels);
    IStyle cellStyle = new CellStyleProxy(configRegistry, DisplayMode.EDIT, configLabels);
    IDataValidator dataValidator = configRegistry.getConfigAttribute(EditConfigAttributes.DATA_VALIDATOR, DisplayMode.EDIT, configLabels);
    Rectangle editorBounds = layer.getLayerPainter().adjustCellBounds(new Rectangle(cellBounds.x, cellBounds.y, cellBounds.width, cellBounds.height));
    int cellStartY = cellBounds.y;
    int cellEndY = cellStartY + cellBounds.height;
    Rectangle clientArea = natTable.getClientAreaProvider().getClientArea();
    int clientAreaEndY = clientArea.y + clientArea.height;
    if (cellEndY > clientAreaEndY) {
        editorBounds.height = clientAreaEndY - cellStartY;
    }
    StyledTextCellEditor cellEditor = (StyledTextCellEditor) configRegistry.getConfigAttribute(EditConfigAttributes.CELL_EDITOR, DisplayMode.EDIT, configLabels);
    ICellEditHandler editHandler = new HsMultiCellEditorHandler(cellEditor, layer);
    HsMultiCellEditor hsCellEditor = new HsMultiCellEditor(cellType, cellEditor, editHandler, columnPosition, rowPosition, columnIndex, rowIndex, dataValidator, originalCanonicalValue, displayConverter, cellStyle, editorBounds);
    return hsCellEditor;
}
Also used : IDataValidator(net.sourceforge.nattable.data.validate.IDataValidator) ICellEditHandler(net.sourceforge.nattable.edit.ICellEditHandler) ILayer(net.sourceforge.nattable.layer.ILayer) LayerCell(net.sourceforge.nattable.layer.cell.LayerCell) Rectangle(org.eclipse.swt.graphics.Rectangle) IDisplayConverter(net.sourceforge.nattable.data.convert.IDisplayConverter) IStyle(net.sourceforge.nattable.style.IStyle) NatTable(net.sourceforge.nattable.NatTable) CellStyleProxy(net.sourceforge.nattable.style.CellStyleProxy)

Example 2 with NatTable

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

the class MenuItemProviders method columnChooserMenuItemProvider.

public static IMenuItemProvider columnChooserMenuItemProvider(final String menuLabel) {
    return new IMenuItemProvider() {

        public void addMenuItem(final NatTable natTable, final Menu popupMenu) {
            MenuItem columnChooser = new MenuItem(popupMenu, SWT.PUSH);
            columnChooser.setText(menuLabel);
            columnChooser.setImage(GUIHelper.getImage("column_chooser"));
            columnChooser.setEnabled(true);
            columnChooser.addSelectionListener(new SelectionAdapter() {

                @Override
                public void widgetSelected(SelectionEvent e) {
                    natTable.doCommand(new DisplayColumnChooserCommand(natTable));
                }
            });
        }
    };
}
Also used : 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) DisplayColumnChooserCommand(net.sourceforge.nattable.columnChooser.command.DisplayColumnChooserCommand)

Example 3 with NatTable

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

the class MenuItemProviders method clearToggleFilterRowMenuItemProvider.

public static IMenuItemProvider clearToggleFilterRowMenuItemProvider(final String menuLabel) {
    return new IMenuItemProvider() {

        public void addMenuItem(final NatTable natTable, final Menu popupMenu) {
            MenuItem menuItem = new MenuItem(popupMenu, SWT.PUSH);
            menuItem.setText(menuLabel);
            menuItem.setImage(GUIHelper.getImage("toggle_filter"));
            menuItem.setEnabled(true);
            menuItem.addSelectionListener(new SelectionAdapter() {

                @Override
                public void widgetSelected(SelectionEvent e) {
                    natTable.doCommand(new ToggleFilterRowCommand());
                }
            });
        }
    };
}
Also used : SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) ToggleFilterRowCommand(net.sourceforge.nattable.filterrow.command.ToggleFilterRowCommand) SelectionEvent(org.eclipse.swt.events.SelectionEvent) NatTable(net.sourceforge.nattable.NatTable) MenuItem(org.eclipse.swt.widgets.MenuItem) Menu(org.eclipse.swt.widgets.Menu)

Example 4 with NatTable

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

the class MenuItemProviders method columnStyleEditorMenuItemProvider.

public static IMenuItemProvider columnStyleEditorMenuItemProvider(final String menuLabel) {
    return new IMenuItemProvider() {

        public void addMenuItem(final NatTable natTable, final Menu popupMenu) {
            MenuItem columnStyleEditor = new MenuItem(popupMenu, SWT.PUSH);
            columnStyleEditor.setText(menuLabel);
            columnStyleEditor.setImage(GUIHelper.getImage("preferences"));
            columnStyleEditor.setEnabled(true);
            columnStyleEditor.addSelectionListener(new SelectionAdapter() {

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

Example 5 with NatTable

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

the class MenuItemProviders method categoriesBasedColumnChooserMenuItemProvider.

public static IMenuItemProvider categoriesBasedColumnChooserMenuItemProvider(final String menuLabel) {
    return new IMenuItemProvider() {

        public void addMenuItem(final NatTable natTable, final Menu popupMenu) {
            MenuItem columnChooser = new MenuItem(popupMenu, SWT.PUSH);
            columnChooser.setText(menuLabel);
            columnChooser.setImage(GUIHelper.getImage("column_categories_chooser"));
            columnChooser.setEnabled(true);
            columnChooser.addSelectionListener(new SelectionAdapter() {

                @Override
                public void widgetSelected(SelectionEvent e) {
                    natTable.doCommand(new ChooseColumnsFromCategoriesCommand(natTable));
                }
            });
        }
    };
}
Also used : 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) ChooseColumnsFromCategoriesCommand(net.sourceforge.nattable.columnCategories.ChooseColumnsFromCategoriesCommand)

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