Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » NatTable » read same data set twice ?
read same data set twice ? [message #1710013] Fri, 02 October 2015 16:06 Go to next message
Ivan Mising name is currently offline Ivan Mising nameFriend
Messages: 32
Registered: July 2009
Member
Hi,

I just tried this logic and notice NatTable read twice same data set.
Is there anyway to prevent this happen ?

Thanks

this is the out put :
left side is column and right side is row.

0=0
0=1
0=2
0=0
0=1
0=2

----------------------------
IDataProvider myDataProvider = new IDataProvider() {

@Override
public int getColumnCount() {
return 5;//26;
}

@Override
public int getRowCount() {
return 1000;
}

@Override
public Object getDataValue(int columnIndex, int rowIndex) {

if( columnIndex == 0 ){//&& rowIndex == 0
System.out.println(columnIndex + "=" + rowIndex );
}
String columnLetter = String
.valueOf((char) ('A' + columnIndex));
String rowNumber = String.valueOf(rowIndex + 1);
return columnLetter + rowNumber;
}

@Override
public void setDataValue(int columnIndex, int rowIndex,
Object newValue) {
// Do nothing
}
};

DataLayer bodyDataLayer = new DataLayer(myDataProvider);

ViewportLayer viewportLayer = new ViewportLayer( bodyDataLayer );

natTable = new NatTable(this, viewportLayer);
Re: read same data set twice ? [message #1710039 is a reply to message #1710013] Fri, 02 October 2015 20:39 Go to previous messageGo to next message
Dirk Fauth is currently offline Dirk FauthFriend
Messages: 2803
Registered: July 2012
Senior Member
I would need to debug why getDataValue() is called twice. Maybe because of a repaint caused by a client are resize or the viewport initializiation. But it shouldn't be an issue as getDataValue() is called a lot of times, e.g. on scrolling as the table gets re-rendered on scrolling.

The real question is, why do you care about how often getDataValue() is called?
Re: read same data set twice ? [message #1710043 is a reply to message #1710039] Sat, 03 October 2015 04:38 Go to previous messageGo to next message
Ivan Mising name is currently offline Ivan Mising nameFriend
Messages: 32
Registered: July 2009
Member
Hi,

not only that it read the visible rows data event just a click to make the window focus. this is important as every row it needs to read an image thumbnail in. if visible rows read twice, am easily out of handle. and, i'm try to dispose the out of visible area images as well.

Thanks
Re: read same data set twice ? [message #1710057 is a reply to message #1710043] Sat, 03 October 2015 13:31 Go to previous messageGo to next message
Dirk Fauth is currently offline Dirk FauthFriend
Messages: 2803
Registered: July 2012
Senior Member
If you load resources in getDataValue() you might run into several issues. IMHO you should rethink your resource handling and look at JFace resources.

Also the disposal of resources that are out of the visible area is currently not supported in NatTable. At least I don't know a way to do this with the current code base. I think you already created a ticket for this.
Re: read same data set twice ? [message #1710061 is a reply to message #1710057] Sat, 03 October 2015 14:18 Go to previous messageGo to next message
Ivan Mising name is currently offline Ivan Mising nameFriend
Messages: 32
Registered: July 2009
Member
Yape, already. but is there anyway to prevent nattable read same data set twice ? Thanks
Re: read same data set twice ? [message #1710063 is a reply to message #1710061] Sat, 03 October 2015 14:36 Go to previous messageGo to next message
Dirk Fauth is currently offline Dirk FauthFriend
Messages: 2803
Registered: July 2012
Senior Member
So you either didn't read my previous posts or you didn't understand.

In short, no you can't prevent that. There is no magic loading mechanism. The data model is accessed directly and this happens all the time, on scrolling, reloading, refreshing, updates, ...

You should not perform long running tasks to access the data model there as it breaks the performance. And you should not deal with resources in the data provider, it is not its intention. And if accessing the data model multiple times creates resource handle issues, you are doing something wrong regarding resource handling and should rethink your resource handling strategy for loading thumbnail images. I already suggested the usage of JFace resources to avoid loading resources multiple times.
Re: read same data set twice ? [message #1710089 is a reply to message #1710063] Sun, 04 October 2015 07:41 Go to previous messageGo to next message
Ivan Mising name is currently offline Ivan Mising nameFriend
Messages: 32
Registered: July 2009
Member
Hi, thanks for your reply. for this topic. actually I just wanted to confirm, is it NatTable will always read same visible data set twice ? or is there anyway that I prevent that ? this nothing to do with dispose objects or not. Hope you understand what I means.... thanks and waiting your reply again. best regards
Re: read same data set twice ? [message #1710098 is a reply to message #1710089] Sun, 04 October 2015 08:06 Go to previous message
Dirk Fauth is currently offline Dirk FauthFriend
Messages: 2803
Registered: July 2012
Senior Member
Quote:
In short, no you can't prevent that. There is no magic loading mechanism. The data model is accessed directly and this happens all the time, on scrolling, reloading, refreshing, updates, ...
Previous Topic:listener triggered when row visible or not fallen into visible client area ?
Next Topic:How can I image to right of cell to some actiom
Goto Forum:
  


Current Time: Sat Mar 06 12:26:46 GMT 2021

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

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

Back to the top