neilcsmith-net commented on PR #7925:
URL: https://github.com/apache/netbeans/pull/7925#issuecomment-2568185376

   The actions already exist and are registered.  With the `Project UI` module 
open in the IDE, look under `Important Files / XML Layer / <this layer in 
context>`.  You can see a reference to the collapse all action under the 
`ProjectTabActions` folder, which is the path for 
`ProjectsRootNode.ACTIONS_FOLDER`.  The path for the additional reference is up 
to you, but could be something like `ProjectTabButtonPanel` ??
   
   You need to add an `iconBase` on the existing action registration at 
https://github.com/apache/netbeans/blob/master/ide/projectui/src/org/netbeans/modules/project/ui/ProjectTab.java#L874
 with a path to the icon in the resources folder - see similar at 
https://github.com/apache/netbeans/blob/master/ide/projectui/src/org/netbeans/modules/project/ui/ProjectTabAction.java#L40
  Use a png file as the base - an svg with the same name should be picked up 
from there.
   
   Add an additional `ActionReference` to the action - eg. 
`@ActionReference(path="ProjectTabButtonPanel", position = 100)`  Use similar 
registration on the other action, with a higher position so it loads in the 
right order.
   
   To load the actions to use in your panel, use 
`Utiltiies.actionsForPath("ProjectTabButtonPanel", 
Lookups.singleton(ProjectTab.ID_LOGICAL))`.  The context is the same as used at 
https://github.com/apache/netbeans/blob/master/ide/projectui/src/org/netbeans/modules/project/ui/ProjectsRootNode.java#L116
  Note use of `ProjectTab.ID_PHYSICAL` for the Files tab.
   
   The `Action[]` returned from that path may contain `null` for defining 
separators.
   
   To create the buttons for your panel then do something at simplest like - 
   
   ```java
   for (Action a : actions) {
     if (a != null) {
       JButton button = new JButton();
       Actions.connect(button, a);
       // add button to bar
     } else {
       // add a separator or ignore
     }
   }
   ```
   
   Hope that helps you get going in the right direction.  Apologies for any 
mistakes - writing some from memory! :smile:


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists

Reply via email to