|
|
Re: A selection model that preserves selection during resort? [message #1343062 is a reply to message #1334252] |
Fri, 09 May 2014 05:59 |
Markus Wahl Messages: 16 Registered: May 2014 |
Junior Member |
|
|
We have created a selection model (org.eclipse.nebula.widgets.nattable.selection.ISelectionModel) which preserves the selection of a specific row after the sort order has changed.
But our problem is now with the tabulate order of the table. The Selection Layer (org.eclipse.nebula.widgets.nattable.selection.SelectionLayer) has a selection anchor and a last selected cell, these are only based on simple coordinates and are constructed outside the sort model. And therefore are not preserved, thus when you tab, you end up on the pre-sort row position.
We have confirmed that this problem still exist if we use the built-in row selection model (org.eclipse.nebula.widgets.nattable.selection.RowSelectionModel), which is row-id bound.
Is this a known bug and in the pipe to get fixed?
Is there any idea of a workaround?
One idea of a solution could be to move the responsibilty of managing and owning the anchor/lastSelectedCell from the selection layer into ISelectionModel.
This is not our workaround, and we cant really see any workarounds.
[Updated on: Fri, 09 May 2014 06:00] Report message to a moderator
|
|
|
|
Re: A selection model that preserves selection during resort? [message #1343731 is a reply to message #1343292] |
Fri, 09 May 2014 12:32 |
Markus Wahl Messages: 16 Registered: May 2014 |
Junior Member |
|
|
We can't find any discussion on priorities or on the topic on how we can convince you. Can you direct us to where that is discussed?
Do you think this is a bug? Should we report it as a bug? If so, where? What priority should we give that bug if we report it?
We have another proposal:
1. Add new interface
/**
* Selection model that holds two pieces of anchor: the selection anchor and last
* selected cell, in order to correct them after the sort order of the underlying data has changed.
*/
public interface IAnchorSelectionModel extends ISelectionModel {
/**
* Retrieves the position coordinates of selectionAnchor
*/
PositionCoordinate getSelectionAnchor();
/**
* Retrieves the position coordinates of the last selected cell
*/
PositionCoordinate getLastSelectedCell();
/**
* Corrects the coordinates of the selection anchor and the last
* selected cell. Takes resorting into account, by finding the new
* coordinates depending on stored ID:s
*/
void updateAnchors();
}
2. Modify SelectionLayer doCommand(ILayerCommand) to update the anchors upon StructuralRefreshCommand and VisualRefreshCommand:
@Override
public boolean doCommand(ILayerCommand command) {
....
} else if (command instanceof StructuralRefreshCommand && command.convertToTargetLayer(this)) {
if(selectionModel instanceof IAnchorSelectionModel) {
((IAnchorSelectionModel) selectionModel).updateAnchors();
}
} else if (command instanceof VisualRefreshCommand && command.convertToTargetLayer(this)) {
if(selectionModel instanceof IAnchorSelectionModel) {
((IAnchorSelectionModel) selectionModel).updateAnchors();
}
}
return super.doCommand(command);
}
3. Modify SelectionLayer constructor:
public SelectionLayer(IUniqueIndexLayer underlyingLayer, ISelectionModel selectionModel,
boolean useDefaultConfiguration, boolean registerDefaultEventHandler) {
.....
this.selectionModel = selectionModel != null ? selectionModel : new SelectionModel(this);
if(selectionModel instanceof IAnchorSelectionModel) {
lastSelectedCell = ((IAnchorSelectionModel) selectionModel).getLastSelectedCell();
selectionAnchor = ((IAnchorSelectionModel) selectionModel).getSelectionAnchor();
} else {
lastSelectedCell = new PositionCoordinate(this, NO_SELECTION, NO_SELECTION);
selectionAnchor = new PositionCoordinate(this, NO_SELECTION, NO_SELECTION);
}
.....
}
We are happy to implement and contribute this to version 1.1.x. We know this will not affect any existing code since our proposal effectively adds a new mode to SelectionLayer, and the existing uses of SelectionLayer will still use the old mode.
|
|
|
|
|
|
|
|
|
|
Re: A selection model that preserves selection during resort? [message #1357247 is a reply to message #1351675] |
Thu, 15 May 2014 12:35 |
István Mészáros Messages: 51 Registered: October 2009 |
Member |
|
|
Hello Markus,
what is the status of your proposal/workaround? I'm facing a similar problem in my project. The requirement is to preserve the selected cells through the following operations:
- sorting
- filtering
- tree node collapse/expand
- columng group collapse/expand
Losing the selection of any cell is only allowed if the cell is no more visible (lays whitin a collapsed row/column or filtered out).
What was the problem with your proposal in the above post?
thanks,
Istvan
[Updated on: Thu, 15 May 2014 12:36] Report message to a moderator
|
|
|
|
|
Re: A selection model that preserves selection during resort? [message #1368570 is a reply to message #1366916] |
Tue, 20 May 2014 07:16 |
Dirk Fauth Messages: 2903 Registered: July 2012 |
Senior Member |
|
|
Nice idea, but I would modify it a bit for a better API and understandable process. This has of course impact on the API, but in that case it seems to me better.
Try the following:
1. Change the visibility of lastSelectedCell, selectionAnchor, lastSelectedRegion from protected to private
2. Update every reference (in SelectionLayer and other selection related classes) to the corresponding getters (which is a way better API than directly operating on the members themselves)
3. In case the ISelectionModel is of type IAnchorSelectionModel, the getters will return the values from there instead of the local members.
I haven't tested this, but for me this seems to be a better approach than listening to various events and call an update.
In terms of backwards compatibility maybe we should not change the visibility of the fields in the end, as there are users out there that extended SelectionLayer and an API change would cause a minor release instead of a bugfix release. But to find the necessary places to change the implementation, it might be a good way to start and to be sure nothing is missed.
Greez,
Dirk
P.S. could you please try to configure the images so they are not expanding the whole page?
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|