Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » ServerTools (WTP) » javascript editor and IStorageEditorInput
javascript editor and IStorageEditorInput [message #489437] Sat, 03 October 2009 00:31 Go to next message
Hallvard Traetteberg is currently offline Hallvard TraettebergFriend
Messages: 673
Registered: July 2009
Location: Trondheim, Norway
Senior Member
Hi,

I'm trying to activate the javascript editor on a String containing
Javascript, and not a file. Hence, I've made an IEditorInput
implementation based on IStorageEditorInput (and not FileEditorInput)
and specify this in the call to openEditor.

However, I get a NullPointerException somewhere in layout-handling code
related to the vertical ruler. In the debugger I can see that the
annotation model is not set, which I think is why the vertical ruler is
incorrectly set up. By manually disabling the vertical ruler (in the
debugger) the editor actually works with my IStorageEditorInput. But I
cannot find a way to get the editor/source viewer correctly initialized
without this manual step, hence my solution is useless.

I've tried contributing an IDocumentProvider, which should give me
control of both the IDocument and IAnnotationModel that is used. But my
class is not used by the editor. Actually, it is instantiated and ends
up as a parentProvider in a delegation chain (as the implicit provider),
but in practice another IDocumentProvider is used instead (set as the
explicit one).

The only solution I've found is to use a temporary file and an ordinary
FileEditorInput, but this litters the file system and is clearly an
unsatisfactory solution.

Any suggestions?

Hallvard
Re: javascript editor and IStorageEditorInput [message #490225 is a reply to message #489437] Wed, 07 October 2009 22:36 Go to previous messageGo to next message
Nitin Dahyabhai is currently offline Nitin DahyabhaiFriend
Messages: 4434
Registered: July 2009
Senior Member

This is a multi-part message in MIME format.
--------------010307060908040509060706
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit

Hallvard Trætteberg wrote:
> I'm trying to activate the javascript editor on a String containing
> Javascript, and not a file. Hence, I've made an IEditorInput
> implementation based on IStorageEditorInput (and not FileEditorInput)
> and specify this in the call to openEditor.
>
> However, I get a NullPointerException somewhere in layout-handling code
> related to the vertical ruler. In the debugger I can see that the
> annotation model is not set, which I think is why the vertical ruler is
> incorrectly set up. By manually disabling the vertical ruler (in the
> debugger) the editor actually works with my IStorageEditorInput. But I
> cannot find a way to get the editor/source viewer correctly initialized
> without this manual step, hence my solution is useless.
>
> I've tried contributing an IDocumentProvider, which should give me
> control of both the IDocument and IAnnotationModel that is used. But my
> class is not used by the editor. Actually, it is instantiated and ends
> up as a parentProvider in a delegation chain (as the implicit provider),
> but in practice another IDocumentProvider is used instead (set as the
> explicit one).
>
> The only solution I've found is to use a temporary file and an ordinary
> FileEditorInput, but this litters the file system and is clearly an
> unsatisfactory solution.
>
> Any suggestions?

I'm sorry it took so long to verify this myself and get you an
answer, but
org.eclipse.wst.jsdt.internal.ui.javaeditor.CompilationUnitD ocumentProvider#connect(Object)
should be handling IStorageEditorInputs already by creating a
special annotation model for them. My test class did supply path
and names ending with ".js", did yours? I've added it into an
org.eclipse.wst.jsdt.ui.tests plug-in into our CVS with the hope
that it will help you track down the problem.


--
---
Nitin Dahyabhai
Eclipse WTP Source Editing
IBM Rational


--------------010307060908040509060706
Content-Type: text/xml;
name="jsdt-ui-tests.psf"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
filename="jsdt-ui-tests.psf"

<?xml version="1.0" encoding="UTF-8"?>
<psf version="2.0">
<provider id="org.eclipse.team.cvs.core.cvsnature">
<project reference=" 1.0,:pserver:anonymous:dev.eclipse.org:/cvsroot/webtools,sou rceediting/tests/org.eclipse.wst.jsdt.ui.tests,org.eclipse.w st.jsdt.ui.tests "/>
</provider>
</psf>

--------------010307060908040509060706--


_
Nitin Dahyabhai
Eclipse Web Tools Platform
Re: javascript editor and IStorageEditorInput [message #490623 is a reply to message #490225] Fri, 09 October 2009 13:05 Go to previous message
Hallvard Traetteberg is currently offline Hallvard TraettebergFriend
Messages: 673
Registered: July 2009
Location: Trondheim, Norway
Senior Member
Nitin,

Thank's for your response. Comments below:

Nitin Dahyabhai wrote:
> Hallvard Trætteberg wrote:
>>
>> ...
>>
>> I've tried contributing an IDocumentProvider, which should give me
>> control of both the IDocument and IAnnotationModel that is used. But
>> my class is not used by the editor. Actually, it is instantiated and
>> ends up as a parentProvider in a delegation chain (as the implicit
>> provider), but in practice another IDocumentProvider is used instead
>> (set as the explicit one).
>>
>> The only solution I've found is to use a temporary file and an
>> ordinary FileEditorInput, but this litters the file system and is
>> clearly an unsatisfactory solution.
>>
>> Any suggestions?
>
> I'm sorry it took so long to verify this myself and get you an answer,
> but
> org.eclipse.wst.jsdt.internal.ui.javaeditor.CompilationUnitD ocumentProvider#connect(Object)
> should be handling IStorageEditorInputs already by creating a special
> annotation model for them. My test class did supply path and names
> ending with ".js", did yours?

I downloaded the Javscript editor's source and tracked the problem to
the lack of a path name. After returning an IPath with a .js extension
from my IStorageInput implementation it works. It seems a bit strange to
have to generate an artificial pathname (since the javascript source
code isn't stored in any file system).

There's another problem, however: Saving is done by the
IDocumentProvider, so without being able to inject my own, I have to
listen to the dirty flag of the editor and react when it changes to
false, i.e. when the editors performs a save (that does nothing), to
store the edited source back where it came from. The cleanest solution
would be to be able to contribute an IDocumentProvider so I could
control the creation of IDocument, IAnnotationModel and storing the
model back. I have tried this, but my contributed one (using an
extension point) is set as the implicit provider and not used, since the
explicit provider (create by the editor, not contributed) overrides the
implicit one.

Comments?

Hallvard
Previous Topic:problem publishing web project into tomcat installation if output folder is WebContent/WEB-INF/class
Next Topic:Re: eclipse Galileo pointing to Europa work space
Goto Forum:
  


Current Time: Sat Apr 20 02:59:50 GMT 2024

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

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

Back to the top