# Creating a Remote Resource Popup Menu Action

# Creating a Remote Resource pop-up Menu Action

In this tutorial, you will use the RSE pop-up menus extension point to create a pop-up menu action that will appear in the context menu for any `.jar` file, for any connection to any system type. The action will be labeled "Show contents" and will simply run the `jar -tvf` JDK command when selected, displaying the results in the command console. You could expand this example to copy the file to a local temporary folder, extract the list of file names within the jar, and display those names in an Eclipse table view.

Tip: If you prefer your Java code to use lined-up braces, select the first two options in the Code Formatter preferences page for Java, via Windows->Preferences. This will affect code generated by wizards. The source code shown assumes this option has been set, but this is not required.

## Step-by-Step: Creating an RSE Remote Resource Pop-up Menu Action

1. If you have not already, first create or prepare a plugin project.
2. Open the plugin.xml file for editing by right-clicking on it and selecting Open With->Text Editor. Before the ending </plugin> statement, add the following lines:

          <!-- ======================================= -->
          <!-- Remote Object Popup Menu Actions        -->
          <!-- ======================================= -->
          <extension point="com.ibm.etools.systems.core.popupMenus">
             <objectContribution id="actions.jar"
                                 typecategoryfilter="files"
                                 typefilter="file"
                                 namefilter="*.jar">
                  <action id="actions.jar.show"
                          enablesFor="1"
                          label="Show contents"
                          tooltip="List contents of this file"
                          class="samples.ui.actions.ShowJarContents">
                  </action>
              </objectContribution>
           </extension>

   Save and close the file.
3. Create the Java package: right-click on the src source folder and select New->Package to open the New Java Package wizard. Enter "samples.ui.actions" for the name of the package and press Finish.
4. Create the Java class: right-click on the new "samples.ui.actions" package folder and select New->Class to open the New Java Class wizard. Enter "ShowJarContents" for the Name and "com.ibm.etools.systems.core.ui.actions.SystemAbstractRemoteFilePopupMenuExtensionAction" for the Superclass. Select the Constructors from superclass check box, as shown here. Press Finish to create the `ShowJarContents` class.
5. Edit the generated `ShowJarContents.java` file as follows:
   1. Add import statement for `import com.ibm.etools.systems.subsystems.*;`
   2. Add the following three statements to the body of the `run()` method:

       		IRemoteFile selectedFile = getFirstSelectedRemoteFile();
       		String cmdToRun = "jar -tvf " + selectedFile.getAbsolutePath();
       		runCommand(cmdToRun);

   The final result after editing is shown here.

Thats it! Now, you can try your new action. Use Run->Run As->Run-time Workbench. Drill down in the RSE to a Jar file in a local or remote connection and right-click to see and run your new action. Notice how it does not appear for files that do not end with the ".jar" extension. This is because of the "namefilter" attribute in our extension point .xml file.