Ask Reuben

User Actions

How can I do what I do at the command line inside Genero Studio?

One of the goals of Genero Studio is that you should be able to do what you need to do inside Genero Studio, it should not be something where you are constantly Alt-Tabbing to a terminal to execute a command at the command line.  One of the configuration tools you have at your disposal is the concept of User Actions, this allows you to create actions that can be triggered by entries in the toolbar, topmenu, accelerator keys, or right-clicking on particular nodes.  You can use these to execute commands from within Genero Studio rather than typing them in at a terminal.

The creation of User Actions is a two step process.  First you define the action i.e what is executed, and then you define how the action is triggered.  Like most actions in a GUI environment, you can trigger it in more than one way.

One example I had was I found that I was using the terminal to peek inside FGLDIR, FGLASDIR etc, and I thought I must be able to do this from inside Genero Studio.  So first I had to define the User Action to open the Projects view at a particular directory, and then I had to modify Topmenu to add an entry for this action.

First step is to create a User Action following the instructions here.  To view and edit user actions, select Preferences >General > User Actions.  The dialog should be self-explanatory, the bit that need most explanation is the Command line field.

The Command line field is where you enter the command you want to be executed.

If you enter “$(environment-variable)” then the environment variable indicated will be substituted into the command.

If you enter “$(open)” then this is an instruction to open the following filename inside Genero Studio

If you click on the Insert Variable button, you can use this as a wizard to select other variables.  In this list you will see entries such as “$(FileBaseName)” which return part of the selected filename if you have right-clicked.

Finally if you enter “$(parameter-name)” where parameter-name does not match anything such as an environment variable or a pre-defined variable, then this is interpreted as a user parameter.  When you execute the action, you will be prompted to enter additional information that will be used as the value for this parameter.

The two check boxes, Display output and Verbose control what appears in the Output panel.

The Always execute locally is for use with Remote configurations and can be used to indicate if the command is executed on the remote or local server.

The Target node field allows you to indicate if the action is available by right-clicking within the Project Manager.  If it is, then you can enter this field and select the appropriate nodes.

The above User Action example simply uses $(open) and $(FGLDIR) to open $FGLDIR inside Genero Studio.

This example below has an example of a user defined parameter, the $(yyyymmdd) …

… so when the action is triggered I am prompted to enter some additional information that is then used in the command.

In this case to open a particular days GAS logs.

Once you have defined an action you then need to define ways to trigger it.  If you had selected an entry in Trigger nodes then the action would be available in the Project view by right-clicking on the appropriate node.

You can also associate the User Action with particular file extensions via File Associations (Tools->Global Setup -> Edit File Associations).  For a file type, when you add an Associated Action, you will find your User Actions in the list of available actions you can select.  Once added then from the Projects or Files View you can right-click on a file node and trigger that action for that particular file.

You can add the action to those actions available from the TopMenus you can see in Genero Studio via Preferences->User Interface->Menus.  This is what I have done with my actions to open particular directories.  I have added them to the File menu.

Similarly you can add actions so that they are available from the Toolbar via Preferences->User Interface->Toolbar.  Normally you would also attach an icon via the Icons property when you initially define the User Action, but if you don’t you will get some text in the toolbar as per the screenshots below.

Finally you can add the action so that it is triggered by certain accelerator keys.   Preferences->User Interface->Accelerators.  You know that you can use a particular set of keys and the action can be triggered.  These keys will appear in a topmenu or right-click menu to provide some indication as to what keys are available.

So if you find yourself Alt-Tabbing between Genero Studio and the command line, and you are thinking to yourself, if only I could do this from Genero Studio, chances are you can.  Look into User Actions and the various ways of triggering a User Action and execute your desired commands directly from within Genero Studio.  There are other configuration options as well, read more here,  some of which will be the subject of future Ask-Reubens.