June 18, 2014

How to Create a Custom Tool in P4V


We all like things to be exactly how we want out of the box. When they aren't, the engineer in me likes being able tweak things. I don't think this is strictly an engineering bias. Whether it's substituting the salad for fries or upgrading the stock speakers for the fancy bass thumping ones, people like being able to customize to their tastes and preferences. In P4V, one way of accomplishing this is through Custom Tools. This is a handy way to link P4V selections and external programs. For example, I have a Swarm Custom Tool that allows you to context click on files and view its content in the Workshop.

Simply do the following (instructions were tested on Ubuntu 13.10):

1.) Click on Tools | Manage Custom Tools...
2.) Click on New | Tool...
3.) In Add Custom Tool dialog, enter:
        Name: View in Swarm
        Application: /path/to/java
        Arguments: -cp /path/to/classfile SwarmCustomTool %D

4.) Check Add to applicable context menus option
5.) Click OK to save and exit out of Add Custom Tool dialog
6.) Click OK to exit out of Mange Custom Tools dialog

Now there should be a View in Swarm context menu on your files as well as a menu item accesible by clicking on Tools | View in Swarm.

View in Swarm menu item

To hear about other tools and share your favorite, join the Perforce Workshop.