|
Re: Textfolding in an eclipse view [message #455649 is a reply to message #455457] |
Thu, 19 May 2005 07:15 |
Reinhard Moser 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!
>
>
|
|
|
Powered by
FUDForum. Page generated in 0.03487 seconds