GFCommandStack does not test canExecute [message #1792885] |
Wed, 25 July 2018 11:18 |
Cameron Weick 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 #1793635 is a reply to message #1793108] |
Mon, 13 August 2018 02:18 |
Cameron Weick 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
|
|
|
|
Powered by
FUDForum. Page generated in 0.04135 seconds