pulldown command menu options - java

I've added a pulldown command to my toolbar
<command
commandId="my.uri.Options"
label="%Options.label"
icon="icons/properties.png"
style="pulldown">
</command>
that under a pull down menu have some toggle options.
I would like to get to those option by pushing the button as well, and not just the menu triangle. Is that possible? Or my approach is all wrong?

Perhaps you could use the onclick event handler, or the you could explore the addEventListener() to change the action for when the menu is clicked.

Related

Android: Linking to URL in Navigation Drawer

I am using the Navigation Components library for my Navigation Drawer. I want one item in said drawer to link to an external Website. The offical documentation doesn't say anything about external links. How do I implement that?
I could create a temporary fragment and navigate to that first but this solution is not very elegant in my opinion.
The line
NavigationUI.setupWithNavController(navigationView, navController);
Calls setNavigationItemSelectedListener internally to connect destinations to menu items - this is how a new destination is launched when you click a menu item. Navigation supports <activity> destinations, allowing you to start an activity when clicking on a menu item. You'd add an activity destination to your graph that uses the same id as your menu item:
<activity
android:id="#+id/nav_login_activity"
app:action="android.intent.action.VIEW"
app:data="https://www.your_url_here.com"/>
Then the default setupWithNavController will call startActivity for you.

Moving custom menuManager at the end of existing RCP app menu

I am working with an RCP application menu. As seen in the image below I am trying to move my newly added Help menu at the end of the freebies menus that come with my RCP application. Currently the code just adds it to the menubar by using a class that was created derived from ActionBarAdvisor .
public class ApplicationActionBarAdvisor extends ActionBarAdvisor
Looking at the other methods available I see an appendToGroup method that might be interesting to use. Only thing is that it requires a groupName and I don't have one. The menu ids I have been using don't seem to suffice as a groupName.
Here is my code
#Override protected void fillMenuBar(IMenuManager menuBar)
{
MenuManager helpMenu = new MenuManager("&Help", IWorkbenchActionConstants.M_HELP);
//menuBar.appendToGroup(menuBar.getId(), helpMenu);
menuBar.add(helpMenu);
helpMenu.add(aboutAction);
}
Fixed it
If you are adding to an RCP which uses the normal Eclipse ActionBarAdvisor (WindowActionBuilder) then there is a group marker with id IWorkbenchActionConstants.MB_ADDITIONS positioned before the existing Window and Help menus.
There is an existing Help menu which has id IWorkbenchActionConstants.M_HELP so you can find this menu using:
IMenuManager helpMenu = menuBar.findMenuUsingPath(IWorkbenchActionConstants.M_HELP);
If you are writing your own action bar builder based on ActionBarBuilder then there are no groups defined in the menu manager and you can't use appendToGroup. You just call add in the order you want the menus to appear.
Creating a custom menu programmatically is not the best way to go about this. Use the plugin.xml extensions tab to create menus then you can easily use the up and down buttons at the right of the text field with All Extensions to rearrange where you want each menu to be. So in this case, it's much easier to use the built-in Help menu of Eclipse. This whole action is resumed by adding the help menu right after the other menus in the plugin.xml file
``` <extension
point="org.eclipse.ui.menus">
<menuContribution
locationURI="menu:org.eclipse.ui.main.menu">
<menu
label="File">
<command
commandId="org.eclipse.ui.file.exit"
label="Exit">
</command>
<command
commandId="org.eclipse.ui.file.save"
label="Save"
style="push">
</command>
</menu>
<menu
label="Help">
<command
commandId="org.eclipse.ui.help.aboutAction"
label="About">
</command>
<command
commandId="org.eclipse.ui.help.helpSearch"
label="Search">
</command>
</menu>
</menuContribution>```
Final Result picture in question area :) I can't load it here

Addition of items to the "NEW" button in eclipse toolbar

I'm developing a custom project plugin wizard.
Currently the custom project wizard option shows up when I press "CTRL+N"
Or when I navigate from toolbar "New -> (drop down list) -> other.
Instead I want my selection to my newprojectwizard in the dropdown list that is generated for the "New" button on toolbar.
We see that the new button on toolbar has the following format.
A list of perspective controlled options.
Dotted lines and "Example"
Dotted line and "other"
I want to put my custom project wizard either in the section along with "example" or "other"
Any help or code snippet highly appreciated.
Use the org.eclipse.ui.perspectiveExtensions extension point to add to the top level new menu. The newWizardShortcut adds the shortcut.
For example:
<extension point="org.eclipse.ui.perspectiveExtensions">
<perspectiveExtension targetID="org.eclipse.pde.ui.PDEPerspective">
<newWizardShortcut id="org.eclipse.pde.ds.ui.wizard"/>
</perspectiveExtension>
</extension>

Java plugin pop-up menu

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>

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".

Categories

Resources