Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » NatTable » Styling with scroll able NatTable
Styling with scroll able NatTable [message #1058214] Mon, 13 May 2013 09:01 Go to next message
Nikhil Shirodkar is currently offline Nikhil ShirodkarFriend
Messages: 9
Registered: May 2013
Junior Member
Hello,

I am trying to add to add styling to some cells.
And for that I used ImagePainter and set the configuration.
The row count in NatTable is relatively higher, so a vertical scroll gets added to NatTable automatically.
Implementing IConfigLabelAccumulator in my class I have added labels to cells depending on row count and column count. ( Method : accumulateConfigLabels())

This styling works perfect if I do not scroll the NatTable.

But when I scroll , the styling do not move. And I realized that, after scrolling the row position and column position do not change, only bodylayer moves.

So how can implement my requirement.

Am I missing out some thing?

Thanking you in advance.

--
Nikhil
Re: Styling with scroll able NatTable [message #1058215 is a reply to message #1058214] Mon, 13 May 2013 09:10 Go to previous messageGo to next message
Dirk Fauth is currently offline Dirk FauthFriend
Messages: 2702
Registered: July 2012
Senior Member
On which layer do you add your IConfigLabelAccumulator? If it is set to the viewport then the position will stay the same as the viewport only knows about the cells that are currently visible.

So either you attach your IConfigLabelAccumulator to the DataLayer, you do some position to index transformation or implement a logic that is more related to content rather than positions.
Re: Styling with scroll able NatTable [message #1058226 is a reply to message #1058215] Mon, 13 May 2013 09:30 Go to previous messageGo to next message
Nikhil Shirodkar is currently offline Nikhil ShirodkarFriend
Messages: 9
Registered: May 2013
Junior Member
Ohh.. Thank you very much for such a fast reply.

Really, that was the only mistake...

When i changed the implementation from body Layer to data layer it worked....

Smile Sorry to trouble you...

Thank you once again.

--
Nikhil
Re: Styling with scroll able NatTable [message #1058437 is a reply to message #1058226] Tue, 14 May 2013 06:18 Go to previous messageGo to next message
Nikhil Shirodkar is currently offline Nikhil ShirodkarFriend
Messages: 9
Registered: May 2013
Junior Member
Hello Dirk,
Actually I have one more question on top of this...
As discussed earlier I have styled some cells using IConfigLabelAccumulator and ImagePainter. Depending on some logic i have added "LabelStack" to few cell and accordingly cells are styled.

Now the question is, how can I add the "LabelStack" to some other cells at runtime and update the NatTable.

Well basically I want to do this on cell selection event.
I got hold on the cell selection event using ILayerListener instance.

So can you please help me to add the "LabelStack" to some other cells at runtime and update the NatTable.

I implemented ILayerListener as --

natTable.addLayerListener(new ILayerListener()
{
public void handleLayerEvent(ILayerEvent event)
{
if (event instanceof CellSelectionEvent)
{
Re: Styling with scroll able NatTable [message #1058548 is a reply to message #1058437] Tue, 14 May 2013 12:43 Go to previous messageGo to next message
Dirk Fauth is currently offline Dirk FauthFriend
Messages: 2702
Registered: July 2012
Senior Member
Sorry, I don't understand your requirement? There is no way to "add" a LabelStack. The LabelStack for each cell is build on rendering. So the only thing would be to get the other cell, get the LabelStack of that cell with cell.getConfigLabels() and add your label. But I'm not sure if that helps on selection.
Re: Styling with scroll able NatTable [message #1058768 is a reply to message #1058548] Wed, 15 May 2013 01:25 Go to previous messageGo to next message
Nikhil Shirodkar is currently offline Nikhil ShirodkarFriend
Messages: 9
Registered: May 2013
Junior Member
Dirk,

Well sorry for my wrong interpretation,what I mean is -
Using IConfigLabelAccumulator I added labels to some specific cells. And using "setConfigLabelAccumulator" method on the bodyDataLayer(basically the dataLayer) I configured a images depending on the value of Labels. And all this works fine.

Now the requirement is -
At the cell selection event, I want paint the selected cell with the same Image.
Now to achieve this I add label to this cell, like this --

natTable.addLayerListener(new ILayerListener()
{
public void handleLayerEvent(ILayerEvent event)
{
if (event instanceof CellSelectionEvent)
{
CellSelectionEvent cellEvent = (CellSelectionEvent) event;
int rowPosition = cellEvent.getRowPosition();
int colPosition = cellEvent.getColumnPosition();
System.out.println("Selected cell: [" + rowPosition + ", " + colPosition + "], ");

LabelStack configLabel = natTable.getConfigLabelsByPosition(colPosition, rowPosition);
configLabel.addLabel(MZ_TraceConstants.LEFT_TO_TOP); // Predefined value of label
//Additional code .... ??
System.out.println("end");
}
}
});

But what should I do after adding the label , so that the corresponding Image will get attached to this Cell.

Please let me know what additional should I do ....


Thanking you.

--
Nikhil
Re: Styling with scroll able NatTable [message #1058796 is a reply to message #1058768] Wed, 15 May 2013 07:25 Go to previous messageGo to next message
Dirk Fauth is currently offline Dirk FauthFriend
Messages: 2702
Registered: July 2012
Senior Member
Well the building of the LabelStack is performed on rendering. This way we ensure that the LabelStack only contains the labels that are necessary at the time of rendering. Adding labels afterwards does not work, as you would need to refresh then and ... on refresh the LabelStack is build again and your label gets lost.

Why don't you modify your IConfigLabelAccumulator and within check the selection state of the corresponding cell.

Guess you have two columns, and when column 1 is asked for its labels it checks the selection state of the cell in column 0:
if (columnIndex == 1 && 
		bodyLayer.getSelectionLayer().isCellPositionSelected(columnPosition-1, rowPosition)) {
	configLabels.addLabel(FOO_LABEL);
}


If you add this code to the IConfigLabelAccumulator in the _001_Custom_styling_of_specific_cells you will see that on selecting a cell in the first column, the style of the cell in the second column will change.

Hope that helps,
Dirk
Re: Styling with scroll able NatTable [message #1058973 is a reply to message #1058796] Thu, 16 May 2013 06:09 Go to previous message
Nikhil Shirodkar is currently offline Nikhil ShirodkarFriend
Messages: 9
Registered: May 2013
Junior Member
yes.. that worked.. Smile

Well actually as you explained, "Well the building of the LabelStack is performed on rendering...". As each cell will be checked for rendering, I built a logic(map of cells) to add label depending on the row and column position.

And at the cell selection event I updated this map.

Its working very well now.

Thank you very much...

--
Nikhil
Previous Topic:Update / refresh Nattable
Next Topic:Unable to get RowHideShowLayer from body layer stack of nattable.
Goto Forum:
  


Current Time: Sun Aug 18 03:23:37 GMT 2019

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

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

Back to the top