Follow Techotopia on Twitter

On-line Guides
All Guides
eBook Store
iOS / Android
Linux for Beginners
Office Productivity
Linux Installation
Linux Security
Linux Utilities
Linux Virtualization
Linux Kernel
System/Network Admin
Programming
Scripting Languages
Development Tools
Web Development
GUI Toolkits/Desktop
Databases
Mail Systems
openSolaris
Eclipse Documentation
Techotopia.com
Virtuatopia.com

How To Guides
Virtualization
General System Admin
Linux Security
Linux Filesystems
Web Servers
Graphics & Desktop
PC Hardware
Windows
Problem Solutions
Privacy Policy

  




 

 

Eclipse RSE Development Guide
Previous Page Home Next Page

Creating a Remote Resource Property Page

In this tutorial, you will use the org.eclipse.ui.propertyPages extension point to create a property page 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.

Tip: If you prefer your Java code to use lined-up braces, select the first two options in the CodeFormatter 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 a Remote Resource Property Page

  1. If you have not already, first create or prepare a plugin project. 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 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>    
    
    
  2. Save and close the file.
  3. Create the Java package: right-click on the src source folder and select New->Package to get the New Java Package wizard. Enter "samples.ui.propertypages" for the name of the package and press Finish.
  4. Create the Java class: right-click on the new "samples.ui.propertypages" package folder and select New->Class to open the New Java Class wizard. Enter "FolderInfoPropertyPage" for the Name and "org.eclipse.rse.files.ui.propertypages.SystemAbstractRemoteFilePropertyPageExtensionAction" for the Superclass. Select the Constructors from superclass check box, as shown here. Press Finish to create the FolderInfoPropertyPage class.
  5. Edit the FolderInfoPropertyPage class to look like this. There are many changes, so you should use the clipboard to copy and paste.
  6. Edit the rseSamplesMesssage.xml file to look like this, where the changes are highlighted.
  7. Edit the rseSamplesResources.properties file to look like this.

Thats it! Now, you can try out your new property page. Use Run->Run As->Run-time Workbench. Drill down in the RSE to a folder in a local or remote connection and right-click to see and run 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 this.

Notice how this property page only appears for folders, due to the <filter name="isDirectory> markup in our extension point xml.


 
 
  Published under the terms of the Eclipse Public License Version 1.0 ("EPL") Design by Interspire