Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » Graphiti » Disabling Undo
Disabling Undo [message #654034] Sun, 13 February 2011 11:43 Go to next message
Jos Warmer is currently offline Jos WarmerFriend
Messages: 108
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 15:50 Go to previous messageGo to next message
Jos Warmer is currently offline Jos WarmerFriend
Messages: 108
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 08:08 Go to previous messageGo to next message
Michael Wenz is currently offline Michael WenzFriend
Messages: 1640
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 15:40 Go to previous messageGo to next message
Jos Warmer is currently offline Jos WarmerFriend
Messages: 108
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 15:48 Go to previous messageGo to next message
Michael Wenz is currently offline Michael WenzFriend
Messages: 1640
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 11:38 Go to previous messageGo to next message
saurav sarkar is currently offline saurav sarkarFriend
Messages: 424
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 11:45 Go to previous messageGo to next message
Michael Wenz is currently offline Michael WenzFriend
Messages: 1640
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 10:23 Go to previous messageGo to next message
Harish  is currently offline Harish Friend
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
Re: Disabling Undo [message #1255605 is a reply to message #730861] Mon, 24 February 2014 16:20 Go to previous messageGo to next message
Surya Kathayat is currently offline Surya KathayatFriend
Messages: 44
Registered: July 2012
Member
Hi Michael,

Implementing ICustomUndoableFeature interface in each feature and retirning false in canUndo and canRedo method does not help!!


Regards
Surya
Re: Disabling Undo [message #1258649 is a reply to message #1255605] Thu, 27 February 2014 15:54 Go to previous messageGo to next message
Michael Wenz is currently offline Michael WenzFriend
Messages: 1640
Registered: July 2009
Location: Walldorf, Germany
Senior Member
Surya,

can you provide some more details? At least in my news reader this appears
as single message without the thread context...

Michael
Re: Disabling Undo [message #1259377 is a reply to message #1258649] Fri, 28 February 2014 10:10 Go to previous message
Surya Kathayat is currently offline Surya KathayatFriend
Messages: 44
Registered: July 2012
Member
Hi Michael,

I need to disable "undo and redo" context menus from diagram editor.

I tried the following two methods, and does not work in my case.

1. As mentioned in this tread, my features implement ICustomUndoableFeature, and canUndo() and canRedo() methods return false. Still, I can see Undo and Redo menus enabled in the diagram context menu!!

public class TaskMoveFeature extends DefaultMoveShapeFeature implements ICustomUndoableFeature {

	@Override
	public boolean canUndo(IContext context) {
		return false;
	}

	@Override
	public boolean canRedo(IContext context) {
		return false;
	}


2. I also tried to extend DiagramEditorContextMenuProvider and override addDefaultMenuGroupUndo method, which infact does nothing.

public class IdmTaskFlowEditorContextMenuProvider extends DiagramEditorContextMenuProvider {

	public IdmTaskFlowEditorContextMenuProvider(EditPartViewer viewer, 
                 ActionRegistry registry, 
                 IConfigurationProvider  configurationProvider) {
		super(viewer, registry, configurationProvider);
	}
	

	@Override
	protected void addDefaultMenuGroupUndo(IMenuManager manager) {
		// do nothing
	}

}


I am not sure if this will work but I tried to set the context menu from configureGraphicalViewer method of IdmDiagramEditor(extends DiagramEditor) as below, but how can I get IConfigurationProvider in parameter 3.


	@Override
	protected void configureGraphicalViewer() {
		super.configureGraphicalViewer();

		...
	
	        getGraphicalViewer().setContextMenu(new IdmTaskFlowEditorContextMenuProvider(getGraphicalViewer(),
					getActionRegistry(), ???));


Any workaround will be appreciated.

Regards
Surya

[Updated on: Fri, 28 February 2014 12:55]

Report message to a moderator

Previous Topic:createContextMenuProvider Method in DiagramEditor not available
Next Topic:Reading created model
Goto Forum:
  


Current Time: Thu Dec 18 18:24:54 GMT 2014

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

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