Overriding TreeViewer Find action [message #526130] |
Thu, 08 April 2010 19: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 #526355 is a reply to message #526130] |
Fri, 09 April 2010 19:07 |
Eclipse User |
|
|
|
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!
|
|
|
|
Powered by
FUDForum. Page generated in 0.02412 seconds