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 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.
<!-- ======================================= -->
<!-- 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>
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.