Enhancing the Tool Behavior Provider
The double-click behaviour is defined in the tool behavior provider.
If you didn’t do so already you must first create a tool behavior provider and add it to the diagram type provider as described here.
There is one method of the tool behavior provider to overwrite:
In this example we want to execute the ”Rename EClass” feature we implemented previously on double-click.
You can see the complete implementation of the double-click behavior here:
@Override
public ICustomFeature
getDoubleClickFeature(IDoubleClickContext context) {
ICustomFeature customFeature =
new TutorialRenameEClassFeature(getFeatureProvider());
// canExecute() tests especially if the context contains
a EClass
if (customFeature.canExecute(context))
{
return
customFeature;
}
return super.getDoubleClickFeature(context);
}
Now start the editor and create a new EClass. Double-click that EClass and the rename dialog appears, which allows changing the class name.