Overriding TreeViewer Find action [message #526130] |
Thu, 08 April 2010 15:22  |
Eclipse User |
|
|
|
Originally posted by: rjl.third-monday.com
Is it possible to override the TreeViewer Find action? I have a
TreeViewer and I want to find specific elements in the tree but not by
the element display label.
For example, my objects in the tree viewer are from my database model
and I want to find (an) object by an attribute of the object. This
object attribute is not part of the name displayed in the tree.
Sooo, if someone hit Ctrl-F, a dialog would popup allowing me to control
the 'find' action.
Thanks!
|
|
|
|
Re: Overriding TreeViewer Find action [message #539939 is a reply to message #526355] |
Mon, 14 June 2010 06:37  |
Eclipse User |
|
|
|
Russ Loucks wrote:
> Boy, spend a couple of months away from Eclipse-land and I forget
> everything; must be my advanced age......
>
> This is a simple problem to solve and I've solved it before with cut n
> paste site-specific actions.....
You might also want to take a look at FilteredTree.
Dani
>
> For completeness, here's the answer:
>
> In my main RCP app plugin ActionBarAdvisor class:
>
> private IWorkbenchAction findAction;
> protected void makeActions(IWorkbenchWindow window) {
> findAction = ActionFactory.FIND.create(window);
> register (findAction);
> }
>
> In my plugin/class with the TreeViewer:
>
> public class MyView extends ViewPart {
> private FindAction findAction = new FindAction();
> private TreeViewer treeViewer;
>
> public void createPartControl(Composite parent) {
>
> IActionBars actionBars = getViewSite().getActionBars();
>
> actionBars.setGlobalActionHandler
> (ActionFactory.FIND.getId(), findAction);
> }
>
> private class FindAction extends WorkbenchActionBase {
> public void run () {
> // display custom dialog with filter widgets
> if (dialog.open() == Window.OK) {
> Object[] selectedObjects = dialog.getSelection();
> if ((null != selectedObjects)
> && (selectedObjects.length > 0))
> {
> treeViewer.setSelection
> (new StructuredSelection
> (selectedObjects[0]));
> }
> }
> }
> }
> }
>
> On 04/08/2010 02:22 PM, Russ Loucks wrote:
>> Is it possible to override the TreeViewer Find action? I have a
>> TreeViewer and I want to find specific elements in the tree but not by
>> the element display label.
>>
>> For example, my objects in the tree viewer are from my database model
>> and I want to find (an) object by an attribute of the object. This
>> object attribute is not part of the name displayed in the tree.
>>
>> Sooo, if someone hit Ctrl-F, a dialog would popup allowing me to control
>> the 'find' action.
>>
>> Thanks!
>
|
|
|
Powered by
FUDForum. Page generated in 0.03464 seconds