|
Re: Updating undo/redo labels [message #1043826 is a reply to message #1041656] |
Thu, 18 April 2013 07:02 |
Cedric Moonen Messages: 274 Registered: August 2009 |
Senior Member |
|
|
I've been trying to debug to see what was happening. The UndoActionHandler setText method is correctly called (with the correct text) and this delegates to a LabelRetargetAction which in the end (simplifying here) ends up calling the commandChanged method of the CommandContributionItem. The code is as follow:
private ICommandListener getCommandListener() {
if (commandListener == null) {
commandListener = new ICommandListener() {
public void commandChanged(CommandEvent commandEvent) {
if (commandEvent.isHandledChanged()
|| commandEvent.isEnabledChanged()
|| commandEvent.isDefinedChanged()) {
updateCommandProperties(commandEvent);
}
}
};
}
return commandListener;
}
So, in the nested commandChanged methdo you can see that the updateCommandProperties is called only if one of the 3 conditions is true. Unfortunately, the commandEvent which is passed in has its changedValues field set to 0, which means that none of the condition will be true and the command won't be updated (thus the text in the menu doesn't change).
Higher up in the call stack, the commandEvent is created like this:
boolean enabledChanged = handlerEvent.isEnabledChanged();
boolean handledChanged = handlerEvent.isHandledChanged();
fireCommandChanged(new CommandEvent(Command.this, false,
false, false, handledChanged, false, false, false,
false, enabledChanged));
So the name changed value and description changed value are set to false.
Is this a bug ? Or am I doing something wrong here ? It is so deeply nested in the eclipse framework that it looks like a bug...
[Updated on: Thu, 18 April 2013 07:05] Report message to a moderator
|
|
|
Powered by
FUDForum. Page generated in 0.02960 seconds