Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Rich Client Platform (RCP) » Overriding TreeViewer Find action
Overriding TreeViewer Find action [message #526130] Thu, 08 April 2010 19:22 Go to next message
Eclipse UserFriend
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 #526355 is a reply to message #526130] Fri, 09 April 2010 19:07 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: rjl.third-monday.com

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.....

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!
Re: Overriding TreeViewer Find action [message #539939 is a reply to message #526355] Mon, 14 June 2010 10:37 Go to previous message
Dani Megert is currently offline Dani MegertFriend
Messages: 3801
Registered: July 2009
Senior Member
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!
>
Previous Topic:Dependencies
Next Topic:PNG Splash Screen
Goto Forum:
  


Current Time: Mon Dec 22 08:45:00 GMT 2014

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

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