This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 250510 - Inconsistent Presenter behaviour for Actions that implement DynamicMenuContent
Summary: Inconsistent Presenter behaviour for Actions that implement DynamicMenuContent
Status: RESOLVED INVALID
Alias: None
Product: platform
Classification: Unclassified
Component: Actions (show other bugs)
Version: 8.0.2
Hardware: All Linux
: P2 normal (vote)
Assignee: Jan Peska
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-02-19 01:16 UTC by sproger1
Modified: 2015-02-19 13:59 UTC (History)
0 users

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description sproger1 2015-02-19 01:16:29 UTC
Actions that implement DynamicMenuContent interface are expected to not cache the MenuPresenters since they are dynamic. However this behaviour is done correctly for two of the three presenters. i.e. Presenter.Popup and Presenter.Menu checks for DynamicMenuContent while Presenter.Toolbar does not (see org.openide.util.actions.Presenter.java)

Why is the behaviour different only for Presenter.Toolbar and not the other two.

This leads to different menu items being shown for the same action when shown in the toolbar (as a DropDown menu) vs when shown in the file menu at the top.


All three Presenters should check if the Action implements DynamicMenuContent.
Comment 1 Ondrej Vrabec 2015-02-19 07:41:24 UTC
What concrete actions implementing Presenter.Toolbar are you talking about?
Comment 2 sproger1 2015-02-19 13:34:10 UTC
The current behavior is fine.
Comment 3 sproger1 2015-02-19 13:59:16 UTC
The issue was with my own implementation of an Action class that implements DynamicContentMenu, Presenter.Popup, and Presenter.Toolbar that I displayed in both the Menu Bar and ToolBar. I will simply add a listener to detect changes and update the toolbar button's dropdown menu accordingly...; The menu bar does not cache the component(JMenu) returned by Action.getPopupPresenter() (i.e. an independent menu is created each time for the Menu Bar) while the toolbar makes only one call to getToolbarPresenter() (since the toolbar is always displayed while the menu bar requires clicks in order to become visible, then the current behavior is correct).It was my understanding that was flawed. I assumed Action.getToolbarPresenter() would be called when I clicked on the drop-down arrow on my button, but, instead the button in the toolbar is the Component returned by getToolbarPresenter() function, thus I need to handle the dynamic content in the Component returned by the getToolbarPresenter() method.

I used an identical pattern for  getPopupPresenter() and  getToolbarPresenter() functions, but it is now clear that they need different behavior and that this is how it should be given the manner in which they are displayed.