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.
The toolbar component returned from NewAction.getToolbarPresenter() does not always show the correct action name. I think the cause for this problem is, that NewAction does not overwrite the method getToolbarPresenter() from its base class CallableSystemAction like it does for the methods getMenuPresenter() and getPopupPresenter(). Since the type of object created by the NewAction can change, this has to be reflected by the texts shown for menu and toolbar. Currently it is only correct for the menu entry.
the problem is that NewAction doesn't fire property change when its name changes so the default toolbar presenter (JButton) doesn't change the display name either.
Could you attach a test case (or a symptom in IDE if any)? Thanks
I created a small module suite project (with Netbeans 6.8M1) which shows the strange handling of the Action.NAME property of a NewAction. The module suite has a TopComponent with a JToolBar. Three components (beside two explanation labels) have been added to the toolbar. - The first component is a NewAction with an Action.Name property set. This property isn't honored at all (no text is displayed). - The second component is the return value of NewAction.getToolbarPresenter(). For this component the text "Add" is displayed. The Action.Name property is used for the tooltip (which is questionable because for normal swing actions the property Action.SHORT_DESCRIPTION is used to set the tooltip text). - The third component is an AbstractAction extension (SetNameAction) which allows to set the Action.Name property of the NewAction. The tooltip on the SetNameAction will show which string will be used next to set the Action.Name property. If you invoke the SetNameAction the only thing that changes is the tooltip text of the component returned by NewAction.getToolbarPresenter(). Best regards, Martin By the way: NewAction.setEnabled(true) isn't honored too
Created attachment 88170 [details] Module suite project showing the issue
Thanks for information. I'm evaluating it...
Reassigned to Standa who known more about the problem.
there are several problems in the attached sample module but none of them is a netbeans bug:) - method JToolBar.add( Action ) creates a JButton and hides the button text if the action has both small and large icons. which is the case for NewAction, even though the icons are just empty rectangles. therefore there nothing visible for the first toolbar button. try JToolBar.add( new JButton( myNewAction ) ) instead - NewAction.setEnabled( true ) has no effect because NewAction is a subclass of NodeAction whose enabled state depends on currently activated Nodes. try adding the following piece of code to your sample TopComponent: Node myNode = new AbstractNode(Children.LEAF) { @Override public NewType[] getNewTypes() { return new NewType[] { new NewType() { @Override public void create() throws IOException { System.out.println("create something new"); } }}; } }; setActivatedNodes(new Node[] { myNode }); - NewAction.putValue( Action.NAME, String ) does work if the action is added to the toolbar as a button instance (see above). when using NewAction.getToolbarPresenter() then button's display name depends on activated nodes, see my example above also see javadoc for org.openide.util.actions.NodeAction