Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » JFace » TableViewer setInput() questions
TableViewer setInput() questions [message #668499] Thu, 05 May 2011 21:09 Go to next message
Catalin Gerea is currently offline Catalin Gerea
Messages: 89
Registered: July 2009
Location: Bucharest, Romania
Member

I have a question related to a table viewer that is updated frequently (3-6 times per minute). This update is performed every time by calling tableViewer.setInput(new_input).

1. Is this the correct way to update the table viewer?


As far I could saw from code: the setInput() from StructuredViewer get's called -> unmapAllElements() -> elementMap = newHashtable(CustomHashtable.DEFAULT_CAPACITY); -> return new CustomHashtable(capacity, getComparer());.

This means that every call to setInput() will trigger the creation of a new CustomHashtable; in my case 8640 new objects per day.

2. How are these new objects destroyed, because I did not saw any code that empties the elementMap?


Thank you in advance for any detail/information about this.


Time is what you make of it.
Re: TableViewer setInput() questions [message #718410 is a reply to message #668499] Wed, 24 August 2011 08:46 Go to previous messageGo to next message
jim liu is currently offline jim liu
Messages: 37
Registered: February 2011
Location: shanghai
Member
I think jre will destroy these objects if these objects are not referenced by other objects.

java eclipse Search
http://javafind.appspot.com/
Re: TableViewer setInput() questions [message #718443 is a reply to message #668499] Wed, 24 August 2011 10:54 Go to previous messageGo to next message
Eclipse User
Originally posted by:

On 2011-05-05 23:09, Catalin Gerea wrote:
> I have a question related to a table viewer that is updated frequently
> (3-6 times per minute). This update is performed every time by calling
> tableViewer.setInput(new_input).

You should use setInput() only, if your input has changed, otherwise you
should better use the refresh() function.

> 1. Is this the correct way to update the table viewer?

I don't know, because you don't say whether your input really has
changed or whether the data within your input has changed. In the latter
case, refresh() is more appropriate, but I don't think that both have
very different performance characteristics. If only a subset of all
elements of the viewer have changed, you should user the refresh
overload that accept an array of objects. If not the structure has
changed, but only aspects that influence the label or icon of the
element, you should use the update() functions.

> As far I could saw from code: the setInput() from StructuredViewer get's
> called -> unmapAllElements() -> elementMap =
> newHashtable(CustomHashtable.DEFAULT_CAPACITY); -> return new
> CustomHashtable(capacity, getComparer());.
>
> This means that every call to setInput() will trigger the creation of a
> new CustomHashtable; in my case 8640 new objects per day.
> 2. How are these new objects destroyed, because I did not saw any code
> that empties the elementMap?

You should not need to care about this: It is an implementation detail
of the viewer. If you are really observing that this has significant
performance disadvantages, you should open a bug report (But you should
first publish what exactly your test situation was).

HTH & Greetings from Bremen,

- Daniel Kr├╝gler
Re: TableViewer setInput() questions [message #718703 is a reply to message #718443] Thu, 25 August 2011 06:03 Go to previous message
Catalin Gerea is currently offline Catalin Gerea
Messages: 89
Registered: July 2009
Location: Bucharest, Romania
Member

Hello Daniel

Thank you for your reply.

1. In my case there is a provider that can be called "InformationProvider" that will provide the input for the table (actually the design is a little bit more complex since the information displayed in the table should be always up-to-date with the rest of the system BUT also consistent with the internal model).
So I cannot say 'a priori' what kind of input I will have: I can have new information (new input) or changes to existing information (changes inside my initial input) or both.
Therefore I think that using "setInput(anInput)" is correct in my case.

2. I will make some further tests and if indeed I will notice unwanted behavior/bad performance I will open a bug report.


Time is what you make of it.
Previous Topic:select multiple cells in a TableViewer ?
Next Topic:Dialog missing title image
Goto Forum:
  


Current Time: Sun Sep 21 00:09:47 GMT 2014

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

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