Main Page | Packages | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | Related Pages

org.objectweb.cjdbc.console.views.InfoViewer Class Reference

Inheritance diagram for org.objectweb.cjdbc.console.views.InfoViewer:

Inheritance graph
[legend]
Collaboration diagram for org.objectweb.cjdbc.console.views.InfoViewer:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 InfoViewer (Object[][] data)
abstract String[] getColumnNames ()
int[] getTraceableColumns ()
abstract void setLabels ()
void updateData (Object[][] data)
String displayText (Object[][] data)
String displayText (String[][] data)
void display ()
String getFrameTitle ()
Object[][] getData ()

Protected Member Functions

abstract Object[][] getDataTypes (Object[][] stats)

Protected Attributes

String frameTitle
String infoViewerMenuBarString
String actionToolTipText
String actionErrorMessage
String actionSuccessMessage
String tableHeaderToolTipText

Detailed Description

Graphical SQL statistics viewer. Quick and dirty implementation.

Author:
Mathieu Peltier

Emmanuel Cecchet

Version:
1.0

Definition at line 57 of file InfoViewer.java.


Constructor & Destructor Documentation

org.objectweb.cjdbc.console.views.InfoViewer.InfoViewer Object  data[][]  ) 
 

Create a InfoViewer

Parameters:
data Stats to display in the table

Definition at line 81 of file InfoViewer.java.

00082   {
00083     if (data != null)
00084     {
00085       this.data = getDataTypes(data);
00086       columnNames = getColumnNames();
00087       setLabels();
00088     }
00089   }


Member Function Documentation

void org.objectweb.cjdbc.console.views.InfoViewer.display  ) 
 

Create the GUI and show it.

Definition at line 282 of file InfoViewer.java.

Referenced by org.objectweb.cjdbc.console.gui.CjdbcGui.publicActionViewCache(), org.objectweb.cjdbc.console.gui.CjdbcGui.publicActionViewCacheStats(), org.objectweb.cjdbc.console.gui.CjdbcGui.publicActionViewRecoveryLog(), and org.objectweb.cjdbc.console.gui.CjdbcGui.publicActionViewSQLStats().

00283   {
00284     //Schedule a job for the event-dispatching thread:
00285     //creating and showing this application's GUI.
00286     javax.swing.SwingUtilities.invokeLater(new Runnable()
00287     {
00288       public void run()
00289       {
00290         createAndShowGUI();
00291       }
00292     });
00293   }

String org.objectweb.cjdbc.console.views.InfoViewer.displayText String  data[][]  ) 
 

Format data for text consoles

Parameters:
data to display
Returns:
a formatted string with tabs and end of line

Definition at line 201 of file InfoViewer.java.

00202   {
00203     if (data == null)
00204     {
00205       return "";
00206     }
00207 
00208     /* Lasse's version starts here */
00209 
00210     // constants used for formatting the output
00211     final String columnPadding = "    ";
00212     final String nameValueSeparator = ":  ";
00213 
00214     // holds the column names
00215     String[] columns = getColumnNames();
00216 
00217     // solve the maximum length for column names
00218     // TODO: refactor this into its own method
00219     int maxNameLength = 0;
00220     for (int i = 0; i < columns.length; i++)
00221     {
00222       maxNameLength = Math.max(maxNameLength, columns[i].length());
00223     }
00224 
00225     // solve the maximum length for column values
00226     // TODO: refactor this into its own method
00227     int maxValueLength = 0;
00228     for (int i = 0; i < data.length; i++)
00229     {
00230       for (int j = 0; j < data[i].length; j++)
00231       {
00232         maxValueLength = Math.max(maxValueLength, data[i][j].length());
00233       }
00234     }
00235 
00236     // construct a separator line based on maximum column and value lengths
00237     // TODO: extract numbers into constants and this block into a new method
00238     char[] separator = new char[columnPadding.length() + maxNameLength
00239         + nameValueSeparator.length() + maxValueLength + 1]; /*
00240      * the newline
00241      * character
00242      */
00243     for (int i = 0; i < separator.length; i++)
00244     {
00245       separator[i] = '-';
00246     }
00247     separator[separator.length - 1] = '\n';
00248 
00249     // loop through all the data and print padded lines into the StringBuffer
00250     StringBuffer sb = new StringBuffer();
00251     for (int i = 0; i < data.length; i++)
00252     {
00253       sb.append(separator);
00254       for (int j = 0; j < data[i].length; j++)
00255       {
00256         // create the padding needed for this particular column
00257         // TODO: extract this into its own method
00258         char[] namePadding = new char[maxNameLength - columns[j].length()];
00259         for (int x = 0; x < namePadding.length; x++)
00260         {
00261           namePadding[x] = ' ';
00262         }
00263 
00264         sb.append(columnPadding);
00265         sb.append(columns[j]);
00266         sb.append(nameValueSeparator);
00267         sb.append(namePadding);
00268         sb.append(data[i][j]);
00269         sb.append("\n");
00270       }
00271       if (i + 1 == data.length)
00272       {
00273         sb.append(separator);
00274       }
00275     }
00276     return sb.toString();
00277   }

