Perforce 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
When you expand or select a tree node, its children are loaded from the 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 Perforce JViews.
Then, go to the installation directory
of the sample and type:
ant run
Topics Covered
- Subclassing ilog.cpl.datasource.IlpDefaultDataSource class to support load-on-demand.
- Using ilog.cpl.model.IlpBeansObject class that implements ilog.cpl.model.IlpObject interface to wrap JavaBeans.
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
-
ilog.cpl.IlpSystem
The class that initializes a JViews TGO application.
-
ilog.cpl.datasource.IlpDefaultDataSource
The default datasource implementation.
-
ilog.cpl.datasource.structure.IlpChild
The interface which defines structural information for a business objects.
-
ilog.cpl.datasource.structure.IlpContainer
The interface which defines structural information for a business objects.
-
ilog.cpl.model.IlpBeansObject
The business object that encapsulates a JavaBean.
-
ilog.cpl.IlpTree
The JViews TGO Tree component.
-
ilog.cpl.IlpTable
The JViews TGO Table component.
Source Files
-
datasource.explorer.Main
The entry point of the sample.
-
datasource.explorer.FileDataSource
The datasource custom implementation.
-
datasource.explorer.OriginFilter
The filter that specifies which objects are displayed in the Table view.