UI Design Elements - pc2ccs/pc2v9 GitHub Wiki

Overview

The overall design of PC2 is intended to support a consistent and flexible User Interface (UI) organization. Included in this approach are implementation features designed to make it easy to re-use various UI components in a variety of different settings.

For example, PC2 includes a user interface for generating Reports. This UI might need to be available via the PC2 Server, the PC2 Admin, and through various other user interfaces. Similarly, PC2 includes a user interface for managing "contest time" -- the ability to start/stop the contest clock, edit time-related values such as the Contest Scheduled Start Time, and perform similar contest time-related functions. This "Time" interface might need to be accessible from the PC2 Server, the PC2 Admin, and possibly via other PC2 clients (for example, a Chief Judge).

To support the ability to display various PC2 UI components in different settings, most PC2 UI components are defined as Java classes which extend the PC2 class JPanePlugin. JPanePlugin is a class which extends javax.swing.JPanel, and can therefore be used wherever a JPanel can be used. JPanePlugin provides a number of services needed by UI components.

The above-mentioned "time management" UI, for example, is implemented by class ui.ContestTimesPane, which extends JPanePlugin. This makes it easy to add a ContestTimesPane to the PC2 Server UI, the PC2 Admin UI, and to any other UI in which it is desired to provide a time management interface.

JPanePlugin Details

In addition to extending javax.swing.JPanel (and therefore being able to to be used wherever a JPanel can be used), JPanePlugin provides a number of PC2-specific functions. For example, it is common for a PC2 UI class to need access to the current "contest model" (that is, to the current implementation of pc2.core.model.IInternalContest), and/or to the current "contest controller" (i.e., the current implementation of pc2.core.model.IInternalController).

JPanePlugin provides for access to these elements by implementing interface UIPlugin, which specifies method setContestAndController(). Any subclass of JPanePlugin therefore contains an implementation of setContestAndController(), which the PC2 component creating a JPanePlugin can invoke to provide the JPanePlugin subclass with access to the contest model and contest controller.

JPanePlugin also provides a variety of additional capabilities, including the ability to determine whether the current module is a PC2 Server; the ability to set and get the frame in which the JPanePlugin is embedded; the ability to display message dialogs to the user; and the ability to display developer-specific details. See the JPanePlugin source code for details on these and other features.

JPanePlugin Usage Examples

For examples of the use of the JPanePlugin class in PC2, see the following: