Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » GEF » Command Stack change and save action(Command Stack change and save action)
Command Stack change and save action [message #754168] Tue, 01 November 2011 07:29 Go to next message
karthick9686@gmail.com Missing nameFriend
Messages: 41
Registered: July 2011
Member
hello friends,

i have an gef based editor the changes in the model causes the isdirty state of the editor to become true and enables the save action .

i have an figure in an editpart for which i have added mouse listener , the mouse presssed event of the listener will causes the figure to resize . the resize is done using an class the executes the command class and i execute it from the editpart by calling the getcommandstack method of the editor instance .

inSpireDesignerEditor.getDomain().getCommandStack().execute( cmd );

i have two problems now .

1. the undo of the command that executed is not working
2. as the figure resizes using the mouse event , the editor save button is not getting enabled , but the is dirty property is true. how to manually eneble the save action from an editpart

[Updated on: Tue, 01 November 2011 07:29]

Report message to a moderator

Re: Command Stack change and save action [message #754171 is a reply to message #754168] Tue, 01 November 2011 07:48 Go to previous messageGo to next message
Alexander Nyßen is currently offline Alexander NyßenFriend
Messages: 49
Registered: July 2009
Location: Lünen
Member
The execution of the command on the stack looks good so far. Concerning your problems,

1) you should check that your command is undoable (canUndo() has to return true) and that you implement undo() properly

2) if you have finished 1) and it still does not work, you should ensure that the save action gets updated when changes to the command stack occur. GraphicalEditor maintains a list of actions (stackActions) for this purpose, which is updated in case the command stack changes. If you are inheriting from GraphicalEditor, make sure UndoAction is contained within this list (which it should in case you have not overwritten createActions() or you have overwritten it with a call to the super implementation). If you are not inheriting from GraphicalEditor, you will have to update the action from within a command stack listener yourself.
Re: Command Stack change and save action [message #754174 is a reply to message #754171] Tue, 01 November 2011 08:06 Go to previous messageGo to next message
karthick9686@gmail.com Missing nameFriend
Messages: 41
Registered: July 2011
Member
hi thanks ,

i have overriden the canundo method and returned true like this

/**
* @see org.eclipse.gef.commands.Command#canUndo()
*/
@Override
public boolean canUndo()
{
// TODO Auto-generated method stub
return true;
}

still its not working .

my class extends abstractgraphicaleditpart and not graphicaleditor. so you told If you are not inheriting from GraphicalEditor, you will have to update the action from within a command stack listener yourself.

how to update the actions . could you please post in the code?


Re: Command Stack change and save action [message #755563 is a reply to message #754174] Tue, 08 November 2011 19:50 Go to previous message
Alexander Nyßen is currently offline Alexander NyßenFriend
Messages: 49
Registered: July 2009
Location: Lünen
Member
Take a look into GraphicalEditor#init(IEditorSite, IEditorInput), where the editor gets registered as command stack listener, and within the GraphicalEditor#commandStackChanged(EventObject) method, which in turn gets called upon changes. It calls updateActions(List) to update all actions that depend on changes being made to the command stack.
Previous Topic:Gef Connection source and endpoint location update
Next Topic:ScrollableThumbnail Nullpointer
Goto Forum:
  


Current Time: Sat Dec 27 19:24:12 GMT 2014

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

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