Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » Sapphire » "Show In Design" action from SSE XML Editor
"Show In Design" action from SSE XML Editor [message #767751] Sun, 18 December 2011 21:15 Go to next message
Roded Bahat is currently offline Roded BahatFriend
Messages: 152
Registered: August 2011
Senior Member
Hi,
I'm working on a "Show In Design" action via the Web Tools SSE right click menu.
The plan is to set the focus on a certain Sapphire ModelElement node in the tree when user the user right clicks an XML node in the document source and clicks the action.

I was wondering if there was an simple way to find a certain ModelElement in the Sapphire editor from the XML's org.w3c.dom.Node object.
Hoping to avoid traversing trees and searching for nodes manually if possible.
Thanks,
Roded
Re: "Show In Design" action from SSE XML Editor [message #768169 is a reply to message #767751] Mon, 19 December 2011 17:29 Go to previous messageGo to next message
Konstantin Komissarchik is currently offline Konstantin KomissarchikFriend
Messages: 1077
Registered: July 2009
Senior Member
XmlEditorResourceStore maintains a mapping of DOM Node to Sapphire IModelElement that it uses for triggering element refresh when the underlying DOM Node changes. See XmlEditorResourceStore.getModelElements() method. This method is protected, but you can subclass XmlEditorResourceStore to gain the access you need or we can make the method public if there is an external user of this data.

- Konstantin
Re: "Show In Design" action from SSE XML Editor [message #769297 is a reply to message #768169] Wed, 21 December 2011 18:49 Go to previous messageGo to next message
Roded Bahat is currently offline Roded BahatFriend
Messages: 152
Registered: August 2011
Senior Member
Thanks Konstantin, looking into it.
Re: "Show In Design" action from SSE XML Editor [message #770320 is a reply to message #769297] Fri, 23 December 2011 23:10 Go to previous messageGo to next message
Roded Bahat is currently offline Roded BahatFriend
Messages: 152
Registered: August 2011
Senior Member
Hi again,
Not sure I follow how to manage this...
I'd need access to the StructuredTextEditor to create a new XmlEditorResourceStore object.
No?
Re: "Show In Design" action from SSE XML Editor [message #771175 is a reply to message #770320] Mon, 26 December 2011 15:00 Go to previous messageGo to next message
Konstantin Komissarchik is currently offline Konstantin KomissarchikFriend
Messages: 1077
Registered: July 2009
Senior Member
Your editor's model is bound to XmlEditorResourceStore, so you don't need to create it; you need to find it. To find it, grab the nearest model element you have access to and invoke this:

XmlEditorResourceStore store = element.adapt( XmlEditorResourceStore.class );


- Konstantin
Re: "Show In Design" action from SSE XML Editor [message #771240 is a reply to message #771175] Mon, 26 December 2011 18:46 Go to previous messageGo to next message
Roded Bahat is currently offline Roded BahatFriend
Messages: 152
Registered: August 2011
Senior Member
Very cool.
Though when running the following, null is returned as the resourceStore.
Anything else I should know?
ReportEditor editor = (ReportEditor)page.getActiveEditor();
final MasterDetailsEditorPage reportDesignFormPage = (MasterDetailsEditorPage)editor.getPage("Design");
final MasterDetailsContentOutline content = reportDesignFormPage.getContentTree();
IReport reportModelElement = (IReport)content.getRoot().getModelElement();
XmlEditorResourceStore resourceStore = reportModelElement.adapt(XmlEditorResourceStore.class);

Thanks a lot

[Updated on: Tue, 27 December 2011 11:30]

Report message to a moderator

Re: "Show In Design" action from SSE XML Editor [message #771327 is a reply to message #771240] Tue, 27 December 2011 00:36 Go to previous messageGo to next message
Roded Bahat is currently offline Roded BahatFriend
Messages: 152
Registered: August 2011
Senior Member
(XmlResourceStore's base is null for that call.)
Re: "Show In Design" action from SSE XML Editor [message #771572 is a reply to message #771327] Tue, 27 December 2011 16:58 Go to previous messageGo to next message
Konstantin Komissarchik is currently offline Konstantin KomissarchikFriend
Messages: 1077
Registered: July 2009
Senior Member
Sorry that didn't work. I was trying to go for the most compact invocation, but it looks like the adapt lookup method isn't finding this particular object type for some reason. Try this instead:

XmlEditorResourceStore store = (XmlEditorResourceStore) ( (RootXmlResource) element.root().resource() ).store();
Re: "Show In Design" action from SSE XML Editor [message #771610 is a reply to message #771572] Tue, 27 December 2011 18:48 Go to previous messageGo to next message
Roded Bahat is currently offline Roded BahatFriend
Messages: 152
Registered: August 2011
Senior Member
That works well. Thank you.
I'm not clear on how to get around getModelElements() being protected,
short of copying the XmlEditorResourceStore object to a sublcass of XmlEditorResourceStore somehow.
Re: "Show In Design" action from SSE XML Editor [message #771735 is a reply to message #771610] Wed, 28 December 2011 02:41 Go to previous messageGo to next message
Konstantin Komissarchik is currently offline Konstantin KomissarchikFriend
Messages: 1077
Registered: July 2009
Senior Member
Probably the easiest thing to do is to make the method public. Please open an enhancement request.

- Konstantin
Re: "Show In Design" action from SSE XML Editor [message #771827 is a reply to message #771735] Wed, 28 December 2011 09:05 Go to previous message
Roded Bahat is currently offline Roded BahatFriend
Messages: 152
Registered: August 2011
Senior Member
Ok,thanks.
367594

[Updated on: Wed, 28 December 2011 09:06]

Report message to a moderator

Previous Topic:Implementing ContentProposalService for child properties
Next Topic:Copy & Paste in Sapphire's editor tree
Goto Forum:
  


Current Time: Tue Apr 23 15:39:33 GMT 2024

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

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

Back to the top