|
|
|
|
|
Re: Migrate ILayerCell from underlying layer to top-level [message #1258285 is a reply to message #1258271] |
Thu, 27 February 2014 03:32   |
Eclipse User |
|
|
|
We have a whole bunch of "old" editor framework that we are wrapping using a custom ICellEditor implementation. Basically it just creates a composite with some arbitrary editor controls on it. Bounds of the editor are calculated using the method i posted above. Now there is (use case one) a UI test framework which tries to programmatically open an editor for a cell. The test framework only has data layer indexes in hand, so what we do there is this:
@Override
public BaseControl getAndCreateTableCellEditor(int rowIndex, int columnIndex) {
DataLayer dataLayer = getLayer().getBodyLayer().getDataLayer();
ILayerCell cell = dataLayer.getCellByPosition(columnIndex, rowIndex);
if (cell == null) {
throw new RuntimeException("No cell available at row=" + rowIndex + " column="
+ columnIndex);
}
// skip re-sizing during programmatic editing
NatTableCellEditor cellEditor = (NatTableCellEditor) natTable.getConfigRegistry()
.getConfigAttribute(EditConfigAttributes.CELL_EDITOR, DisplayMode.EDIT);
try {
cellEditor.setAutoResizeCell(false);
natTable.doCommand(new EditCellCommand(natTable, natTable.getConfigRegistry(), cell));
} finally {
cellEditor.setAutoResizeCell(true);
}
// check if we could create an editor
NatTableCellEditor activeEditor = (NatTableCellEditor) natTable.getActiveEditor();
if (activeEditor == null) {
throw new CellNotEditableException(rowIndex, columnIndex);
}
return editor;
}
Firing this EditCellCommand with the cell from the data layer will somehow skip the offsetting required to take header layers into account (row and column headers), thus the editor will be opened a little too high, and a little too far on the left. I confirmed that the coordinates that are passed to calculacteBounds (by nattable itself) are off by that amount.
BTW, i solved the viewport issue, by always converting to selection layer positions, so only the cell/editor offset issue remains.
|
|
|
Re: Migrate ILayerCell from underlying layer to top-level [message #1258310 is a reply to message #1258285] |
Thu, 27 February 2014 03:57   |
Eclipse User |
|
|
|
The cell coordinates in NatTable are all using offsets. So if you are getting cell 1,1 of the body data layer, it will be 2,2 in a grid, because there is one row in the column header and one column in the row header. Using the method above, your code will never work in a grid composition.
Maybe this kind of code helps:
natTable.doCommand(new SelectCellCommand(getLayer().getBodyLayer().getSelectionLayer(), columnIndex, rowIndex, false, false));
natTable.doCommand(new EditSelectionCommand(natTable, natTable.getConfigRegistry()));
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.28156 seconds