|Writing plugin output in an html editor [message #560203]
||Tue, 21 September 2010 14:50
| Michel Simeon
Registered: December 2009
I am developping a software (called MADS) that would work as follows:|
- data is entered as text following a specific syntax; I have developed the sysntax and the corresponding specialized editor using the excellent TMF/XText package.
- a MADS menu item and toolbar button show up when the MADS editor is active. They trigger reading the selected item from the MADS editor, running the corresponding calculations and producing tables as defined in the data set.
- so far I am sending the output to a standard editor as plain text
- I would like to produce the output in html and view/save/print it in a viewer / editor / browser such as the one in WTP.
Having open an html file in the editor, I tried the following:
IEditorPart editor = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActi vePage().getActiveEditor();
IDocumentProvider dp = ((AbstractTextEditor) editor).getDocumentProvider();
IDocument doc = dp.getDocument(editor.getEditorInput());
I egt the following error:
org.eclipse.jst.pagedesigner.editors.HTMLEditor cannot be cast to org.eclipse.ui.texteditor.AbstractTextEditor
How do I get the html editor's document ?
|Re: Writing plugin output in an html editor [message #609331 is a reply to message #560203]
||Tue, 21 September 2010 20:48
| Nick Sandonato
Registered: July 2009
The HTMLEditor is actually an instance of MultiPageEditorPart, but fortunately it does contain an ITextEditor that you can get to.
What you'll need to do is first check if the editor is an instance of ITextEditor. If it is, you'll be able to get the document provider from it. Otherwise, you'll want to get the adapted object for the ITextEditor. You can do this by invoking editor.getAdapter(ITextEditor.class), then that value can be cast to an ITextEditor and you'll be able to get a document provider from it (given that it's not null).
[Updated on: Tue, 21 September 2010 20:55]
Report message to a moderator
Powered by FUDForum
. Page generated in 0.01743 seconds