Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » Sapphire » Transient properties as property editors
Transient properties as property editors [message #770279] Fri, 23 December 2011 20:13 Go to next message
Roded Bahat is currently offline Roded BahatFriend
Messages: 152
Registered: August 2011
Senior Member
Hello,
I'm trying to allow my users to run an action from within my Sapphire editor.
I'd like this action to receive parameters from the user by property editors in the same editor.
My initial intuition was to add the parameters as transient properties to the relevant element and allow editing them via a property editor, this however isn't the solution it seems.
I then tired to use regular value properties and disable all data binding to the model with a custom XML binder. This seemed like a good idea till I realized that passing the properties' values to the action handler doesn't work Smile (also causes some issues with the PossibleValuesService).
Any pointers would be much appreciated.
Thanks,
Roded
Re: Transient properties as property editors [message #770545 is a reply to message #770279] Sat, 24 December 2011 15:51 Go to previous messageGo to next message
Roded Bahat is currently offline Roded BahatFriend
Messages: 152
Registered: August 2011
Senior Member
I managed this by binding the properties to a static variable in the binder.
It suits my purpose.
Any reason not to do this?
Re: Transient properties as property editors [message #771173 is a reply to message #770545] Mon, 26 December 2011 14:58 Go to previous messageGo to next message
Konstantin Komissarchik is currently offline Konstantin KomissarchikFriend
Messages: 1077
Registered: July 2009
Senior Member
As you've discovered transient properties cannot be presented in UI. Transient properties allow you to attach arbitrary objects to the model without conforming to Sapphire's requirements, but as a consequence you loose ability to persist the content of these properties and ability to present them in UI.

For gathering user input in an action, I recommend using a separate model instance instead of your editor's model. The action's model can then be bound to memory resource (as opposed to XML resource) and you will not need to deal with any binding issues. Just call MyActionModel.TYPE.instantiate() (using the zero-arg constructor) in your action handler. Once you've gathered user's input, you can do what you need done to the editor's model and dispose of the action's model.

- Konstantin
Re: Transient properties as property editors [message #771317 is a reply to message #771173] Tue, 27 December 2011 00:05 Go to previous messageGo to next message
Roded Bahat is currently offline Roded BahatFriend
Messages: 152
Registered: August 2011
Senior Member
Hi, Sounds like a good idea.
But I could still use some more details (or an exmaple if available).
How do I include a Property Editor of a different model in a composite used to edit properties of my editor's model?
Thanks
Re: Transient properties as property editors [message #771566 is a reply to message #771317] Tue, 27 December 2011 16:43 Go to previous messageGo to next message
Konstantin Komissarchik is currently offline Konstantin KomissarchikFriend
Messages: 1077
Registered: July 2009
Senior Member
Perhaps it would be best if you described exactly what you are trying to accomplish in a bit more detail. I don't want to lead you in the wrong direction.

- Konstantin
Re: Transient properties as property editors [message #771619 is a reply to message #771566] Tue, 27 December 2011 19:06 Go to previous messageGo to next message
Roded Bahat is currently offline Roded BahatFriend
Messages: 152
Registered: August 2011
Senior Member
What I'm trying might be a bit unorthadox and it could very well change in the future,
but my current requirement is, in some elements' editor page, to show the user 2 more property editors (which have nothing to do with the model) and an action link.
The action link will do some processing based on the 2 "transient" and print the output to the console.
Hope I'm clear enough, if not I'd be glad explain further.
Re: Transient properties as property editors [message #771737 is a reply to message #771619] Wed, 28 December 2011 02:44 Go to previous messageGo to next message
Konstantin Komissarchik is currently offline Konstantin KomissarchikFriend
Messages: 1077
Registered: July 2009
Senior Member
Ok. If you are trying to show these properties together with your actual editor properties on the same screen, the easiest thing to do is to keep it all in one model. Make them value properties and use the solution you found with a custom binding that keeps state in a member variable. Doesn't need to be a static variable since the binding object's lifecycle matches the element.

- Konstantin
Re: Transient properties as property editors [message #771951 is a reply to message #771737] Wed, 28 December 2011 16:21 Go to previous messageGo to next message
Roded Bahat is currently offline Roded BahatFriend
Messages: 152
Registered: August 2011
Senior Member
Ok, I'll carry on.
Though I think I prefer it static to keep the properties' values between elements.
Thanks
Re: Transient properties as property editors [message #772022 is a reply to message #771951] Wed, 28 December 2011 20:12 Go to previous messageGo to next message
Roded Bahat is currently offline Roded BahatFriend
Messages: 152
Registered: August 2011
Senior Member
Ah well,
Using a static variable isn't working as I though it would (having the same values for all properties in the editor of the same name).
The notifyPropertyChangeListeners is changing it back I suspect.
Re: Transient properties as property editors [message #774265 is a reply to message #772022] Tue, 03 January 2012 16:05 Go to previous messageGo to next message
Konstantin Komissarchik is currently offline Konstantin KomissarchikFriend
Messages: 1077
Registered: July 2009
Senior Member
You need to tell Sapphire if there is a relationship between properties such that when one changes, the other changes as well. You can do this using the @DependsOn annotation. See examples in samples project.

- Konstantin
Re: Transient properties as property editors [message #774287 is a reply to message #774265] Tue, 03 January 2012 16:30 Go to previous messageGo to next message
Roded Bahat is currently offline Roded BahatFriend
Messages: 152
Registered: August 2011
Senior Member
Not sure I follow you in this case.
My problem is that when binding FieldA in my editor to a static variable, different occurences of property editors of FieldA in my editor retain their different values instead of having all property editors of FieldA change when changing any one of them (static behaviour I suppose).
It's not a major issue, but would be nice to figure out how to make the property editors all bind to the same static model.
Re: Transient properties as property editors [message #774293 is a reply to message #774287] Tue, 03 January 2012 16:35 Go to previous messageGo to next message
Konstantin Komissarchik is currently offline Konstantin KomissarchikFriend
Messages: 1077
Registered: July 2009
Senior Member
Sapphire model needs to know when to re-read property value from the resource. It isn't re-read on every access. Using @DependsOn between linked properties is one way to trigger a refresh. Another way is to write a smarter binding that knows when this static field changes and triggers refresh call on the bound property.

- Konstantin
Re: Transient properties as property editors [message #774300 is a reply to message #774293] Tue, 03 January 2012 16:52 Go to previous messageGo to next message
Roded Bahat is currently offline Roded BahatFriend
Messages: 152
Registered: August 2011
Senior Member
I understand.
How do I trigger a refresh call on a specific property (shared by all model elements)?
Re: Transient properties as property editors [message #774471 is a reply to message #774300] Wed, 04 January 2012 01:05 Go to previous messageGo to next message
Konstantin Komissarchik is currently offline Konstantin KomissarchikFriend
Messages: 1077
Registered: July 2009
Senior Member
Assuming that you are doing it from your custom binding implementation, you can access the model element associated with that binding instance using element() method. There is a one to one relationship between a binding and a model element. So, you would setup a singleton data provider with a listener mechanism, each binding instance would listen on this data provider. When it changes, the binding calls refresh on its model element. In this manner, you will accomplish refresh on all active model elements.

- Konstantin
Re: Transient properties as property editors [message #775037 is a reply to message #774471] Thu, 05 January 2012 07:15 Go to previous messageGo to next message
Roded Bahat is currently offline Roded BahatFriend
Messages: 152
Registered: August 2011
Senior Member
Are you referuing to a listener mechanism of my implementation or is there any way of using Sapphire's classes for simplification?
Thanks,
Roded
Re: Transient properties as property editors [message #775212 is a reply to message #775037] Thu, 05 January 2012 15:14 Go to previous message
Konstantin Komissarchik is currently offline Konstantin KomissarchikFriend
Messages: 1077
Registered: July 2009
Senior Member
I was figuring you'd implement an object with a listener, but you could create a standalone sapphire model element for this purpose.

- Konstantin
Previous Topic:Workspace closed Exception with JUnitTests
Next Topic:Polymorphic XML extension support
Goto Forum:
  


Current Time: Thu Apr 18 03:32:39 GMT 2024

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

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

Back to the top