TableViewer setInput() questions [message #668499] |
Thu, 05 May 2011 21:09 |
|
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 #718443 is a reply to message #668499] |
Wed, 24 August 2011 10:54 |
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 |
|
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.
|
|
|
Powered by
FUDForum. Page generated in 0.03327 seconds