| <!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 Property Page</title> |
| </head> |
| |
| <body bgcolor="#ffffff"> |
| <h1>Creating a Remote Resource Property Page</h1> |
| <p>In this tutorial, you will use the |
| <samp><A href="../plugin/propertypage.html">org.eclipse.ui.propertyPages</a></samp> |
| extension point to |
| create a <a href="propertypage_run_done.gif">property page</a> that will appear |
| in the Properties dialog for any folder, for any connection to |
| any system type. The page will be labeled "Folder Contents" and will show the |
| cumulative size of the contents of the folder, and the number of folders and files within it. |
| This will show the extension point, plus how to use some of the RSE user interface helpers, as well |
| as the remote file API for querying information about remote folders and files. |
| </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 a Remote Resource Property Page</h2> |
| <ol> |
| <li>If you have not already, first <a href="pdeProject.html">create or prepare a plugin project</a>. |
| |
| 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 Property Pages --> |
| <!-- ======================================= --> |
| <extension point="org.eclipse.ui.propertyPages"> |
| <page name="Folder Contents" |
| class="samples.ui.propertypages.FolderInfoPropertyPage" |
| id="samples.ui.PropertyPage1"> |
| <enabledWhen> |
| <instanceof value="org.eclipse.rse.subsystems.files.core.subsystems.IRemoteFile"/> |
| </enabledWhen> |
| <filter name="isDirectory" value="true"/> |
| </page> |
| </extension> |
| </code></pre></li> |
| <li>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 get the <B>New |
| Java Package</B> wizard. Enter <B>"samples.ui.propertypages"</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.propertypages"</B> package folder and select <B>New->Class</B> to open the <B>New |
| Java Class</B> wizard. Enter <B>"FolderInfoPropertyPage"</B> for the <b>Name</b> |
| and <b>"org.eclipse.rse.files.ui.propertypages.SystemAbstractRemoteFilePropertyPageExtensionAction"</b> |
| for the <b>Superclass</b>. Select the <b>Constructors from superclass</b> check box, as shown |
| <A href="propertypage_newClass.gif">here</A>. |
| Press <b>Finish</b> to create the <samp><a href="FolderInfoPropertyPage1.html">FolderInfoPropertyPage</a></samp> class. |
| </li> |
| <li>Edit the <samp>FolderInfoPropertyPage</samp> class to look like <A href="FolderInfoPropertyPage2.html">this</A>. There are many changes, so you should use |
| the clipboard to copy and paste. |
| </li> |
| <li>Edit the <samp>rseSamplesMesssage.xml</samp> file to look like <A href="rseSamplesMessages2.html">this</A>, where the changes are highlighted. |
| </li> |
| <li>Edit the <samp>rseSamplesResources.properties</samp> file to look like <A href="rseSamplesResources2.html">this</A>. |
| </li> |
| </ol> |
| |
| <p>Thats it! Now, you can try out your new property page. Use <b>Run->Run As->Run-time Workbench</b>. Drill |
| down in the RSE to a folder in a local or remote connection and right-click to <a href="propertypage_see.gif">see</a> |
| and <a href="propertypage_run_during.gif">run</a> your new property page. This sample is a unique case, in that this operation could potentially run for a long time, as you are recursively walking all |
| the sub-folders and files to accumulate the size and count information. Because of this, we put this work |
| in a background thread, and update the GUI as each sub-folder is processed. We also supply a stop button |
| to the user and watch for them pressing Cancel or closing the dialog. When the thread ends, the |
| result looks like <a href="propertypage_run_done.gif">this</a>. |
| <p>Notice how this property page only appears for folders, due to the <b><samp><filter name="isDirectory></samp></b> markup |
| in our extension point xml. |
| </body> |
| </html> |