Rogue Wave JViews TGO Sample: Data Source - JavaBeans


Description

This sample shows how implement a custom data source that loads directories on demand.

How to Use the Sample

The main frame is similar to a file explorer: it contains a tree on the left, and a table on the right. The tree shows the file hierarchy. It allows you to select and expand tree nodes. The table shows the contents of the directory selected in the tree.

When you expand or select a tree node, its children are loaded from the file system.

This sample does not work as an applet, as it accesses the local file system.

All available drives will be accessed, including floppy drives. If you do not have a floppy inserted, the drive will be ignored. Files that cannot be read by the application are not listed in the table and tree components.

How to Run the Sample as an Application

This sample can be run as an application. The installation directory contains an executable JAR file, datasource-explorer.jar, that allows you to execute the sample with a double click from a file browser. Note that if you are using Internet Explorer, you can open the installation directory and execute the JAR file from the browser. This technique may not work in other Web browsers.

Alternatively, you can run the sample application from the command line. First check that the Ant utility is properly configured. If not, see the instructions on how to configure Ant for Rogue Wave JViews.

Then, go to the installation directory of the sample and type:

ant run

Topics Covered

Detailed Description

This sample shows how to extend a ilog.cpl.datasource.IlpDefaultDataSource to implement a custom data source in order to work with the java.io.File class, and load on demand the contents of directories. In this sample, the java.io.File class is considered as JavaBeans. The tree and table work like a regular file explorer.

The code of the custom data source is defined in the FileDataSource class. This data source implementation first initializes the file system root objects as ilog.cpl.model.IlpObject instances. Then, to support load-on-demand, it redefines the method ilog.cpl.datasource.IlpDefaultDataSource.getContainerInterface to return its own implementation of the ilog.cpl.datasource.structure.IlpContainer interface for a directory. As this implementation does not store the containment relationship of files and directories, the ilog.cpl.datasource.IlpDefaultDataSource.getChildInterface method is also redefined to return a custom implementation of the ilog.cpl.datasource.structure.IlpChild interface for files.

Installation Directory

The Data Source - JavaBeans sample is installed here.

Classes Involved

Source Files

Copyright © Rogue Wave Software, Inc. 1997, 2015. All rights reserved. Legal terms.