Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    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 20:43 Go to next message
Milton  is currently offline Milton Friend
Messages: 10
Registered: October 2009
Junior Member
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 12:52 Go to previous messageGo to next message
Dani Megert is currently offline Dani MegertFriend
Messages: 3802
Registered: July 2009
Senior Member
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 16:37 Go to previous message
Milton  is currently offline Milton Friend
Messages: 10
Registered: October 2009
Junior Member
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: Thu Apr 25 01:07:28 GMT 2024

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

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

Back to the top