Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » ServerTools (WTP) » I'd like to add a JS editor as a page in a FormEditor
I'd like to add a JS editor as a page in a FormEditor [message #537244] Tue, 01 June 2010 16:31 Go to next message
Mark Storer is currently offline Mark StorerFriend
Messages: 46
Registered: May 2010
Location: Vista, CA
Member

I'm trying to add a JS editor as a page in my FormEditor-derived class.

The "Discouraged Access" thing is rather off-putting. On the other hand, the wiki page states that one of the JSDT's design goals is to be usable elsewhere.

So I'm lead to believe that there's a Right Way to Do It, and that
@Override
protected addPages() {
    ...
    IFile jsFile = buildTempJSFile( model.getModel().getServerScript());
    IEditorInput jsInput = new FileEditorInput(jsFile);
    jsEditor = new CompilationUnitEditor(); // warning: Disouraged Access

    addPage(SCRIPT_PAGE_IDX, jsEditor, jsInput);
    ...
}

ain' it.

I've searched the forums here and the wiki without success. So what is the Approved Technique (or if I missed something, a pointer would be nice)?


--Mark Storer
Senior Software Engineer
Autonomy Cardiff

import legalese.disclaimer;
Disclaimer<Cardiff> disCard = null;

Google Code Search
Re: I'd like to add a JS editor as a page in a FormEditor [message #537858 is a reply to message #537244] Thu, 03 June 2010 21:26 Go to previous message
Mark Storer is currently offline Mark StorerFriend
Messages: 46
Registered: May 2010
Location: Vista, CA
Member

I've come up with an alternative to new CompilationUnitEditor(), though it still relies on *.internal.*
            //
            // add script editor page
            //
            IFile jsFile = buildTempJSFile(model.getModel().getServerScript());
            IEditorInput jsInput = new FileEditorInput(jsFile);
            EditorDescriptor desc = (EditorDescriptor) IDE
                    .getEditorDescriptor(jsFile);
            if (desc != null) {
                jsEditor = desc.createEditor();

                addPage(SCRIPT_PAGE_IDX, jsEditor, jsInput);
                setPageText(SCRIPT_PAGE_IDX, "Server Script");
            }

EditorDescriptor, the implementation of IEditorDescriptor, has a handy public method for getting an IEditorPart, but it's not Exposed To The Public through IEditorDescriptor.

This technique is actually pretty darn good in general. IDE.getEdtiorDescriptor() can take a string argument to some nonexistant file, "blah.js", or "foo.xml", etc etc.

You can then stick the IEditorPart into an addPage call along with an IEditorInput, and you're good to go.

This strikes me as a really Useful Thing for folks making FormEditor-derived editors to simply ask for an editor based on an extension and throw it into a page. Any chance of it become Public? I understand there are efforts made not to create new editors on the same resource, but are there any other reasons why you might not want to build a new editor for a page?

It could easily be misused, but I see quite a few other public methods hither and yon marked as "don't use this, it's just for X, Y, or Z". A "Only use this for X" strikes me as down right secure by comparison.





--Mark Storer
Senior Software Engineer
Autonomy Cardiff

import legalese.disclaimer;
Disclaimer<Cardiff> disCard = null;

Google Code Search
Previous Topic:JIT Concept Question
Next Topic:How to modify contents of the Outline view for a CSS file?
Goto Forum:
  


Current Time: Thu Apr 25 16:44:10 GMT 2024

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

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

Back to the top