Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » [emf] Notifier after CompoundCommand / Trigger Databinding
[emf] Notifier after CompoundCommand / Trigger Databinding [message #508469] Mon, 18 January 2010 22:58 Go to next message
Jeff S. is currently offline Jeff S.Friend
Messages: 29
Registered: July 2009
Junior Member
So this may not be the correct list to ask this question (it may be more
of a JFace/Databinding issue), but I'm going to give it a shot.

First off, here's a link to the project I'm working on:
http://tinyurl.com/svn-trunk (google code link- minimized using tinyurl)

This program lets you create/load/manage/save .esx files for a hardware
sampler. I reverse engineered the file format, and created an ecore
model for it. Right now the program's in the beginning stages because I
keep getting held up with what should be simple tasks (but I've been
away from Java for so long- I'm making them difficult).

My problem right now is: I've created a CompoundCommand that lets a user
select x number of .wav/.aiff files to load into the workspace. After
doing this, I want the "info" tab to be updated with how much "memory"
is left in the workspace. This value is a derived attribute. After the
Command is ran, the derived value *is* updated, but the display on my
"form" is not updated until I choose a different tab, and come back to
the "info" tab. It will also be updated if I have the "Outline View"
expanded so that a "sample" is highlighted (when you import .wav/.aiff
files- the array of "samples" is changed).

I've created a quick screencast to demonstrate the issue (around 1:30 long):
http://screenr.com/pD1
The "click me" buttons display the value stored in my model. The text
in the form is supposed to be databinded to this value, but it only
seems to change when I "enter" the tab, or have a sample selected from
the "Outline View".

My CompoundCommand is in the importAudioFiles() function in this file
(EsxEditorAdvisor.java):
http://tinyurl.com/EsxEditorAdvisor-java (google code link- minimized
using tinyurl)

The databinding is done in this file (EsxEditorPartInfo.java):
http://tinyurl.com/EsxEditorPartInfo-java (google code link- minimized
using tinyurl)

Can anybody take some time to help me out with this? Once I figure this
step out, I'll be able to get a lot more of the UI work done.

Thanks in advance for any help you can provide!

-Jeff
Re: [emf] Notifier after CompoundCommand / Trigger Databinding [message #508578 is a reply to message #508469] Tue, 19 January 2010 13:56 Go to previous messageGo to next message
Thomas Schindl is currently offline Thomas SchindlFriend
Messages: 6512
Registered: July 2009
Senior Member
Are you sure your setInput() method is called? The databinding code
looks ok. Though you'll leak Observables, Bindings, ... because you are
never disposing them (See my EMF-Databinding series for pointers on how
to deal with Observables).

Tom

[1] http://tomsondev.bestsolution.at/2009/06/06/galileo-improved -emf-databinding-support/

Am 19.01.10 04:51, schrieb Jeff S.:
> So this may not be the correct list to ask this question (it may be more
> of a JFace/Databinding issue), but I'm going to give it a shot.
>
> First off, here's a link to the project I'm working on:
> http://tinyurl.com/svn-trunk (google code link- minimized using tinyurl)
>
> This program lets you create/load/manage/save .esx files for a hardware
> sampler. I reverse engineered the file format, and created an ecore
> model for it. Right now the program's in the beginning stages because I
> keep getting held up with what should be simple tasks (but I've been
> away from Java for so long- I'm making them difficult).
>
> My problem right now is: I've created a CompoundCommand that lets a user
> select x number of .wav/.aiff files to load into the workspace. After
> doing this, I want the "info" tab to be updated with how much "memory"
> is left in the workspace. This value is a derived attribute. After the
> Command is ran, the derived value *is* updated, but the display on my
> "form" is not updated until I choose a different tab, and come back to
> the "info" tab. It will also be updated if I have the "Outline View"
> expanded so that a "sample" is highlighted (when you import .wav/.aiff
> files- the array of "samples" is changed).
>
> I've created a quick screencast to demonstrate the issue (around 1:30
> long):
> http://screenr.com/pD1
> The "click me" buttons display the value stored in my model. The text
> in the form is supposed to be databinded to this value, but it only
> seems to change when I "enter" the tab, or have a sample selected from
> the "Outline View".
>
> My CompoundCommand is in the importAudioFiles() function in this file
> (EsxEditorAdvisor.java):
> http://tinyurl.com/EsxEditorAdvisor-java (google code link- minimized
> using tinyurl)
>
> The databinding is done in this file (EsxEditorPartInfo.java):
> http://tinyurl.com/EsxEditorPartInfo-java (google code link- minimized
> using tinyurl)
>
> Can anybody take some time to help me out with this? Once I figure this
> step out, I'll be able to get a lot more of the UI work done.
>
> Thanks in advance for any help you can provide!
>
> -Jeff
Re: [emf] Notifier after CompoundCommand / Trigger Databinding [message #508657 is a reply to message #508578] Tue, 19 January 2010 18:22 Go to previous messageGo to next message
Jeff S. is currently offline Jeff S.Friend
Messages: 29
Registered: July 2009
Junior Member
Tom-

Thanks for taking the time to answer. The setInput() *is* being called.

Inside the setInput() call is the only place I assign the variable:
this.esxFile.

I then bind the EsxPackage.Literals.ESX_FILE__MEM_FREE_IN_BYTES feature
to a Text field.

When I click on the button, I simple display
this.esxFile.getMemFreeInBytes() (which is the derived
EsxPackage.Literals.ESX_FILE__MEM_FREE_IN_BYTES feature).

My thinking is that whenever I click the button, the value should
*always* match what is displayed in my Text field (if the databinding
was setup properly).

This is not the case.

If you look at the :35 second mark from this screencast:
http://screenr.com/pD1

You'll notice that the Text field displays: 25165822, but the Dialog
displays: 23869688. I guess I didn't make that very clear from my
original post :)

