Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Platform » Dynamic toolbar won't appear in Eclipse RCP app
Dynamic toolbar won't appear in Eclipse RCP app [message #1871514] Fri, 27 September 2024 07:48 Go to next message
I S is currently offline I SFriend
Messages: 31
Registered: May 2022
Member
I built an RCP app with java 17 and Eclipse 2024.06 using Maven Tycho plugin 4.0.8.

In plugin.xml I defined a toolbar:
<plugin>
    <extension point="org.eclipse.ui.menus">
        <menuContribution locationURI="toolbar:org.eclipse.ui.main.toolbar?after=additions">
            <toolbar id="com.company.project.ui.admin.zone.toolbar">
                <dynamic
                        class="com.company.project.ui.admin.zone.editor.util.SelectZonesDropDownContributionItem"
                        id="com.company.project.ui.admin.zone_selector_contribution">
                    <visibleWhen checkEnabled="false">
                        <with variable="activeEditorId">
                            <equals value="com.company.project.client.editors.zone"></equals>
                        </with>
                    </visibleWhen>
                </dynamic>
            </toolbar>
        </menuContribution>
    </extension>
</plugin>

I expect the toolbar to be appeared in my app but nothing happens, there is just empty space on the toolbar where my dropdowns should be located. In debugger I see that SelectZonesDropDownContributionItem is created but overridden public void fill(final ToolBar parent, final int index) is never executed as well as other overridden methods.
In the past, the application had been built with Eclipse Mars (using Eclipse Product export wizard) and Java 8 and it worked (no Tycho). Recently, I updated the Eclipse framework and started to use Tycho to build the app. Basically, I'm lost, I don't know if the problem related to the updated Eclipse 2024.06, Tycho, my MANIFEST.MF or plugin.xml files or something else.
Please let me know if any information needed to understand the problem better.
Re: Dynamic toolbar won't appear in Eclipse RCP app [message #1871517 is a reply to message #1871514] Fri, 27 September 2024 11:46 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33258
Registered: July 2009
Senior Member
Does it function properly when you debug launch it from the development environment where you work on this code?

Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Dynamic toolbar won't appear in Eclipse RCP app [message #1871544 is a reply to message #1871517] Mon, 30 September 2024 00:40 Go to previous messageGo to next message
I S is currently offline I SFriend
Messages: 31
Registered: May 2022
Member
Hi Ed,

no, it doesn't, I tried to set a few breakpoints in overriden methods but non of them hit. For example, I tried breakpoints in those two methods (I removed most of the code from the methods for better readability). The same breakpoints were hit with Mars release and Java 8.

However, I see that SelectZonesDropDownContributionItem default constructor and its parent consturctors are being executed. But overriden getContributionItems() and fill() methods won't be executed.

@Override
protected IContributionItem[] getContributionItems() {
        return new IContributionItem[0]; // <<<<======== set up the breakpoint here
    }

