| 
| Invoking Find/Replace [message #333890] | Mon, 12 January 2009 14:54  |  | 
| Eclipse User  |  |  |  |  | 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 03:36   |  | 
| Eclipse User  |  |  |  |  | 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 09:56   |  | 
| Eclipse User  |  |  |  |  | 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
 |  |  |  | 
|  | 
|  | 
|  | 
| 
| Re: Invoking Find/Replace [message #333960 is a reply to message #333956] | Wed, 14 January 2009 12:19  |  | 
| Eclipse User  |  |  |  |  | Bret Schuhmacher wrote: > Daniel Megert wrote:
 >
 >>> IFindReplaceTarget (because SourceViewer extends a TextEditor).
 >> SourceViewer does not extend TextEditor.
 >
 > My mistake - I thought it did.  Thanks.
 >
 >
 >
 >
 >> Either the part from getActiveWorkbenchPart() must return a valid
 >> IFindReplaceTarget (which the Properties view probably won't) or you
 >> must use the 3.3 API:
 >> FindReplaceAction.FindReplaceAction(ResourceBundle, String, Shell,
 >> IFindReplaceTarget) where you pass in
 >> yourTextViewer.getFindReplaceDocumentAdapter().
 >
 >
 > Hmmmm... I added both the v3.3 and the v3.4
 > org.eclipse.ui.workbench.texteditor.jar to my Eclipse project and I
 > get no complaints from Eclipse when I use that constructor, but they
 > both cause problems further down the line when I try to start my app
 > due to their upgraded version requirements (i.e. they want upgraded
 > jface and other jars).
 Sure. You can't just go and grab a single JAR from one version and put
 it into the other one.
 
 Dani
 >
 > Thanks for your assistance, Dani, but it looks like I'm stuck :-(.  I
 > wonder if I can reimplement my editor to implement the
 > IFindReplaceTarget interface...
 >
 > Rgds,
 >
 > Bret
 >
 |  |  |  | 
Powered by 
FUDForum. Page generated in 0.44515 seconds