Skip to main content



      Home
Home » Eclipse Projects » Rich Client Platform (RCP) » How to add columns in SourceViewer at right side?
How to add columns in SourceViewer at right side? [message #1060416] Fri, 24 May 2013 10:31 Go to next message
Eclipse UserFriend
Hi,

I have some special requirement to the text editor. I want to show the source code (C, C++) in editor with line number, hot-spots (overview ruler) and some colums at the right side of the text. These columns will have some information about corresponding line. Something like attached screen-shot. How can I do this? I found org.eclipse.ui.workbench.texteditor.rulerColumns; which can be used for line based information but the problem is it adds the column to the ruler i.e. at left hand side of text and I want it right side. Also the overview ruler is outside the scroll bar hence can not be used. Could you please help me to acheive this requirement?

For this I have implemented extension point "org.eclipse.ui.editors". And override createPartControl() method of EditorPart (pasting code below); where I am creating SourceViewer control and rulers.

------------------------------

public void createPartControl(Composite parent) {
final SashForm sashForm = new SashForm(parent, SWT.HORIZONTAL);
sashForm.setLayout(new RowLayout());

CompositeRuler lineNumRuler = new CompositeRuler();
LineNumberRulerColumn lineCol = new LineNumberRulerColumn();
lineNumRuler.addDecorator(0, lineCol);

OverviewRuler overviewRuler = new OverviewRuler(null, 10, null);

SourceViewer viewer = new SourceViewer(sashForm, lineNumRuler,
overviewRuler, true, SWT.V_SCROLL | SWT.H_SCROLL | SWT.MULTI
| SWT.BORDER | SWT.FULL_SELECTION);

AnnotationRulerColumn col = new AnnotationRulerColumn(10);
viewer.addVerticalRulerColumn(col);

Document document = new Document("My C code here");
viewer.setDocument(document);
}
------------------------------------

--
God bless you and all,
Ramesh
  • Attachment: editor.png
    (Size: 32.47KB, Downloaded 216 times)
Re: How to add columns in SourceViewer at right side? [message #1061179 is a reply to message #1060416] Thu, 30 May 2013 08:33 Go to previous messageGo to next message
Eclipse UserFriend
I have added few left rulers to annotate text of RCP with line data using org.eclipse.ui.workbench.texteditor.rulerColumns extension point. You may use ruler context menu, like "Show Line Numbers" and add you rulers "Show.. " items.
Re: How to add columns in SourceViewer at right side? [message #1061693 is a reply to message #1061179] Mon, 03 June 2013 09:59 Go to previous messageGo to next message
Eclipse UserFriend
Thanks for reply Stella. I did not understand second part
> You may use ruler context menu, like "Show Line Numbers" and add you rulers "Show.. " items.

Do you mean context menu allows me to move ruler column at the right side of the text widget?
Re: How to add columns in SourceViewer at right side? [message #1061698 is a reply to message #1061693] Mon, 03 June 2013 10:18 Go to previous message
Eclipse UserFriend
No, I mean that context menu allows to show/hide the additional line info that you plan to add on the left side of the editor.
Previous Topic:Relative layout issue with views from different plug-ins
Next Topic:Detecting unsaved changes in a plugin view
Goto Forum:
  


Current Time: Fri Apr 18 09:03:43 EDT 2025

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

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

Back to the top