Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » Sapphire » Regarding 0.5.1 and thanks.
Regarding 0.5.1 and thanks. [message #892810] Fri, 29 June 2012 19:41 Go to next message
John Bradley is currently offline John BradleyFriend
Messages: 3
Registered: June 2012
Junior Member
I just wanted to convey my thanks for this project. In less than a week I was able to implement a fully functional license manager with a JSON based resource (with some rest communication). The forms worked well in every situation I used them and any functionality I wasn't able to achieve with the already created annotations, I could easily implement with various listeners/services.

For example the one that comes to mind is having a field mirror the value of another field under certain circumstances (attached by a listener on the property you would like to monitor):

	private static final class ValueCloneListener extends FilteredListener<PropertyEvent> {
		
		private ValueProperty watchedProperty;
		private ValueProperty cloneToProperty;
		
		public ValueCloneListener(ValueProperty watchedProperty, ValueProperty cloneToProperty) {
			this.watchedProperty = watchedProperty;
			this.cloneToProperty = cloneToProperty;
		}
		
		public void handleTypedEvent(PropertyEvent event) {
			IModelElement element = event.element();
			if (element != null) {
				cloneWatchedProperty(element);
			}
		}
		
		public void cloneWatchedProperty(IModelElement element) {
			element.write(cloneToProperty, element.read(watchedProperty).getText(false));
		}
	}


If there is a better way of doing this I'd be interested in knowing!

Another thing that I discovered (possibly incorrectly?) is that Actuator handlers dispose of themselves after they handle whether they should be enabled or not. This led me to just using regular menu items to handle enablement dynamically.

It's possible this has been mentioned elsewhere, but Page header text seems to not execute the sapphire EL like the image does. (Easily worked around)

Amazing job, fun to work with and allowed me to finish this project quicker than I had planned.

[Updated on: Fri, 29 June 2012 19:48]

Report message to a moderator

Re: Regarding 0.5.1 and thanks. [message #892874 is a reply to message #892810] Sun, 01 July 2012 01:19 Go to previous messageGo to next message
Greg Amerson is currently offline Greg AmersonFriend
Messages: 119
Registered: March 2010
Senior Member
John Bradley wrote on Fri, 29 June 2012 15:41


If there is a better way of doing this I'd be interested in knowing!



Nothing comes to my mind that would work better. Konstantin or another commiter may have a better suggestion.

John Bradley wrote on Fri, 29 June 2012 15:41

Another thing that I discovered (possibly incorrectly?) is that Actuator handlers dispose of themselves after they handle whether they should be enabled or not. This led me to just using regular menu items to handle enablement dynamically.


That sounds like a bug if the handlers are being disposed after enablement check, perhaps you should open a bug?

John Bradley wrote on Fri, 29 June 2012 15:41

It's possible this has been mentioned elsewhere, but Page header text seems to not execute the sapphire EL like the image does. (Easily worked around)


Page header text definitely should respond to EL, if it isn't in the 0.5.1 release, please open a bug.

John Bradley wrote on Fri, 29 June 2012 15:41

Amazing job, fun to work with and allowed me to finish this project quicker than I had planned.


I share your sentiments, sapphire takes the drudgery out of building Eclipse UIs
Re: Regarding 0.5.1 and thanks. [message #893112 is a reply to message #892810] Mon, 02 July 2012 16:41 Go to previous messageGo to next message
Konstantin Komissarchik is currently offline Konstantin KomissarchikFriend
Messages: 1077
Registered: July 2009
Senior Member
Quote:
I just wanted to convey my thanks for this project. In less than a week I was able to implement a fully functional license manager with a JSON based resource (with some rest communication).


Thanks! Always good to hear from new adopters, especially when they have such a good experience with Sapphire. Increasing the adoption is very important for long-term health of the project, so help us spread the word where you can.

You may also want to put yourself on the Sapphire users map on Ohloh.

http://www.ohloh.net/p/sapphire

http://www.ohloh.net/p/sapphire/map


Quote:
For example the one that comes to mind is having a field mirror the value of another field under certain circumstances (attached by a listener on the property you would like to monitor):

If there is a better way of doing this I'd be interested in knowing!


I'd have to have more details about your property cloning scenario to be able to tell if there is a better approach than using a listener. In broad terms, there are three approaches: (a) use a listener at model level, (b) perform cloning at resource level, or (c) use a DefaultValueService.

Note that for the listener approach, you can attach listeners declaratively to the model with @Listeners annotation. To use this annotation, you do need a listener implementation with a zero-argument constructor.

Quote:
Another thing that I discovered (possibly incorrectly?) is that Actuator handlers dispose of themselves after they handle whether they should be enabled or not. This led me to just using regular menu items to handle enablement dynamically.


Could you elaborate on this?

Quote:
It's possible this has been mentioned elsewhere, but Page header text seems to not execute the sapphire EL like the image does. (Easily worked around)


Yes, this field is not EL-enabled right now, but it would clearly be useful. Please open an enhancement request.

[Updated on: Mon, 02 July 2012 16:43]

Report message to a moderator

Re: Regarding 0.5.1 and thanks. [message #893348 is a reply to message #893112] Tue, 03 July 2012 16:10 Go to previous messageGo to next message
John Bradley is currently offline John BradleyFriend
Messages: 3
Registered: June 2012
Junior Member
Quote:
You may also want to put yourself on the Sapphire users map on Ohloh.


I will do so!

Quote:
I'd have to have more details about your property cloning scenario to be able to tell if there is a better approach than using a listener. In broad terms, there are three approaches: (a) use a listener at model level, (b) perform cloning at resource level, or (c) use a DefaultValueService.

Note that for the listener approach, you can attach listeners declaratively to the model with @Listeners annotation. To use this annotation, you do need a listener implementation with a zero-argument constructor.


The annotated listener is the approach I took. My problem was that if a certain field (an enum backed list dropdown) selected a certain value, I would need to disable one field from being edited and have it mirror the value of a different field.

For example you have a license type "Internal" which means the Issued To and Issued By must be the same value. The 'issued to' becomes disabled and starts mirroring the values of 'issued by'. My approach was just to add a listener to the list dropdown that added/removed the clone listener depending on the currently selected item. I'll presume this is similar to what you described in the 'listener approach' .

"(Re. actuator)"
Could you elaborate on this?

I have a handler condition that controls the enablement of an actuator. Unfortunately (or by design and my total misunderstanding of the intended use-case Smile the actuator handler condition disposes of itself immediately after establishing the initial enablement state.

Quote:
Yes, this field is not EL-enabled right now, but it would clearly be useful. Please open an enhancement request.

I found a similar bug report 382449 so I'm not sure what the protocol is for 'concurring' with the report.



Thanks Greg as well as Konstantin for the detailed replies.

John


Re: Regarding 0.5.1 and thanks. [message #893356 is a reply to message #893348] Tue, 03 July 2012 16:36 Go to previous messageGo to next message
Konstantin Komissarchik is currently offline Konstantin KomissarchikFriend
Messages: 1077
Registered: July 2009
Senior Member
Quote:
For example you have a license type "Internal" which means the Issued To and Issued By must be the same value. The 'issued to' becomes disabled and starts mirroring the values of 'issued by'. My approach was just to add a listener to the list dropdown that added/removed the clone listener depending on the currently selected item. I'll presume this is similar to what you described in the 'listener approach' .


The listener approach is likely the way to go in this scenario.

Quote:
I have a handler condition that controls the enablement of an actuator. Unfortunately (or by design and my total misunderstanding of the intended use-case Smile the actuator handler condition disposes of itself immediately after establishing the initial enablement state.


Ok. Now I understand. The handler condition is intended to cover broad applicability needs. As you've discovered, it is only checked once during part initialization. You can implement dynamic enablement in an action handler itself. Typically by registering a listener in handler init(), calling setEnabled() when appropriate and then removing the listener when DisposeEvent is received.

Quote:
I found a similar bug report 382449 so I'm not sure what the protocol is for 'concurring' with the report.


Nothing particularly formal. Just CC yourself on the bug and leave a comment indicating that you have a need for stated functionality as well. Sometimes it is helpful to describe your scenario as well if that would help guide the implementation strategy.
Re: Regarding 0.5.1 and thanks. [message #893362 is a reply to message #893356] Tue, 03 July 2012 17:12 Go to previous message
John Bradley is currently offline John BradleyFriend
Messages: 3
Registered: June 2012
Junior Member
Worked perfectly. Thanks again.
Previous Topic:Unsortable lists
Next Topic:How to run the examples?
Goto Forum:
  


Current Time: Thu Mar 28 15:14:42 GMT 2024

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

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

Back to the top