Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » ServerTools (WTP) » Writing plugin output in an html editor
Writing plugin output in an html editor [message #560203] Tue, 21 September 2010 14:50 Go to next message
Michel Simeon is currently offline Michel SimeonFriend
Messages: 130
Registered: December 2009
Senior Member
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 ?

Thanks
MS
Re: Writing plugin output in an html editor [message #609331 is a reply to message #560203] Tue, 21 September 2010 20:48 Go to previous messageGo to next message
Nick Sandonato is currently offline Nick SandonatoFriend
Messages: 126
Registered: July 2009
Senior Member
Hi Michel,

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

Re: Writing plugin output in an html editor [message #626495 is a reply to message #609331] Wed, 22 September 2010 15:32 Go to previous messageGo to next message
Michel Simeon is currently offline Michel SimeonFriend
Messages: 130
Registered: December 2009
Senior Member
Thanks Nick for the tip, it worked.

Next question: The html editor is made of two tabs, one with two panes - design and preview, and one which is the viewer.

How do I tell the editor to show the viewer ?

MS
Re: Writing plugin output in an html editor [message #628669 is a reply to message #626495] Thu, 23 September 2010 15:42 Go to previous message
Nick Sandonato is currently offline Nick SandonatoFriend
Messages: 126
Registered: July 2009
Senior Member
For an instance of MultiPageEditorPart, you would need to invoke setActiveEditor(IEditorPart), where the IEditorPart is whatever editor is within the page you want to activate. However, I don't know if the HTMLEditor provides any way of exposing that editor part, unfortunately.
Previous Topic:Multiple Web Services in one project
Next Topic:Export ear => which action are done?
Goto Forum:
  


Current Time: Fri Apr 26 11:50:55 GMT 2024

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

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

Back to the top