Possible bug in FilterRowDataProvider.getDataValue(int, int) [message #1366209] |
Mon, 19 May 2014 07:53 |
István Mészáros Messages: 51 Registered: October 2009 |
Member |
|
|
There might be a bug in the getDataValue method of the FilterRowDataProvider.
setDataValue does a column index translation before accessing the filter map:
@Override
public void setDataValue(int columnIndex, int rowIndex, Object newValue) {
columnIndex = columnHeaderLayer.getColumnIndexByPosition(columnIndex);
if (ObjectUtils.isNotNull(newValue)) {
filterIndexToObjectMap.put(columnIndex, newValue);
} else {
filterIndexToObjectMap.remove(columnIndex);
}
filterStrategy.applyFilter(filterIndexToObjectMap);
columnHeaderLayer.fireLayerEvent(new FilterAppliedEvent(columnHeaderLayer));
}
but getDataValue does not:
@Override
public Object getDataValue(int columnIndex, int rowIndex) {
return filterIndexToObjectMap.get(columnIndex);
}
Although this caused problems for me using my custom multi-combo filter editor, and i could solve those problems overriding getDataValue like
@Override
public Object getDataValue(int columnIndex, int rowIndex) {
columnIndex = columnHeaderLayer.getColumnIndexByPosition(columnIndex);
return super.getDataValue(columnIndex, rowIndex);
}
i'm still not sure this is a bug, but might worth to post it if someone else has similar problems.
|
|
|
|
|
|
|
Re: Possible bug in FilterRowDataProvider.getDataValue(int, int) [message #1366355 is a reply to message #1366320] |
Mon, 19 May 2014 09:17 |
István Mészáros Messages: 51 Registered: October 2009 |
Member |
|
|
I needed to change the combo filtering because afaik the default combo filter does not use null to indicate that no filtering is active (= all items are selected). Therefore when the filter state is persisted, all the items are listed in the presisted state as "selection" of the filter combo. In my project this is not acceptable because items of the combo columns may change frequently, so accidental filtering may occur when a previosly persisted filter state is loaded. This can be avoided if the filter editor uses null if all items are selected.
Yes the composition is similar to the examples, although quite complex because i need a lot of functionality.
Currently i solved my issue by overriding the registerCommandHandlers() methond in my FilterRowDataLayer subclass:
@Override
protected void registerCommandHandlers() {
registerCommandHandler(new ColumnResizeCommandHandler(this));
registerCommandHandler(new MultiColumnResizeCommandHandler(this));
registerCommandHandler(new RowResizeCommandHandler(this));
registerCommandHandler(new MultiRowResizeCommandHandler(this));
registerCommandHandler(new StructuralRefreshCommandHandler());
registerCommandHandler(new VisualRefreshCommandHandler());
registerCommandHandler(new UpdateDataCommandHandler(this) {
@Override
protected boolean doCommand(UpdateDataCommand command) {
try {
int columnPosition = command.getColumnPosition();
int rowPosition = command.getRowPosition();
if (!ObjectUtils.equals(
getDataValue(columnHeaderLayer.getColumnIndexByPosition(columnPosition), rowPosition),
command.getNewValue())) {
setDataValue(columnPosition, rowPosition, command.getNewValue());
fireLayerEvent(new CellVisualChangeEvent(
ProjectMonitorFilterRowDataLayer.this, columnPosition, rowPosition));
}
return true;
} catch (Exception e) {
return false;
}
}
});
}
The key change is that an inline override of UpdateDataCommandHandler does the column index translation before calling getDataValue so the comparsion will always succeed.
It looks like both the regular and my custom filter are now working properly.
[Updated on: Mon, 19 May 2014 09:17] Report message to a moderator
|
|
|
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.05104 seconds