Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » Sapphire » Implementing multiple Services on the same Property?
Implementing multiple Services on the same Property? [message #1033044] Wed, 03 April 2013 19:54 Go to next message
Ellen Badgley is currently offline Ellen BadgleyFriend
Messages: 35
Registered: October 2012
Member
Is this possible?

Briefly, I have a property that references the "ID" string of another element elsewhere in the model, like so:

@XmlBinding(path = "")
@Service(impl=FusibleReferenceService.class)
@Reference(target=Fusible.class)
@Required
@Label(standard = "Fusion Input")
	
ValueProperty PROP_INPUT = new ValueProperty(TYPE, "input");

ReferenceValue<String,Fusible> getInput();

void setInput(String id);


The catch is that PROP_INPUT can reference an element located in one of two separate locations elsewhere in the model (a list of Sensors, and a list of FusionNodes, both of which extend the Fusible class). The ReferenceService implementation takes care of resolving references given that IDs are unique within the model.

However, I'd also like to provide the user with a list of possible values to pick from, representing the combined IDs of all sensors/fusion nodes...and @PossibleValues doesn't do the trick, because there are multiple paths within the model that need to be examined. However, when I attempt to add another @Service annotation to specify my implementation of PossibleValuesService, I get an error. Hence my question: is it possible to do both things at the same time, and if not, is there an alternate approach?
Re: Implementing multiple Services on the same Property? [message #1033084 is a reply to message #1033044] Wed, 03 April 2013 20:57 Go to previous messageGo to next message
Ellen Badgley is currently offline Ellen BadgleyFriend
Messages: 35
Registered: October 2012
Member
An update: never mind. I attached the PossibleValuesService implementation to the property editor itself, and that is having the desired effect. It appears I've been over-concentrating on the model itself and ignoring the possibilities in the UI!
Re: Implementing multiple Services on the same Property? [message #1033086 is a reply to message #1033044] Wed, 03 April 2013 20:59 Go to previous messageGo to next message
Konstantin Komissarchik is currently offline Konstantin KomissarchikFriend
Messages: 1077
Registered: July 2009
Senior Member
Use @Services annotation to attach multiple services. This is a workaround for Java's limitation of not allowing multiple annotations of the same type in any one spot.

@Services( { @Service( impl = ExampleReferenceService.class ), @Service( impl = ExamplePossibleValuesService.class ) } )


- Konstantin
Re: Implementing multiple Services on the same Property? [message #1036720 is a reply to message #1033086] Mon, 08 April 2013 18:26 Go to previous messageGo to next message
Ellen Badgley is currently offline Ellen BadgleyFriend
Messages: 35
Registered: October 2012
Member
Ah, cool. It's good to know it can be done both ways. Thanks!
Re: Implementing multiple Services on the same Property? [message #1036763 is a reply to message #1036720] Mon, 08 April 2013 19:34 Go to previous messageGo to next message
Konstantin Komissarchik is currently offline Konstantin KomissarchikFriend
Messages: 1077
Registered: July 2009
Senior Member
Right. Generally, it isn't a good idea to attach PossibleValuesService at property editor level. The browsing will work, but you will miss out on other features, such as validation. With a reference property, you will still get validation from ReferenceService, so it may not be an issue, but in general model services should be attached to the model.

- Konstantin
Re: Implementing multiple Services on the same Property? [message #1037477 is a reply to message #1036763] Tue, 09 April 2013 15:49 Go to previous message
Ellen Badgley is currently offline Ellen BadgleyFriend
Messages: 35
Registered: October 2012
Member
That confirms my "gut feeling" re: attaching to the model rather than the editor. Thanks for the more detailed explanation.
Previous Topic:How to hide outline from SapphireEditorForXml?
Next Topic:Adding listener to a ListSelectionService from outside Sapphire?
Goto Forum:
  


Current Time: Sun Oct 06 16:26:53 GMT 2024

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

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

Back to the top