mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-05 08:05:24 +02:00

Get rid of etools references. The tutorial still requires some work since it is hard to update from the code. All highlighting and anchor creation is done by hand, as are the differences from step to step.
88 lines
4.7 KiB
HTML
Executable file
88 lines
4.7 KiB
HTML
Executable file
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
|
|
<html>
|
|
|
|
<head>
|
|
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=UTF-8">
|
|
<META HTTP-EQUIV="Content-Style-Type" CONTENT="text/css">
|
|
<meta name="copyright" content="Copyright (c) IBM Corporation and others 2002, 2006. This page is made available under license. For full details see the LEGAL in the documentation book that contains this page." >
|
|
<LINK REL="STYLESHEET" HREF="../../book.css" TYPE="text/css">
|
|
<title>Creating a Remote Resource Popup Menu Action</title>
|
|
</head>
|
|
|
|
<body bgcolor="#ffffff">
|
|
<h1>Creating a Remote Resource pop-up Menu Action</h1>
|
|
<p>In this tutorial, you will use the RSE <A href="../plugin/popup.html">pop-up menus
|
|
extension point</A> to
|
|
create a pop-up menu action that will appear
|
|
in the context menu for any <samp>.jar</samp> file, for any connection to
|
|
any system type. The action will be labeled "Show contents" and will simply
|
|
run the <samp>jar -tvf</samp> 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.
|
|
</p>
|
|
|
|
<p><b>Tip:</b> If you prefer your Java code to use lined-up braces, select the
|
|
first two options in the <b><A href="preferences_JavaFormatting.gif">Code
|
|
Formatter</A></b> preferences page for <b>Java</b>, via <b>Windows->Preferences</b>.
|
|
|
|
This will affect code generated by wizards. The source code shown assumes this option has been set, but this is not required.
|
|
|
|
<h2>Step-by-Step: Creating an RSE Remote Resource Pop-up Menu Action</h2>
|
|
|
|
<ol>
|
|
<li>If you have not already, first <a href="pdeProject.html">create or prepare a plugin project</a>.
|
|
</li>
|
|
<li>Open the <b>plugin.xml</b> file for editing by right-clicking on it and selecting
|
|
<b>Open With->Text Editor</b>. Before the ending </plugin> statement, add the following lines:
|
|
<pre><code>
|
|
<!-- ======================================= -->
|
|
<!-- Remote Object Popup Menu Actions -->
|
|
<!-- ======================================= -->
|
|
<extension point="org.eclipse.rse.ui.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>
|
|
</code></pre>
|
|
Save and close the file.
|
|
</li>
|
|
<li>
|
|
Create the Java package: right-click on the <B>src</B> source folder and select <B>New->Package</B> to open the <B>New
|
|
Java Package</B> wizard. Enter <B>"samples.ui.actions"</B> for the name of the package and press <B>Finish</B>.</li>
|
|
<li>
|
|
Create the Java class: right-click on the new <B>"samples.ui.actions"</B> package folder and select <B>New->Class</B> to open the <B>New
|
|
Java Class</B> wizard. Enter <B>"ShowJarContents"</B> for the <b>Name</b>
|
|
and <b>"org.eclipse.rse.files.ui.actions.SystemAbstractRemoteFilePopupMenuExtensionAction"</b>
|
|
for the <b>Superclass</b>. Select the <b>Constructors from superclass</b> check box, as shown
|
|
<A href="popup_newClass.gif">here</A>.
|
|
Press <b>Finish</b> to create the <samp><a href="ShowJarContents1.html">ShowJarContents</a></samp> class.
|
|
</li>
|
|
<li>Edit the generated <samp>ShowJarContents.java</samp> file as follows:
|
|
<ol>
|
|
<li type="i">Add import statement for <samp><b>import com.ibm.etools.systems.subsystems.*;</b></samp></li>
|
|
<li type="i">Add the following three statements to the body of the <samp>run()</samp> method:</li>
|
|
<pre><code>
|
|
IRemoteFile selectedFile = getFirstSelectedRemoteFile();
|
|
String cmdToRun = "jar -tvf " + selectedFile.getAbsolutePath();
|
|
runCommand(cmdToRun);
|
|
</code></pre>
|
|
</ol>
|
|
The final result after editing is shown <a href="ShowJarContents2.html">here</a>.
|
|
</li>
|
|
</ol>
|
|
|
|
<p>Thats it! Now, you can try your new action. Use <b>Run->Run As->Run-time Workbench</b>. Drill
|
|
down in the RSE to a Jar file in a local or remote connection and right-click to <a href="popup_see.gif">see</a> and <a href="popup_run.gif">run</a> 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.
|
|
</body>
|
|
</html>
|