Is it possible to hide/remove arbitrary context menu items in Eclipse (3.6) - eclipse

My question can be split into three:
Is it possible to hide/remove arbitrary context menu items in Eclipse (3.6) by ...
standard UI?
some existing plug-in?
custom plug-in?
I failed to find ways to do this by methods 1 and 2. If the only option is creating custom plug-in, could anyone push me towards the right direction where to start (I have some experience in Java, but not in Eclipse plug-ins).

You can hide menus or menu entries through the standard GUI: see help
To hide a menu item or toolbar button:
Switch to the perspective that you want to configure.
Select Window > Customize Perspective....
Open the Menu Visibility or Tool Bar Visibility tab.
Find the item you want to hide.
Uncheck the check box next to the item. Uncheck a menu to hide all its children.
Click OK to cause the changes to take effect.
But that will hide this entry from all the menus (contextual or not) in which it is present.
So it may not be as fine-grained as you want through the GUI.
You can also try it through a plugin (see also Menu contribution)
The first steps are pretty standard for using extensions in Eclipse.
Open the plugin.xml file and add the org.eclipse.ui.activities extension.
Then create an activity node and give it a unique ID.
Then create an activityPatternBinding node and use the unique ID for the activity to find the pattern node to the activity node.
The activityPatternBinding node requires that you supply a regular expression for the ID string of the UI element that you wish to hide.
The problem is that there appears to be at least 3 ways that menu items and toolbar buttons are added to the UI.
The first way is through the newer Command/Menu Extensions.
The second way is through the older ActionSets Extension.
Then there are other UI elements that appear to be hard coded into the Workbench and do not have ID strings and cannot be hidden using the Activities Extension. Luckily there are few of this third type of UI element.
Considering you are talking about the latest Eclipse, I will copy only the first way:
1/ Use the Plug-In Spy
The first way is to use the Plug-In Spy.
Press alt-shift-F2 and click on a menu item or toolbar button that you want to be hidden.
If there is an ID string under the heading "active action definition identifier" then you are in luck.
This item has been added using the Command Extension and you can use this ID as the pattern argument for the Activities Extension.
But not all items that have been added using the Command Extension present their ID string to the plug-in spy.
As a side note, the ID strings are period separated.
For instance the ID for a button might be "org.eclipse.ui.navigate.backwardHistory".
Regular expressions use the period to stand for any character. Luckily the period used as a wild card matches with actual period characters so you don't need to escape them if you don't want to. I find it makes it a bit easier to read if they are not escaped and it is highly unlikely it will cause any ambiguous matches.

Related

Add hotkeys to Eclipse

I use IBM Rational Developer for i, which is based on Eclipse, to develop applications for IBM i. During development, I constantly use my mouse to send the source code to the IBM i server and start compiling it. To do this, right-click on the project, select Remote Actions and Submit Build in the submenu. This is very exhausting.
Could you configure a hotkey to perform this action?
There are a few strategies for this.
In Preferences and "Keys", you can list key bindings, assign new bindings, and clear existing bindings. It's convenient to sort by the "Binding" column so you can see functions bound to the same sequence right next to each other, to check for possible key sequences to bind functions to.
A general approach is that I bind several functions to key sequences beginning with "Ctrl+;" (control-semicolon). Nothing else uses that prefix, so it doesn't conflict with anything. You can use any prefix that is convenient for you.
The "right-click" operation is actually a specific function, called "show-context-menu". I bind "Ctrl+;, ." (control-semicolon, then period) to this function.
Once the context menu is visible, you can use down-arrow and up-arrow to move through the menu. Up-arrow on the first item goes to the last item. Also, when the context menu is visible, each menu item will have one letter underlined, which is the "accelerator" for that menu item. If you press that key while the menu is shown, it will execute that item, or simply select it if it has a submenu. If there are multiple items with that same accelerator, it will go to the first one, and the next one if you press it again. If it has a submenu, right-arrow will open the submenu.
In your situation, you would have to have the project selected in the project or package explorer. You could do that with the mouse. I'm not aware of good strategies for directly selecting a particular project in the explorer.
Another thing you'll want to do is look in the "Keys" list to see if the function you want to execute is defined, so you could bind a key sequence to it, but you'll still likely have to have the project selected when that sequence is pressed.
This process of exploring functions and keys is much more convenient if you use the "Emacs+" plugin (no elisp knowledge or use required). It provides functions for showing what key sequences are bound to which functions, and vice versa.
Well, you could always use a more general hotkey facility that isn't specific to RDi. If you're using Windows, I recommend AutoHotkey. This would let you assign keystrokes or mouse movements/clicks to any key combination you like.

Using Blueprism, How to right click on a web application and select an option using Key or Click events?

