Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Platform » Best strategy to bind handler to a control
Best strategy to bind handler to a control [message #327855] Tue, 06 May 2008 13:46 Go to next message
Teddy Walker is currently offline Teddy WalkerFriend
Messages: 18
Registered: July 2009
Junior Member
What is the best strategy to activate command handlers for a single
control? For example, bind a special handler for the copy command to
each control in a form or a dialog. Three ideas:

1) Use IServiceLocatorCreator to create a handler service for each
control and activate/deactivate the ServiceLocator on focus change
- internal code, will it be public in future versions?
- it works

2) Create an expression for each control, use it when register the
handlers and reevaluate it on focus change
- does this work?

3) Write a "wrapper handler" selecting the handler of the control which
has the focus
- requires most new code


Teddy
Re: Best strategy to bind handler to a control [message #327958 is a reply to message #327855] Fri, 09 May 2008 13:45 Go to previous messageGo to next message
Paul Webster is currently offline Paul WebsterFriend
Messages: 6859
Registered: July 2009
Location: Ottawa
Senior Member

Within one context (like your dialog or form), one common pattern is to
activate one handler and have it delegate to different controls in
focus. Similar to org.eclipse.ui.actions.TextActionHandler for actions.

Another way would be to use the IFocusService to register the controls
that can accept focus, and then use IHandlerService to activate the
handlers for those controls (also available declaratively while using
org.eclipse.ui.handlers)

PW


--
Paul Webster
http://wiki.eclipse.org/Platform_Command_Framework
http://wiki.eclipse.org/Command_Core_Expressions
http://wiki.eclipse.org/Menu_Contributions
http://wiki.eclipse.org/Menus_Extension_Mapping
http://help.eclipse.org/help33/index.jsp?topic=/org.eclipse. platform.doc.isv/guide/workbench.htm


Re: Best strategy to bind handler to a control [message #328257 is a reply to message #327958] Tue, 20 May 2008 12:04 Go to previous message
Teddy Walker is currently offline Teddy WalkerFriend
Messages: 18
Registered: July 2009
Junior Member
Hi Paul,

thank you very much. I didn't know IFocusService - it works fine!

Teddy


Paul Webster wrote [2008-05-09 15:45]:
> Within one context (like your dialog or form), one common pattern is to
> activate one handler and have it delegate to different controls in
> focus. Similar to org.eclipse.ui.actions.TextActionHandler for actions.
>
> Another way would be to use the IFocusService to register the controls
> that can accept focus, and then use IHandlerService to activate the
> handlers for those controls (also available declaratively while using
> org.eclipse.ui.handlers)
>
> PW
>
>
Previous Topic:Tableviewer with databinding and inline edit support for boolean
Next Topic:Launching 3.4M7 as PDE runtime workbench from Eclipse 3.3.2
Goto Forum:
  


Current Time: Tue Jul 16 13:48:01 GMT 2024

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

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

Back to the top