Software

JCTable, LiveTable, and Data Sources

JClass LiveTable is a Java GUI component that displays rows and columns of user-interactive text, images, hypertext links, and other Java components in a scrollable window. The component creates a table-formatted view of a given set of data and can come from a variety of different source types. LiveTable is used as part of a Model-View-Controller (MVC) architecture for data handling, a software design pattern that separates out the concerns of storing/managing data (model) and its display (view) as well as the accepting of inputs (controller). 

The data in the table cells is stored in an external data source that you create, rather than the JCTable object itself. With LiveTable’s MVC architecture, the data source object is the Model, which manages the underlying data being displayed and manipulated. The JCTable object acts as both the view (the object displaying the data to the user) and the controller (the object that manipulates and modifies the data).

Between the JCTable object and the data source lies an object that implements the DataViewModel and/or the SortableDataViewModel. The default implementation in the table is a TableDataView. While most developers will never have to work with it directly, it’s important to realize that the TableDataView monitors the data source for changes and notifies the JCTable object when they occur. Additionally, the TableDataView has a set of translation tables that allow it to re-map rows or columns from the data source to the table. This is how JClass LiveTable can support features like column sorting and row or column swapping, where the appearance of the table changes, without manipulating the data source itself. 

Getting Your Data Into JCTable

Because the JCTable object and the data source are separated, you are able to use whatever data storage mechanism required — JCTable object is agnostic as to where the data comes from. JClass LiveTable includes several stock data sources to save you the work of writing data sources for the most common data types. 

One of the most basic data types is the JCVectorDataSource, which simply stores its data in memory using vectors. The JCVectorDataSource class contains methods that allow you to set individual elements, or to set all the data in the data source from a vector or an array of objects. 

Since JCVectorDataSource implements TableDataModel, it can’t be edited by the JCTable object. If you want users to be able to edit the cell values through the table, you should use JCEditableVectorDataSource. The JCEditableVectorDataSource class is a subclass of JCVectorDataSource that implements the EditableTableDataModel interface model.

Additional data sources include JCInputStreamDataSource, a base class for any data source that relies on streamed input that can handle comma-separated value (CSV) data files, JCFileDataSource (which creates an input data stream from a file), JCResultSetDataSource (a simple read-only source that reads from databases using JDBC), and JCURLDataSource (which uses URLs to create a data source object). There is also support for XML data source — you can create a custom data format and create an interpreter to support it — or you can use a built-in specification.

If the stock data sources provided with JClass LiveTable do not meet your needs, you can create your own data source objects by implementing the TableDataModel interface.

Dynamically Updating Data from the Source

JClass LiveTable supports updating the data displayed in the table when the underlying data source changes independent of the application hosting it — for example, you may have a table displaying stock market prices with data arriving in real–time over a network socket. As new prices arrive, the table will be able to update the values of the appropriate cells. These updates are done by sending events to listener objects that have registered themselves with the data source. When the JCTable object receives messages it retrieves the new value from the data source and repaints the appropriate cell.

There are a number of update commands available, including the changes to the value of individual cells, rows, and columns. Moreover, there are options to add, remove, or move rows or columns. Alternatively, there is a “reset” option to make the JCTable object re-initialize itself by re-reading the number of rows, number of columns and the data from the data source.

Updating the Underlying Data

In addition to updating the contents displayed in the table, JCTable allows users interacting directly with the table to update the data of the underlying data source. Among the stock data sources, JCEditableCachedDataSource, JCEditableFileDataSource, and JCEditableVectorDataSource provide implementations that allow programs to handle those updates, thereby allowing end users to edit cell values and have that reflected in the data source. Client applications can create their implementations of the EditableTableDataModel interface by implementing the method SetTableDataItem.

JTable and Performance

Using this MVC architecture improves the performance of JClass LiveTable programs by removing the need to load all the table’s data into memory, then copy it to the JCTable object. Only the data that is currently displayed by the JCTable object is copied from the data source. An external data source can manage large sets of data more efficiently than the JCTable object can, providing for a dynamic end user experience for a large data set.

Upgrade to Scout Solutions JClass LiveTable 

For a limited time, Scout Solutions is offering a free upgrade to our new and improved JClass software for current Quest JClass customers. With the purchase of a new support agreement, you will receive access to our dedicated expert JClass Support team who can solve technical issues and answer questions. Save yourself the trouble of upgrading to a new software and upgrade your current version of JClass LiveTableClaim your free upgrade and get access to our new version of JClass!

Tag:

Leave a Comment

Subscribe

Subscribe our newsletter to stay updated every moment