How to add sub menus into context menu in Nattable? - eclipse-rcp

I am using Nattable in my application. I have built a context menu which popups on right click on any row in the nattable.Now I would like to add sub menu items for one of the menu item in the context menu. Is it possible to add sub menus into context menu in Nattable ?
This is how I have constructed context menu,
Creating context menu using PopupMenuBuilder class and Binding context menu into Nattable by extending AbstractUiBindingConfiguration class.
Thanks in Advance! :)

There is no build-in support for sub-menus. But as you basically create the menus programmatically by using the AbstractUiBindingConfiguration you can also programmatically add the sub-menu items this way. Typically by using the SWT.CASCADE style bit on the MenuItem and setting a Menu to that MenuItem.
Creating sub-menus programmatically is shown in this SWT Snippet

Related

Adding a static "new" option to MUI5 Autocomplete

MUI5 Autocomplete does not seem to have a footer option in which you can place a custom "new item" option. The required flow is:
Autocomplete's options drawer is opened
Scroll to the bottom of the options drawer
New custom model is clicked (last option)
Result: A modal is opened to customize the new custom item
What is the best course of action to support such a behaviour?
Adding it manually can collide with the sort/search capabilities of the AutoComplete component.

Use same keyEquivalent in NSPopupButton menu as in Main menu

I have an NSPopUpButton that has a few menu items that expose identical functionality to some main menu items. Those are actions most relevant to the users current context.
To signal that those items also have keyEquivalents (shortcuts), I wanted to set their keyEquivalents to the same keys as the items in the main menu.
Unfortunately that doesn't seem to work, since the conflicting items now have their keyEquivalents removed in the main menu (presumably automatically by AppKit).
Is it somehow possible to show the same keyEquivalent in the NSPopUpButton menu?
Normally context menus are not the most logical place to show shortcut info. However, if you really want this, then the best / probably only working option is to reuse the menu in the main menu that you want to show in your NSPopUpButton, like this:
myPopUpButton.menu = (NSApp.delegate as! AppDelegate).myMenu
In this example, myMenu is an #IBOutlet to one of the NSMenu items of the application main menu.
If you want to show a slightly different menu in your popup, then you can implement menuWillOpen of the NSMenuDelegate to dynamically hide or add menu items.

LibreOffice: How to create popup menu in a form?

I design an application in LibreOffice Base 5.3 using forms and Star Basic macros.
Is it possible to create a custom context menu which popups on right mouse button click and is bound to datagrid in a form?

How can i hide toolbar menu item or whole toolbar depending on perspective in eclipse rcp?

I want to hide the toolbar item or whole toolbar when I m in specific perspective .
Till now I have tried to define a perspective extension and inside it i defined all the menubar and toolbar item needed to be hidden and linked them with the respective id.But contrary to my expectation when i opened the application all the menu item are gone as expected but toolbar item are still visible.Is there anything which I am doing wrong here.
2nd approach :
WorkbenchWindow window = (WorkbenchWindow) PlatformUI.getWorkbench()
.getActiveWorkbenchWindow();
window.setCoolBarVisible(b.getSelection());
// window.toggleToolbarVisibility();
But here as window is an internal class so I donot want to use this approach.
Any light on my first approach is appreciated ..

Steps needed to add context menu to eclipse outline view

I would like to add a context menu to the Eclipse standard Outline View. Just adding a menuContribution with url
popup:org.eclipse.ui.views.ContentOutline
did not work, so I guess I need to create the context menu first. Here, I read that the menu has to be created in the view's createPartControl() method. But when adding a context menu to another view like the Outline View, where do I put this code?
To create a context menu for a view use something like:
MenuManager contextMenu = new MenuManager();
Control control = viewer.getControl();
Menu menu = contextMenu.createContextMenu(control);
control.setMenu(menu);
getSite().registerContextMenu("menu id", contextMenu, viewer);
where viewer is the outline tree viewer.
The final registerContextMenu call means that you can contribute to this menu using the menu id you specify.
This menuContribution locationURI worked for me:
popup:org.eclipse.jdt.ui.outline