| 
| Syntax Coloring for a Non-File based Editor [message #336137] | Tue, 26 May 2009 03:30  |  | 
| Eclipse User  |  |  |  |  | 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 #336213 is a reply to message #336137] | Fri, 29 May 2009 14:13  |  | 
| Eclipse User  |  |  |  |  | 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
 |  |  |  | 
Powered by 
FUDForum. Page generated in 0.04663 seconds