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; }
public PositionCoordinate executeSearch(Object valueToMatch) { ILayer contextLayer = getContextLayer(); if (!(contextLayer instanceof SelectionLayer)) { throw new RuntimeException( "For the GridSearchStrategy to work it needs the selectionLayer to be passed as the contextLayer."); } SelectionLayer selectionLayer = (SelectionLayer) contextLayer; PositionCoordinate selectionAnchor = selectionLayer.getSelectionAnchor(); boolean hadSelectionAnchor = true; if (selectionAnchor.columnPosition < 0 || selectionAnchor.rowPosition < 0) { selectionAnchor.columnPosition = 0; selectionAnchor.rowPosition = 0; hadSelectionAnchor = false; } int anchorColumnPosition = selectionAnchor.columnPosition; int startingRowPosition; int[] columnsToSearch = null; final int columnCount = selectionLayer.getColumnCount(); if (searchDirection.equals(ISearchDirection.SEARCH_FORWARD)) { int rowPosition = hadSelectionAnchor ? selectionAnchor.rowPosition + 1 : selectionAnchor.rowPosition; if (rowPosition > (contextLayer.getRowCount() - 1)) { rowPosition = wrapSearch ? 0 : contextLayer.getRowCount() - 1; } int rowCount = selectionLayer.getRowCount(); startingRowPosition = rowPosition < rowCount ? rowPosition : 0; if (selectionAnchor.rowPosition + 1 >= rowCount && anchorColumnPosition + 1 >= columnCount && hadSelectionAnchor) { if (wrapSearch) { anchorColumnPosition = 0; } else { return null; } } else if (selectionAnchor.rowPosition == rowCount - 1 && anchorColumnPosition < columnCount - 1) { anchorColumnPosition++; } columnsToSearch = getColumnsToSearchArray(columnCount, anchorColumnPosition); } else { int rowPosition = selectionAnchor.rowPosition - 1; if (rowPosition < 0) { rowPosition = wrapSearch ? contextLayer.getRowCount() - 1 : 0; } startingRowPosition = rowPosition > 0 ? rowPosition : 0; if (selectionAnchor.rowPosition - 1 < 0 && anchorColumnPosition - 1 < 0 && hadSelectionAnchor) { if (wrapSearch) { anchorColumnPosition = columnCount - 1; } else { return null; } } else if (selectionAnchor.rowPosition == 0 && anchorColumnPosition > 0) { anchorColumnPosition--; } columnsToSearch = getDescendingColumnsToSearchArray(anchorColumnPosition); } PositionCoordinate executeSearch = searchGrid( valueToMatch, contextLayer, selectionLayer, anchorColumnPosition, startingRowPosition, columnsToSearch); return executeSearch; }