Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » NatTable » ToggleCheckBoxColumnAction for spanned columns
ToggleCheckBoxColumnAction for spanned columns [message #1184353] Wed, 13 November 2013 11:43 Go to next message
Jan Krakora is currently offline Jan KrakoraFriend
Messages: 477
Registered: December 2009
Location: Prague
Senior Member
I would like to add the ToggleCheckBoxColumnAction to a column header.
But this class together with the ColumnHeaderCheckBoxPainter are useful only for columns where all rows can be converted to a boolean value, AFAIK.

Is there an alternative for columns where some rows are not of boolean value?

[Updated on: Wed, 13 November 2013 11:57]

Report message to a moderator

Re: ToggleCheckBoxColumnAction for spanned columns [message #1184384 is a reply to message #1184353] Wed, 13 November 2013 12:10 Go to previous messageGo to next message
Dirk Fauth is currently offline Dirk FauthFriend
Messages: 2703
Registered: July 2012
Senior Member
Well, I'm not pretty familiar with that. But I would assume that this action is intended to check/uncheck all checkboxes in a column. And for checkboxes this means boolean values. Or at least for the default case.

Looking at the source code, an UpdateDataCommand is fired for boolean values. So the "alternative" would be to implement a custom action that is aware of your data model. But I would not know an general alternative as it is quite related to the data model. Or am I missing something?
Re: ToggleCheckBoxColumnAction for spanned columns [message #1184495 is a reply to message #1184384] Wed, 13 November 2013 13:48 Go to previous messageGo to next message
SD Khan is currently offline SD KhanFriend
Messages: 63
Registered: May 2013
Member
Hi Jan!

It is quite possible but you will have to write some code for that Smile, Follow the following steps

1. Provide you own implementation of IMouseAction interface and in the run method do whatever you want.

2. Extend the image painter class and create an image object in it, provide the setter method while override the getImage(...) method and return that image object in the overridden getImage(...) method.

3. Register the image painter in configuration and bind the action along with the painter uing ui binding registry.


Now, keep an object of that extended image painter in your implemented class of IMouseAction. In the run method add your logic and set the image of the image painter class accordingly.

For Example

class MyImagePainter extends ImagePainter
{
   Image imageObject

   public void setImage(Image image)
   {
	this.imageObject= image;
   }

   @Override
   protected Image getImage(ILayerCell cell, IConfigRegistry configRegistry)
   {
	//return the currently saved image
	return imageObject;
   }	
 
// more methods if required.
......
........

}

MyAction implements IMouseAction
{ 
   MyImagePainter imagePainterObj;

   
   public void run(NatTable nattable, MouseEvent event)
   {
      // add your code logic and set image accordingly
     
      // For example
      //if(state)
        //imagePainterObj.setImage(checkedImage)
      //else
        //imagePainterObj.setImage(unCheckedImage)      
   }

// more methods if required.
......
........
}


Now whenever you will click on your painter image, run method of your implemented action will execute and you can do you logic there. Set image there if you want, while getImage(...) will be called internally and will display the latest image on the header.

@Dirk
@Jan
In case of any query or you see any problem with this approach feel free to share Smile.

Regards,
SD Khan
Re: ToggleCheckBoxColumnAction for spanned columns [message #1184510 is a reply to message #1184495] Wed, 13 November 2013 14:00 Go to previous messageGo to next message
Dirk Fauth is currently offline Dirk FauthFriend
Messages: 2703
Registered: July 2012
Senior Member
Thanks for your answer. But I'm not sure if that matches the question. Smile

You are showing a way to switch icons in a painter. Which is also interesting. But I understood the question that using the specified action the data model of all values in that column should be changed. For which you would need to implement a custom IMouseAction similar to ToggleCheckBoxColumnAction which performs updates accordingly.
Re: ToggleCheckBoxColumnAction for spanned columns [message #1184534 is a reply to message #1184510] Wed, 13 November 2013 14:17 Go to previous messageGo to next message
SD Khan is currently offline SD KhanFriend
Messages: 63
Registered: May 2013
Member
Yup, Definitely, that will be the part of logic which should be add in the run method, as you directed.

@Jan, I don't know about your model but as in my case i am using event list, so if i want's to do this, i will directly change my row in the event list instead of using data update command. So you should update the image and update your model in the action and change will be reflected right away.

Regards,
SD Khan
Re: ToggleCheckBoxColumnAction for spanned columns [message #1185903 is a reply to message #1184534] Thu, 14 November 2013 10:42 Go to previous messageGo to next message
Jan Krakora is currently offline Jan KrakoraFriend
Messages: 477
Registered: December 2009
Location: Prague
Senior Member
Well, my question is about the fact, that the ToggleCheckBoxColumnAction takes rowCount into account when computing the boolean state it sends to all rows.

This is problem when you have a column that doesn't contain boolean values in all rows.
More precisely if you have cells that are not interested in the ToggleCheckBoxColumnAction activity.

Also the ColumnHeaderCheckBoxPainter#getCheckedCellsCount(int columnPosition, IConfigRegistry configRegistry).
It assumes that all cells in that column are boolean values by default.

Sure, I can create modifications of this objects myself. I wondered if there is any support out of the box.
Re: ToggleCheckBoxColumnAction for spanned columns [message #1185910 is a reply to message #1185903] Thu, 14 November 2013 10:47 Go to previous messageGo to next message
Dirk Fauth is currently offline Dirk FauthFriend
Messages: 2703
Registered: July 2012
Senior Member
Quote:
I wondered if there is any support out of the box.


As you might know already, not there is no such support out of the box. The default is to have the same value type in a column. So this is the default implementation. Although I'm pretty sure there could be some generic solution that also fits different scenarios.

This is also a good example on extensibility of NatTable. Not every use case is considered in NatTable itself, but one of the big advantages in NatTable is that it is easily extensible for such use cases.
Re: ToggleCheckBoxColumnAction for spanned columns [message #1185951 is a reply to message #1185910] Thu, 14 November 2013 11:22 Go to previous message
Jan Krakora is currently offline Jan KrakoraFriend
Messages: 477
Registered: December 2009
Location: Prague
Senior Member
Yep, I got it. Cool
Previous Topic:Problem with loader:
Next Topic:Issue with RowSelectionProvider
Goto Forum:
  


Current Time: Thu Aug 22 11:18:28 GMT 2019

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

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

Back to the top