I have a question with regard to the Eclipse Modeling Framework. I specified an EMF-model and and used EMF to create an corresponding editor for it. Now I want to add custom functionality in form of dialogs and wizards to this editor. To do so, I defined according context menu groups and items in the editor's plugin.xml to allow the user to invoke these dialogs / wizards. In the editor's presentation package, I created new classes for the dialogs / wizards.
My question is now, how it is possible to access the model that the user is currently working on in these dialogs / wizards? This is needed for example to load some parts of the model into the dialog / wizard and let the user change it.
I did research on this but cannot find a sufficient answer. I came across the editing domain as a mechanism that could be used via "editor".getEditingDomain().getResourceSet().getResources().get(0).getContents().get(0); But here I don't know where to get the "editor" part (the instance of the editor I guess?).
I would 开发者_C百科be glad to get some hints on how to proceed.
cheers,
erik
If you're using JFace, you can implement the ISelectionChangedListener to trigger a method whenever the user selects something in the model. This will pass a SelectionChangedEvent into the selectionChanged method. From there, you can get the user's current selection as an ISelection using event.getSelection();.
Hope this helps.
精彩评论