Problems with folding text in viewpart [message #1236360] |
Mon, 27 January 2014 02:30 |
Jens Vevstad Messages: 1 Registered: January 2014 |
Junior Member |
|
|
Hi,
I'm fairly new to RCP programming and I do have problems in creating fold-able text in a ViewPart
I'm using a ProjectionViewer and the text is partitioned and styled OK but the folding tag (+/- icons) is placed to the very left on the vertical grey ruler.
Nothing happen when I'm clicking the folding icon. I have done some tracing and for me it looks like the mouse event of the vertical ruler is fired instead of an folding icon event.
Everything works as expected when placing the folding code inside a TextEditor, the folding icon is nicely placed to the right of the vertical ruler and works as expected.
Do anybody have example code for placing a folding text inside a ViewPart?
My code for defining and activating the viewPart is as follows:
public class TextView extends ViewPart {
:
public TextView(){
this.colorManager = new ColorManager();
this.annotationModel = new ProjectionAnnotationModel();
this.annotationAccess = new DefaultMarkerAnnotationAccess();
this.verticalRuler = (new VerticalRuler( 12 ));
this.overviewRuler = new OverviewRuler(annotationAccess, 20, colorManager);
}
public void createPartControl(Composite parent) {
parent.setLayout(new FillLayout());
composite = new Composite(parent, SWT.NONE);
composite.setLayout(new FillLayout(SWT.VERTICAL));
}
public void setResources(MySourceViewerConfiguration sourceViewConfiguration, MyDocumentProvider documentProvider, String txt){
this.documentProvider = documentProvider;
this.sourceViewConfiguration = sourceViewConfiguration;
this.sourceViewConfiguration.setEditor(this);
this.sourceViewConfiguration.setColorManager(colorManager);
int i_style = SWT.V_SCROLL | SWT.H_SCROLL | SWT.MULTI | SWT.BORDER | SWT.FULL_SELECTION;
projectionViewer = new ProjectionViewer( composite,getVerticalRuler(), getOverviewRuler(), false, i_style );
projectionViewer.configure(this.sourceViewConfiguration);
projectionViewer.setRangeIndicator(new DefaultRangeIndicator());
projectionSupport = new ProjectionSupport( projectionViewer,getAnnotationAccess(), getSharedColors() );
projectionSupport.install();
fSourceViewerDecorationSupport= new SourceViewerDecorationSupport(projectionViewer, getOverviewRuler(), getAnnotationAccess(), getSharedColors());
fSourceViewerDecorationSupport.hideAnnotationOverview();
projectionViewer.showAnnotationsOverview( true );
try {
IDocument doc = documentProvider.createAnDocument(txt); // A simple wrapper for private method createDocument
projectionViewer.setDocument( doc,annotationModel);
} catch (CoreException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
projectionViewer.enableProjection();
projectionViewer.doOperation( ProjectionViewer.TOGGLE );
composite.layout();
}
|
|
|
Powered by
FUDForum. Page generated in 0.03938 seconds