Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse 4 » [XWT] change input when viewer's selection changes
[XWT] change input when viewer's selection changes [message #491184] Tue, 13 October 2009 11:04 Go to next message
Erdal Karaca is currently offline Erdal Karaca
Messages: 729
Registered: July 2009
Senior Member
I have two tables A, B. If user changes selection of table A, then table B should change its input.

Example:
A: input={Binding path=mybooks}
B: input={Binding path=SELECTED_BOOK/authors}

A contains books. B shows the selected book's authors.
When user selects another book, authors must be updated accordingly.
How would I express this in xwt?
Re: [XWT] change input when viewer's selection changes [message #491516 is a reply to message #491184] Wed, 14 October 2009 17:09 Go to previous messageGo to next message
Yves YANG is currently offline Yves YANG
Messages: 687
Registered: July 2009
Senior Member
You can find the solution in the demo e4 contact in XWT. The same concept is used. It is in fact the Master/detail presentation pattern.

Precisely, your A listens the selection event and put the selected element in the variable Selection of IEclipseContext. The view part of XWT listens the property change event on IEclipseContext and takes the Selection as data context. So in your B, you can just bind the list to "authors" directly.

[Updated on: Wed, 14 October 2009 17:11]

Report message to a moderator

Re: [XWT] change input when viewer's selection changes [message #491675 is a reply to message #491516] Thu, 15 October 2009 09:07 Go to previous messageGo to next message
Erdal Karaca is currently offline Erdal Karaca
Messages: 729
Registered: July 2009
Senior Member
Can this also be done completely in xwt/declaratively, i.e. without coding in java (accessing IEclipseContext)?

On your blog you mentioned the new trigger concept which could be used for this...
Could you please provide a sample to show how to change a viewer's input based on the selection of another viewer?

Yves YANG wrote on Wed, 14 October 2009 17:09
You can find the solution in the demo e4 contact in XWT. The same concept is used. It is in fact the Master/detail presentation pattern.

Precisely, your A listens the selection event and put the selected element in the variable Selection of IEclipseContext. The view part of XWT listens the property change event on IEclipseContext and takes the Selection as data context. So in your B, you can just bind the list to "authors" directly.


Re: [XWT] change input when viewer's selection changes [message #492118 is a reply to message #491675] Sun, 18 October 2009 16:03 Go to previous messageGo to next message
Yves YANG is currently offline Yves YANG
Messages: 687
Registered: July 2009
Senior Member
There are two way to manage the synchronization beween views:
1. Solution of data binding on a context object
All views set a object as data context. The viwe binds with a property
object context. The synchronization is done through the the property change
notification of the object context. It is the solution used in e4 contact
demo. The object context is IEclipseContext in case of e4 integration. Of
course, you can define your object context if you are outside of e4
workbench.

2. Event handling
This is manual solution. You define a Java controller that listens the
selection event. When the event getraised, you call set input to other
views.
You can find this solution in an example under
org.eclipse.e4.xwt/examples/org.eclipse.e4.emf.demo in eclipse CVS.
..
The event trigger is mains used inside a view, not between views

Best regards
Yves YANG
"Erdal Karaca" <erdal.karaca.de@googlemail.com> wrote in message
news:hb76q9$63p$1@build.eclipse.org...
> Can this also be done completely in xwt/declaratively, i.e. without coding
> in java (accessing IEclipseContext)?
>
> On your blog you mentioned the new trigger concept which could be used for
> this...
> Could you please provide a sample to show how to change a viewer's input
> based on the selection of another viewer?
>
> Yves YANG wrote on Wed, 14 October 2009 17:09
>> You can find the solution in the demo e4 contact in XWT. The same concept
>> is used. It is in fact the Master/detail presentation pattern. Precisely,
>> your A listens the selection event and put the selected element in the
>> variable Selection of IEclipseContext. The view part of XWT listens the
>> property change event on IEclipseContext and takes the Selection as data
>> context. So in your B, you can just bind the list to "authors" directly.
>
>
Re: [XWT] change input when viewer's selection changes [message #496969 is a reply to message #491675] Wed, 11 November 2009 17:23 Go to previous messageGo to next message
Yves YANG is currently offline Yves YANG
Messages: 687
Registered: July 2009
Senior Member
"Erdal Karaca" <erdal.karaca.de@googlemail.com> wrote in message
news:hb76q9$63p$1@build.eclipse.org...
> Can this also be done completely in xwt/declaratively, i.e. without coding
> in java (accessing IEclipseContext)?
>
> On your blog you mentioned the new trigger concept which could be used for
> this...
> Could you please provide a sample to show how to change a viewer's input
> based on the selection of another viewer?
>
> Yves YANG wrote on Wed, 14 October 2009 17:09
>> You can find the solution in the demo e4 contact in XWT. The same concept
>> is used. It is in fact the Master/detail presentation pattern. Precisely,
>> your A listens the selection event and put the selected element in the
>> variable Selection of IEclipseContext. The view part of XWT listens the
>> property change event on IEclipseContext and takes the Selection as data
>> context. So in your B, you can just bind the list to "authors" directly.
>
>

