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"
Related
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));
}
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>
// TrayUtilitiesDemo is a call which is returning me tray icon create by current java process.
MyMenu.setLabel("MyMenu");
TrayUtilitiesDemo.addPopupMenu(MyMenu);
TrayIcon trayIcon = TrayUtilitiesDemo.getTrayIcon();
System.out.println("TrayIcons are: "+trayIcon);
when i am doing
trayIcon.getPopupMenu().countItems();
it is retrun only 1 menuitem. which is added by me that is MyMenu.
there are other 4 menuitems are there added by some other class which is creating this tray icon.
and not able to get the ActionListener also.
basically i want to right click on tray icon click and click on menuitem in PopupMenu added by other class(or by other process) for automation.
using windows 7 machine.
please help.
I need some help with Google web toolkit to make a vertical menu with expanding submenu items.
I want to create a vertical menu that woks like the left menu on the showcase of GWT
I tried this:
VerticalPanel vertpanel = new VerticalPanel();
MenuBar menubar = new MenuBar(true);//set to true so its set to vertical alignment
MenuBar subbar = new MenuBar(true);
MenuBar subbar2 = new MenuBar(true);
subbar.addItem("Fist item of submenu1", new AddEmployeeCommand());
subbar.addItem("Second item of submenu1", new AddEmployeeCommand());
subbar2.addItem("First item of submenu2", new AddEmployeeCommand());
subbar2.addItem("Second item of submenu2", new AddEmployeeCommand());
menubar.addItem("sub 1", subbar);
menubar.addItem("sub 2", subbar2);
vertpanel.add(menubar);
RootPanel.get().add(menubar);
But that doesn't work because the menu items won't expand to show their subitems. Although it works when I make it a horizontal menubar but that's not what I want.
You'll need to use DisclosurePanels in order to achieve that.
Check it out in the GWT showcase.
That's probably using a DosclosurePanel, not a Menu Bar.
http://gwt.google.com/samples/Showcase/Showcase.html#!CwDisclosurePanel
maybe you can have a look to a StackPanel
Gwt Stackpanel showcase
Using SWT, what is the common way to indicate that a menu item (from a taskbar menu) is the currently active selection? Checkmark? Bold? How is this done with code?
Use the CHECK style during instantiation:
MenuItem menuItem = new MenuItem(menu, SWT.CHECK);
Use getSelection to check status:
boolean isSelected = menuItem.getSelection();
org.eclipse.swt.widgets.MenuItem setSelection(true) / getSelection()
The style of the selection depends on the style of the menu item: CHECK, CASCADE, PUSH, RADIO, SEPARATOR, as in:
(source: developpez.com)
(source: developpez.com)
MenuItem.getSelection()