eclipse plugin development-adding button to toolbar and its behaviour - eclipse

Using eclipse plugin, I am trying to add some buttons in toolbar and want to perform some action onclick to that button.
so what i did in extension tab i added org.eclipse.ui.menus and so added a menucontribution to it with URI location- toolbar:org.eclipse.ui.main.toolbar.And then a toolbar in it with a command lets say Design
so by doing this a got a button on toolbar with name Design.
now i want it should be clickable (as for now it is inactive) and on click i can add some behavior/action to it.
please help.

You can use "Hello,World Command" plug-in template which adds a "Sample Menu" in the toolbar and start from that point.

Related

Adding action item to a treeview's toolbar of eclipse plugin

There is a an eclipse plugin (I don't have source code of it) that I want to contribute to.
Plugin has an Editor, in this editor there is a TreeView with a toolbar.
I want to add new button to this toolbar with my action.
Can it be done?
I wasn't able to get useful information using Plugin Spy.
(Alt-Shift-F1 shows info about the editor and not about the view inside the editor,)
Or it's possible to add toolbar buttons only to eclipse 'core' views like 'Navigator'?
No, you can't add to the Toolbar from outside of the plugin unless the plugin has provided extension points to allow this.

Eclipse RCP - remove command from the popup

I am working on a tool (which is built over Eclipse). In that there is a popup menu called "Edit Properties" if a object is right clicked. I need to hide this menu command. Provided that it should not be gets hided from the standard menu, should only be hide from the popup.
How to do this? Can anyone suggest me?

Tooltips in Eclipse RCP window toolbar menus

I created a window with a toolbar with menus. Now I want menu items to have tooltips, and I did not succeed.
I'm on Ubuntu 12.04.
What I've already tryed:
Set the 'tooltip' for menu contribution in plugin.xml
Set the 'description' for the command
Setup tooltip text in the actions in submenus that I create programmatically using ManuManager and Action.
Regards,
Vladimir
According to the description of the popupMenus extension point tooltips are only shown when the action is part of a toolbar. There exists an Eclipse Bug considering this problem.

Adding "open file" button to eclipse toolbar

I know you can add new buttons to the eclipse toolbar by writing a custom plugin but just how would i go about adding a simple "open file" button like most editors have?
I guess I can use this as a template to do what i want, but what's the commandId for the "open file dialog":
How to add undo / redo buttons to toolbar in Eclipse?
thank you!
If you want to have a toolbar button which mimics the behaviour of the menu File->Open File..., then you are searching for the command id
org.eclipse.ui.edit.text.openLocalFile
which you would want to use instead of the command ids for the undo/redo in your example.
I don't believe there is a specific commandId for open file dialog that you can use in the toolbar or menu. You would have to create a class that implements the IHandler interface and use something like the JFileChooser to handle the selection of the file.

Search text field on menu bar

In a Eclipse RCP application, is there any way I can have text field (for search) on menu bar?
For example I have menu:
File Edit ... Search: |___text field___|
The text field is located at the right end of the menu bar.
I don't think that is easily possible. But you could use the CoolBar to create this functionality.
You can place an SWT control on the toolbar, but it doesn't work for menus. Here is the toolbar way:
Open the extensions tab in plugin.xml file
Add a menuContribution extension to org.eclipse.ui.menus and set it as a toolbar (toolbar:ID)
Add a toolbar to this menuContribution
Add a control to this toolbar
Double click and create the class which extends WorkbenchWindowControlContribution and fill the createControl(...) function using the desired SWT controls.
After setting the menuContribution as a menu, it is still possible to add a control, but unfortunately, it does not show any controls.