It will be fixed in the next release M2.

Best regards
Yves YANG
Re: [XWT] change input when viewer's selection changes [message #498853 is a reply to message #496969] Wed, 18 November 2009 14:40 Go to previous messageGo to next message
Erdal Karaca is currently offline Erdal Karaca
Messages: 729
Registered: July 2009
Senior Member
In your 1.0M2 N&N you announced the rework for the master/detail pattern...
I applied it this way:

<tableViewer x:name="master" ...>...</tableViewer>

<tableViewer input="{Binding elementName=master,path=selection}">...

I thought that the second table viewer would listen for the master's selection changes and reload using its new selection as input.
However, the selection is only applied once on creation...

Do I miss something?
Re: [XWT] change input when viewer's selection changes [message #499089 is a reply to message #498853] Thu, 19 November 2009 13:47 Go to previous messageGo to next message
Yves YANG is currently offline Yves YANG
Messages: 687
Registered: July 2009
Senior Member
"Erdal Karaca" <erdal.karaca.de@googlemail.com> wrote in message
news:he1iis$tt6$1@build.eclipse.org...
> In your 1.0M2 N&N you announced the rework for the master/detail
> pattern...
> I applied it this way:
>
> <tableViewer x:name="master" ...>...</tableViewer>
>
> <tableViewer input="{Binding elementName=master,path=selection}">...
>
> I thought that the second table viewer would listen for the master's
> selection changes and reload using its new selection as input.

Yes, it is.

> However, the selection is only applied once on creation...
It is matter of implementation.. In fact, in JFace data binding, we listen a
fixed collection created for the tableviewer corresponding to
singleSelection (it is the Jface Data Binding name, not selection). The
content gets changed when the selection changes.

Best regards
Yves YANG
>
> Do I miss something?
Re: [XWT] change input when viewer's selection changes [message #499104 is a reply to message #499089] Thu, 19 November 2009 15:58 Go to previous messageGo to next message
Erdal Karaca is currently offline Erdal Karaca
Messages: 729
Registered: July 2009
Senior Member
Could you not just provide an example?

How would the second tableViewer be kept in sync with the first's selection?
Re: [XWT] change input when viewer's selection changes [message #499109 is a reply to message #499104] Thu, 19 November 2009 16:27 Go to previous messageGo to next message
Yves YANG is currently offline Yves YANG
Messages: 687
Registered: July 2009
Senior Member
Here you are !

yves
"Erdal Karaca" <erdal.karaca.de@googlemail.com> wrote in message
news:he4bhq$vcr$1@build.eclipse.org...
> Could you not just provide an example?
>
> How would the second tableViewer be kept in sync with the first's
> selection?


Re: [XWT] change input when viewer's selection changes [message #499202 is a reply to message #499109] Fri, 20 November 2009 07:23 Go to previous messageGo to next message
Erdal Karaca is currently offline Erdal Karaca
Messages: 729
Registered: July 2009
Senior Member
Does xwt need 3.6 to run, now?
Re: [XWT] change input when viewer's selection changes [message #499208 is a reply to message #499202] Fri, 20 November 2009 07:46 Go to previous messageGo to next message
Erdal Karaca is currently offline Erdal Karaca
Messages: 729
Registered: July 2009
Senior Member
Beside the new 3.6 dependencies (i just removed bundle-versions to compile against 3.5), this seems to work, now!
Re: [XWT] change input when viewer's selection changes [message #499236 is a reply to message #499202] Fri, 20 November 2009 09:21 Go to previous message
Yves YANG is currently offline Yves YANG
Messages: 687
Registered: July 2009
Senior Member
The 3.6 is requried by e4 CSS, not XWT. From the code base, XWT can work
with eclipse 3.4

