Custom Tools

You can add commands and submenus to the Tools menu. The tools can then be accessed from the Tools menu in P4V and optionally from context menus. You can export your custom tool definitions to a file from which other P4V users can import them.

Adding custom tools

To add custom tools to P4V:
  1. Choose Tools>Custom Tools... The Custom Tools dialog is displayed.
  2. Click Add Tool. The Add Custom Tool dialog is displayed.
  3. In the Name field, enter the name of the menu item you want to appear on the Tools menu.
  4. Use the Placement field to define where you want the tool to appear in the Tools menu.
  5. (Optional) To add a submenu for the new tool, click New Submenu. The New Submenu dialog is displayed. Check the Add to applicable context menus checkbox if you want the new tool to be available in P4V context menus.
  6. Specify the application that you want to associate with this command in the Application field. To browse to the application, click Browse. (You can drag and drop the application from an Explorer or Finder window to the Application field.)

    Important: To define tools that issue p4 commands, specify "p4" in the Application field and the command and desired arguments (for example, "fix -c %c job000001") in the Arguments field. On Windows machines, you can specify the command and arguments together in the Application field, but if you export the resulting definition to a non-Windows machine, it will not work.

  7. In the Arguments field, enter command arguments using the specifiers listed in the following table.
    %a Selected label.
    %b Selected branch.
    %C, %c Selected changelists.
    %D, %d Selected files or folders (depot syntax used for depot files).
    %F, %f Selected files (workspace syntax used for depot files).
    %i Selected workspace specifications.
    %J, %j Selected jobs.
    %O, %o Depends on which pane has focus:
      When left pane has focus, selected checked out files.
      When right pane has focus, all checked out files.
    %P, %p Selected pending changelists.
    %s Selected submitted changelists.
    %u Selected user.
    $c Current workspace specification.
    $p Current port.
    $r Current client workspace root.
    $u Current user.
    $D Arguments from prompt dialog.
    $% Literal '%' character.
    $$ Literal '$' character.
    Notes about arguments:
  8. In the Start in field, specify the directory where you want the command to execute. You can specify the directory using operating system syntax (for example: C:\tmp) or specify %f, which uses the directory of the selected file.(Note: If you specify %f, omit any other values. For example, %f\temp is invalid.) If you do not specify a value in the Start in field, the value of the field depends on whether you specify other file selection parameters (% parameters) in the Arguments field, as follows:
  9. (Windows) If the command must run in a DOS window, check Console application. To close the DOS window when the command is finished running, check Close window upon completion.
  10. To enable users to enter arguments after they choose the custom tool menu item, check Prompt user for arguments. Enter the required arguments in the field below that checkbox. To enable users to browse when prompted, check Add file browser to prompt dialog.
  11. To refresh P4V after the tool application finishes running, check Refresh P4V upon completion.
  12. To save your entries, click OK.

Importing and exporting tools

You can export the tools you've defined to a file that other P4V users can then use to import those tools. Likewise, you can import tools that other P4V users have created.

To import tools:
  1. Choose Tools>Custom Tools... The Custom Tools dialog is displayed.
  2. Click Import tools... P4V displays a dialog that enables you to select the file to be imported.
  3. Enter the file name or browse to the file and click Open. The tool definitions are imported.
  4. Click OK to save your changes.
To export tools:
  1. Choose Tools>Custom Tools... The Custom Tools dialog is displayed.
  2. Click Export tools... A dialog that allows you to select a location to which to export the tools is displayed.
  3. Enter in a file name and Browse to the location to which you would like to save it.
  4. Click Save to save the file. Another P4V user can now import those tools from it.
  5. When you are finished, click OK.

Editing tools and the Tools menu

After you add tools to P4V, you can edit them, define how they are displayed in the Tools menu, and specify when tools are available from context menus in P4V.

To edit a tool:
  1. Choose Tools>Custom Tools... The Custom Tools dialog is displayed.
  2. Select the tool and click Edit. The Edit Custom Tool dialog is displayed. In this dialog, you can edit the tool name and/or functionality of the tool.
  3. In the Placement field, you can also change the submenu in which the tool is located.
  4. Click OK to save your changes.
  5. To change the location of the tool in the menu, click Move up or Move down buttons.

To add a new submenu:

  1. Choose Tools>Custom Tools... The Custom Tools dialog is displayed.
  2. Click the New Submenu... button. The New Submenu dialog is displayed.
  3. Enter a name for the new submenu.
  4. Check the Include submenu in context menus checkbox if you want the new submenu to be available in context menus.
  5. Click OK to save your changes.
To edit a submenu:
  1. Choose Tools>Custom Tools... The Custom Tools dialog is displayed.
  2. Click the submenu you want to edit and click the Edit button. The Edit Submenu dialog is displayed. Edit the name of the submenu and check or uncheck the Include submenu in context menus checkbox.
  3. Click OK to save your changes.
To remove a tool or submenu:
  1. Choose Tools>Custom Tools... The Custom Tools dialog is displayed.
  2. Select the tool or submenu that you want to remove and click Remove. If you have a submenu selected to remove, you are prompted to remove only the submenu or to remove the submenu and all tools within it
  3. .
  4. Click OK to save your changes.
Note: On Windows, if a tool does not run, verify that the files that it opens have their extensions mapped to the required application.