Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Rich Client Platform (RCP) » how to define activeWhen for Undo/Redo handlers
how to define activeWhen for Undo/Redo handlers [message #663613] Tue, 05 April 2011 20:46 Go to next message
Carlo Salinari is currently offline Carlo SalinariFriend
Messages: 66
Registered: October 2010
Member
Hi,

I've an rcp application with the classic Edit/Undo and Edit/Redo commands.

Their activeWhen clauses look like this (undo case):

<activeWhen>
<test
property="undo.history.canUndo">
</test>
</activeWhen>

where undo.history.canUndo is a propertyTester that returns:

PlatformUI.getWorkbench().getOperationSupport().getOperation History().canUndo(myContext);

The problem is that it seems that the activeWhen clause is only
evaluated when the selection changes, and not each time the Edit menu is
opened!

If I undo an operation without changing the selection, the handler
active-state isn't refreshed and the UI goes out of sync with respect to
the canUndo/canRedo status.

How can I solve this?
How do you guys handle your Undo/Redo commands?

Cheers,
Carlo
Re: how to define activeWhen for Undo/Redo handlers [message #663757 is a reply to message #663613] Wed, 06 April 2011 12:29 Go to previous messageGo to next message
Paul Webster is currently offline Paul WebsterFriend
Messages: 6859
Registered: July 2009
Location: Ottawa
Senior Member

On 04/05/2011 04:46 PM, Carlo Salinari wrote:
> The problem is that it seems that the activeWhen clause is only
> evaluated when the selection changes, and not each time the Edit menu is
> opened!

Property testers aren't tied to the source providers (which provide
event driven variables for the core expressions).

You need to 1) know when that property changes and 2) call
org.eclipse.ui.services.IEvaluationService.requestEvaluation (String) to
allow users of that property to re-evaluate.

PW

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


Re: how to define activeWhen for Undo/Redo handlers [message #663771 is a reply to message #663757] Wed, 06 April 2011 13:09 Go to previous messageGo to next message
Carlo Salinari is currently offline Carlo SalinariFriend
Messages: 66
Registered: October 2010
Member
On 4/6/2011 2:29 PM, Paul Webster wrote:
> On 04/05/2011 04:46 PM, Carlo Salinari wrote:
>> The problem is that it seems that the activeWhen clause is only
>> evaluated when the selection changes, and not each time the Edit menu is
>> opened!
>
> Property testers aren't tied to the source providers (which provide
> event driven variables for the core expressions).
>
> You need to 1) know when that property changes and 2) call
> org.eclipse.ui.services.IEvaluationService.requestEvaluation (String) to
> allow users of that property to re-evaluate.
>
> PW
>

It works! You made my day Paul, thanks.

P.S.
May I shamelessly ask you to give a look also to my other message titled
"problem with TriggeredOperations"? :-)
I don't understand how to undo composite operations.
Re: how to define activeWhen for Undo/Redo handlers [message #663772 is a reply to message #663771] Wed, 06 April 2011 13:13 Go to previous message
Paul Webster is currently offline Paul WebsterFriend
Messages: 6859
Registered: July 2009
Location: Ottawa
Senior Member

On 04/06/2011 09:09 AM, Carlo Salinari wrote:
> It works! You made my day Paul, thanks.

Excellent.

>
> P.S.
> May I shamelessly ask you to give a look also to my other message titled
> "problem with TriggeredOperations"? :-)
> I don't understand how to undo composite operations.

Unfortunately, neither do I :-)

Later,
PW

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


Previous Topic:Handlers enabledWhen based on String in View
Next Topic:Adapter pattern in eclipse: is it possible to have multiple adapter factories on platform?
Goto Forum:
  


Current Time: Fri Apr 19 07:22:21 GMT 2024

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

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

Back to the top