Perforce JViews TGO Sample: Tree Component - Basic


Description

This sample shows how to use the basic features of the Perforce JViews TGO tree component.

How to Use the Sample

The sample shows a basic tree, with a few nodes representing network elements and the shelves, cards, ports, and LEDs they contain. The sample illustrates the representation of predefined JTGO business objects in the tree component, as well as the basic features provided by the tree.

The tree supports standard interaction for expanding and collapsing nodes, as well as multiple selection. Click a node to select it. Use the Shift key to select several adjacent nodes or Ctrl to select individual nodes. You will see the names of the selected nodes appear in the 'Current selection' area at the bottom of the screen. The JTGO tree component has two representations for selection: Highlight and Checkbox. To switch between the two modes use the 'Selection mode' list in the lower part of the sample window.

The sample also shows how to define custom behavior. Double-clicking any tree node shows a small dialog with some information about the associated business object. Right-clicking any node displays a contextual pop-up menu that allows you to set the selected nodes as roots of the tree. To reset the tree to its original state, right-click outside any node and select 'Reset root nodes' from the pop-up menu.

Using the 'Filter pattern' text field in the lower part of the window you can apply a simple filter to the tree. Type a text into the field, press Return, and only the nodes with names containing the given pattern are displayed. Note that a node will only be shown if its parent is also shown. Using '1' or '2' as the pattern gives the best results in this sample.

Finally, the sample shows how the look of the predefined business objects and the tree component can be customized by style sheets. You can select from a number of predefined style sheet files (each of which change a single aspect of the representation) using the 'Style sheet' list in the lower part of the screen.

How to Run the Sample as an Application

This sample can be run as an application. The installation directory contains an executable JAR file, tree-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

Detailed Description

This sample shows how to create a JTGO tree 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:

Installation Directory

The Tree Component - Basic sample is installed here.

Classes Involved

Source Files

Copyright © 2021 Rogue Wave Software, Inc., a Perforce company. All rights reserved. Legal terms.