Undo/Redo in ActionBar not refreshed [message #33741] |
Mon, 21 October 2002 08:01  |
Eclipse User |
|
|
|
I create and implement one Command of my own that extends AbstractCommand
to set some property of an editpart.
When an GEF editor is opened, if the first Command get run is MyCommand,
the toolbar's Undo button is not enabled at once. I can still do undo from
popup menu. And after that the toolbar's undo/redo functions are OK.
While if the Command get run is a predefined command such as CreateCommand
and SetConstraintCommand, the problem does not happen.
I am a little bit confused because it seems MyCommand and
SetConstraintCommand are almost the same one and they are called in the
same way by calling DefaultCommandStack.execute(...), what's the problem?
|
|
|
|
Re: Undo/Redo in ActionBar not refreshed [message #34426 is a reply to message #33811] |
Mon, 21 October 2002 21:01  |
Eclipse User |
|
|
|
The calculateEnabled() method calls getCommandStack().canUndo(), which
returns true for both MyCommand and SetConstraintCommand. Possibly that's
the reason why in the ContextMenu the Undo enablement is always OK. I
think the problem is possibly caused by my modification to
ActionBarContributor for some purpose, by re-creating all actions
everytime when the editor get activated like following, is there any
problem in the following code that may cause the problem, Randy?
public class MyActionBarContributor
extends org.eclipse.ui.part.EditorActionBarContributor
{
private IEditorPart activeEditor;
private IEditorPart getActiveEditor(){
return activeEditor;
}
public void setActiveEditor(IEditorPart editor){
activeEditor = editor;
ActionRegistry registry;
registry = (ActionRegistry) editor.getAdapter(ActionRegistry.class);
IActionBars bars = getActionBars();
String id;
id = IWorkbenchActionConstants.UNDO;
bars.setGlobalActionHandler(id,registry.getAction(id));
...
IToolBarManager tbm = bars.getToolBarManager();
id = IWorkbenchActionConstants.UNDO;
if (tbm.find(id) != null) tbm.remove(id);
tbm.add(registry.getAction(id));
...
tbm.update(false);
}
}
Randy Hudson wrote:
> put a breakpoint in the UndoAction's calculateEnabled method.
> "Joe" <zhujun@cn.ibm.com> wrote in message
> news:ap0qbi$nft$1@rogue.oti.com...
> > I create and implement one Command of my own that extends AbstractCommand
> > to set some property of an editpart.
> >
> > When an GEF editor is opened, if the first Command get run is MyCommand,
> > the toolbar's Undo button is not enabled at once. I can still do undo from
> > popup menu. And after that the toolbar's undo/redo functions are OK.
> >
> > While if the Command get run is a predefined command such as CreateCommand
> > and SetConstraintCommand, the problem does not happen.
> >
> > I am a little bit confused because it seems MyCommand and
> > SetConstraintCommand are almost the same one and they are called in the
> > same way by calling DefaultCommandStack.execute(...), what's the problem?
> >
|
|
|
Powered by
FUDForum. Page generated in 0.02651 seconds