Home » Eclipse Projects » JFace » ComboViewer dropdown list not updated with new data
| | |
Re: ComboViewer dropdown list not updated with new data [message #756169 is a reply to message #756166] |
Fri, 11 November 2011 11:39 |
Daniel Krügler Messages: 853 Registered: July 2009 |
Senior Member |
|
|
On 2011-11-11 11:57, Mikael Petterson wrote:
> Daniel Krügler wrote on Fri, 11 November 2011 05:23
>> On 2011-11-11 10:50, Mikael Petterson wrote:
>> > Hi,
>> >
>> > I am opening a new dialog form an existing Dialog. When I close the new
>> > dialog (NewActivityDialog) the comboViewer will not be updated with new
>> > data from activities. Why?
>>
>> What do you precisely mean with "will not be updated"?
>>
>> When I call
>> ArrayList<String> activities =
>> (ArrayList<String>)provider.listMyActivities();
>>
>> after a new activity has been called the new activity is in the list.
>> But I cannot get it into the drop down list in ComboViewer.
I can only assume, that you are using the Viewer API incorrectly, we
probably need to see a minimal, complete test case of what does not work.
>> > Any ideas what I am missing here?
>> > comboViewer.getCombo().removeAll();
>>
>> You should always ensure that you invoke the *viewer* methods, why are
>> you not using setInput instead?
>>
>> I got duplicates. But I will try it again.
I'm not sure about what you refer by "duplicates". If your input
contains "duplicates", those will be part of the presented viewer
content, because a viewer is not a set. If you call setInput, the old
input will be replaced by the new one, a refresh happens automagically,
so it is impossible that the viewer still contains parts of the previous
model.
Your description:
<quote>
This works fine as log as my activities are static but I my case I have
a method
String [] activities = getAllActivities();
Example:
First time it is executed:
e.g. activities will contain {"one","two","three"};
Second time it is executed ( new has been created):
e.g. activities will contain {"one","two","three","four"};
So it also contains the old ones.
</quote>
is not really helpful, because you don't show us, what
getAllActivities() returns at the first call and what it returns at the
second call. Your example does not really prove that the old ones are
still used. I would expect that the first call of getAllActivities()
returned {"one","two","three"} and that the second call returned
{"one","two","three","four"}, which would completely explain the outcome
of your experiment.
>> But how do I do that when I have an arraylist?
arraylist of what? If this is an ArrayList<String> and if each element
of this array refers to existing parts of the content, you can construct
an StructuredSelection object from this List.
HTH & Greetings from Bremen,
Daniel Krügler
|
|
|
Goto Forum:
Current Time: Wed Sep 25 23:42:07 GMT 2024
Powered by FUDForum. Page generated in 0.03747 seconds
|