Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » Graphiti » Weird code in FeatureExecutionHandler
Weird code in FeatureExecutionHandler [message #1691874] Fri, 10 April 2015 09:20 Go to next message
Jerome S. is currently offline Jerome S.Friend
Messages: 9
Registered: March 2015
Junior Member
Hello Michael,

I have found a strange piece of code in FeatureExecutionHandler that might be buggy. Here is the relevant code:

public Object execute(ExecutionEvent event) throws ExecutionException {
	final IToolBehaviorProvider featureProvider = getToolBehaviorProvider();

	PictogramElement pes[] = getSelectedPictogramElements(event);
	CustomContext context = new CustomContext(pes);
	IFeature feature = featureProvider.getCommandFeature(context, event.getParameter(HINT_PARAMETER_ID));
	if (feature != null && feature.canExecute(context)) {
		executeOnCommandStack(new GenericFeatureCommandWithContext(feature, context));
	}

	return null;
}


What is strange is that:

  • featureProvider.getCommandFeature() returns a ICustomFeature, you are handling this as a simple IFeature
  • the variable context is of type "CustomContext", shouldn't it be of type ICustomContext?
  • as feature is of type IFeature, the canExecute method called is the one with the "IContext" and not the one with the "ICustomContext". I think this might lead to problems as the user expects his ICustomFeature returned by getCommandFeature() to be executed as a ICustomFeature and not as a IFeature...


What do you think about that? A workaround would be just to declare context as ICustomContext and feature as ICustomFeature, I don't see any other modifications as ICustomFeature and ICustomContext are children of IFeature and IContext.

Best regards,
Re: Weird code in FeatureExecutionHandler [message #1692175 is a reply to message #1691874] Tue, 14 April 2015 07:18 Go to previous messageGo to next message
Michael Wenz is currently offline Michael WenzFriend
Messages: 1931
Registered: July 2009
Location: Walldorf, Germany
Senior Member
Hello Jerome,

sorry, I had overlooked this first...

That indeed sounds strange and should be aligned. At first glance your
proposal appears correct. Would you please file a bugzilla to track that
change?

Thanks,
Michael
Re: Weird code in FeatureExecutionHandler [message #1692181 is a reply to message #1692175] Tue, 14 April 2015 07:59 Go to previous message
Jerome S. is currently offline Jerome S.Friend
Messages: 9
Registered: March 2015
Junior Member
Hello Michael,

No problem, here is the created bugzilla: https://bugs.eclipse.org/bugs/show_bug.cgi?id=464571

Good luck!
Jérôme
Previous Topic:Local build with buckminster
Next Topic:Accessing domain objects through property section
Goto Forum:
  


Current Time: Fri Apr 26 19:03:20 GMT 2024

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

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

Back to the top