Best regards
Yves YANG
"Erdal Karaca" <erdal.karaca.de@googlemail.com> wrote in message
news:he61o4$n8f$1@build.eclipse.org...
> Does xwt need 3.6 to run, now?
>
Re: [XWT] change input when viewer's selection changes [message #563923 is a reply to message #491516] Thu, 15 October 2009 09:07 Go to previous message
Erdal Karaca is currently offline Erdal Karaca
Messages: 729
Registered: July 2009
Senior Member
Can this also be done completely in xwt/declaratively, i.e. without coding in java (accessing IEclipseContext)?

On your blog you mentioned the new trigger concept which could be used for this...
Could you please provide a sample to show how to change a viewer's input based on the selection of another viewer?

Yves YANG wrote on Wed, 14 October 2009 17:09
> You can find the solution in the demo e4 contact in XWT. The same concept is used. It is in fact the Master/detail presentation pattern.
>
> Precisely, your A listens the selection event and put the selected element in the variable Selection of IEclipseContext. The view part of XWT listens the property change event on IEclipseContext and takes the Selection as data context. So in your B, you can just bind the list to "authors" directly.
Re: [XWT] change input when viewer's selection changes [message #563973 is a reply to message #491675] Sun, 18 October 2009 16:03 Go to previous message
Yves YANG is currently offline Yves YANG
Messages: 687
Registered: July 2009
Senior Member
There are two way to manage the synchronization beween views:
1. Solution of data binding on a context object
All views set a object as data context. The viwe binds with a property
object context. The synchronization is done through the the property change
notification of the object context. It is the solution used in e4 contact
demo. The object context is IEclipseContext in case of e4 integration. Of
course, you can define your object context if you are outside of e4
workbench.

2. Event handling
This is manual solution. You define a Java controller that listens the
selection event. When the event getraised, you call set input to other
views.
You can find this solution in an example under
org.eclipse.e4.xwt/examples/org.eclipse.e4.emf.demo in eclipse CVS.
..
The event trigger is mains used inside a view, not between views

Best regards
Yves YANG
"Erdal Karaca" <erdal.karaca.de@googlemail.com> wrote in message
news:hb76q9$63p$1@build.eclipse.org...
> Can this also be done completely in xwt/declaratively, i.e. without coding
> in java (accessing IEclipseContext)?
>
> On your blog you mentioned the new trigger concept which could be used for
> this...
> Could you please provide a sample to show how to change a viewer's input
> based on the selection of another viewer?
>
> Yves YANG wrote on Wed, 14 October 2009 17:09
>> You can find the solution in the demo e4 contact in XWT. The same concept
>> is used. It is in fact the Master/detail presentation pattern. Precisely,
>> your A listens the selection event and put the selected element in the
>> variable Selection of IEclipseContext. The view part of XWT listens the
>> property change event on IEclipseContext and takes the Selection as data
>> context. So in your B, you can just bind the list to "authors" directly.
>
>
Re: [XWT] change input when viewer's selection changes [message #564662 is a reply to message #491675] Wed, 11 November 2009 17:23 Go to previous message
Yves YANG is currently offline Yves YANG
Messages: 687
Registered: July 2009
Senior Member
"Erdal Karaca" <erdal.karaca.de@googlemail.com> wrote in message
news:hb76q9$63p$1@build.eclipse.org...
> Can this also be done completely in xwt/declaratively, i.e. without coding
> in java (accessing IEclipseContext)?
>
> On your blog you mentioned the new trigger concept which could be used for
> this...
> Could you please provide a sample to show how to change a viewer's input
> based on the selection of another viewer?
>
> Yves YANG wrote on Wed, 14 October 2009 17:09
>> You can find the solution in the demo e4 contact in XWT. The same concept
>> is used. It is in fact the Master/detail presentation pattern. Precisely,
>> your A listens the selection event and put the selected element in the
>> variable Selection of IEclipseContext. The view part of XWT listens the
>> property change event on IEclipseContext and takes the Selection as data
>> context. So in your B, you can just bind the list to "authors" directly.
>
>

