use of net.heartsome.cat.ts.ui.xliffeditor.nattable.editor.TagDisplayConverter in project translationstudio8 by heartsome.
the class CellDisplayValueSearchUtil method findCell.
static CellRegion findCell(final ILayer layer, final IConfigRegistry configRegistry, final PositionCoordinate[] cellsToSearch, final Object valueToMatch, final ICellSearchStrategy cellSearchStrategy) {
final List<PositionCoordinate> cellCoordinates = Arrays.asList(cellsToSearch);
// Find cell
CellRegion targetCoordinate = null;
String stringValue = valueToMatch.toString();
final IDisplayConverter displayConverter = configRegistry.getConfigAttribute(CellConfigAttributes.DISPLAY_CONVERTER, DisplayMode.NORMAL, XLIFFEditorImplWithNatTable.SOURCE_EDIT_CELL_LABEL);
for (int cellIndex = 0; cellIndex < cellCoordinates.size(); cellIndex++) {
final PositionCoordinate cellCoordinate = cellCoordinates.get(cellIndex);
final int columnPosition = cellCoordinate.columnPosition;
final int rowPosition = cellCoordinate.rowPosition;
// Convert cell's data
if (displayConverter instanceof TagDisplayConverter) {
LayerCell cell = new LayerCell(cellCoordinate.getLayer(), cellCoordinate.getColumnPosition(), cellCoordinate.getRowPosition());
((TagDisplayConverter) displayConverter).setCell(cell);
}
final Object dataValue = displayConverter.canonicalToDisplayValue(layer.getDataValueByPosition(columnPosition, rowPosition));
// Compare with valueToMatch
if (dataValue instanceof String) {
String dataValueString = dataValue.toString();
IRegion region;
if ((region = cellSearchStrategy.executeSearch(stringValue, dataValueString)) != null) {
targetCoordinate = new CellRegion(cellCoordinate, region);
break;
}
((DefaultCellSearchStrategy) cellSearchStrategy).setStartOffset(-1);
}
}
return targetCoordinate;
}
Aggregations