Java plugin pop-up menu - java

I have a plugin which adds a view. This view contains a table which contains on each row some informations. I would like to have a popup menu when I press the right mouse click.
How can I add the extension org.eclipse.ui.menus and after creating the menuContribution to see it in the view ?

In your ViewPart use this code:
MenuManager contextMenu = new MenuManager();
contextMenu.setRemoveAllWhenShown(true);
getSite().registerContextMenu(contextMenu, viewer);
Control control = viewer.getControl();
Menu menu = contextMenu.createContextMenu(control);
control.setMenu(menu);
where viewer is your TableViewer.
The context menu this creates has the same id as your view so you contribute to it with:
<menuContribution
locationURI="popup:your.view.id">
....
</menuContribution>

Related

How can i disable/remove context menu from combobox?

I have created an editable JComboBox. I want to add specific context menu but default context menu appears when right click.
Is there a way to remove it?
You can set the popup menu of the editor of the combo box by using:
ComboBoxEditor editor = comboBox.getEditor();
JTextField textField = (JTextField)editor.getEditorComponent();
textField.setComponentPopupMenu(...);

Java Swing Menu Click

I have some problem swing menu click event.
I want to click 'My Status' how can I handle this please help me.
For example about this image, I want to add click event for system tools.
This is a short example for my application.
List<Menu> menuItems = new ArrayList<>();
for (File file : files) {
Menu menuItem = new Menu();
menuItem.setLabel(file.getName());
menuItem.setName(file.getPath());
menuItems.add(menuItem);
menuItem.addActionListener(newMenuItemClickActions(menuItem));
}

add the same menu contribution to two registered context menus(in different views)

I have two views in my application.there are treeviewer in both the views on which i want to add context menus.
I registered the context menues using
getsite().registerCOntextMenu(menu,treeviewer);
in both the views
Now i added the menu contribution in plugin.xml file as
<menuContribution
locationURI="popup:org.eclipse.ui.popup.any?before=editions">
<command
commandId="com.eclipse.command1"
label="action"
style="push">
</command>
</menuContribution>
but this menu is shown in only one of the context menu not in both.
so is there any way to add this menu to all the registered context menus or using the id for menu so that they can be identified.
If you are referring to a group in locationURI then this group has to be present in the menu.
In general:
Any pop-up menu which is registered with the workbench should also define a GroupMarker in the registered menu with id IWorkbenchActionConstants.MB_ADDITIONS[="additions"].
In your case, the group should be named "editions".

Mouse Click event

I am using RCP with eclipse 3.6 and java 6.
The user needs to click with right mouse buttom then opened a menu where he makes a choice.
Which mouse event is that?
How to fill the menu with choices?.
Regards,
Haythem
Have a look at this article about RCP and eclipse 3.6. The section that I've linked to describes how to create a context menu (for a table), that will pop up when right clicking.
What I need is how to create mouseeventlistener from a menu and menuitem
Sectionstop in my code is the composite where the mouselistener will be added
Menu menu = new Menu (parent.getShell(), SWT.POP_UP);
MenuItem item = new MenuItem (menu, SWT.PUSH);
item.setText("Text 1");
MenuItem item2 = new MenuItem (menu, SWT.PUSH);
item2.setText("text 2");
sectionStop.setMenu (menu);
Since you are on your RCP, the basic question is where does the user right clicks. Is it on your view/editor or on an object that you contributed to some viewers? A better If you then you should look into contributing via the proper extension points. Either org.eclipse.ui.popupMenus or org.eclipse.ui.menus with locationURI "popup:org.eclipse.ui.popup.any"

Remove default items from custom context menu on BlackBerry

I want to create my own context menu.
When a user clicks the BlackBerry menu button, the menu should open with only my menu items -- and not the 'Hide keyboard' and 'Switch Application' items that are included by default.
protected void makeMenu(Menu menu, int instance) {
menu.deleteAll();
// add your code here
}
Try this out

Categories

Resources