Skip to main content



      Home
Home » Eclipse Projects » Rich Client Platform (RCP) » Add AutoEditStrategy to my Source Viewer(prependAutoEditStrategy not working)
Add AutoEditStrategy to my Source Viewer [message #492817] Wed, 21 October 2009 16:43 Go to next message
Eclipse UserFriend
Hi, I am trying to change the default auto-indent behavior of an AbstractDecoratedTextEditor. I need to do things like increasing the indentation when the cursor is after an opening bracket { and the user inserts a new line.

To do this I implemented my own IAutoEditStrategy and added the following code in the method createSourceViewer in my subclass of AbstractDecoratedTextEditor:

ISourceViewer viewer = super.createSourceViewer(parent, ruler, styles);
ITextViewerExtension2 viewerExt2 = (ITextViewerExtension2) viewer;
viewerExt2.prependAutoEditStrategy(new TestScriptAutoIndentStrategy(), IDocument.DEFAULT_CONTENT_TYPE);
return viewer;


Nevertheless this is not working. Method customizeDocumentCommand in my IAutoEditStrategy is never called. I tried to search through Eclipse source code to determine how is the default IAutoEditStrategy created and/or assigned to the viewer but couldn't find anything.

Thanks.
Re: Add AutoEditStrategy to my Source Viewer [message #493171 is a reply to message #492817] Fri, 23 October 2009 08:52 Go to previous messageGo to next message
Eclipse UserFriend
Milton wrote:
> Hi, I am trying to change the default auto-indent behavior of an
> AbstractDecoratedTextEditor. I need to do things like increasing the
> indentation when the cursor is after an opening bracket { and the user
> inserts a new line.
>
> To do this I implemented my own IAutoEditStrategy and added the
> following code in the method createSourceViewer in my subclass of
> AbstractDecoratedTextEditor:
>
>
> ISourceViewer viewer = super.createSourceViewer(parent, ruler, styles);
> ITextViewerExtension2 viewerExt2 = (ITextViewerExtension2) viewer;
> viewerExt2.prependAutoEditStrategy(new TestScriptAutoIndentStrategy(),
> IDocument.DEFAULT_CONTENT_TYPE);
> return viewer;
This will most likely be overwritten when the viewer is configured. Take
a look at:
org.eclipse.jface.text.source.SourceViewerConfiguration.getA utoEditStrategies(ISourceViewer,
String)

Dani
>
>
> Nevertheless this is not working. Method customizeDocumentCommand in
> my IAutoEditStrategy is never called. I tried to search through
> Eclipse source code to determine how is the default IAutoEditStrategy
> created and/or assigned to the viewer but couldn't find anything.
>
> Thanks.
icon14.gif  Re: Add AutoEditStrategy to my Source Viewer [message #493218 is a reply to message #493171] Fri, 23 October 2009 12:37 Go to previous message
Eclipse UserFriend
Thanks a lot Dani, I changed getAutoEditStrategies in my SourceViewerConfiguration class and that worked.

Milton.
Previous Topic:Problem update an RCP app through P2 (Cannot complete the install because of a conflicting dependenc
Next Topic:Update Manager: Resulting configuration does not contain the platform
Goto Forum:
  


Current Time: Wed Jul 16 07:39:40 EDT 2025

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

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

Back to the top