String org.objectweb.cjdbc.console.views.InfoViewer.displayText Object  data[][]  ) 
 

Display text. This allows to show text without loading graphic contents

Parameters:
data to display
Returns:
a formatted String

Definition at line 187 of file InfoViewer.java.

Referenced by org.objectweb.cjdbc.console.text.Console.showInfo().

00188   {
00189     this.data = getDataTypes(data);
00190     columnNames = getColumnNames();
00191     setLabels();
00192     return displayText(getDataTypes(data));
00193   }

abstract String [] org.objectweb.cjdbc.console.views.InfoViewer.getColumnNames  )  [pure virtual]
 

Get column names

Returns:
a array of strings

Implemented in org.objectweb.cjdbc.console.views.BackendViewer, org.objectweb.cjdbc.console.views.CacheStatsViewer, org.objectweb.cjdbc.console.views.CacheViewer, org.objectweb.cjdbc.console.views.ClientsViewer, org.objectweb.cjdbc.console.views.ControllerLoadViewer, org.objectweb.cjdbc.console.views.DatabasesViewer, org.objectweb.cjdbc.console.views.RecoveryLogViewer, org.objectweb.cjdbc.console.views.SchedulerViewer, and org.objectweb.cjdbc.console.views.SQLStatViewer.

Object [][] org.objectweb.cjdbc.console.views.InfoViewer.getData  ) 
 

Returns:
Returns the data.

Definition at line 468 of file InfoViewer.java.

00469   {
00470     return data;
00471   }

abstract Object [][] org.objectweb.cjdbc.console.views.InfoViewer.getDataTypes Object  stats[][]  )  [protected, pure virtual]
 

Subclasses should overide this method to get coherent sorting

Parameters:
stats to display
Returns:
same sized objects array but with proper types default is strings only

Implemented in org.objectweb.cjdbc.console.views.BackendViewer, org.objectweb.cjdbc.console.views.CacheStatsViewer, org.objectweb.cjdbc.console.views.CacheViewer, org.objectweb.cjdbc.console.views.ClientsViewer, org.objectweb.cjdbc.console.views.ControllerLoadViewer, org.objectweb.cjdbc.console.views.DatabasesViewer, org.objectweb.cjdbc.console.views.RecoveryLogViewer, org.objectweb.cjdbc.console.views.SchedulerViewer, and org.objectweb.cjdbc.console.views.SQLStatViewer.

String org.objectweb.cjdbc.console.views.InfoViewer.getFrameTitle  ) 
 

Returns:
Returns the frameTitle.

Definition at line 460 of file InfoViewer.java.

00461   {
00462     return frameTitle;
00463   }

int [] org.objectweb.cjdbc.console.views.InfoViewer.getTraceableColumns  ) 
 

Return the list of traceable data for this viewer

Returns:
an array of names

Reimplemented in org.objectweb.cjdbc.console.views.BackendViewer, org.objectweb.cjdbc.console.views.CacheStatsViewer, org.objectweb.cjdbc.console.views.ControllerLoadViewer, org.objectweb.cjdbc.console.views.DatabasesViewer, and org.objectweb.cjdbc.console.views.SchedulerViewer.

Definition at line 112 of file InfoViewer.java.

00113   {
00114     return new int[0];
00115   }

abstract void org.objectweb.cjdbc.console.views.InfoViewer.setLabels  )  [pure virtual]
 

Set the labels for the frame

Implemented in org.objectweb.cjdbc.console.views.BackendViewer, org.objectweb.cjdbc.console.views.CacheStatsViewer, org.objectweb.cjdbc.console.views.CacheViewer, org.objectweb.cjdbc.console.views.ClientsViewer, org.objectweb.cjdbc.console.views.ControllerLoadViewer, org.objectweb.cjdbc.console.views.DatabasesViewer, org.objectweb.cjdbc.console.views.RecoveryLogViewer, org.objectweb.cjdbc.console.views.SchedulerViewer, and org.objectweb.cjdbc.console.views.SQLStatViewer.

void org.objectweb.cjdbc.console.views.InfoViewer.updateData Object  data[][]  ) 
 

Update the data in the InfoTableModel and refresh the frame

Parameters:
data fresh and new

Definition at line 127 of file InfoViewer.java.

References org.objectweb.cjdbc.console.views.InfoViewer.InfoTableModel.setData().

00128   {
00129     this.data = getDataTypes(data);
00130     if (frame != null)
00131     {
00132       frame.repaint();
00133       frame.setVisible(true);
00134       model.setData(data);
00135     }
00136     else
00137     {
00138       createAndShowGUI();
00139     }
00140   }


The documentation for this class was generated from the following file:
Generated on Mon Apr 11 22:03:17 2005 for C-JDBC by  doxygen 1.3.9.1