Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Platform » Syntax Coloring for a Non-File based Editor
Syntax Coloring for a Non-File based Editor [message #336137] Tue, 26 May 2009 07:30 Go to next message
Eclipse UserFriend
Originally posted by: pajai.extrabright.com

Hi everybody,

I am trying to get the syntax coloring working when setting an editor's
content programmatically (for an existing editor, e.g. the Java one),
but I have not come to a solution until now. I am not able to set the
content type programmatically. The syntax coloring appears to work only
when opening a file which extension is defined in the
org.eclipse.ui.editors extension point.

What I am doing until now:

- define MyEditorInput extending IEditorInput

- define MyDocumentProvider extending AbstractDocumentProvider and
override createDocument, where I return a Document with the content I
want if getting a parameter of type MyEditorInput. (I tried to override
the method getContentType(Object), but it is never called.)

- Open the Java editor programmatically with my custom input.

Anyone has an idea what I should do for the syntax coloring to work or
how I can set the content type programmatically?

Thanks in advance.
Cheers,

Patrick
Re: Syntax Coloring for a Non-File based Editor [message #336205 is a reply to message #336137] Fri, 29 May 2009 07:22 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: pajai.extrabright.com

Anyone?

It seems to me like a tricky thing, since syntax coloring within an
editor is linked to a file extension. I am wondering if no one had a
similar problem...

Cheers,
P.
Re: Syntax Coloring for a Non-File based Editor [message #336208 is a reply to message #336205] Fri, 29 May 2009 09:59 Go to previous messageGo to next message
Dani Megert is currently offline Dani MegertFriend
Messages: 3802
Registered: July 2009
Senior Member
Patrick J. wrote:
> Anyone?
>
> It seems to me like a tricky thing, since syntax coloring within an
> editor is linked to a file extension.
This is not true. Syntax coloring has nothing to do with a file or a
file extension.

Dani
> I am wondering if no one had a similar problem...
>
> Cheers,
> P.
Re: Syntax Coloring for a Non-File based Editor [message #336213 is a reply to message #336137] Fri, 29 May 2009 18:13 Go to previous message
Nitin Dahyabhai is currently offline Nitin DahyabhaiFriend
Messages: 4434
Registered: July 2009
Senior Member

Patrick J. wrote:
> Hi everybody,
>
> I am trying to get the syntax coloring working when setting an editor's
> content programmatically (for an existing editor, e.g. the Java one),
> but I have not come to a solution until now. I am not able to set the
> content type programmatically. The syntax coloring appears to work only
> when opening a file which extension is defined in the
> org.eclipse.ui.editors extension point.
>
> What I am doing until now:
>
> - define MyEditorInput extending IEditorInput
>
> - define MyDocumentProvider extending AbstractDocumentProvider and
> override createDocument, where I return a Document with the content I
> want if getting a parameter of type MyEditorInput. (I tried to override
> the method getContentType(Object), but it is never called.)
>
> - Open the Java editor programmatically with my custom input.

Have you tried implementing IStorageEditorInput and *not* overriding
the document provider?

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


_
Nitin Dahyabhai
Eclipse Web Tools Platform
Previous Topic:Find fields with SearchEngine
Next Topic:Sample for using FilteredItemsSelectionDialog
Goto Forum:
  


Current Time: Fri Apr 19 23:59:27 GMT 2024

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

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

Back to the top