Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » NatTable » Editing columns within row header
Editing columns within row header [message #997272] Fri, 04 January 2013 21:19 Go to next message
Rashmy A is currently offline Rashmy A
Messages: 149
Registered: July 2009
Senior Member
Hello,
I'd like to get your advice on a path of implementation to follow for my use case.

Most of the examples in NatTable have a row header with a single column (indicating row number) or there are no row headers at all. For example:
   Colm1 Colm2 Colm3
1  v1    v2    v3
2  v11   v12   v13
3  v21   v22   v23


I have a use case where we would like to display multiple columns in the row header and also be able to edit it.
So this is how it was implemented-
               Colm1  Colm2  Colm3
Class1  TypeA  v1     v2     v3
Class2  TypeB  v11    v12    v13
Class3  TypeB  v21    v22    v23


Here within the row header we have 2 columns -
one to show class name and,
another for type name

For editing a cell in the row header-
A double-click MouseEvent listener was added to turn the row header cell into an editable field. Since this is on a MouseEvent, we know the exact cell that is being edited. No call to Selection layer is required. Everything good thus far.

Next, there was need to use the F2 key within the row header to get into editable mode-
This means user selects cell in row header (single mouse click or keyboard navigation), then hits F2 key.
The issue here is that I'm using the default SelectionModel provided by NatTable. So when we select a row, it selects all cells in that row. For example, if user clicks on cell containing "TypeB", it selects all cells in that row. After this, if user hits F2 key there is no way for me to find out which cell in the row header the user wanted to edit. Did the user want to edit cell containing class name or type name? This is the issue at hand.

Question:
Is it advisable to have editable columns within the row header? If yes, does it mean we have to develop our own SelectionModel?
The only reason I started using multiple columns in row header is because the row header is frozen when I horizontally scroll the table. Should I stop having multiple columns in row header and have these columns in body layer and then just freeze the columns that should not be scrolled when using the horizontal scroll bar? Is there any other suggestion you would like to provide?

Thanks!
Rashmy
Re: Editing columns within row header [message #997308 is a reply to message #997272] Sat, 05 January 2013 14:59 Go to previous messageGo to next message
Dirk Fauth is currently offline Dirk Fauth
Messages: 1339
Registered: July 2012
Senior Member
Hi Rashmy,

First, yes in your case I suggest to use the freeze layer as this is what you're trying to achieve.

Second, it should be possible to make cells in the row header editable. It is not related to the SelectionModel that the whole row is selected on clicking a cell in the row header. There should be some default bindings configured that are responsible for that behaviour. On overriding the default row header configuration at this part you should be able to solve your issue also.

Nevertheless I suggest the FreezeLayer.

I'm currently on vacation, so sorry for no more detailed description. Hope the information points into the right direction.

Greez,
Dirk
Re: Editing columns within row header [message #997450 is a reply to message #997308] Mon, 07 January 2013 15:04 Go to previous messageGo to next message
Rashmy A is currently offline Rashmy A
Messages: 149
Registered: July 2009
Senior Member
Thanks Dirk for the replying during your vacation.

I had looked into the row header configurations to see if selection of a cell can be controlled and I could not find anything. The row header layer asks the SelectionLayer if a row is fully selected and applies that label. I'm on NatTable 2.3.2. Let me know if there is something available. I would like to keep the implementation with multiple columns in a row header and not switch to Freezablelayer since we are towards the end of our development.

Thanks,
Rashmy
Re: Editing columns within row header [message #997452 is a reply to message #997450] Mon, 07 January 2013 15:25 Go to previous messageGo to next message
Dirk Fauth is currently offline Dirk Fauth
Messages: 1339
Registered: July 2012
Senior Member
Have a look at the DefaultSelectionBindings. I think you need to override configureRowHeaderMouseClickBindings() to use the SelectCellAction instead of the ViewportSelectRowAction and then set your customized selection bindings to the SelectionLayer.
Re: Editing columns within row header [message #997865 is a reply to message #997452] Tue, 08 January 2013 22:36 Go to previous messageGo to next message
Rashmy A is currently offline Rashmy A
Messages: 149
Registered: July 2009
Senior Member
Hi Dirk,
I tried implementing your suggestion but it does not seem to work.

Here are the changes I made:
-Create my own Selection layer bindings
-Override configureRowHeaderMouseClickBindings() and register ViewportSelectCellAction. Could not use SelectCellAction since I have a viewport layer too. In the action, I created my own ViewportSelectCellCommand (similar to ViewportSelectRowCommnd) and in the command handler I made a call to SelectCellCommand.

Now using the example I provided earlier:
               Colm1  Colm2  Colm3
Class1  TypeA  v1     v2     v3
Class2  TypeB  v11    v12    v13
Class3  TypeB  v21    v22    v23


Clicking on cell containing "TypeB" selected the following cells:
Class2
TypeB
v11
Colm1

This is because of how the SelectionModel has stored these selections and also how the display mode is computed.
RowHeaderLayer: We are not using the column position at all to check for selection
public String getDisplayModeByPosition(int columnPosition, int rowPosition) {
  int selectionLayerRowPosition = LayerUtil.convertRowPosition(this, rowPosition, 
selectionLayer);

  if (selectionLayer.isRowPositionSelected(selectionLayerRowPosition))
  {
   return DisplayMode.SELECT;
  }
  else
  {
   return super.getDisplayModeByPosition(columnPosition, rowPosition);
  }
}


Similarly when we ask for display mode in the column header layer and body layer, we just get it from SelectionModel which seems return true even if the selection was made only in the row header layer.

Does this mean, I need my own SelectionModel?
Am I missing something?

Thanks,
Rashmy



Re: Editing columns within row header [message #998662 is a reply to message #997865] Thu, 10 January 2013 13:09 Go to previous messageGo to next message
Dirk Fauth is currently offline Dirk Fauth
Messages: 1339
Registered: July 2012
Senior Member
Hi,

well I don't think the issue is related to the SelectionModel. It is moreover that the row header doesn't have a SelectionLayer, and therefore no selection is handled in the row header like it is in the body. So there might be more to do to get the row header editable.

You possibly need to rethink your row header composition or at least register some custom configuration to make it editable. Also you need to register ui bindings so the editors are evaluated correctly on row header mouse clicks (by default the editors are only registered to body mouse clicks).

I really think it is easier for you you refactor your code to use the FreezeLayer instead of working on editable row headers. But if you get it working in a clean way tho, feel free to contribute some tutorial on that. We would be happy to include such advanced topics to our documentation. Wink

Greez,
Dirk
Re: Editing columns within row header [message #998719 is a reply to message #998662] Thu, 10 January 2013 14:54 Go to previous messageGo to next message
Rashmy A is currently offline Rashmy A
Messages: 149
Registered: July 2009
Senior Member
Hi Dirk,
The cells in the row header are editable (I did register and contribute the required handlers and bindings for MouseClick to the row header). So a user can click into a cell in the row header and if it supports editing, it gets into the edit mode. No issues with this.

Further when we mouse click into a cell in the row header, it was selecting all cells in the row header and all cells in the body layer for that row. So I turned off row_full_selected. All was good thus far - user can mouse click into a cell in the row header and if editable it goes into edit mode.

Now the requirement was - show me exactly which cell in the row header was clicked (via selection) and allow the user to use F2 key to get into edit mode. That's why everything now came back to selection. If I know exactly which cell is selected in the row header, things become easy Smile

I'll spend some time to get selection working on row header. If not, I'll go with FreeableLayer Smile

Thanks for your time,
Rashmy
Re: Editing columns within row header [message #1002057 is a reply to message #998719] Thu, 17 January 2013 21:07 Go to previous messageGo to next message
Rashmy A is currently offline Rashmy A
Messages: 149
Registered: July 2009
Senior Member
Hi Dirk,
I've attempted to use Freezable Layer but it appears this too does not satisfy all my requirements. It appears we need a SelectionLayer in the RowHeader region and it has to work well with the SelectionLayer in the body region. Any possibility of submitting enhancement requests for NatTable Smile

Thanks,
Rashmy
Re: Editing columns within row header [message #1002214 is a reply to message #1002057] Fri, 18 January 2013 07:31 Go to previous message
Dirk Fauth is currently offline Dirk Fauth
Messages: 1339
Registered: July 2012
Senior Member
Hi Rashmy,

why does the FreezableLayer not satisfy all of your requirements? What is so special?

Well, you can of course report an enhancement request via bugzilla. But as it is open source development, I can't tell you when we are able to look at that. Dependent on your detailed requirements it could be easy or complicated. Not sure at the moment.

We also offer sponsored development in NatTable. This way you could convince us to develop requests to the NatTable earlier. Wink
Mainly this is because we develop NatTable in our spare time. If there is a sponsor, we could convince our bosses to do work on NatTable at work.

Greez,
Dirk
Previous Topic:Greater than (>) does not work at filter using regular expression?
Next Topic:Unregister Keybindings
Goto Forum:
  


Current Time: Fri Oct 24 17:01:32 GMT 2014

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

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