It will be fixed in the next release M2.

Best regards
Yves YANG
Re: [XWT] change input when viewer's selection changes [message #564762 is a reply to message #496969] Wed, 18 November 2009 14:40 Go to previous message
Erdal Karaca is currently offline Erdal Karaca
Messages: 729
Registered: July 2009
Senior Member
In your 1.0M2 N&N you announced the rework for the master/detail pattern...
I applied it this way:

<tableViewer x:name="master" ...>...</tableViewer>

<tableViewer input="{Binding elementName=master,path=selection}">...

I thought that the second table viewer would listen for the master's selection changes and reload using its new selection as input.
However, the selection is only applied once on creation...

Do I miss something?
Re: [XWT] change input when viewer's selection changes [message #564779 is a reply to message #498853] Thu, 19 November 2009 13:47 Go to previous message
Yves YANG is currently offline Yves YANG
Messages: 687
Registered: July 2009
Senior Member
"Erdal Karaca" <erdal.karaca.de@googlemail.com> wrote in message
news:he1iis$tt6$1@build.eclipse.org...
> In your 1.0M2 N&N you announced the rework for the master/detail
> pattern...
> I applied it this way:
>
> <tableViewer x:name="master" ...>...</tableViewer>
>
> <tableViewer input="{Binding elementName=master,path=selection}">...
>
> I thought that the second table viewer would listen for the master's
> selection changes and reload using its new selection as input.

Yes, it is.

> However, the selection is only applied once on creation...
It is matter of implementation.. In fact, in JFace data binding, we listen a
fixed collection created for the tableviewer corresponding to
singleSelection (it is the Jface Data Binding name, not selection). The
content gets changed when the selection changes.

Best regards
Yves YANG
>
> Do I miss something?
Re: [XWT] change input when viewer's selection changes [message #564791 is a reply to message #499089] Thu, 19 November 2009 15:58 Go to previous message
Erdal Karaca is currently offline Erdal Karaca
Messages: 729
Registered: July 2009
Senior Member
Could you not just provide an example?

How would the second tableViewer be kept in sync with the first's selection?
Re: [XWT] change input when viewer's selection changes [message #564808 is a reply to message #564791] Thu, 19 November 2009 16:27 Go to previous message
Yves YANG is currently offline Yves YANG
Messages: 687
Registered: July 2009
Senior Member
Here you are !

yves
"Erdal Karaca" <erdal.karaca.de@googlemail.com> wrote in message
news:he4bhq$vcr$1@build.eclipse.org...
> Could you not just provide an example?
>
> How would the second tableViewer be kept in sync with the first's
> selection?


Re: [XWT] change input when viewer's selection changes [message #564825 is a reply to message #499109] Fri, 20 November 2009 07:23 Go to previous message
Erdal Karaca is currently offline Erdal Karaca
Messages: 729
Registered: July 2009
Senior Member
Does xwt need 3.6 to run, now?
Re: [XWT] change input when viewer's selection changes [message #564838 is a reply to message #564825] Fri, 20 November 2009 07:46 Go to previous message
Erdal Karaca is currently offline Erdal Karaca
Messages: 729
Registered: July 2009
Senior Member
Beside the new 3.6 dependencies (i just removed bundle-versions to compile against 3.5), this seems to work, now!
Re: [XWT] change input when viewer's selection changes [message #564904 is a reply to message #564825] Fri, 20 November 2009 09:21 Go to previous message
Yves YANG is currently offline Yves YANG
Messages: 687
Registered: July 2009
Senior Member
The 3.6 is requried by e4 CSS, not XWT. From the code base, XWT can work
with eclipse 3.4

Best regards
Yves YANG
"Erdal Karaca" <erdal.karaca.de@googlemail.com> wrote in message
news:he61o4$n8f$1@build.eclipse.org...
> Does xwt need 3.6 to run, now?
>
Previous Topic:[xwt] combo cell editor for enums
Next Topic:org.eclipse.emf.ecore.xmi.PackageNotFoundException: Package with uri 'http://www.eclipse.org/ui/2008
Goto Forum:
  


Current Time: Mon Jul 28 06:20:17 EDT 2014

Powered by FUDForum. Page generated in 0.04716 seconds