Anyways, thanks again. I have skimmed over your tutorial in the past
(quite a few times). I'll try to re-read your posts in full tonight
after work.

In the meantime, would incorrectly disposing my Observables/Bindings
cause the databinding not to work properly, or just cause some memory
leaks? I still don't see why the Text display doesn't match the Dialog
display (unless I'm supposed to be triggering some type of notification
after running my CompoundCommmand)....

-Jeff

On 1/19/2010 8:56 AM, Tom Schindl wrote:
> Are you sure your setInput() method is called? The databinding code
> looks ok. Though you'll leak Observables, Bindings, ... because you are
> never disposing them (See my EMF-Databinding series for pointers on how
> to deal with Observables).
>
> Tom
>
> [1] http://tomsondev.bestsolution.at/2009/06/06/galileo-improved -emf-databinding-support/
>
> Am 19.01.10 04:51, schrieb Jeff S.:
>> So this may not be the correct list to ask this question (it may be more
>> of a JFace/Databinding issue), but I'm going to give it a shot.
>>
>> First off, here's a link to the project I'm working on:
>> http://tinyurl.com/svn-trunk (google code link- minimized using tinyurl)
>>
>> This program lets you create/load/manage/save .esx files for a hardware
>> sampler. I reverse engineered the file format, and created an ecore
>> model for it. Right now the program's in the beginning stages because I
>> keep getting held up with what should be simple tasks (but I've been
>> away from Java for so long- I'm making them difficult).
>>
>> My problem right now is: I've created a CompoundCommand that lets a user
>> select x number of .wav/.aiff files to load into the workspace. After
>> doing this, I want the "info" tab to be updated with how much "memory"
>> is left in the workspace. This value is a derived attribute. After the
>> Command is ran, the derived value *is* updated, but the display on my
>> "form" is not updated until I choose a different tab, and come back to
>> the "info" tab. It will also be updated if I have the "Outline View"
>> expanded so that a "sample" is highlighted (when you import .wav/.aiff
>> files- the array of "samples" is changed).
>>
>> I've created a quick screencast to demonstrate the issue (around 1:30
>> long):
>> http://screenr.com/pD1
>> The "click me" buttons display the value stored in my model. The text
>> in the form is supposed to be databinded to this value, but it only
>> seems to change when I "enter" the tab, or have a sample selected from
>> the "Outline View".
>>
>> My CompoundCommand is in the importAudioFiles() function in this file
>> (EsxEditorAdvisor.java):
>> http://tinyurl.com/EsxEditorAdvisor-java (google code link- minimized
>> using tinyurl)
>>
>> The databinding is done in this file (EsxEditorPartInfo.java):
>> http://tinyurl.com/EsxEditorPartInfo-java (google code link- minimized
>> using tinyurl)
>>
>> Can anybody take some time to help me out with this? Once I figure this
>> step out, I'll be able to get a lot more of the UI work done.
>>
>> Thanks in advance for any help you can provide!
>>
>> -Jeff
>
Re: [emf] Notifier after CompoundCommand / Trigger Databinding [message #508675 is a reply to message #508657] Tue, 19 January 2010 19:10 Go to previous messageGo to next message
Thomas Schindl is currently offline Thomas SchindlFriend
Messages: 6512
Registered: July 2009
Senior Member
Hi Jeff,

I think I now see the problem memUsedInBytes and memFreeInBytes are
derived. The problem is there are not change notifications fired when
the value is modified.

You need to fire change events in this case. With something like this:

---------8<--------------------
> protected EsxFileImpl() {
> super();
> init();
> }
>
> private void init() {
> eAdapters().add(new AdapterImpl() {
> @Override
> public void notifyChanged(Notification msg) {
> if( EsxPackage.Literals.ESX_FILE__SAMPLES.equals(msg.getFeature( )) ) {
> if (eNotificationRequired()) {
> eNotify(new ENotificationImpl(EsxFileImpl.this, Notification.SET, EsxPackage.ESX_FILE__MEM_FREE_IN_BYTES, new Integer(0), new Integer(getMemFreeInBytes())));
> eNotify(new ENotificationImpl(EsxFileImpl.this, Notification.SET, EsxPackage.ESX_FILE__MEM_USED_IN_BYTES, 0, getMemUsedInBytes()));
> }
> }
> }
> });
> }
>
> protected EsxFileImpl(EsxRandomAccess in, IProgressMonitor monitor) throws EsxException {
> super();
> init();

---------8<--------------------



Tom

Am 19.01.10 19:22, schrieb Jeff S.:
> Tom-
>
> Thanks for taking the time to answer. The setInput() *is* being called.
>
> Inside the setInput() call is the only place I assign the variable:
> this.esxFile.
>
> I then bind the EsxPackage.Literals.ESX_FILE__MEM_FREE_IN_BYTES feature
> to a Text field.
>
> When I click on the button, I simple display
> this.esxFile.getMemFreeInBytes() (which is the derived
> EsxPackage.Literals.ESX_FILE__MEM_FREE_IN_BYTES feature).
>
> My thinking is that whenever I click the button, the value should
> *always* match what is displayed in my Text field (if the databinding
> was setup properly).
>
> This is not the case.
>
> If you look at the :35 second mark from this screencast:
> http://screenr.com/pD1
>
> You'll notice that the Text field displays: 25165822, but the Dialog
> displays: 23869688. I guess I didn't make that very clear from my
> original post :)
>
> Anyways, thanks again. I have skimmed over your tutorial in the past
> (quite a few times). I'll try to re-read your posts in full tonight
> after work.
>
> In the meantime, would incorrectly disposing my Observables/Bindings
> cause the databinding not to work properly, or just cause some memory
> leaks? I still don't see why the Text display doesn't match the Dialog
> display (unless I'm supposed to be triggering some type of notification
> after running my CompoundCommmand)....
>
> -Jeff
>
> On 1/19/2010 8:56 AM, Tom Schindl wrote:
>> Are you sure your setInput() method is called? The databinding code
>> looks ok. Though you'll leak Observables, Bindings, ... because you are
>> never disposing them (See my EMF-Databinding series for pointers on how
>> to deal with Observables).
>>
>> Tom
>>
>> [1] http://tomsondev.bestsolution.at/2009/06/06/galileo-improved -emf-databinding-support/
>>
>>
>> Am 19.01.10 04:51, schrieb Jeff S.:
>>> So this may not be the correct list to ask this question (it may be more
>>> of a JFace/Databinding issue), but I'm going to give it a shot.
>>>
>>> First off, here's a link to the project I'm working on:
>>> http://tinyurl.com/svn-trunk (google code link- minimized using tinyurl)
>>>
>>> This program lets you create/load/manage/save .esx files for a hardware
>>> sampler. I reverse engineered the file format, and created an ecore
>>> model for it. Right now the program's in the beginning stages because I
>>> keep getting held up with what should be simple tasks (but I've been
>>> away from Java for so long- I'm making them difficult).
>>>
>>> My problem right now is: I've created a CompoundCommand that lets a user
>>> select x number of .wav/.aiff files to load into the workspace. After
>>> doing this, I want the "info" tab to be updated with how much "memory"
>>> is left in the workspace. This value is a derived attribute. After the
>>> Command is ran, the derived value *is* updated, but the display on my
>>> "form" is not updated until I choose a different tab, and come back to
>>> the "info" tab. It will also be updated if I have the "Outline View"
>>> expanded so that a "sample" is highlighted (when you import .wav/.aiff
>>> files- the array of "samples" is changed).
>>>
>>> I've created a quick screencast to demonstrate the issue (around 1:30
>>> long):
>>> http://screenr.com/pD1
>>> The "click me" buttons display the value stored in my model. The text
>>> in the form is supposed to be databinded to this value, but it only
>>> seems to change when I "enter" the tab, or have a sample selected from
>>> the "Outline View".
>>>
>>> My CompoundCommand is in the importAudioFiles() function in this file
>>> (EsxEditorAdvisor.java):
>>> http://tinyurl.com/EsxEditorAdvisor-java (google code link- minimized
>>> using tinyurl)
>>>
>>> The databinding is done in this file (EsxEditorPartInfo.java):
>>> http://tinyurl.com/EsxEditorPartInfo-java (google code link- minimized
>>> using tinyurl)
>>>
>>> Can anybody take some time to help me out with this? Once I figure this
>>> step out, I'll be able to get a lot more of the UI work done.
>>>
>>> Thanks in advance for any help you can provide!
>>>
>>> -Jeff
>>
>
Re: [emf] Notifier after CompoundCommand / Trigger Databinding [message #508721 is a reply to message #508675] Tue, 19 January 2010 23:50 Go to previous message
Jeff S. is currently offline Jeff S.Friend
Messages: 29
Registered: July 2009
Junior Member
Tom-

Thanks again! I had a suspicion it was something due to "derived"
values (I'd read in the past that you need to handle notification events
specially w/ derived attributes). The only thing that made me think it
was something else, is because it was working sometimes. Specifically
when I had a sample highlighted in the "outline view" (then imported
samples while the outline view was active).

Anyways, when I get home tonight I'm going to play around w/ making the
changes you suggested. Thanks!


On 1/19/2010 2:10 PM, Tom Schindl wrote:
> Hi Jeff,
>
> I think I now see the problem memUsedInBytes and memFreeInBytes are
> derived. The problem is there are not change notifications fired when
> the value is modified.
>
> You need to fire change events in this case. With something like this:
>
> ---------8<--------------------
>> protected EsxFileImpl() {
>> super();
>> init();
>> }
>>
>> private void init() {
>> eAdapters().add(new AdapterImpl() {
>> @Override
>> public void notifyChanged(Notification msg) {
>> if( EsxPackage.Literals.ESX_FILE__SAMPLES.equals(msg.getFeature( )) ) {
>> if (eNotificationRequired()) {
>> eNotify(new ENotificationImpl(EsxFileImpl.this, Notification.SET, EsxPackage.ESX_FILE__MEM_FREE_IN_BYTES, new Integer(0), new Integer(getMemFreeInBytes())));
>> eNotify(new ENotificationImpl(EsxFileImpl.this, Notification.SET, EsxPackage.ESX_FILE__MEM_USED_IN_BYTES, 0, getMemUsedInBytes()));
>> }
>> }
>> }
>> });
>> }
>>
>> protected EsxFileImpl(EsxRandomAccess in, IProgressMonitor monitor) throws EsxException {
>> super();
>> init();
>
> ---------8<--------------------
>
>
>
> Tom
>
> Am 19.01.10 19:22, schrieb Jeff S.:
>> Tom-
>>
>> Thanks for taking the time to answer. The setInput() *is* being called.
>>
>> Inside the setInput() call is the only place I assign the variable:
>> this.esxFile.
>>
>> I then bind the EsxPackage.Literals.ESX_FILE__MEM_FREE_IN_BYTES feature
>> to a Text field.
>>
>> When I click on the button, I simple display
>> this.esxFile.getMemFreeInBytes() (which is the derived
>> EsxPackage.Literals.ESX_FILE__MEM_FREE_IN_BYTES feature).
>>
>> My thinking is that whenever I click the button, the value should
>> *always* match what is displayed in my Text field (if the databinding
>> was setup properly).
>>
>> This is not the case.
>>
>> If you look at the :35 second mark from this screencast:
>> http://screenr.com/pD1
>>
>> You'll notice that the Text field displays: 25165822, but the Dialog
>> displays: 23869688. I guess I didn't make that very clear from my
>> original post :)
>>
>> Anyways, thanks again. I have skimmed over your tutorial in the past
>> (quite a few times). I'll try to re-read your posts in full tonight
>> after work.
>>
>> In the meantime, would incorrectly disposing my Observables/Bindings
>> cause the databinding not to work properly, or just cause some memory
>> leaks? I still don't see why the Text display doesn't match the Dialog
>> display (unless I'm supposed to be triggering some type of notification
>> after running my CompoundCommmand)....
>>
>> -Jeff
>>
>> On 1/19/2010 8:56 AM, Tom Schindl wrote:
>>> Are you sure your setInput() method is called? The databinding code
>>> looks ok. Though you'll leak Observables, Bindings, ... because you are
>>> never disposing them (See my EMF-Databinding series for pointers on how
>>> to deal with Observables).
>>>
>>> Tom
>>>
>>> [1] http://tomsondev.bestsolution.at/2009/06/06/galileo-improved -emf-databinding-support/
>>>
>>>
>>> Am 19.01.10 04:51, schrieb Jeff S.:
>>>> So this may not be the correct list to ask this question (it may be more
>>>> of a JFace/Databinding issue), but I'm going to give it a shot.
>>>>
>>>> First off, here's a link to the project I'm working on:
>>>> http://tinyurl.com/svn-trunk (google code link- minimized using tinyurl)
>>>>
>>>> This program lets you create/load/manage/save .esx files for a hardware
>>>> sampler. I reverse engineered the file format, and created an ecore
>>>> model for it. Right now the program's in the beginning stages because I
>>>> keep getting held up with what should be simple tasks (but I've been
>>>> away from Java for so long- I'm making them difficult).
>>>>
>>>> My problem right now is: I've created a CompoundCommand that lets a user
>>>> select x number of .wav/.aiff files to load into the workspace. After
>>>> doing this, I want the "info" tab to be updated with how much "memory"
>>>> is left in the workspace. This value is a derived attribute. After the
>>>> Command is ran, the derived value *is* updated, but the display on my
>>>> "form" is not updated until I choose a different tab, and come back to
>>>> the "info" tab. It will also be updated if I have the "Outline View"
>>>> expanded so that a "sample" is highlighted (when you import .wav/.aiff
>>>> files- the array of "samples" is changed).
>>>>
>>>> I've created a quick screencast to demonstrate the issue (around 1:30
>>>> long):
>>>> http://screenr.com/pD1
>>>> The "click me" buttons display the value stored in my model. The text
>>>> in the form is supposed to be databinded to this value, but it only
>>>> seems to change when I "enter" the tab, or have a sample selected from
>>>> the "Outline View".
>>>>
>>>> My CompoundCommand is in the importAudioFiles() function in this file
>>>> (EsxEditorAdvisor.java):
>>>> http://tinyurl.com/EsxEditorAdvisor-java (google code link- minimized
>>>> using tinyurl)
>>>>
>>>> The databinding is done in this file (EsxEditorPartInfo.java):
>>>> http://tinyurl.com/EsxEditorPartInfo-java (google code link- minimized
>>>> using tinyurl)
>>>>
>>>> Can anybody take some time to help me out with this? Once I figure this
>>>> step out, I'll be able to get a lot more of the UI work done.
>>>>
>>>> Thanks in advance for any help you can provide!
>>>>
>>>> -Jeff
>>>
>>
>
Previous Topic:EMF Databinding with jface tableviewer and celleditors
Next Topic:[emf-dev] Modify adding the new child/sibling node in EMF
Goto Forum:
  


Current Time: Wed Nov 20 06:52:10 GMT 2019

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

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

Back to the top