|
|
Re: DOM object [message #714587 is a reply to message #714343] |
Thu, 11 August 2011 00:25 |
|
On 8/10/2011 7:29 AM, Mathew wrote:
> to anyone interested:
> private IDocument getXmlDocument() {
> StructuredTextEditor textEditor = (StructuredTextEditor)
> getAdapter(StructuredTextEditor.class);
> IDocumentProvider provider = textEditor.getDocumentProvider();
> IDocument document = provider.getDocument(textEditor.getEditorInput());
> return document;
> }
>
> private IDOMModel getXmlModel() {
> IDocument document = getXmlDocument();
> IStructuredModel model = null;
> model = StructuredModelManager.getModelManager()
> .getExistingModelForEdit(document);
> IDOMModel dom = (IDOMModel) model;
> return dom;
> }
Don't forget to call #releaseFromEdit() on the model when you're done.
You might also consider decoupling the view from the editor--the
selection sent across the workbench's selection service should contain
DOM Nodes, from which you can access the DOM Document and model if needed.
http://www.eclipse.org/articles/Article-WorkbenchSelections/article.html
http://wiki.eclipse.org/New_Help_for_Old_Friends_IV#Selection_in_the_XML.2FHTML.2FJSP_Editors
--
Nitin Dahyabhai
Eclipse WTP Source Editing and JSDT
IBM Rational
_
Nitin Dahyabhai
Eclipse Web Tools Platform
|
|
|
|
Powered by
FUDForum. Page generated in 0.03714 seconds