Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » Textfolding in an eclipse view
Textfolding in an eclipse view [message #455457] Sun, 15 May 2005 16:35 Go to next message
Thomas is currently offline ThomasFriend
Messages: 151
Registered: July 2009
Senior Member
Hello everybody!

It Is possible to integrate text folding in an editor, but i have
difficulties to implement this feature in a view. Doas anybody have any
suggestions?

big thx!
Re: Textfolding in an eclipse view [message #455649 is a reply to message #455457] Thu, 19 May 2005 07:15 Go to previous message
Reinhard Moser is currently offline Reinhard MoserFriend
Messages: 43
Registered: July 2009
Member
Hi thomas,

i used folding with an ProjectionViewer in a FormPage. When you use
the ProjectionViewer in your view you can also implement folding without
problems.

1. Create an overview ruler, a projection model and the projection viewer

...
int i_style = SWT.MULTI | SWT.V_SCROLL | SWT.H_SCROLL;
IVerticalRuler verticalRuler = new VerticalRuler( 5 );
IOverviewRuler overviewRuler = new
OverviewRuler(getAnnotationAccess(),12, getSharedColors() );
ProjectionAnnotationModel annotation_model = new
ProjectionAnnotationModel();
projectionViewer = new ProjectionViewer( composite_body,
verticalRuler, overviewRuler , true, i_style );
SourceViewerDecorationSupport sourceViewerDecorationSupport = new
SourceViewerDecorationSupport(
projectionViewer , overviewRuler, getAnnotationAccess(),
this.getSharedColors() );
sourceViewerDecorationSupport.hideAnnotationOverview();
projectionViewer.showAnnotationsOverview( false );
projectionViewer.setDocument( new Document(), annotation_model );
....

protected IAnnotationAccess createAnnotationAccess() {
return new DefaultMarkerAnnotationAccess();
}

protected IAnnotationAccess getAnnotationAccess() {
if ( this.annotation_access_ == null )
this.annotation_access_ = this.createAnnotationAccess();
return this.annotation_access_;
}

private ISharedTextColors getSharedColors() {
return EditorsPlugin.getDefault()
.getSharedTextColors();
}

2. Then you have to add ProjectionSupport to you viewer:

projectionSupport = new ProjectionSupport( projectionViewer,
getAnnotationAccess(), getSharedColors() );
projectionSupport.install();
projectionViewer.doOperation( ProjectionViewer.TOGGLE );

3. then you need to update your folding regions to the projection
annotation model of your ProjectionViewer through a ReconcilerStrategy

Setting the reconciling strategy:

public class xyz extends
SourceViewerConfiguration {
....
public IReconciler getReconciler( ISourceViewer _source_viewer ) {
YourReconcilerStrategy reconcilerStrategy = new
YourReconcilerStrategy ();
MonoReconciler monoReconciler = new MonoReconciler(
reconcilerStrategy , false );
monoReconciler.setProgressMonitor( new NullProgressMonitor() );
monoReconciler.setDelay( 500 );
return monoReconciler;
}

You find an implementation of this in the following example plugin (it
implements a recipe editor:
http://www.eclipse-magazin.de/itr/ausgaben/psfile/datei/67/e icher_edi41b857491d490.zip
(look at the classes RecipeReconcilingStrategy and
RecipeFoldingStructureProvider)

Hope this helps

Reinhard

Thomas schrieb:
> Hello everybody!
>
> It Is possible to integrate text folding in an editor, but i have
> difficulties to implement this feature in a view. Doas anybody have any
> suggestions?
>
> big thx!
>
>
Previous Topic:Scroll with mouse (ScrolledComposite)
Next Topic:SWT Table - How to move from cell to cell using tab- / arrow keys?
Goto Forum:
  


Current Time: Thu Sep 26 12:11:48 GMT 2024

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

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

Back to the top