Perforce JViews TGO Sample: TGO-SDM Adapter - Converter
Description
This sample shows how to use the TGO-SDM Adapter to convert a JViews TGO XML file into a JViews SDM XML file.
How to Use the Sample
In the center of the frame, you can see the JViews TGO view (to the left) and the JViews Diagrammer view (to the right)
with their corresponding interactive menus.
File
: Provides commands to open a JViews TGO XML file and save the corresponding JViews
Diagrammer XML file. Also provides commands to load styling data (CSS file) for JViews TGO and
JViews Diagrammer, and to exit the application.
Open TGO XML File
: Opens the JViews TGO XML input file to be converted to an SDM XML file.
Open TGO CSS File
: Opens a JViews TGO styling file (CSS) to be applied to the
displayed JViews TGO objects.
Open Diagrammer CSS File
: Opens a JViews Diagrammer styling file (CSS) to be applied
to the displayed JViews Diagrammer objects.
Save Diagrammer XML File
: Saves a business data file to JViews Diagrammer XML format.
This file can then be imported in the Wizard of the Designer for JViews Diagrammer.
Help
: Provides additional information about this sample.
About
: Opens a splash image with licensing and other details about the sample.
File > Open TGO XML File
. The network and
diagram views are updated with corresponding data.
File > Open TGO CSS File
. The parsed
CSS file is applied to the JViews TGO network view.
File > Open Diagrammer CSS File
.
The parsed CSS file is applied to the diagram view.
File > Save Diagrammer XML
File
. The displayed diagram view is stored in JViews Diagrammer XML format.
diagrammer-sphere-palette.jar
(located in
the data
directory). Both files were created with the Designer for JViews Diagrammer tool.
How to Run the Sample as an Application
This sample can
be run as an application.
The installation directory contains
an executable JAR file,
tgosdmadapter-converter.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 Perforce JViews TGO application using a deployment descriptor
- Initializing and configuring the TGO-SDM Adapter module
- Associating a JViews TGO data source with the TGO-SDM Adapter module
- Creating network and diagram components
- Loading and applying styling to network and diagram components
- Reading and writing XML files
Detailed Description
This sample illustrates how to use the TGO-SDM Adapter (ilog.cpl.sdm.IlpDefaultSDMAdapter)
to convert business data (ilog.cpl.model.IlpObject) from a JViews TGO data source
(ilog.cpl.datasource.IlpDataSource) to a JViews Diagrammer model
(ilog.views.sdm.IlvSDMModel). When the data is in JViews Diagrammer format, it can be stored
in a JViews Diagrammer XML file to be imported in a JViews Diagrammer application, such as the JViews Diagrammer
Designer.
For the sake of simplicity, the main class converter.Main is responsible for building the GUI, handling
file access (opening and saving XML and CSS files), as well as managing the JViews TGO data source to JViews Diagrammer
model conversion. Some key methods are:
-
doSample(java.awt.Container)
: Entry point to assemble the UI and trigger the routines to load the default files and to perform the initial model conversion. -
reloadCSSStyles()
: Method responsible for loading the assigned JViews TGO and JViews Diagrammer CSS files and applying them to the corresponding components. -
reloadBusinessObjects()
: Method responsible for loading the assigned JViews TGO XML file and applying it to the appropriate JViews TGO data sources (one for the JViews TGO view and one for the JViews Diagrammer view).
The TGO-SDM Adapter is designed to map the JViews TGO data source hierarchy (parent-child relationships, link connectivity, for example) as well as the binding between the JViews TGO attributes (ilog.cpl.model.IlpAttribute) and the JViews Diagrammer SDM properties (ilog.views.sdm.IlvSDMModel.getObjectProperty).
The attribute binding is defined by an interface, converter.BindingSupport, that can be extended to provide customized binding between JViews TGO attributes and SDM properties. The default implementation (converter.util.DefaultAttributeBinding) only applies the standard binding that is available through ilog.cpl.sdm.IlpDefaultSDMAdapter.addDefaultBindings.
To be able to load and convert custom JViews TGO business data, the user must either modify the JViews TGO deployment descriptor file (deploy.xml) to parse the custom JViews TGO class declarations (ilog.cpl.model.IlpClass), or make sure that the class declaration is properly embedded in the JViews TGO XML file being parsed.
This sample is supported by the following data files:
- network.xml: Contains basic business data in JViews TGO data source format. This file is loaded by default.
- network.css: Contains JViews TGO styling definitions. This file is loaded by default.
- diagrammer.css: Contains basic JViews Diagrammer styling definitions. This file is loaded by default.
- diagrammer-sphere.css: Contains other JViews Diagrammer styling definitions. This file must be loaded manually by the user.
-
diagrammer-sphere-palette.jar
: Defines the specific symbol palette that is used by the diagrammer-sphere.css styling definitions.
Installation Directory
The TGO-SDM Adapter - Converter sample is installed here.
Classes Involved
-
ilog.tgo.IltSystem
The class that initializes a JViews TGO application.
-
ilog.cpl.sdm.IlpDefaultSDMAdapter
The default TGO-SDM Adapter implementation.
-
ilog.tgo.datasource.IltDefaultDataSource
The default JViews TGO data source implementation.
-
ilog.views.sdm.IlvSDMModel
The JViews Diagrammer model interface.
-
ilog.cpl.IlpNetwork
The JViews TGO Network component.
-
ilog.views.diagrammer.IlvDiagrammer
The JViews Diagrammer component.
Source Files
-
converter.Main
The entry point of the sample.
-
converter.BindingSupport
The interface that defines how JViews TGO attributes are converted to JViews Diagrammer properties by the TGO-SDM Adapter.
-
converter.util.DefaultAttributeBinding
The default implementation for the
converter.BindingSupport
interface. -
converter.util.FileChooserFilter
Support implementation to be used with
java.swing.JFileChooser
.