Bug 145378 - [Coolbar]RCP appication loses Icons/actions with IDE Stable Builds RC6 and RC7
Summary: [Coolbar]RCP appication loses Icons/actions with IDE Stable Builds RC6 and RC7
Status: VERIFIED FIXED
Alias: None
Product: Platform
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 3.2   Edit
Hardware: PC Windows 2000
: P3 normal (vote)
Target Milestone: 3.2.1   Edit
Assignee: Eric Moffatt CLA
QA Contact:
URL:
Whiteboard:
Keywords: contributed
: 136847 (view as bug list)
Depends on:
Blocks:
 
Reported: 2006-06-05 12:54 EDT by Martin Holmes CLA
Modified: 2006-12-08 07:34 EST (History)
8 users (show)

See Also:


Attachments
Make ToolBarContributionItem implements IToolBarContributionItem (1.13 KB, patch)
2006-06-21 10:37 EDT, Kostadin Bajalcaliev CLA
no flags Details | Diff
Modified browser example showing the workaround (132.71 KB, application/zip)
2006-06-21 15:29 EDT, Nick Edgar CLA
no flags Details
-REVERSE- Patch proposal for 3.2.1 for this defect (1.14 KB, patch)
2006-08-15 10:52 EDT, Eric Moffatt CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Martin Holmes CLA 2006-06-05 12:54:08 EDT
When launching an RCP application from PDE icons/actions are lost.

RC6 loses a general action from the toolbar even thou' it appears in the main menu. The action is added to the toolbar from the plugin manifest and is hooked in as follows using the ToolBarContributionItem.

		protected void fillCoolBar(ICoolBarManager cbManager) {		
			cbManager.add(new GroupMarker("group.file"));
			{ // File Group
				IToolBarManager fileToolBar = new ToolBarManager(cbManager.getStyle());
				fileToolBar.add(new Separator(IWorkbenchActionConstants.NEW_GROUP));
				fileToolBar.add(new GroupMarker(IWorkbenchActionConstants.OPEN_EXT));
				fileToolBar.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS));
				cbManager.add(new ToolBarContributionItem(fileToolBar,IWorkbenchActionConstants.TOOLBAR_FILE));
			}
			cbManager.add(new GroupMarker(IWorkbenchActionConstants.MB_ADDITIONS));
			cbManager.add(new GroupMarker(IWorkbenchActionConstants.GROUP_EDITOR));
		}


RC7 loses the above as well as the "run garbage collection" icon on the bottom right of the workbench window.

The two mentioned problems work correctly in the Eclipse 3.1.2 final release.
Comment 1 Eric Moffatt CLA 2006-06-07 23:30:37 EDT
Martin, the "run garbage collection" was turnd off for release (we use it but most of our clients don't really want it). If you want it back ou can find it under "Window > Preferences > General > Show Heap Staus".

Could you be more specific as to the other action that is lost (what menu item is i?)
Comment 2 Kostadin Bajalcaliev CLA 2006-06-21 10:37:58 EDT
Created attachment 44999 [details]
Make ToolBarContributionItem implements IToolBarContributionItem

The same problem occurs when contributing actions from one action set to another via plugin.xml
If org.eclipse.jface.action.ToolBarContributionItem is changed to implement IToolBarContributionItem expected behavior as pre-RC6 is restored.


PluginActionSetBuilder.contributeAdjunctCoolbarAction(ActionDescriptor ad, ActionSetActionBars bars) {
    ...
    // create a coolitem for the toolbar id if it does not yet exist               
    IToolBarManager toolBarManager = bars.getToolBarManager(toolBarId);
    ...
}

ActionSetActionBars.getToolBarManager(String actionId) {
    ...

    >> Condition fails if cbItem is instance of ToolBarContributionItem
    if (cbItem instanceof IToolBarContributionItem) {
    ...
    } else {
        >> This should not execute, but it does in case of adjunct type
        >> resulting in creation of second contribution with the same toolBarId

        coolItemToolBarMgr = actionBarConfigurer.createToolBarManager();
     
        // If this is not an adjunct type then create a tool bar
        // contribution item
        // we don't create one for an adjunct type because another action
        // set action bars contains one

        IContributionItem toolBarContributionItem = actionBarConfigurer
                    .createToolBarContributionItem(coolItemToolBarMgr,
                            toolBarId);
    }
    ...
}
Comment 3 Nick Edgar CLA 2006-06-21 15:25:54 EDT
I believe Kostadin's patch is correct and will fix the problem.

However, I would have expected the action set action(s) to appear in their own toolbar when it failed to match the specified toolbar (due to the instanceof check failing), but it does not.  So there seems to be another problem here in the processing of "adjunct" action set actions (those that add to a toolbar other than their own).

The workaround for the first problem is to use IActionBarConfigurer2.createToolBarManager and createToolBarContributionItem
For example, I modified the browser example to do:

	protected void fillCoolBar(ICoolBarManager coolBar) {
		IActionBarConfigurer2 cfg = (IActionBarConfigurer2) getActionBarConfigurer();
		
		IToolBarManager toolBar = cfg.createToolBarManager();
		coolBar.add(cfg.createToolBarContributionItem(toolBar, "standard"));

                // add actions to toolBar as before
       }

and added an action set that contributes an action to the "standard" toolbar.
It works when using the IActionBarConfigurer2 factory methods, but not when using ToolBarManager / ToolBarContributionItem directly.
Comment 4 Nick Edgar CLA 2006-06-21 15:26:18 EDT
I think this should be a 3.2.1 candidate.
Comment 5 Nick Edgar CLA 2006-06-21 15:29:27 EDT
Created attachment 45028 [details]
Modified browser example showing the workaround

This is a modification of the browser example to use the IActionBarConfigurer2 factory methods to create the hardwired "standard" toolbar, with an action set adding an action to that toolbar.
Comment 6 Nick Edgar CLA 2006-06-21 16:27:09 EDT
It turns out that Konstadin's fix also fixes up the second problem mentioned in comment 3.  If the action set action's toolbar path is changed to "standard2/additions" instead of "standard/additions" the action still shows up, but in its own toolbar.
Comment 7 Eric Moffatt CLA 2006-06-23 09:07:32 EDT
Applied the patch and committed (in the 3.3 stream) in >20060623.

I'll mark it fixed once it's in 3.2.1
Comment 8 Eric Moffatt CLA 2006-08-15 09:37:24 EDT
Fixed, committed to the 3.2.1. stream in >20060815.
Comment 9 Eric Moffatt CLA 2006-08-15 10:52:13 EDT
Created attachment 47912 [details]
-REVERSE- Patch proposal for 3.2.1 for this defect
Comment 10 Boris Bokowski CLA 2006-08-15 12:04:57 EDT
+1 for 3.2.1.
Comment 11 Eric Moffatt CLA 2006-08-31 10:44:37 EDT
Verified in M20060830-0800.
Comment 12 Eric Moffatt CLA 2006-09-08 08:42:23 EDT
Committed in >20060908. Add an attribution for the patch.
Comment 13 Paul Webster CLA 2006-12-08 07:34:18 EST
*** Bug 136847 has been marked as a duplicate of this bug. ***