Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » NatTable » Selection and focus
Selection and focus [message #1014263] Mon, 25 February 2013 13:19 Go to next message
Jon Dahlberg is currently offline Jon DahlbergFriend
Messages: 11
Registered: February 2013
Junior Member
I am using NatTable and the GlazedListGridLayer class from one of the examples and I am reading large sets of data from file into the table (~ more than 1M rows and some processing while reading so it takes awhile).

During the reading process I want to be able to right-click on rows and select actions depending on the contents of the row. However with my current implementation the selection is lost when new rows are added (via the underlying event list). Have I implemented it wrong somehow to cause this behavior? Or is there some way to pause table updates for awhile so that I can select rows when I need to?
Re: Selection and focus [message #1015162 is a reply to message #1014263] Wed, 27 February 2013 15:41 Go to previous messageGo to next message
Dirk Fauth is currently offline Dirk FauthFriend
Messages: 2902
Registered: July 2012
Senior Member
Hi,

I need to investigate a bit further on this. And there is already an open ticket on it:

AFAIK this is related to the SelectionLayerStructuralChangeEventHandler. This one clears the selection on changes to the vertical structure. It might be that it clears to often or determines to clear the selection to often. I'm not quite sure about this yet.

There might be a workaroung for you until the bug is fixed. You can create the SelectionLayer telling to not use the default event handler. Then instead register another event handler that could look like this:

public class PreserveSelectionStructuralChangeEventHandler implements ILayerEventHandler<IStructuralChangeEvent> {

	private final SelectionLayer selectionLayer;
	
	public PreserveSelectionStructuralChangeEventHandler(SelectionLayer selectionLayer) {
		this.selectionLayer = selectionLayer;
	}

	public Class<IStructuralChangeEvent> getLayerEventClass() {
		return IStructuralChangeEvent.class;
	}

	@Override
	public void handleLayerEvent(IStructuralChangeEvent event) {
		PositionCoordinate[] coords = this.selectionLayer.getSelectedCellPositions();
		for (PositionCoordinate coord : coords) {
			if (coord.getColumnPosition() >= this.selectionLayer.getColumnCount()
					|| coord.getRowPosition() >= this.selectionLayer.getRowCount()) {
				//if the coordinates of the selected cells are outside the valid range remove the selection
				this.selectionLayer.clearSelection(
						coord.getColumnPosition(), 
						coord.getRowPosition());
			}
		}

	}
	
	
}


Note that this should be only a workaround. I will investigate on this in more detail to found a general solution.

Greez,
Dirk
Re: Selection and focus [message #1015352 is a reply to message #1015162] Thu, 28 February 2013 10:15 Go to previous message
Jon Dahlberg is currently offline Jon DahlbergFriend
Messages: 11
Registered: February 2013
Junior Member
Thank you! Your suggested workaround did the trick.
Previous Topic:KeyEvents not getting registered on WizardDialog
Next Topic:Is 1.0.0 actually released?
Goto Forum:
  


Current Time: Sat Apr 20 00:37:34 GMT 2024

Powered by FUDForum. Page generated in 0.03678 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top