Programatically change icon for a eclipse RCP command - eclipse

I have a menu drop down action in the coolbar. It has 3 sub items that form a radio group. I would like to change the icon shown in the coolbar when the user selects one of these options.
I've googled and seen that I should look at:
org.eclipse.ui.commands.ICommandService.refreshElements(String, Map)
and
org.eclipse.ui.commands.IElementUpdater
Its probably the right thing to look at exception its not enough information. One or two small code snippets will be excellent.
Thanks in advance.

Ok basically if you don't want to use a "custom" control the what to do it is to have your handler (handler that is linked to the specific command) implement IElementUpdater. When every the toolbar item gets shown or clicked on (i.e if the user selects on the the radio buttons) the method: updateElement(UIElement element, Map parameters) gets called.
The element has a setIcon() method and this is what i used to change the icon of the menu drop down action.

Every update to the Coolbar points to the specialization of the WorkbenchWindowControlContribution class.
This bug 186800 has some code example in it which can be of interest.

Related

Custom Work Item Types don't show in any Board or Backlog?

We've created a new work item type called "Improvement", but found that it does not show in any board or backlog - only search. After some digging in settings, I found this:
Can you really not add new work item types and get them into your workflow along side the default types?
In this page, hover with the mouse on the work item level you want to include your custom item and click "Edit":
In the screen that opens you can add the custom work item.

Is there any event on Click of OK button in Properties Window

I am using this EA_OnNotifyContextItemModified method for tracing the changes in the properties window of an element in EA.
I need to know is there any event on click of “OK/Cancel/Apply” buttons in the properties window of EA.
As shown in the image, i need to know is there any event that will be called particularly on click of "OK/Cancel/Apply" buttons of that window
It's either EA_OnPostNewElement if the element has been created newly or EA_OnNotifyContextItemModified if you have modified an existing element.
Btw. you find both in the help in this chapter and this one.

Should I provide new GWT place?

I have a general question for GWT Activity and Places paradigm realization
For example, I have a place "productList" and appropriate view ProductListView. A have a table with some Product entity in each row. I wanna to double click on row and got popup window which allow me to edit Product in doubleclicked row. How to implement it? Should I provide new place "editProduct" for this activity?
A popup dialog is not a place - users would not expect to see it when they press the back button. So there is no need to create a special EditProduct place.
You can think of "places" as something that users may want to see when they click on Back or Forward buttons, or something they want to bookmark.

how to show up the perspective button without click?

I have two perspectives , but to see the second perspective , as you know have to click button 'open perspective'.
Is there way that the second perspective button shown up automatically , when application start up?
This is an old topic, but I thought I would offer a more concrete answer since the accepted one is not the most direct in getting to a solution.
In your ApplicationWorkbenchWindowAdvisor.preWindowOpen() method use the below code to add perspectives to the perspective switcher.
// Get a reference to the preferences store
IPreferenceStore prefStore = PlatformUI.getPreferenceStore();
// Set the value for the perspective bar preference. Insert your own
// perspective id values.
prefStore.setValue(IWorkbenchPreferenceConstants.PERSPECTIVE_BAR_EXTRAS, "project.perspective.id.1, project.perspective.id.2,...");
There are a number of preference values that you can set through IWorkbenchPreferenceConstants (see api).
It sounds like you want the default size of the perspective switcher (the bar containing the perspective buttons) to be larger than usual. To do that, you could perhaps use an instance of the ActionBarAdvisor class; you'll probably also need a WorkbenchWindowAdvisor class.
I don't see any methods to directly access the switcher object, so I think you'll have to look at the component tree to find it.
Seems like there ought to be an easier way, but I don't see one.
The perspectives show up on a tab. Although it's not clear just from looking at it, the end of the tab can be dragged so it's longer and can display more perspective buttons.
Right click mouse on the perspective toolbar, then select dock it on left or top left. You would see more toolbar items of other perspective, and show more on the toolbar.

Dynamic GWT Menu

How can I modify a GWT menu - grey out some entries, put a checkmark next to others, according to my application state?
My app has a menu bar across the top - File, Edit, View, Insert, Format, etc. I have a number of paragraphs, each of which could have a different format. When the user clicks on Format, I want the format menu to show a checkmark next to the menuItem that corresponds to the format of the currently selected paragraph. If some formats are inappropriate for the currently selected paragraph, I want to grey those menuItems out.
The main issue is when to do the update: (a) when the Format menu button is clicked, or (b) each time my user selects a new paragraph?
I find option (a) more appealing. But how can I detect this? A MenuItem doesn't have any facility for adding event listeners. It could be a mouseClick that I need, but it might be a mouseOver: if the user clicks on the Insert menuItem the Insert menu will appear, but then if the mouse is moved over Format, then the Format menu will appear.
Option (b) sounds simpler, but wastes more processor time.
For my contextMenu (right click on the paragraph), it's much easier, because the menu is only constructed when the right click happens.
I've resorted to using the square-root symbol (&#8730) for a tick. Does anyone know a nicer way? Do I need to use HTML and use " Plain-Format" for my menu item?
Finally, is there a way to disable (grey-out) a menu item so that it can't be selected?
Option (a) sounds better from a conserving resources point of view.
Instead of using the square-root symbol, why don't you use an image (using the com.google.gwt.user.client.ui.Image class)?
I think a more elegant/simple solution might be to use the checkbox class for your menu items. That way you could have automatic ticks/checks instead of having to use an image or the square-root symbol. Also, you will be able to "grey-out" items with setEnabled(false). Otherwise, you will have to write your own widget or add your own functionality to your menu labels in order to "grey-out" items.