Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Rich Client Platform (RCP) » Replace (or extend) CTRL+F functionality in CNF
Replace (or extend) CTRL+F functionality in CNF [message #911466] Tue, 11 September 2012 17:01 Go to next message
Craig Petre is currently offline Craig PetreFriend
Messages: 32
Registered: April 2011
Member
In my RPC application I have my own navigator which extends CommonNavigator and I was trying to figure out how I could extend or replace the default functionality of CTRL+F (while the navigator is focused). This brings up a small textbox in the lower right corner of the navigator and allows you to do live searching of the nodes in the tree. I would like to have more control over how this search is performed in my navigator, but have not been able to figure out how to go about this. The textbox itself seems a bit unusual in that I can't find any information on it with plugin spy or SWT spy, which is why I've been having a hard time figuring out what code is responsible for it. Any ideas?

Thanks!
Re: Replace (or extend) CTRL+F functionality in CNF [message #915594 is a reply to message #911466] Mon, 17 September 2012 15:51 Go to previous messageGo to next message
Craig Petre is currently offline Craig PetreFriend
Messages: 32
Registered: April 2011
Member
This behavior turns out not to be a result of CTRL+F, but rather a result of typing anything into the navigator causes the search box to show up. I wasn't able to figure out how to hook into this search behavior, but I was able to figure out how to disable it and add my own handler.

To add a handler for CTRL+F to the common navigator you extend "org.eclipse.ui.commands" with a command using "org.eclipse.ui.edit.findReplace" as an ID and define your own handler. Next I added a KeyListener to the Tree which is part of the CommonViewer (<your common navigator object>.getCommonViewer().getTree().addKeyListener) and in there I added similar handling code to spawn my own search box and then set the KeyEvent's "doit" value to false so the eclipse default handler would not also attempt to run (the annoying search box in the bottom right of the navigator). I'm sure you could probably find the handler causing the search box and remove it from one of the controls under the CommonViewer, but setting "doit" to false worked for me.
Re: Replace (or extend) CTRL+F functionality in CNF [message #1097171 is a reply to message #915594] Thu, 29 August 2013 10:19 Go to previous messageGo to next message
Sheetal Bhatewara is currently offline Sheetal BhatewaraFriend
Messages: 14
Registered: August 2013
Junior Member
Hi Craig,

Could you please elaborate more , in which eclipse plugin exactly this CTRL+F functionality for find text box in the navigator view (or Error log, Problems View) is implemented?

We want to implement the same functionality for Virtual table viewer in out RCP application.
Detailed description can be found at:-
http://www.eclipse.org/forums/index.php/t/497009/
Re: Replace (or extend) CTRL+F functionality in CNF [message #1097311 is a reply to message #1097171] Thu, 29 August 2013 14:26 Go to previous messageGo to next message
Craig Petre is currently offline Craig PetreFriend
Messages: 32
Registered: April 2011
Member
I'm a little fuzzy on the details as I did this awhile ago. I overrode the CTRL+F functionality in my application by adding an extension point to my plugin of the type "org.eclipse.ui.commands" and under that extension point I added a command which I gave the ID of "org.eclipse.ui.edit.findReplace", then I created my own handler for this command. The handler has a function "isHandled" and I return true there if the current active part is my navigator. This means, my handler's execute method will be called whenever CTRL+F is pressed while my navigator is focused (which overrides the default implementation of CTRL+F).

The second part of my implementation was to override the default behavior when typing while the navigator is focused. Usually, on linux, typing while the navigator is focused causes that little search box to pop up. So to get around this, in my navigator's overridden implementation of createPartControl I did something like "this.getCommonViewer().getTree().addKeyListener(new KeyListener(){...etc...}); Where I added the behavior I wanted for when keys were pressed while the navigator was focused, then at the end of my overridden implementation of "keyPressed" I added "e.doit=false" to prevent further handling of the event by the framework (which eliminates that little text box on linux systems).
Re: Replace (or extend) CTRL+F functionality in CNF [message #1105892 is a reply to message #1097311] Tue, 10 September 2013 12:00 Go to previous messageGo to next message
Sheetal Bhatewara is currently offline Sheetal BhatewaraFriend
Messages: 14
Registered: August 2013
Junior Member
Hi Craig,

Thanks a lot for the pointers.

As you mentioned, in Linux, typing while the navigator is focused causes that little search box to pop up.
And we want the same behavior, in another view, which doesn't provide it by default.
So, we will have to implement it in our view.

So, some pointers in that respect will be really helpful.
Re: Replace (or extend) CTRL+F functionality in CNF [message #1105918 is a reply to message #1105892] Tue, 10 September 2013 12:41 Go to previous messageGo to next message
Craig Petre is currently offline Craig PetreFriend
Messages: 32
Registered: April 2011
Member
Well, I wasn't able to figure out how to get that little search box under my control, so that's why I ended up overriding it to keep it hidden. What I did instead was add my own textbox to my control (and you should be able to do something similar in your view) which was hidden by default. Then once you start typing I am listening for those key events in my control and if I receive one, I unhide my textbox and populate it with the key that was typed, then transfer keyboard focus to the textbox. Once the textbox loses focus, I hide it again. Not sure if that is very helpful, but that's what I did.
Re: Replace (or extend) CTRL+F functionality in CNF [message #1106418 is a reply to message #1105918] Wed, 11 September 2013 04:28 Go to previous message
Sheetal Bhatewara is currently offline Sheetal BhatewaraFriend
Messages: 14
Registered: August 2013
Junior Member
We will try with the approach you have suggested.
Thanks a lot!
Previous Topic:Take screenshot of RCP application window
Next Topic:ISO 9241?
Goto Forum:
  


Current Time: Sun Dec 21 17:32:43 GMT 2014

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

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