Perforce JViews TGO Sample: Equipment Component - Basic
Description
This sample shows how to use the basic features of the Perforce JViews TGO equipment component.
How to Use the Sample
The JTGO equipment component provides multiple predefined modes of interaction. In this sample, the default behavior is to allow objects to be selected but not moved. You can select a different mode from the toolbar at the top of the screen. The following interactors are enabled in the sample:
- Select
Allows you to select all objects. To select a shelf, click close to its border. To select multiple objects, drag a rectangle around them. - Pan
Moves the contents of the view. - Zoom in
Zooms in by a specified factor. - Zoom out
Zooms out by a specified factor. - Reset zoom
Resets the zoom factor to the original setting. - Zoom back
Restores the view to the previous zoom factor. - Fit to contents
Resizes the image so that the whole content displays in the available area. - Zoom on rectangle
Zooms in on an area delimited by dragging a rectangle around it.
How to Run the Sample as an Application
This sample can
be run as an application.
The installation directory contains
an executable JAR file,
equipment-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 an equipment component
- Loading a project file containing component configuration and data source configuration
Detailed Description
This sample shows how to create a JTGO equipment component and use its basic features. The code specific to this sample is in the doSample
method of the class basic.Main. This sample includes the following steps:
- Initialize the application using the method ilog.tgo.IltSystem.Init. You can pass a deployment descriptor file to this method. The deployment descriptor contains information about global settings for the application.
In this sample, the deployment descriptor is called deploy. The deployment descriptor also contains directories to be added to the search path. These directories are necessary to locate:- the background file of the equipment in the resources directory,
- the data source file and the equipment configuration file in the data directory.
- Create an equipment component.
The equipment component is an instance of the class ilog.cpl.IlpEquipment. - 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 ilog.tgo.datasource.IltDefaultDataSource.
- The data file equipment is read containing predefined JTGO classes (business objects).
- And finally the data source is attached to the equipment component.
- Default interactor to use
For a list of available interactors, see the ilog.tgo.interactor and ilog.cpl.equipment.interactor packages. - Buttons to add to the toolbar
For a list of available buttons, see the ilog.cpl.network.action.toolbar and ilog.cpl.equipment.action.toolbar packages. - Background file to load
For a list of available background file types, see the ilog.cpl.equipment.renderer.IlpBackgroundsRenderer.
- Add the equipment to your Swing application.
IlpEquipment
is a SwingJComponent
, which means that it can be added to your application like any other Swing component.
Installation Directory
The Equipment 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.IlpEquipment
The equipment component.
-
ilog.cpl.project.IlpTGOProject
The project definition.
-
ilog.cpl.equipment.renderer.IlpBackgroundsRenderer
This class gives control over the backgrounds of an IlpEquipmentView.
Source Files
-
basic.Main
The entry point of the sample.
-
basic.AlarmPopupMenuFactory
The factory that creates the pop-up menu in the objects.
-
basic.ShowDetailsAction
The action that displays details about objects upon a double-click.