actions in Context Menu [message #449256] |
Thu, 11 May 2006 09:26  |
Eclipse User |
|
|
|
Originally posted by: quest_lee.126.com
Why there is no selection being sent to the action?
the problem is as followed:
I have an action Called NewFileAction:
class NewFileAction extends Actioin implements
ISelectionListener,ActionFactory.IWorkbenchAction
{...}
a ViewPart called FileView which has a TreeViewer:
class FileView extends ViewPart
{...}
in this FileView, I created a Context Menu,and add an instance of NewFileAction into this menu,when I right
click on the tree, the context menu popup, then I clicked
on the newFileAction, there should be some action.However,
what I found is that there is no selection sent to NewFileAction.Why this happened?
I also as the newFileAction in file menu bar, which works correctly.
Any help is appreciated!
some of the code are,
public class NewFileView extends ViewPart {
private TreeViewer treeViewer;
public void createPartControl(Composite parent) {
getSite().setSelectionProvider(treeViewer);
...
createContextMenu();
}
private void createContextMenu() {
MenuManager menuMgr = new MenuManager();
menuMgr.setRemoveAllWhenShown(true);
menuMgr.addMenuListener(new IMenuListener() {
public void menuAboutToShow(IMenuManager mgr) {
fillContextMenu(mgr);
}
});
Menu menu = menuMgr.createContextMenu(treeViewer.getControl());
treeViewer.getControl().setMenu(menu);
getSite().registerContextMenu(menuMgr, treeViewer);
}
private void fillContextMenu(IMenuManager mgr) {
mgr.add(new GroupMarker(IWorkbenchActionConstants.MB_ADDITIONS));
IWorkbenchWindow window = getSite().getWorkbenchWindow();
mgr.add(new NewFileAction(window));
}
...
}
|
|
|
|
Re: actions in Context Menu [message #449405 is a reply to message #449263] |
Fri, 12 May 2006 02:48  |
Eclipse User |
|
|
|
Originally posted by: quest_lee.126.com
Since I registered an instance of NewFileAction
in ApplicationActionBarAdvisor by its ID,
if I could get this action object and send it
to the context menu?
By this by, I don't need to care about the selection
thing.
Thank you.
|
|
|
Powered by
FUDForum. Page generated in 0.05889 seconds