Perforce JViews TGO Sample: Table Component - Alarm
Description
This sample shows how to use alarm objects with the Perforce JViews TGO table component.
How to Use the Sample
Both raw alarms and impact alarms are used in this sample. Each type of alarm has a distinguished set of severities and
graphical representation.
Managed Object Instance
name. You can also see the list of selected alarms in
the Current selection
field.
- To acknowledge an alarm, click any of its cells with the right mouse button to display the pop-up menu associated with the alarm object, and select Acknowledge. The alarm will be acknowledged, and the acknowledged time, acknowledged user and acknowledged system will be set.
- To display the information of an alarm in a separate dialog, double-click on a table row.
- To display hidden attributes or hide visible attributes, right-click in the table column headers and select the appropriate options in the contextual menu.
-
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 an additional 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-alarm.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
-
Basic initialization.
See the table/basic sample for details. - Declaring predefined business object for alarms in XML.
- Setting a date format for alarm date attributes using cascading style sheets.
Detailed Description
This sample shows how to create and use a JTGO table component with predefined alarm objects. The specific code of this sample is in the doSample method of alarm.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.
- Create a standard data source of class ilog.tgo.datasource.IltDefaultDataSource.
-
Create a table component.
The table component is of the class ilog.cpl.IlpTable, a JavaBean with a default constructor. -
Attach the table component to the data source using the
ilog.cpl.IlpTable.setDataSource method.
Because a data source may contain many objects of different classes, this method takes as a second argument the class to display. In this case, the table will display predefined alarm objects, which are instances of the business class ilog.tgo.model.IltAlarm. -
Set styling information by loading cascading style sheets.
The data file table is read using the ilog.cpl.IlpTable.setStyleSheets method. The styling information sets the following characteristics on the given table component: - Table view properties, such as grid visibility, auto-resize mode and selection mode.
- Table controller properties, such as view and header interactors.
- Table columns, such as the preferred width and the label column in the Table Header.
- Table cell properties, such as labels, tooltips and icons.
-
Create a text field to filter the list of alarms displayed in the table.
The text field and its listener are standard Swing components. When triggered, the listener will call the setFilter method of the table component to apply a filter to the current table contents. -
Read a data file into the data source.
The data file alarm is read using the ilog.cpl.datasource.IlpDefaultDataSource.parse method. The file contains instances of the JTGO predefined alarm classe: ilog.tgo.model.IltAlarm. - Add the table to your Swing application. IlpTable is a Swing JComponent, so it can be added to your application like any other Swing component.
Installation Directory
The Table Component - Alarm sample is installed here.
Classes Involved
-
ilog.tgo.IltSystem
The class that initializes a JViews TGO application.
-
ilog.tgo.datasource.IltDefaultDataSource
The default datasource implementation.
-
ilog.cpl.IlpTable
The table component.
-
ilog.tgo.model.IltAlarm
The alarm business object.
-
ilog.cpl.table.IlpTableResizeMode
The table component resize mode definition.
-
ilog.cpl.table.interactor.IlpDefaultTableViewInteractor
The default table view interactor implementation.
-
ilog.cpl.table.interactor.IlpDefaultTableHeaderInteractor
The default table header interactor implementation.
-
ilog.cpl.table.IlpDefaultTableHeaderMenuFactory
The factory that creates a pop-up menu for the table header.
-
ilog.cpl.table.selection.IlpTableSelectionMode
The table component selection mode definition.
-
ilog.cpl.interactor.IlpGestureAction
The action that is associated with a gesture in an interactor.
Source Files
-
alarm.Main
The entry point of the sample.
-
alarm.AlarmPopupMenuFactory
The factory that creates the pop-up menu for the alarm objects.
-
alarm.ShowDetailsAction
The action to display object details upon double-click.