Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Rich Client Platform (RCP) » Toolbars contributed to the coolbar not visible(Toolbars contributed to the coolbar after application initialization are not visible unless you manually lock and then unlock the toolbar region.)
Toolbars contributed to the coolbar not visible [message #1861195] Thu, 28 September 2023 19:09 Go to next message
Rick Vaughan is currently offline Rick VaughanFriend
Messages: 4
Registered: July 2010
Junior Member
We have an RCP application that we recently upgraded from using Eclipse 4.16 to Eclipse 4.25 and the toolbars that we add to the CoolbarManager after application initialization, are not displayed. We found, in one of our applications, that if we use the RMB menu to Lock and then unlock the toolbar area, our toolbars are now displayed. Unfortunately, this workaround is not available in a second application. We have verified that when we add our toolbars, the coolbarManager.getLockLayout API returns false. We have also verified that the toolbars themselves are visible, as are all the buttons in each toolbar at the time the coolbar.update call is made.

We have attempted to work around this issue in a number of different ways, but none have worked, including calling setLockLayout(true) followed by a setLockLayout(false). What we are wondering, is if this is an Eclipse issue or we need to change the way we are contributing our toolbars.

Note also - toolbars that we contribute in the ApplicationActionBarAdvisor fillCoolBar method are properly displayed.

This is how we are contributing the majority of our toolbars (again, this occurs after the application is fully initialized and displayed) - we have been doing it this way for many years:

        Display.getDefault().asyncExec(new Runnable() 
        {
            public void run() 
            {
                ICoolBarManager cool_bar_mgr = getCoolBarManager();
                if (cool_bar_mgr != null && !s_already_populated)
                {
                    s_already_populated = true;
                                                    
                    Vector<ToolbarInfoStruct> toolbar_infos_vec = MyApplication.getEclipseToolbarData();
                    
                    // For each toolbar ...
                    for (int i = 0; i < toolbar_infos_vec.size(); i++)
                    {
                        ToolbarInfoStruct tb_info_struct = toolbar_infos_vec.elementAt(i);
                        String tb_english_name = tb_info_struct.getEnglishName();
                        MyToolbarManager tb_mgr = new MyToolbarManager(cool_bar_mgr.getStyle(), tb_english_name);
                        
                        cool_bar_mgr.add(new ToolBarContributionItem(tb_mgr, tb_english_name));
                        
                        s_regID_to_tbMgr_map.put(tb_english_name, tb_mgr);
                        s_localizedID_to_regID.put(
                                tb_info_struct.getLocalizedName(), 
                                tb_english_name);
                        
                        // For each button/separator ...                                    
                        for (int j = 0; j < tb_info_struct.getButtons().size(); j++)
                        {
                            ButtonInfoStruct button_info = tb_info_struct.getButtons().elementAt(j);
                            if (isCmdIDSupported(button_info.getCmdID()))
                            {
                                if (button_info.getCmdID() == -1)
                                {
                                    tb_mgr.add(new Separator());
                                }
                                else
                                {
                                    try 
                                    {
                                        BaseToolbarButtonAction tb_action = null;
                                        
                                        // Check if the button we need is already on a different toolbar. 
                                        Object obj_from_map = s_native_cmd_id_to_action_map.get(button_info.getCmdID());
                                        if (obj_from_map instanceof BaseToolbarButtonAction)
                                        {
                                            // We already have an action for this button, so use the one we've already
                                            // created
                                            tb_action = (BaseToolbarButtonAction)obj_from_map;
                                        }
                                        else
                                        {
                                            // Create a brand-new Action for this button
                                            ImageDescriptor descriptor = button_info.getImageDescriptor();          
                                            String eclipse_cmd_id = s_cmd_starter + "cmd_" + button_info.getCmdID();
                                            tb_action = new BaseToolbarButtonAction(tb_mgr, button_info.getTooltip(), button_info.getCmdID(), eclipse_cmd_id, descriptor);
                                        }
                                    
                                        tb_mgr.add(tb_action);
                                        s_native_cmd_id_to_action_map.put(button_info.getCmdID(), tb_action);
                                    } 
                                    catch (Exception e) 
                                    {
                                        e.printStackTrace();
                                    }
                                }
                            }
                        }
                        
                        tb_mgr.setVisVisibilityRepresentation(false);
                        tb_mgr.setVisible(false);                                   
                    }
                }
                MyApplication.authorizeEclipseToolbarRefresh();
            }
        });         


Toolbar visibility = true is set elsewhere and is then immediately followed by an update to the Coolbar:
        Display.getDefault().syncExec(new Runnable() 
        {
            public void run() 
            {
                ICoolBarManager coolbar_manager = getCoolBarManager();
                if (coolbar_manager != null)
                {   
                    coolbar_manager.update(true);
                }   
            }
        }); 


Any help on resolving this would be greatly appreciated.

Thanks,
Rick



Re: Toolbars contributed to the coolbar not visible [message #1862600 is a reply to message #1861195] Wed, 13 December 2023 13:56 Go to previous message
Rick Vaughan is currently offline Rick VaughanFriend
Messages: 4
Registered: July 2010
Junior Member
We attempted to create a smaller application that exhibited the problem, and even though we used the exact same sequence of toolbar creation, the application worked. After some investigation, I now understand why - the sample application would not exit correctly. I will explain what I found. Looking at the workspace for our Test application (not the sample we were trying to create), I found the .metadata.plugins\org.eclipse.e4.workbench\workbench.xmi file, which contained references to our toolbars with visible="false". This file is written on application exit and sometime after Eclipse 4.16 (we moved from 4.16 to 4.25), always contains our toolbar info with visible="false" (we are setting them false as part of clean up of other components we created). If I removed that file, the Test application works. This is why we never saw the issue with the sample application, because it never exited properly. Note also, that using version of Eclipse 4.16 and prior, our toolbars were not persisted to the workbench.xmi file, thus there was no problem, so this is what caused the problem to appear. The solution to the issue was to remove our toolbars from the CoolBarManager as the application is going down, so that they are not there to be persisted.
Previous Topic:maven tycho product launcher failed
Next Topic:Detect User Inactivity and Logout (Eclipse RCP)
Goto Forum:
  


Current Time: Sat Jul 27 09:23:12 GMT 2024

Powered by FUDForum. Page generated in 0.03368 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top