Weird code in FeatureExecutionHandler [message #1691874] |
Fri, 10 April 2015 05:20  |
Eclipse User |
|
|
|
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,
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.03185 seconds