|
|
Re: Dynamic toolbar won't appear in Eclipse RCP app [message #1871544 is a reply to message #1871517] |
Mon, 30 September 2024 00:40 |
I S 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".
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 |
I S 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 #1871559 is a reply to message #1871550] |
Mon, 30 September 2024 07:21 |
I S 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
|
|
|
|
Powered by
FUDForum. Page generated in 0.04073 seconds