Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » Graphiti » Disabling Undo
Disabling Undo [message #654034] Sun, 13 February 2011 06:43 Go to next message
Jos Warmer is currently offline Jos Warmer
Messages: 104
Registered: October 2010
Senior Member
Hi,

I am trying to disable undo in my Graphiti editor. I have redefined canUndo() to return false in all features. Disregarding this, the Undo option in the default popup menu is still enabled and performing an undo. I see several types of undo: Undo Layout, Undo Update, Undo Add and Undo Do. I don't understand why Graphiti still assumes it can undo things.

Is there anything else that I can do to disable the undo command? I just want it to be removed from the standard popup menu.

Jos
Re: Disabling Undo [message #654216 is a reply to message #654034] Mon, 14 February 2011 10:50 Go to previous messageGo to next message
Jos Warmer is currently offline Jos Warmer
Messages: 104
Registered: October 2010
Senior Member
Hi,

I am still wondering why Graphiti allows undo while all features are non-undo-able, but at least I found a reasonable workaround to disable the Undo menu option. It works as follows:

  1. Define your own subclass of DiagramEditorContextMenuProvider
  2. Override the method addDefaultMenuGroupUndo(IMenuManager manager) to do nothing.
  3. Define your own subclass of DiagramEditor.
  4. Override the method createContextMenuProvider() to return a new instance of your own subclass of DiagramEditorContextMenuProvider.

If needed, you can tweak the menus further by overriding other methods in the subclass of DiagramEditorContextMenuProvider

Jos
Re: Disabling Undo [message #654522 is a reply to message #654216] Wed, 16 February 2011 03:08 Go to previous messageGo to next message
Michael Wenz is currently offline Michael Wenz
Messages: 1295
Registered: July 2009
Location: Walldorf, Germany
Senior Member
Jos,

it is not possible for the framework to determine if really all features are
not undoable or if there isin the end not one single feature in a certain
selection or whatever state that could be undone. That's simply the reason.

Of course could we introduce a flag to disable undo that could be set by a
tool, but as of today such a flag does not exist.

Michael
Re: Disabling Undo [message #658720 is a reply to message #654522] Wed, 09 March 2011 10:40 Go to previous messageGo to next message
Jos Warmer is currently offline Jos Warmer
Messages: 104
Registered: October 2010
Senior Member
Michael,

Each feature that is executed can directly be asked by the framework whether it is undo-able (the canUndo() method is there). This way the framework should be able to know whether an applies feature is undo-able and can remove (or disable) the Undo option. Ain't that right?

Jos
Re: Disabling Undo [message #658723 is a reply to message #658720] Wed, 09 March 2011 10:48 Go to previous messageGo to next message
Michael Wenz is currently offline Michael Wenz
Messages: 1295
Registered: July 2009
Location: Walldorf, Germany
Senior Member
In principle yes, the problem starts you you have to determine all features
that are available for a tool. There's no guarantee that you get the full
set in any state you ask the tool for all its features. Even if you could
get really all features and they all return false on canUndo() in that state
you could not guarantee that they there is not a single other state in which
one feature will return true.

Michael


"Jos Warmer" wrote in message news:il86ku$enh$1@news.eclipse.org...

Michael,

Each feature that is executed can directly be asked by the framework whether
it is undo-able (the canUndo() method is there). This way the framework
should be able to know whether an applies feature is undo-able and can
remove (or disable) the Undo option. Ain't that right?

Jos
Re: Disabling Undo [message #730855 is a reply to message #658723] Thu, 29 September 2011 07:38 Go to previous messageGo to next message
saurav sarkar is currently offline saurav sarkar
Messages: 416
Registered: July 2009
Senior Member
Hi,

I would like to know if there is any way to disable undo button in the context menu and the tool bar.
Please note we are not extending DiagramEditor for our Graphiti editor.
We tried returing false in the hasChanges() method of the features but it did not help.

Cheers,
Saurav


Re: Disabling Undo [message #730861 is a reply to message #730855] Thu, 29 September 2011 07:45 Go to previous messageGo to next message
Michael Wenz is currently offline Michael Wenz
Messages: 1295
Registered: July 2009
Location: Walldorf, Germany
Senior Member
Simply implement the Graphiti interface ICustomUndoableFeature (available in
Graphiti 0.8.0) in your feature and return false for canUndo() and
canRedo().

HTH,
Michael


"saurav" schrieb im Newsbeitrag news:j61klo$mk5$1@news.eclipse.org...

Hi,

I would like to know if there is any way to disable undo button in the
context menu and the tool bar.
Please note we are not extending DiagramEditor for our Graphiti editor.
We tried returing false in the hasChanges() method of the features but it
did not help.

Cheers,
Saurav
--
My Blog http://codifyit.blogspot.com/
Follow me: http://twitter.com/sauravs
Re: Disabling Undo [message #732247 is a reply to message #730861] Tue, 04 October 2011 06:23 Go to previous message
Harish  is currently offline Harish
Messages: 1
Registered: October 2011
Junior Member
Hi Jos,

As suggested by you, we were able to disable the Undo option in the context menu by creating our own DiagramEditorContextMenuProvider and overriding the method.

We also have to disable the Undo and Redo button in the toolbar, Please suggest how to do it.

Thanks,
Harish
Previous Topic:Graphiti service release 0.7.2 is available for download
Next Topic:Strange Polygon Behaviour
Goto Forum:
  


Current Time: Thu Jun 20 07:11:52 EDT 2013

Powered by FUDForum. Page generated in 0.03154 seconds