Standard Navigator view has the "Link with Editor" action button. If this button checked, each click on Navigator view element should open (or activate) proper resource editor.
And this feature is implemented and works perfect in all cases, but...
In our application we have to implement another very useful feature: user should have an opportunity to drag any elements of Navigator view and drop it on the proper editor. In our specific case this is the Graphical Editor and drag and drop the similar element to opened editor have to create a proper "call" graphical node.
This requirement conflicts with "link" one.
It seems to be simple: add to the editor drop() method line that disables the "link" functionality, complete the drop operation and enable "link" backward. Unfortunately,
this solution does not work, the "drop" is too late! Certainly, user can uncheck link button temporarily, but he wants them both!
The solution is a little bit sophisticated: we have to enter to the drag operation.
This is a proper startDrag() method of CommonDragAdapter class, so we have to extent this class and override it's startDrag() method... But this class is final!
Then we have to take a code of this class and copy it to our own, let us say MyDragAdapter. We have to extend the CommonViewer class to override it's initDragAndDrop() method. But this new MyViewer class' createCommonActionGroup() method does not except this class instance as parameter, and so on... So this is final design:
1. Take the Eclipse CommonNavigatorManager, CommonNavigatorActionGroup, LinkEditorAction, CommonViewer and CommonNavigator classes code and copy it to your own classes.
2. Change proper fields, constructors and methods to get your own classes instances.
3. Take the CommonDragAdapter code to your own MyDragAdapter class.
Change startDrag()method:
4. Override initDragAndDrop() method in your MyViewer class:
5. Then, in NavigatorLinkHelper class add code below to the activateEditor() method:
6. And, finally, do not forget to add call setLinkEditorEnabled(true) in your editor' handleDrop() method!
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment