use of net.sourceforge.nattable.layer.ILayer in project translationstudio8 by heartsome.
the class SelectionSearchStrategy method executeSearch.
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 coordinate = CellDisplayValueSearchUtil.findCell(selectionLayer, configRegistry, getSelectedCells(selectionLayer), valueToMatch, getComparator(), isCaseSensitive());
return coordinate;
}
use of net.sourceforge.nattable.layer.ILayer in project translationstudio8 by heartsome.
the class DisplayColumnStyleEditorCommandHandler method doCommand.
@Override
public boolean doCommand(DisplayColumnStyleEditorCommand command) {
ILayer nattableLayer = command.getNattableLayer();
int columnIndex = nattableLayer.getColumnIndexByPosition(command.columnPosition);
// Column style
Style slectedCellStyle = (Style) configRegistry.getConfigAttribute(CELL_STYLE, NORMAL, USER_EDITED_STYLE_LABEL + columnIndex);
dialog = new ColumnStyleEditorDialog(Display.getCurrent().getActiveShell(), slectedCellStyle);
dialog.open();
if (dialog.isCancelPressed()) {
return true;
}
applySelectedStyleToColumn(command, columnIndex);
return true;
}
use of net.sourceforge.nattable.layer.ILayer in project translationstudio8 by heartsome.
the class ViewportLayer method moveRowPositionIntoViewport.
/**
* @see {@link #moveColumnPositionIntoViewport(int, boolean)}
*/
public void moveRowPositionIntoViewport(int scrollableRowPosition, boolean forceEntireCellIntoViewport) {
ILayer underlyingLayer = getUnderlyingLayer();
if (underlyingLayer.getRowIndexByPosition(scrollableRowPosition) >= 0) {
if (scrollableRowPosition >= getMinimumOriginRowPosition()) {
int originRowPosition = getOriginRowPosition();
if (scrollableRowPosition < originRowPosition) {
// Move up
setOriginRowPosition(scrollableRowPosition);
} else {
int scrollableRowStartY = underlyingLayer.getStartYOfRowPosition(scrollableRowPosition);
int scrollableRowEndY = scrollableRowStartY + underlyingLayer.getRowHeightByPosition(scrollableRowPosition);
int clientAreaHeight = getClientAreaHeight();
int viewportEndY = underlyingLayer.getStartYOfRowPosition(getOriginRowPosition()) + clientAreaHeight;
if (viewportEndY < scrollableRowEndY) {
int targetOriginRowPosition;
if (forceEntireCellIntoViewport || isLastRow(scrollableRowPosition)) {
targetOriginRowPosition = underlyingLayer.getRowPositionByY(scrollableRowEndY - clientAreaHeight) + 1;
} else {
targetOriginRowPosition = underlyingLayer.getRowPositionByY(scrollableRowStartY - clientAreaHeight) + 1;
}
// Move down
setOriginRowPosition(targetOriginRowPosition);
}
}
}
}
}
use of net.sourceforge.nattable.layer.ILayer 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;
}
use of net.sourceforge.nattable.layer.ILayer in project translationstudio8 by heartsome.
the class VerticalViewportLayer method moveRowPositionIntoViewport.
@Override
public void moveRowPositionIntoViewport(int scrollableRowPosition, boolean forceEntireCellIntoViewport) {
ILayer underlyingLayer = getUnderlyingLayer();
if (underlyingLayer.getRowIndexByPosition(scrollableRowPosition) >= 0) {
if (scrollableRowPosition >= getMinimumOriginRowPosition()) {
// 滚动条滚动过的行数
int originRowPosition = getOriginRowPosition();
if (scrollableRowPosition < originRowPosition) {
// Move up
if (scrollableRowPosition % 2 != 0) {
scrollableRowPosition -= 1;
}
setOriginRowPosition(scrollableRowPosition);
} else {
scrollableRowPosition = scrollableRowPosition / VerticalNatTableConfig.ROW_SPAN * VerticalNatTableConfig.ROW_SPAN;
// 编辑区的高(不包括滚动过的区域)
int clientAreaHeight = getClientAreaHeight();
// 编辑区的高(包括滚动过的区域)
int viewportEndY = underlyingLayer.getStartYOfRowPosition(originRowPosition) + clientAreaHeight;
// 当前选中行的起始位置(包括滚动过的区域)
int scrollableRowStartY = underlyingLayer.getStartYOfRowPosition(scrollableRowPosition);
if (clientAreaHeight <= 0) {
return;
}
int currentRowHeight = 0;
for (int i = 0; i < VerticalNatTableConfig.ROW_SPAN; i++) {
if (rowHeightCalculator != null)
rowHeightCalculator.recaculateRowHeight(scrollableRowPosition + i);
int currentSubRowHeight = underlyingLayer.getRowHeightByPosition(scrollableRowPosition + i);
currentRowHeight += currentSubRowHeight;
if (currentRowHeight >= clientAreaHeight) {
setOriginRowPosition(scrollableRowPosition + i);
return;
}
}
// 当前选中行的结束位置,包括不可见的部分(包括滚动过的区域)
int scrollableRowEndY = scrollableRowStartY + currentRowHeight;
if (viewportEndY < scrollableRowEndY) {
// 选中行下半部分没有显示完全时
if (currentRowHeight >= clientAreaHeight) {
// 当前行高大于等于编辑区的高
// Move up:设置起始行为当前行
setOriginRowPosition(scrollableRowPosition);
} else {
// int targetOriginRowPosition = underlyingLayer.getRowPositionByY(scrollableRowEndY
// - clientAreaHeight) + 1;
// // targetOriginRowPosition = targetOriginRowPosition
// // + (VerticalNatTableConfig.ROW_SPAN - targetOriginRowPosition %
// VerticalNatTableConfig.ROW_SPAN);
// // Move up:将当前选中行显示完全
// setOriginRowPosition(targetOriginRowPosition);
scrollableRowPosition = scrollableRowPosition + (VerticalNatTableConfig.ROW_SPAN - scrollableRowPosition % VerticalNatTableConfig.ROW_SPAN);
int ch = clientAreaHeight;
int r = scrollableRowPosition;
for (; r > 0; r--) {
int h = rowHeightCalculator.recaculateRowHeight(r);
ch -= h;
if (ch < 0) {
break;
}
}
r += 1;
if (r % 2 == 0) {
r -= 1;
}
setOriginRowPosition(r);
}
}
}
}
}
}
Aggregations