Home » Eclipse Projects » Eclipse Platform » [Databinding] Is it possible to create a Detail IObservableList based off an IObservableList?
[Databinding] Is it possible to create a Detail IObservableList based off an IObservableList? [message #326442] |
Wed, 19 March 2008 23:26 |
Matt Seashore Messages: 58 Registered: July 2009 |
Member |
|
|
Here's the scenario:
I have a 'master' list of objects in Table A. Then, based on an
observable ofthe selected object in Table A, I currently use
MasterDetailObservables.detailList(IObservableValue...) to get an
IObservableList of children of the selected object. This 'detail' list
is used to populate the input of Table B.
This works well, but now I'd like to allow multiple selections in Table
A and populate Table B with the children of *all* selected objects in
Table A.
The (new in 3.4) ViewersObservables.observeMultiSelection(...) method
gives me an IObservableList of the selected objects in Table A instead
of an IObservableValue. However, from what I can find, almost no
databinding methods take in an IObservableList.
So, the question is, using an IObservableList is it possible to create
a "detail" IObservableList? If not, are there any examples/patterns of
how something like this could done using Databinding?
Thanks,
Matt
|
|
|
Re: [Databinding] Is it possible to create a Detail IObservableList based off an IObservableList? [message #326446 is a reply to message #326442] |
Thu, 20 March 2008 00:54 |
Matthew Hall Messages: 368 Registered: July 2009 |
Senior Member |
|
|
I'm not sure if I understood you correctly, but have you looked at
ComputedList? As long as all your dependencies are accessed
IObservables, the list recalculates itself any time a dependency changes.
For example:
final IObservableList selection =
ViewersObservables.observeMultiSelection(masterViewer);
IObservableList detailList = new ComputedList() {
protected List calculate() {
List result = new ArrayList();
for (Object element : selection) {
result.addAll(childrenOf(element));
}
return result;
}
};
Hope this helps,
Matthew
Matt Seashore wrote:
> Here's the scenario:
>
> I have a 'master' list of objects in Table A. Then, based on an
> observable ofthe selected object in Table A, I currently use
> MasterDetailObservables.detailList(IObservableValue...) to get an
> IObservableList of children of the selected object. This 'detail' list
> is used to populate the input of Table B.
>
> This works well, but now I'd like to allow multiple selections in Table
> A and populate Table B with the children of *all* selected objects in
> Table A.
>
> The (new in 3.4) ViewersObservables.observeMultiSelection(...) method
> gives me an IObservableList of the selected objects in Table A instead
> of an IObservableValue. However, from what I can find, almost no
> databinding methods take in an IObservableList.
>
> So, the question is, using an IObservableList is it possible to create
> a "detail" IObservableList? If not, are there any examples/patterns of
> how something like this could done using Databinding?
>
> Thanks,
>
> Matt
>
>
>
>
|
|
| |
Re: [Databinding] Is it possible to create a Detail IObservableList based off an IObservableList? [message #326452 is a reply to message #326446] |
Thu, 20 March 2008 05:15 |
Matt Seashore Messages: 58 Registered: July 2009 |
Member |
|
|
I think that is exactly what I'm looking for, thanks!
Matthew Hall wrote:
> I'm not sure if I understood you correctly, but have you looked at
> ComputedList? As long as all your dependencies are accessed
> IObservables, the list recalculates itself any time a dependency changes.
>
> For example:
>
> final IObservableList selection =
> ViewersObservables.observeMultiSelection(masterViewer);
> IObservableList detailList = new ComputedList() {
> protected List calculate() {
> List result = new ArrayList();
> for (Object element : selection) {
> result.addAll(childrenOf(element));
> }
> return result;
> }
> };
>
> Hope this helps,
>
> Matthew
>
> Matt Seashore wrote:
>> Here's the scenario:
>>
>> I have a 'master' list of objects in Table A. Then, based on an
>> observable ofthe selected object in Table A, I currently use
>> MasterDetailObservables.detailList(IObservableValue...) to get an
>> IObservableList of children of the selected object. This 'detail'
>> list is used to populate the input of Table B.
>>
>> This works well, but now I'd like to allow multiple selections in Table
>> A and populate Table B with the children of *all* selected objects in
>> Table A.
>>
>> The (new in 3.4) ViewersObservables.observeMultiSelection(...) method
>> gives me an IObservableList of the selected objects in Table A instead
>> of an IObservableValue. However, from what I can find, almost no
>> databinding methods take in an IObservableList.
>>
>> So, the question is, using an IObservableList is it possible to create
>> a "detail" IObservableList? If not, are there any examples/patterns of
>> how something like this could done using Databinding?
>>
>> Thanks,
>>
>> Matt
>>
>>
>>
>>
|
|
|
Re: [Databinding] Is it possible to create a Detail IObservableList based off an IObservableList? [message #326455 is a reply to message #326448] |
Thu, 20 March 2008 05:32 |
Matt Seashore Messages: 58 Registered: July 2009 |
Member |
|
|
> Why not using this ObservableList as the setInput to Table B?
That's a valid point. The main reason to avoid doing this would be to
make the implementation of Table B simpler and without code changes.
Admittedly any changes to Table B would be pretty small (the
contentProvider would need to go get the detail object, rather than just
displaying what's in the list), so, I guess other reason would be...it's
just more fun to use the Databinding framework! :-)
Thanks,
Matt
Tom Schindl wrote:
> Matt Seashore schrieb:
>> Here's the scenario:
>>
>> I have a 'master' list of objects in Table A. Then, based on an
>> observable ofthe selected object in Table A, I currently use
>> MasterDetailObservables.detailList(IObservableValue...) to get an
>> IObservableList of children of the selected object. This 'detail'
>> list is used to populate the input of Table B.
>>
>> This works well, but now I'd like to allow multiple selections in Table
>> A and populate Table B with the children of *all* selected objects in
>> Table A.
>>
>> The (new in 3.4) ViewersObservables.observeMultiSelection(...) method
>> gives me an IObservableList of the selected objects in Table A instead
>> of an IObservableValue. However, from what I can find, almost no
>> databinding methods take in an IObservableList.
>
> Why not using this ObservableList as the setInput to Table B?
>
> Tom
>
|
|
|
Re: [Databinding] Is it possible to create a Detail IObservableList based off an IObservableList? [message #326465 is a reply to message #326455] |
Thu, 20 March 2008 09:38 |
Thomas Schindl Messages: 6651 Registered: July 2009 |
Senior Member |
|
|
Ok. I just reread your question and my anwser is inpropriate :-(
Tom
Matt Seashore schrieb:
> > Why not using this ObservableList as the setInput to Table B?
>
> That's a valid point. The main reason to avoid doing this would be to
> make the implementation of Table B simpler and without code changes.
>
> Admittedly any changes to Table B would be pretty small (the
> contentProvider would need to go get the detail object, rather than just
> displaying what's in the list), so, I guess other reason would be...it's
> just more fun to use the Databinding framework! :-)
>
> Thanks,
>
> Matt
>
> Tom Schindl wrote:
>> Matt Seashore schrieb:
>>> Here's the scenario:
>>>
>>> I have a 'master' list of objects in Table A. Then, based on an
>>> observable ofthe selected object in Table A, I currently use
>>> MasterDetailObservables.detailList(IObservableValue...) to get an
>>> IObservableList of children of the selected object. This 'detail'
>>> list is used to populate the input of Table B.
>>>
>>> This works well, but now I'd like to allow multiple selections in Table
>>> A and populate Table B with the children of *all* selected objects in
>>> Table A.
>>>
>>> The (new in 3.4) ViewersObservables.observeMultiSelection(...) method
>>> gives me an IObservableList of the selected objects in Table A instead
>>> of an IObservableValue. However, from what I can find, almost no
>>> databinding methods take in an IObservableList.
>>
>> Why not using this ObservableList as the setInput to Table B?
>>
>> Tom
>>
--
B e s t S o l u t i o n . at
------------------------------------------------------------ --------
Tom Schindl JFace-Committer
------------------------------------------------------------ --------
|
|
|
Goto Forum:
Current Time: Thu Nov 14 10:00:11 GMT 2024
Powered by FUDForum. Page generated in 0.03364 seconds
|