Workbench Action connection with widgets and views

SWT Designer allows you to create the views, editors, perspectives, pref pages, composites, etc. that comprise Eclipse SWT & RCP applications and plug-ins.

Moderators: Konstantin.Scheglov, gnebling, Alexander.Mitin, jwren, Eric Clayberg

Workbench Action connection with widgets and views

Postby avier5 » Thu Jun 16, 2005 4:52 am

Hi All,

I have a view with a simple text field. I want that each action(write, delete etc.) in this text field will trigger the workbench actions in the main menu(actions like undo , redo and so on).
In other words how I can use the workbench actions (that I create from the ActionFactory) in my views and widgets

How can I achieve such ability?

Thanks,
Avier5 :D
avier5
 
Posts: 41
Joined: Thu Jul 22, 2004 12:12 am

Re: Workbench Action connection with widgets and views

Postby Eric Clayberg » Mon Jun 20, 2005 5:10 am

avier5 wrote:I have a view with a simple text field. I want that each action(write, delete etc.) in this text field will trigger the workbench actions in the main menu(actions like undo , redo and so on).
In other words how I can use the workbench actions (that I create from the ActionFactory) in my views and widgets
How can I achieve such ability?

You need to hook various Eclipse global actions. Assuming that you have your own delete action named "deleteAction", you would hook it to the Eclipse Edit > Delete command like this...

Code: Select all
private void hookGlobalActions() {
    getViewSite().getActionBars().setGlobalActionHandler(
        IWorkbenchActionConstants.DELETE,
        deleteAction);
}

BTW, Eclipse plugin development questions like this are better directed to the Eclipse Platform (or RCP) newsgroup.

This is also discussed on pp314-315 of our book.
Eric Clayberg
Software Engineering Manager
Google
http://code.google.com/webtoolkit/download.html

Author: "Eclipse Plug-ins"
http://www.qualityeclipse.com
Eric Clayberg
Moderator
 
Posts: 4503
Joined: Tue Sep 30, 2003 6:39 am
Location: Boston, MA USA


Return to SWT Designer

Who is online

Users browsing this forum: No registered users and 1 guest