Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Sapphire » How to programmatically call "Sapphire.Add" or "Sapphire.Browse"
How to programmatically call "Sapphire.Add" or "Sapphire.Browse" [message #1074018] Fri, 26 July 2013 00:05 Go to next message
Joshua Spaulding is currently offline Joshua Spaulding
Messages: 16
Registered: April 2013
Junior Member
I'm trying to modify the ListProperty "Sapphire.Add" action to immediately call the "Sapphire.Browse" action. So far I have filtered out the "Sapphire.Add" event and replaced with my own custom ActionHandler. I would like to now call "Sapphire.Add" and Sapphire.Browse in my action handler. Is this possible?

Also let me know if this is the wrong approach. Thanks.

[Updated on: Fri, 26 July 2013 00:06]

Report message to a moderator

Re: How to programmatically call "Sapphire.Add" or "Sapphire.Browse" [message #1074389 is a reply to message #1074018] Fri, 26 July 2013 16:28 Go to previous messageGo to next message
Konstantin Komissarchik is currently offline Konstantin Komissarchik
Messages: 940
Registered: July 2009
Senior Member
You will not be able to call "Sapphire.Add" from your action handler since you've filtered it out, so it "doesn't exist" in your context, but its implementation is quite simple. You just need to call insert on the list.

PropertyEditorPart listPropertyEditorPart = (PropertyEditorPart) getPart();
ElementList<?> list = (ElementList<?>) listPropertyEditorPart.property();
Element entry = list.insert();


Next, you need to locate the part corresponding to the table cell where you want to browse.

PropertyEditorPart cellPropertyEditorPart = listPropertyEditorPart.getChildPropertyEditor( entry, ListEntry.PROP_SOMETHING );


Then call browse.

cellPropertyEditorPart.getActions().getAction( "Sapphire.Browse" ).getFirstActiveHandler().execute( context );

Re: How to programmatically call "Sapphire.Add" or "Sapphire.Browse" [message #1074712 is a reply to message #1074389] Sat, 27 July 2013 14:31 Go to previous messageGo to next message
Joshua Spaulding is currently offline Joshua Spaulding
Messages: 16
Registered: April 2013
Junior Member
Thanks but I'm running into an issue.

listPropertyEditorPart.getProperty() is returning the ListProperty but I can't figure out how to call insert.

what is ElementList<?> in your example?

[Updated on: Sat, 27 July 2013 14:40]

Report message to a moderator

Re: How to programmatically call "Sapphire.Add" or "Sapphire.Browse" [message #1075559 is a reply to message #1074712] Mon, 29 July 2013 16:27 Go to previous messageGo to next message
Konstantin Komissarchik is currently offline Konstantin Komissarchik
Messages: 940
Registered: July 2009
Senior Member
The snippets in my prior post are based on Sapphire 0.7 API. Here is a translated version of the first snippet for 0.6.x API. The other two snippets should be the same.

PropertyEditorPart listPropertyEditorPart = (PropertyEditorPart) getPart();
ModelElementList<?> list = (ModelElementList<?>) listPropertyEditorPart.getLocalModelElement().read( listPropertyEditorPart.getProperty() );
IModelElement entry = list.insert();
Re: How to programmatically call "Sapphire.Add" or "Sapphire.Browse" [message #1075744 is a reply to message #1075559] Tue, 30 July 2013 01:28 Go to previous message
Joshua Spaulding is currently offline Joshua Spaulding
Messages: 16
Registered: April 2013
Junior Member
Thank you. That's working for me.
Previous Topic:Pass values to custom validation service
Next Topic:Trigger ValueImageService programmatically
Goto Forum:
  


Current Time: Sat Sep 20 14:20:20 GMT 2014

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

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