Go To Line into Editor [message #280167] |
Mon, 31 January 2005 16:35 |
Eclipse User |
|
|
|
Originally posted by: francem.tiscali.it
Hi all, that's my question:
I want to open from a view a file into an editor and move the editor to a
specified line as i can do with CTRL+A shortcut.
My code from view/initpart/doubleclick action:
......
try {
projectFile.create(is, false,null);
}
catch (CoreException e){}
try {
project.refreshLocal(IResource.DEPTH_INFINITE,null);
}
catch (CoreException e){}
....
IEditorPart editor = null;
try {
editor = IDE.openEditor(getSite().getPage(),projectFile, editorId,true);
}
catch (PartInitException e) {}
And then whait i can do to move to a specified line into that editor?
Thank to all for answer.
Horus
|
|
|
Re: Go To Line into Editor [message #280239 is a reply to message #280167] |
Tue, 01 February 2005 10:03 |
Eclipse User |
|
|
|
Originally posted by: daniel.megert.gmx.net
Horus wrote:
> Hi all, that's my question:
>
> I want to open from a view a file into an editor and move the editor
> to a specified line as i can do with CTRL+A shortcut.
>
> My code from view/initpart/doubleclick action:
>
> .....
>
> try {
> projectFile.create(is, false,null);
> }
> catch (CoreException e){}
>
> try {
> project.refreshLocal(IResource.DEPTH_INFINITE,null);
> }
> catch (CoreException e){}
>
> ...
>
> IEditorPart editor = null;
>
> try {
> editor = IDE.openEditor(getSite().getPage(),projectFile,
> editorId,true);
> } catch (PartInitException e) {}
>
>
> And then whait i can do to move to a specified line into that editor?
Take a look at GotoLineAction.
Dani
>
> Thank to all for answer.
>
> Horus
>
>
|
|
|
Re: Go To Line into Editor [message #280271 is a reply to message #280239] |
Tue, 01 February 2005 16:11 |
Eclipse User |
|
|
|
Originally posted by: francem.tiscali.it
>> And then whait i can do to move to a specified line into that editor?
>
> Take a look at GotoLineAction.
>
> Dani
>
Thanks for your answer but i can't find how to use GoToLineAction.
Can un post an example or just a link to an example plz?
And what i've to import in my plugin to use that Action?
<import plugin="???"/>
Tnx Again. :)
Horus
|
|
|
Re: Go To Line into Editor [message #280277 is a reply to message #280271] |
Tue, 01 February 2005 16:57 |
Eclipse User |
|
|
|
Originally posted by: Chris_Laffra.ca.ibm.com
There is a class called org.eclipse.ui.texteditor.GotoLineAction
It does jump to a line number (the Ctrl-L action).
--
Chris Laffra, http://eclipsefaq.org
"Horus" <francem@tiscali.it> wrote in message
news:cto9nn$gpf$1@www.eclipse.org...
> >> And then whait i can do to move to a specified line into that editor?
> >
> > Take a look at GotoLineAction.
> >
> > Dani
> >
>
> Thanks for your answer but i can't find how to use GoToLineAction.
>
> Can un post an example or just a link to an example plz?
>
> And what i've to import in my plugin to use that Action?
> <import plugin="???"/>
>
> Tnx Again. :)
>
> Horus
>
>
|
|
|
Re: Go To Line into Editor [message #280287 is a reply to message #280277] |
Tue, 01 February 2005 17:16 |
Eclipse User |
|
|
|
Originally posted by: francem.tiscali.it
Still having problem.
I've seen the class in the eclipse doc but i don't find how to use it,
starting from the fact i don't find how to import in my plugin the class you
mentioned.
From plugin.xml
<requires>
<import plugin="what i must put down here?"/>
Tnx Again.
"Chris Laffra" <Chris_Laffra@ca.ibm.com> ha scritto nel messaggio
news:ctocgi$1n0$1@www.eclipse.org...
> There is a class called org.eclipse.ui.texteditor.GotoLineAction
> It does jump to a line number (the Ctrl-L action).
>
> --
> Chris Laffra, http://eclipsefaq.org
>
>
> "Horus" <francem@tiscali.it> wrote in message
> news:cto9nn$gpf$1@www.eclipse.org...
>> >> And then whait i can do to move to a specified line into that editor?
>> >
>> > Take a look at GotoLineAction.
>> >
>> > Dani
>> >
>>
>> Thanks for your answer but i can't find how to use GoToLineAction.
>>
>> Can un post an example or just a link to an example plz?
>>
>> And what i've to import in my plugin to use that Action?
>> <import plugin="???"/>
>>
>> Tnx Again. :)
>>
>> Horus
>>
>>
>
>
|
|
|
Re: Go To Line into Editor [message #280297 is a reply to message #280287] |
Tue, 01 February 2005 18:34 |
Eclipse User |
|
|
|
Originally posted by: Chris_Laffra.ca.ibm.com
The suggestion is you look at the class to see how it
does its magic, and then you do the same.
--
Chris Laffra, http://eclipsefaq.org
"Horus" <francem@tiscali.it> wrote in message
news:ctodg1$8j9$1@www.eclipse.org...
> Still having problem.
>
> I've seen the class in the eclipse doc but i don't find how to use it,
> starting from the fact i don't find how to import in my plugin the class
you
> mentioned.
>
> From plugin.xml
>
> <requires>
>
> <import plugin="what i must put down here?"/>
>
>
>
> Tnx Again.
>
>
>
> "Chris Laffra" <Chris_Laffra@ca.ibm.com> ha scritto nel messaggio
> news:ctocgi$1n0$1@www.eclipse.org...
> > There is a class called org.eclipse.ui.texteditor.GotoLineAction
> > It does jump to a line number (the Ctrl-L action).
> >
> > --
> > Chris Laffra, http://eclipsefaq.org
> >
> >
> > "Horus" <francem@tiscali.it> wrote in message
> > news:cto9nn$gpf$1@www.eclipse.org...
> >> >> And then whait i can do to move to a specified line into that
editor?
> >> >
> >> > Take a look at GotoLineAction.
> >> >
> >> > Dani
> >> >
> >>
> >> Thanks for your answer but i can't find how to use GoToLineAction.
> >>
> >> Can un post an example or just a link to an example plz?
> >>
> >> And what i've to import in my plugin to use that Action?
> >> <import plugin="???"/>
> >>
> >> Tnx Again. :)
> >>
> >> Horus
> >>
> >>
> >
> >
>
>
|
|
|
Re: Go To Line into Editor [message #280303 is a reply to message #280297] |
Tue, 01 February 2005 19:25 |
Eclipse User |
|
|
|
Originally posted by: francem.tiscali.it
I'm sorry to annoying you but... still having the same problem...
ITextEditor editor= getTextEditor();
IDocumentProvider provider= editor.getDocumentProvider();
IDocument document= provider.getDocument(editor.getEditorInput());
try {
int start= document.getLineOffset(line);
editor.selectAndReveal(start, 0);
IWorkbenchPage page= editor.getSite().getPage();
page.activate(editor);
} catch (BadLocationException x) {
// ignore
}
What i must include into my plugin to get this code working?
I cannot resolve ITextEditor, IDocumentProvider and naturally
selectAndReveal.
I got an EditorPart from IDE.openEditor i think i'll have to cast to
ItextEditor but... i miss something to import ItextEditor, still exist? I'm
using Eclipse 3.0
Horus
"Chris Laffra" <Chris_Laffra@ca.ibm.com> ha scritto nel messaggio
news:ctoi4s$c6r$1@www.eclipse.org...
> The suggestion is you look at the class to see how it
> does its magic, and then you do the same.
>
> --
> Chris Laffra, http://eclipsefaq.org
>
>
|
|
|
Re: Go To Line into Editor [message #280348 is a reply to message #280303] |
Wed, 02 February 2005 11:09 |
Eclipse User |
|
|
|
Originally posted by: francem.tiscali.it
I was missing this:
<import plugin="org.eclipse.ui.workbench.texteditor" />
I've found it in an example on this ngroup.
Tnx all.
"Horus" <francem@tiscali.it> ha scritto nel messaggio
news:ctol3i$4cm$1@www.eclipse.org...
> I'm sorry to annoying you but... still having the same problem...
>
> ITextEditor editor= getTextEditor();
>
> IDocumentProvider provider= editor.getDocumentProvider();
> IDocument document= provider.getDocument(editor.getEditorInput());
> try {
>
> int start= document.getLineOffset(line);
> editor.selectAndReveal(start, 0);
>
> IWorkbenchPage page= editor.getSite().getPage();
> page.activate(editor);
>
> } catch (BadLocationException x) {
> // ignore
> }
>
> What i must include into my plugin to get this code working?
> I cannot resolve ITextEditor, IDocumentProvider and naturally
> selectAndReveal.
>
> I got an EditorPart from IDE.openEditor i think i'll have to cast to
> ItextEditor but... i miss something to import ItextEditor, still exist?
> I'm using Eclipse 3.0
>
> Horus
>
> "Chris Laffra" <Chris_Laffra@ca.ibm.com> ha scritto nel messaggio
> news:ctoi4s$c6r$1@www.eclipse.org...
>> The suggestion is you look at the class to see how it
>> does its magic, and then you do the same.
>>
>> --
>> Chris Laffra, http://eclipsefaq.org
>>
>>
>
>
|
|
|
Powered by
FUDForum. Page generated in 0.03252 seconds