Invoking Find/Replace [message #333890] |
Mon, 12 January 2009 19:54 |
Bret Schuhmacher Messages: 26 Registered: July 2009 |
Junior Member |
|
|
Hi all,
I'm trying to create a simple Find/Replace dialog by reusing the standard
Ctrl+F dialog. I have a SourceViewer and I'm catching the Ctrl+F now. I
call doFindReplace(), below. I've tried to create an action, like this:
protected void doFindReplace() {
ActionFactory.FIND.create( getActiveWorkbenchWindow());
FindReplaceAction fandrAction = new FindReplaceAction(getPRB(),
"Editor.FindReplace.", getActiveWorkbenchPart());
fandrAction.runWithEvent(new Event());
// fandrAction.run();
}
None of that code works - nothing ever pops up. What am I doing wrong?
FWIW, getPRB() returns an empty resource bundle. Do I need to instantiate
the FindReplaceDialog class myself? Do I need to subclass
FindReplaceAction, overriding run() myself? I just want a simple
find/replace dialog to pop up, targeted at my editor (from which I pressed
Ctrl+F).
I cannot find any examples, though. I'm targeting v3.2 in case the API
has changed in the last year or so.
Thanks in advance!
Bret
|
|
|
Re: Invoking Find/Replace [message #333895 is a reply to message #333890] |
Tue, 13 January 2009 08:36 |
Dani Megert Messages: 3802 Registered: July 2009 |
Senior Member |
|
|
Bret Schuhmacher wrote:
> Hi all,
>
> I'm trying to create a simple Find/Replace dialog by reusing the
> standard Ctrl+F dialog. I have a SourceViewer and I'm catching the
> Ctrl+F now. I call doFindReplace(), below. I've tried to create an
> action, like this:
> protected void doFindReplace() {
> ActionFactory.FIND.create( getActiveWorkbenchWindow());
> FindReplaceAction fandrAction = new FindReplaceAction(getPRB(),
> "Editor.FindReplace.", getActiveWorkbenchPart());
>
> fandrAction.runWithEvent(new Event());
> // fandrAction.run();
>
> }
>
> None of that code works - nothing ever pops up. What am I doing
> wrong? FWIW, getPRB() returns an empty resource bundle. Do I need to
> instantiate the FindReplaceDialog class myself? Do I need to subclass
> FindReplaceAction, overriding run() myself? I just want a simple
> find/replace dialog to pop up, targeted at my editor (from which I
> pressed Ctrl+F).
Make sure your active workbench part provides an IFindReplaceTarget adapter.
Dani
>
> I cannot find any examples, though. I'm targeting v3.2 in case the
> API has changed in the last year or so.
>
> Thanks in advance!
>
> Bret
>
|
|
|
Re: Invoking Find/Replace [message #333899 is a reply to message #333895] |
Tue, 13 January 2009 14:56 |
Bret Schuhmacher Messages: 26 Registered: July 2009 |
Junior Member |
|
|
Thanks for the reply, Dani. I'm confused, though, since my SourceViewer
is a TextViewer, which appears to have all the right methods required of a
IFindReplaceTarget, although it doesn't say it implements that interface
on this page:
http://help.eclipse.org/help32/index.jsp?topic=/org.eclipse. platform.doc.isv/reference/extension-points/index.html
If I try to implement IFindReplaceTarget in my subclassed SourceViewer I
get a message that TextViewer.findAndSelect(...) cannot hide the public
abstract method in IFindReplaceTarget. I can do this:
fSourceViewer.getFindReplaceTarget(), but I cannot pass that to the
FindReplaceAction constructor, which wants a WorkbenchPart, not a
FindReplaceTarget.
Ideas?
Thanks again,
Bret
|
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.04824 seconds