Perforce JViews TGO Sample: Table Component - Basic
Description
This sample shows how to use the basic features of the Perforce JViews TGO table component.
How to Use the Sample
- To select a row, click anywhere inside one of its cells. Use the
Shift
key to select several adjacent rows orCtrl
to select individual rows. - To move a column, click its header and drag it to a new location. To resize it, click the separator between two columns in the header and drag it left or right.
- The table also allows you to sort the rows based on the contents of one or more columns. To do so, click a column header; an indicator of the sort order will appear. Clicking again inverts the order, clicking a third time removes the indicator.
-
The data can also be sorted based on more than one column. To add a column to refine the sort, use the
Shift
key and click the column header. Note that an indicator of the priority appears in the column header, and that the first column selected has the highest priority. You can sort on as many columns as you want. If multiple columns are sorted, you should shift-click the header to change the sort order for a column. - To replace the current sort order with a new one, click any column header.
How to Run the Sample as an Application
This sample can
be run as an application.
The installation directory contains
an executable JAR file,
table-basic.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
- Initializing a JTGO application.
- Creating a table component.
- Setting the business class accepted by the component.
- Setting the project configuration.
- Adding the table to your Swing application.
Detailed Description
This sample shows how to create and use a JTGO table component and use its basic features. The specific code of this sample is in the doSample method of basic.Main. It contains the following steps:
-
Initialize the application using the method ilog.cpl.IlpSystem.Init.
You can pass the name of a deployment descriptor file to this method, but in this sample you do not need one. -
Create a table component.
The table component is of the class ilog.cpl.IlpTable, a JavaBean with a default constructor. -
Specify which business class will be displayed by the table component using the the
ilog.cpl.IlpTable.setAcceptedClass method.
In this case, we initially show instances of IltNetworkElement. However, the sample provides a combo box to change the class of objects displayed. -
Create a combo box to change the class displayed.
The combo box and its listener are standard Swing components. When triggered, the listener will call the ilog.cpl.IlpTable.setAcceptedClass method of the table component to show instances of a different class. -
Load a project configuration (project) from an XML file.
The project configuration defines the component configuration files (CSS files) and the data source information. When the project file is set, the following steps are performed: - The configuration files are applied to the component.
- A data source is created according to the class specified in the project configuration. In this case, it creates a standard data source of class IltDefaultDataSource.
- The data file network is read containing predefined JTGO classes (business objects).
- And finally the data source is attached to the component.
- View configuration
- Interactor configuration
- Table header configuration
- Table cell configuration
-
Add the table to your Swing application.
IlpTable
is a SwingJComponent
, so it can be added to your application like any other Swing component.
Installation Directory
The Table Component - Basic sample is installed here.
Classes Involved
-
ilog.tgo.IltSystem
The class that initializes a JViews TGO application.
-
ilog.tgo.datasource.IltDefaultDataSource
The default data source implementation.
-
ilog.cpl.IlpTable
The table component.
-
ilog.cpl.project.IlpTGOProject
The project definition.
-
ilog.cpl.model.IlpAttribute
The business attribute definition.
-
ilog.cpl.table.selection.IlpTableSelectionMode
The table component selection mode definition.
-
ilog.cpl.table.IlpTableResizeMode
The table component resize mode definition.
Source Files
-
basic.Main
The entry point of the sample.
-
basic.AlarmPopupMenuFactory
The factory that creates pop-up menus for the objects.
-
basic.ShowDetailsAction
The action that displays object details upon a double-click.