Historical data

Historical data

The goal is to provide inspectIT with the functionality to select a timeframe for which graphical data will be displayed. This feature must be provided by the GUI (and supported by the CMR).

  • There are two main tasks to achieve this; first, a new SWT container must be added to the inspectIT GUI. By using this new element users will be able to set the period of time whose data will be displayed in the Graph.
  • A new procedure to fetch the historical information from the inspectIT database must be set in place, as a basis for the new GUI functionality.

The proposed element will look like the following:
To avoid panel saturation, the new "Details Pane" will be implemented as a collapsable section thus enabling the user to modify the parameters without sacrificing viewable area. The "Zeitraum" or "Timeframe" section depicted in the figure refers to the area where the first time controls reside; with these controls, the user can select the amount of days, hours and minutes that will be fetched from the database and displayed in the graphs. One implementation option for these three elements is the "spinner" widget of the SWT framework.

In the "bis" section, users will be able to select the sample's end date and time. There are two, mutually exclusive, options for this:

  • Live: This means that the graphs will be continuously updated as new information is entered into the database; Implemented via a SWT.CHECK button.
  • Calendar: By using the calendar control, users will select a specific end date and time for the time frame; the calendar will appear inside a popup window after clicking the correspondent button. This feature will be implemented using an element of type DateTime from the SWT classes.

More information about the SWT widgets can be found here

Implementation

As proposed before, the implementation of this new feature was divided in two steps:*Graphical elements creation *Controller classes implementation

Step 1: Graphical Elements implementation

Regarding the graphical elements implementation the main class to deal with is the SensorTypeViewController class from the de.novatec.novaspy.rcp.editor.graph packet in the inspectIT project.

It is this class the one in charge of handling the presentation of the right hand section of the inspectIT; more specifically the relevant entry point for the implementation of this new functionality was the !createPartControl method.

Before the expandable section was added to the GUI, the container hierarchy on the GUI was somehow the following:

  • inspectIT GUI
    • Parent Composite
      • JFreeChart

and as part of the requirements this new hierarchy was proposed:

  • inspectIT GUI
    • (grand)Parent Composite
      • Parent Composite
        • ChartParent
          • JFreeChart
        • DetailsPane

The new hierarchy was implemented as follows: The existing "parent" composite was renamed to "grandParent" and inside it a new "parent" composite was created, this new parent cmposite holds the "detailsPane" composite and the JFree chart elements. createPartControl organizes elements in a composite (the parent Composite) that it receives as a parameter; inside this composite elements are ordered using a grid layout, and it is in the top part of this layout where the expandable bar described in the requirements section had to be located. The method createDetailsPane was created to return an object of type PGGroup (ultimately another composite) that was assigned to a newly created class variable called "detailsPane" and holds all the required functionality elements. Therefore it is safe to say that for the inspectIT GUI "detailsPane" is the variable that contains all the historical data feature. createDetailsPane is called right before the the method that creates the graphs so that the expandable bar was located on top of the afore mentioned grid layout. createDetailsPane places inside the new "parent" composite all the grpahical elements described in the proposed expandable section. This method uses two oterh methods to fill the expndable bar:

addFirstRow, which contains the following SWT widgets::

  • One SWT spinner to hold the "days" amount to use in the historical search
  • One SWT spinner to hold the "hours" amount to use in the the historical search (default value set to 1).
  • One SWT spinner to hold the "minutes" amount to use in the historical search

addSecondRow, which contains the following elements::

  • One SWT chechkbox button to control the "Live" mode toggle.
  • One Nebula project !CDateTime widget to display a popup calendar and time control..
  • One nomral SWT button to trigger the historical search.

It is important to note that the Nebula widget was used due to the fact that the standard SWT control was more difficult to implement and its features were more powerfull and visually attractive; also, both methods create a new composite (innerComposite) to hold its elements. More information about the Nebula project widgets can be found here.

Step 2: Controller classes implementation

Once all the graphical elements were in place, the actual logical procedures to perform the historical serch needed to be added. To acomplish this there were two main project elements that needed to be modified:

  • The PlotController interface.
  • The DefaultPlotController class.

The former needed its "update" overloaded to recieve two parameters of type "Date"; this method was of course implemented in the "DefaultPlotController" class. The new update(Date, Date) method in DefaultPlotController is just a proxy method to call the getDataObjectsFromToDate from the "DataAccessService" class which returns a List of data that is in turn passed to the "updateUpperPlotData" and "updateLowerPlotData" methods to display it in the graphs.

Additional Steps: Connecting the view and the controllers

The SensorTypeViewController class "addSecondRow" method was further modified to include "selection listeners" in charge of triggering the new "historical search" feature.

First, a selection listener was added to the "Live" checkbox to disable or enable the calendar control and the "update" button; this was accomplished by calling the "setEnabled" method of each widget. Inside this toggle a new method (startUpdateTimer) was also created to control the "Live" mode functionality. So when the "live" checkbox is selected a new timer is created and a new "UpdateGraphTimer" object (inner class) is attached to it with a time interval of 5 seconds; if the "Live" checkbox is unchecked the timer object is distroyed and the widgets are disabled.

Another selection listener was added to the "update" button to trigger the "update(Date, Date)" method described previously; the first date parameter is the "start" date and is formed by the values in the spinners from the first row or "Zeitraum" section; the second parameter, the end date, is obtained from the !CDateTime control in the second row or the "bis" section.

The final implementation of the Details Pane looks like the following With the calendar control and "Update" widgets disabled:

With the "Live" button unchecked and the calendar control popup: