|
|
Re: Adding a predefined popup menu to a TreeViewer without an id [message #632795 is a reply to message #631768] |
Thu, 14 October 2010 10:13 |
staudta Messages: 17 Registered: August 2010 |
Junior Member |
|
|
Thank you that worked fine.
The menuContribution that I'm reusing has some commands, and these commands have conditions as "visibleWhen" and than an "iterate" element. This iterate element seems to get an empty Collection that means that the selection is not contributed.
I thought that I need do add a SelectionProvider.
Well if I'm looking the View-Implementation that this code adds the selection Provider:
private TreeViewer viewer;
...
public void createPartControl(Composite parent) {
...
getSite().setSelectionProvider(viewer);
...
with
public IWorkbenchPartSite getSite() {
return partSite;
}
Can I provide a SelectionProvider for a org.eclipse.jface.dialogs.Dialog?
My code looks currently like this
protected Control createDialogArea(final Composite parent) {
final Composite composite = (Composite) super.createDialogArea(parent);
composite.getShell().setSize(composite.getShell().computeSize(400, 200));
composite.setLayout(new FillLayout());
viewer = new TreeViewer(composite, SWT.SINGLE | SWT.H_SCROLL | SWT.V_SCROLL);
viewer.setContentProvider( new WXContentProvider() );
IDecoratorManager decoratorManager = PlatformUI.getWorkbench().getDecoratorManager();
viewer.setLabelProvider(new DecoratingLabelProvider(new WXLabelProvider(), decoratorManager.getLabelDecorator()));
viewer.setSorter(new WXViewerSorter());
viewer.setInput(WorkspaceManager.getInstance().getCurrentWorkspace());
final MenuManager menuMgr = new MenuManager();
menuMgr.setRemoveAllWhenShown(true);
IMenuService menuService = (IMenuService) PlatformUI.getWorkbench().getService(IMenuService.class);
menuService.populateContributionManager(menuMgr, "popup:<view-id>");
viewer.getControl().setMenu(menuMgr.createContextMenu(viewer.getControl()));
parent.pack();
return composite;
}
Thank you, Adrian
[Updated on: Thu, 14 October 2010 10:48] Report message to a moderator
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.04337 seconds