and
@Override
public void fill(final ToolBar parent, final int index) {
        item.setText(UiMessages.getString("select_zone")); // <<<<======== here

        item.addListener(SWT.Selection, event -> {
            fixMenuPosition(event, parent, selectZoneMenu); // <<<<======== and here
       }
}


Also, please find the screenshots attached to understand what I mean saying "I see just empty space".
https://i.ibb.co/tqL0QHN/Screenshot-1.jpg
https://i.ibb.co/BLMGpRS/Screenshot-2.jpg

Thanks!

[Updated on: Mon, 30 September 2024 00:49]

Report message to a moderator

Re: Dynamic toolbar won't appear in Eclipse RCP app [message #1871547 is a reply to message #1871544] Mon, 30 September 2024 05:39 Go to previous messageGo to next message
I S is currently offline I SFriend
Messages: 31
Registered: May 2022
Member
I found an exception in logs I didn't see yesterday.
!ENTRY org.eclipse.ui 4 0 2024-09-30 15:15:17.998
!MESSAGE Loaded class is of incorrect type: expected(org.eclipse.ui.menus.WorkbenchWindowControlContribution) got (com.company.project.ui.admin.zone.editor.util.SelectZonesDropDownContributionItem)
!STACK 0
java.lang.IllegalArgumentException: Loaded class is of incorrect type: expected(org.eclipse.ui.menus.WorkbenchWindowControlContribution) got (com.company.project.ui.admin.zone.editor.util.SelectZonesDropDownContributionItem)
    at org.eclipse.ui.internal.util.Util.safeLoadExecutableExtension(Util.java:513)
    


Seems like my SelectZonesDropDownContributionItem is not compatible anymore and it has to extend WorkbenchWindowControlContribution instead of CompoundContributionItem. Is it correct? And if yes, how can I do that? WorkbenchWindowControlContribution doesn't have getContributionItems() and fill() methods.

[Updated on: Mon, 30 September 2024 05:41]

Report message to a moderator

Re: Dynamic toolbar won't appear in Eclipse RCP app [message #1871550 is a reply to message #1871547] Mon, 30 September 2024 05:52 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33258
Registered: July 2009
Senior Member
I don't really know how this is supposed to work of what's changed. I asked because I was doubtful that the build has something to do with it. Perhaps something has changed in the framework or some bug has been introduced. But from what I can tell looking at the code, it's always needed to be a WorkbenchWindowControlContribution

https://github.com/eclipse-platform/eclipse.platform.ui/blob/8a8979f427fedbde95bfaf668eda25016d968b78/bundles/org.eclipse.ui.workbench/Eclipse%20UI/org/eclipse/ui/internal/menus/DynamicToolBarContributionItem.java#L138-L141

Can you make your compound into individual contributions?


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Dynamic toolbar won't appear in Eclipse RCP app [message #1871559 is a reply to message #1871550] Mon, 30 September 2024 07:21 Go to previous messageGo to next message
I S is currently offline I SFriend
Messages: 31
Registered: May 2022
Member
Hi Ed, sorry but I think I got lost. I created a new test project and added a toolbar and menu. As far as I understand (but obviously I'm wrong) my menu and toolbar have to have a push button with the same ContributionItem class and they have to execute the same my.test2.command. It works for the menu item as expected and command is being executed. But for toolbar, the button is not created and I see the exception I mentioned in the previous post. However, it worked for Eclipse Mars with Java 8. I just want to make sure we are on the same page. If it looks or sounds weird to you, could you please share an example or maybe a howto I can read?
   <extension point="org.eclipse.ui.menus">
      <menuContribution
            allPopups="false"
            locationURI="toolbar:org.eclipse.ui.main.toolbar?after=additions">
         <toolbar
               id="my.test2.toolbar">
            <dynamic
                  class="my.test2.ContributionItem"
                  id="my.test2.dynamic2">
            </dynamic>
         </toolbar>
      </menuContribution>
      
      <menuContribution
            allPopups="false"
            locationURI="menu:org.eclipse.ui.main.menu?after=additions">
         <menu
               label="File">
	   <dynamic
                  class="my.test2.ContributionItem"
                  id="my.test2.dynamic2">
            </dynamic>
         </menu>
      </menuContribution>
   </extension>


The ContributionItem class is below
public class ContributionItem extends CompoundContributionItem{
	@Override
	protected IContributionItem[] getContributionItems() {
	    return new IContributionItem[] {
	    	     new CommandContributionItem(PlatformUI.getWorkbench().getActiveWorkbenchWindow(), null,
	    	     "my.test2.command", Collections.emptyMap(), null, null, null,
	    	     "Click me", null, null, SWT.NONE)
	    	   };
	}
}

[Updated on: Mon, 30 September 2024 07:24]

Report message to a moderator

Re: Dynamic toolbar won't appear in Eclipse RCP app [message #1871565 is a reply to message #1871559] Mon, 30 September 2024 10:48 Go to previous message
Ed Merks is currently offline Ed MerksFriend
Messages: 33258
Registered: July 2009
Senior Member
Sorry, I don't really have a clue how this is supposed to work. You're more likely to reach people who know more than me via the issues or discussions. for this GitHub repository:

https://github.com/eclipse-platform/eclipse.platform.ui


Ed Merks
Professional Support: https://www.macromodeling.com/
Previous Topic:Feature Request: Individual project Launch configuration file
Next Topic:IntroPart is null when show welcome screen from Window>Show View > Others.. > General >
Goto Forum:
  


Current Time: Sat Dec 07 15:44:56 GMT 2024

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

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

Back to the top