selecting text programmatically [message #151531] |
Thu, 18 August 2005 20:11  |
Eclipse User |
|
|
|
Originally posted by: no.yes.maybe
Hi,
given the IFile for a C file currently opened in an editor, I need to
programmatically reveal its editor and select a certain line number. How
can I do this?
THank you,
Roberto
|
|
|
Re: selecting text programmatically [message #151716 is a reply to message #151531] |
Sun, 21 August 2005 15:31  |
Eclipse User |
|
|
|
roberto wrote:
> given the IFile for a C file currently opened in an editor, I need to
> programmatically reveal its editor and select a certain line number. How
> can I do this?
This works from a view, where you have the ViewPart
int lineNumber=0;
IFile file=... ;
ViewPart vp=... ;
if (file != null && file.exists()) {
IWorkbenchPage wbp = vp.getSite().getPage();
try {
IEditorPart editor = IDE.openEditor(wbp, file);
String markerID="org.eclipse.core.resources.textmarker";
IMarker marker =file.createMarker(markerID);
marker.setAttribute(IMarker.LINE_NUMBER, lineNumber);
IDE.gotoMarker(editor, marker);
} catch (Exception e) {
e.printStackTrace();
}
}
|
|
|
Powered by
FUDForum. Page generated in 0.04157 seconds