Skip to main content



      Home
Home » Eclipse Projects » GEF » Undo/Redo in ActionBar not refreshed
Undo/Redo in ActionBar not refreshed [message #33741] Mon, 21 October 2002 08:01 Go to next message
Eclipse UserFriend
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 #33811 is a reply to message #33741] Mon, 21 October 2002 09:19 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: hudsonr.us.eye-bee-em.com

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?
>
Re: Undo/Redo in ActionBar not refreshed [message #34426 is a reply to message #33811] Mon, 21 October 2002 21:01 Go to previous message
Eclipse UserFriend
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?
> >
Previous Topic:Create a "Separator Figure" in the graphic Editor/figure
Next Topic:How to get ConnectionEditPart properties to show up in Property Window
Goto Forum:
  


Current Time: Wed Apr 23 22:59:39 EDT 2025

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

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

Back to the top