Bug 519088

Summary: Enhance exception message for AbstractBehavior#getFeedbackPartFactory(IViewer viewer)
Product: [Tools] GEF Reporter: Markus Muehlbrandt <markus.muehlbrandt>
Component: GEF MVCAssignee: gef-inbox <gef-inbox>
Status: NEW --- QA Contact:
Severity: normal    
Priority: P3 CC: matthias.wienand
Version: unspecified   
Target Milestone: ---   
Hardware: PC   
OS: Linux   
Whiteboard: low-hanging fruit

Description Markus Muehlbrandt CLA 2017-07-03 03:29:56 EDT
In the actual GEF 5.0.0 release the getFeedBackPartFactory(IViewer viewer) method of AbstractBehavior class has a default implementation which directly throws an UnsupportedOperationException.

Maybe it makes more sense to remove the default implementation and make the function abstract so that subclasses are forced to implement the method.
Comment 1 Matthias Wienand CLA 2017-07-06 09:08:45 EDT
In addition to getFeedbackPartFactory(IViewer), AbstractBehavior also defines getHandlePartFactory(IViewer). Both methods throw an UnsupportedOperationException in their default implementation, so that they only need to be implemented if the individual behavior needs to access a feedback or handle part factory.

Behaviors can apply any logic in response to changes. Some behaviors might need to generate feedback, others might need to generate handles, others might need to generate both or none. Therefore, I think it is wrong to force an implementation for these methods, however, I am open for a discussion.

There is no doubt that the exception message can be enhanced, though. It should probably give more information about the error, along the lines: "The default mechanism for generation of feedback depends on a feedback part factory that needs to be made accessible by implementing the getFeedbackPartFactory(IViewer) method of the respective behavior. In order to query the factory from the viewer using a dedicated rule, an implementation can delegate to getFeedbackPartFactory(IViewer, String)."

What do you think?