Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Sapphire » Proper use of/examples for InitialValueService?
Proper use of/examples for InitialValueService? [message #1015720] Fri, 01 March 2013 21:36 Go to next message
Ellen Badgley is currently offline Ellen Badgley
Messages: 35
Registered: October 2012
Member
I'm facing some confusion about the proper way to initialize an ImpliedElementProperty, and I'm wondering if 1) InitialValueService is the right way to go, and 2) if there are any examples for what I am attempting.

I have a model element type called Node (for simplicity). Node has two properties, a ValueProperty called "Id" and another property representing a location, like so:

@Required
@XmlBinding(path="displayPosition")
@Type(base=GeoPosition.class)
ImpliedElementProperty PROP_DISPLAYPOSITION = new ImpliedElementProperty(TYPE, "displayPosition");
	
GeoPosition getDisplayPosition();


where GeoPosition is a pretty basic lat/lon pair:

@GenerateImpl
public interface GeoPosition extends IModelElement {
	
	ModelElementType TYPE = new ModelElementType(GeoPosition.class);
	
	@XmlBinding(path="Lat")
	@Type(base=BigDecimal.class)
	@Required
	ValueProperty PROP_LAT = new ValueProperty(TYPE, "Lat");
	Value<BigDecimal> getLat();
	void setLat(BigDecimal value);
	void setLat(String value);
	
	@XmlBinding(path="Lon")
	@Type(base=BigDecimal.class)
	@Required
	ValueProperty PROP_LON = new ValueProperty(TYPE, "Lon");
	Value<BigDecimal> getLon();
	void setLon(BigDecimal value);
	void setLon(String value);
}


When a new Node is created, I want to set an initial value for its <displayPosition>, and I want it to be dynamic (lat/lon computed based on the locations of other model elements of a type other than Node).

What is the proper approach to doing this? I've tried implementing an InitialValueService and applying it to PROP_DISPLAYPOSITION, but it doesn't seem to be triggering. Any advice would be much appreciated.
Re: Proper use of/examples for InitialValueService? [message #1015724 is a reply to message #1015720] Fri, 01 March 2013 22:00 Go to previous messageGo to next message
Konstantin Komissarchik is currently offline Konstantin Komissarchik
Messages: 941
Registered: July 2009
Senior Member
InitialValueService is only applicable for value properties, so you will need to attach to Lat and Lon properties instead.

- Konstantin
Re: Proper use of/examples for InitialValueService? [message #1015741 is a reply to message #1015724] Sat, 02 March 2013 02:06 Go to previous messageGo to next message
Ellen Badgley is currently offline Ellen Badgley
Messages: 35
Registered: October 2012
Member
Got it, thanks. Is the @Service annotation specifying the InitialValueService simply ignored if it's attached to an ElementProperty?

[Updated on: Sat, 02 March 2013 02:10]

Report message to a moderator

Re: Proper use of/examples for InitialValueService? [message #1015743 is a reply to message #1015741] Sat, 02 March 2013 02:11 Go to previous messageGo to next message
Ellen Badgley is currently offline Ellen Badgley
Messages: 35
Registered: October 2012
Member
Also, it strikes me that having the ability to specify an initialization service for an ElementProperty would be a useful thing to have as well.
Re: Proper use of/examples for InitialValueService? [message #1016026 is a reply to message #1015743] Mon, 04 March 2013 16:08 Go to previous message
Konstantin Komissarchik is currently offline Konstantin Komissarchik
Messages: 941
Registered: July 2009
Senior Member
Services aren't restricted to ones that the framework is aware of in a particular context. Framework extensions and solution developers can design services too. As the result, there is no validation attempted for services that aren't recognized.

- Konstantin
Previous Topic:Announcing Sapphire 0.5.4 and 0.6.1 Releases
Next Topic:Monitoring adds/removes to a ModelElementList
Goto Forum:
  


Current Time: Tue Oct 21 15:32:51 GMT 2014

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

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