Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » Graphiti » GFCommandStack does not test canExecute
GFCommandStack does not test canExecute [message #1792885] Wed, 25 July 2018 11:18 Go to next message
Cameron Weick is currently offline Cameron WeickFriend
Messages: 4
Registered: July 2009
Junior Member
When executing GEF commands on the GFCommandStack (implemented by Graphiti) the stack does not test the commands canExecute method before executing the command. The result is that the command's canExecute method can not be used as expected without manually writing code prior to calling getCommandStack().execute(...).

Is their any reason for this? Any chance of getting this patched into the GFCommandStack?

[Updated on: Thu, 26 July 2018 04:18]

Report message to a moderator

Re: GFCommandStack does not test canExecute [message #1793108 is a reply to message #1792885] Tue, 31 July 2018 09:01 Go to previous messageGo to next message
Michael Wenz is currently offline Michael WenzFriend
Messages: 1932
Registered: July 2009
Location: Walldorf, Germany
Senior Member
Cameron,

the reason for this is probably that Graphiti does the canExecute checks on feature level (e.g. AbstractAddFeature.canExecute) from inside the command wrappers, not on the level of the command stack. This might still be some remains from the former non-EMF modelling infrastructure. I'm not sure what side effects might arise from adding that additional check without having al look at all possible paths...

Do you have a specific case where you execute a feature and its canExecute (or can<operation>) method is not called?

Michael
Re: GFCommandStack does not test canExecute [message #1793635 is a reply to message #1793108] Mon, 13 August 2018 02:18 Go to previous messageGo to next message
Cameron Weick is currently offline Cameron WeickFriend
Messages: 4
Registered: July 2009
Junior Member
Hi Michael,

We are not working with Features to edit all variables in the model, their are small variables that are changed (i.e. booleans, narratives, etc..) on model objects and standard GEF commands are appropriate for making these changes. It is a requirement for the model to be changed in any way that the edit is performed through the Transactional EMF framework and we found that the GFCommandStack (which already does all the conversion) used for the GraphicalEditor in Graphiti is the right solution for this. It was just simply that these additional command don't have a canExecute call and therefore are executed every time, despite the condition on canExecute.

Our solution was to simply override the GFCommandStack, placing a canExecute call prior to calling super (see below - the class name is different to what we use due to IP). We have been testing this implementation without error for weeks, it will likely not cause issue if you do implement this additional check to the command stack. It is appropriate to check the canExecute on the GEF command prior to converting it to the EMF RecordingCommand.

@SuppressWarnings("restriction")
public class GEFEMFCommandStack extends GFCommandStack {

	/**
	 * @param configurationProvider
	 * @param editingDomain
	 */
	public GEFEMFCommandStack(IConfigurationProvider configurationProvider, TransactionalEditingDomain editingDomain) {
		super(configurationProvider, editingDomain);
	}

	/* (non-Javadoc)
	 * @see org.eclipse.graphiti.ui.internal.editor.GFCommandStack#execute(org.eclipse.gef.commands.Command)
	 */
	@Override
	public void execute(Command gefCommand) {
		if(gefCommand != null && gefCommand.canExecute()) {
			super.execute(gefCommand);
		}
	}
}


Regards,

Cameron Weick
Re: GFCommandStack does not test canExecute [message #1793643 is a reply to message #1793635] Mon, 13 August 2018 07:17 Go to previous message
Michael Wenz is currently offline Michael WenzFriend
Messages: 1932
Registered: July 2009
Location: Walldorf, Germany
Senior Member
Hi Cameron,

sounds reasonable, and I would like to go for that, but I'm not fully sure it will not have sie effects, e.g. in use cases you are not touching.

Please open a Bugzilla against Graphiti for this and I will try to do that change and check it.

Thanks,
Michael
Previous Topic:Dashed yellow underline blinking all over code randomly
Next Topic:how to increase quality of zoomed diagrams
Goto Forum:
  


Current Time: Thu Dec 05 13:16:20 GMT 2024

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

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

Back to the top