Using BluePrism, how to right click on a web application and select an option using Key or Click events in Region Mode or Accessibility Mode?
It doesn't spy any of the menu items with an error saying :
Unable to spy the element
I had the same problem and fixed it with the following:
Because the window that shows up is a System window, it means it's no longer part of the IE Application Modeller, as it's using a different thread and a different ID.
So you'll need to create a different object specifically for this operation. I created one with
Object Name: IE - Popup Message
Window Title: Message from webpage
Windows Process iexplore
When attaching to it use index of 0, and then you can easily use UI Automation or Acessibility to identify the button you want to press.
But yes, you'll need to use a different object, I'd suggest making this one and every time there's a system popup for IE to identify the different buttons and use this object as a common interface between them.
This needs clear details about right-click behaviour; where is it showing a specific menu item or general right-click option.
In case application-specific option ->
then you can select global mouse click with text as 'right' to select the menu item and then finally using the Arrow keys (Up, Down to move the desired location )

Adding menu listener for Paste option in SWT Browser

I have a org.eclipse.swt.browser.Browser instance created in a composite. I would like to know when some content is pasted in the browser using the (platform specific) right click context menu and selecting the paste option.
In the menuDetected() of MenuDetectListener, I get a notification when the context menu is detected in the browser.
How can I know if the Paste option is selected from the context menu?
Regards,
Noopur
No you can't access the selected context menu item. There is no direct provision for that. At least not in eclipse 3.7. Although, you could try different combinations of events for determining the menu item. For example, in windows the internet explorer populates the status bar with 'inserts the clipboard...' when your mouse pointer hovers over the Paste menu item, you can capture this using StatusTextListener event.
Note: The hack is not an elegant solution, even if you get it working, there is still some possibility that it may break with new or older releases of SWT or in fact its behavior may vary with operating systems !!

Eclipse plug-in: How to create a new menu for eclipse plugin with key combination?

I've been looking about this question but I couldn't find it. I need to create a new "popup menu" and assign a key pressed (in other words, I need press "F3+right-click" (for example) and this action will be appear a new popup menu, with my actions in my workbench). I don't need a submenu for my right-click... i need a new and alone menu
Example, in eclipse, when i right-click with my mouse over workbench I see a popmenu with: "undo, revert file, save, cut, copy..." and more, but i need create a new menu instead of eclipse menu, so, when I press "F3+right-click" (example) i need see my popup-menu with my actions... this is my problem, i need to create a new menu and call it with key/mouse combination...
I've been reading the forums but i don't know where to post this question and I don't know where to search (maybe i write a wrong question in the search... i think...).
I hope someone can help me.
Thank you very much;)
I assume that you would like to see this menu in an editor (rather than in a view because that would be slightly different). Most of what you need to do here is to extend eclipse extension points through declaring them in the plugin.xml for your plugin.
Thankfully, Eclipse ships with a few extension point wizards to help you get started with this. To get there, do the following
Open the plugin.xml for your plugin
Go to the extensions page
Click on Add...
Click on Extension Wizards
The "Popup Menu" wizard
After filling in all the details, there are still a few more pieces that you need to do.
The wizard creates an Object contribution, that will add the new popup menu to an object of a specified type in all views. You can change this to being an editor contribution, so that the menu item will show in editors instead.
The final step is to connect this menu item with a key-binding. For that, you need to create a new Command extension.
Start with the Command extension point wizard.
After filling in the details, you get a command, a handler, and a binding. You can remove the handler, since you will connect your action created previously to the command you just created.
From here, you need to fill in all of the stub Java classes created by the wizards and you should be in business.
This is a very rough set of steps you need to do to implement the keybindinds (and, yes, it is way more complicated than it needs to be). For more detail, you can go here:
http://www.vogella.de/articles/EclipseCommands/article.html

Eclipse code template to insert a bookmark?

Eclipse has a nifty feature which allows you to define "templates" for code. I have created one to automatically put in a println and add a "TODO" comment. I'd like for this to also add a bookmark so I can easily find it again.
(The codebase I am working with makes it unfeasible to use just the Task List to find what I need to do since there are a lot of TODOs laying around.)
My current template is simply System.out.println("don't commit me!"); //TODO: fix this ${cursor}.
A bookmark is part of the editor.
You can find all of your TODO comments in the Eclipse Tasks view. If the Tasks view isn't open, just left click on Window -> Show View -> Tasks (not Task List).
If you left click on the Tasks description to make sure the Tasks view has focus, then double click on the Tasks description, Eclipse will open the editor and take you to the TODO line.
If you have the code already open in the Eclipse editor, Eclipse draws blue rectangles on the right side of the editor to mark all of the TODO comments. Left clicking on the blue rectangles will take you to the TODO comment line.
Edited to add: You can sort the Tasks view by clicking on any of the titles, like Resource.
I don't think it's possible via a code template.
It's certainly possible with the a key shortcut that can be assigned to add bookmark in:
Window->Preferences->Keys
but you still have the prompt to enter the name of the bookmark (rather than use a default set of text).
If you really want to get close to the functionality you want you could take a look at the Eclipse Bookmarks plugin:
http://www.etc.to/eclipse_bookmarks_plugin
and maybe hack it to do what you want... (if it doesn't already)...