Dynamic toolbar won't appear in Eclipse RCP app [message #1871514] |
Fri, 27 September 2024 03:48  |
Eclipse User |
|
|
|
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 #1871544 is a reply to message #1871517] |
Sun, 29 September 2024 20:40   |
Eclipse User |
|
|
|
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".


Thanks!
[Updated on: Sun, 29 September 2024 20:49] by Moderator
|
|
|
|
|
Re: Dynamic toolbar won't appear in Eclipse RCP app [message #1871559 is a reply to message #1871550] |
Mon, 30 September 2024 03:21   |
Eclipse User |
|
|
|
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 03:24] by Moderator
|
|
|
|
Powered by
FUDForum. Page generated in 0.05664 seconds