|
From: <rga...@us...> - 2002-10-21 19:54:15
|
Update of /cvsroot/csms/csms-core/src/java/org/fanfoot/gui
In directory usw-pr-cvs1:/tmp/cvs-serv23650
Modified Files:
ControlCentre.java
Log Message:
Refactoring
Index: ControlCentre.java
===================================================================
RCS file: /cvsroot/csms/csms-core/src/java/org/fanfoot/gui/ControlCentre.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** ControlCentre.java 21 Oct 2002 12:01:14 -0000 1.2
--- ControlCentre.java 21 Oct 2002 19:54:12 -0000 1.3
***************
*** 70,75 ****
/**
! *@author rgardler
! *@created 21 October 2002
*/
public class ControlCentre extends JFrame implements EventParserListener {
--- 70,75 ----
/**
! *@author rgardler
! *@created 21 October 2002
*/
public class ControlCentre extends JFrame implements EventParserListener {
***************
*** 140,149 ****
* file.
*
! *@exception FileNotFoundException Description of the Exception
! *@exception IOException Description of the Exception
! *@throws FileNotFoundException if the default configuration
! * file cannot be found
! *@throws IOException if there is a problem reading
! * the properties file
*/
public ControlCentre() throws FileNotFoundException, IOException {
--- 140,149 ----
* file.
*
! *@exception FileNotFoundException Description of the Exception
! *@exception IOException Description of the Exception
! *@throws FileNotFoundException if the default configuration file
! * cannot be found
! *@throws IOException if there is a problem reading the properties
! * file
*/
public ControlCentre() throws FileNotFoundException, IOException {
***************
*** 198,227 ****
getContentPane().add(tabpneEvents, java.awt.BorderLayout.NORTH);
! mnuFile.setMnemonic('F');
! mnuFile.setText("File");
! mnuItemParseFile.setMnemonic('F');
! mnuItemParseFile.setText("Parse File");
! mnuItemParseFile.addActionListener(
! new java.awt.event.ActionListener() {
! public void actionPerformed(java.awt.event.ActionEvent evt) {
! mnuItemParseFileActionPerformed(evt);
! }
! });
! mnuFile.add(mnuItemParseFile);
! mnuitemParseURL.setText("Parse URL");
! mnuitemParseURL.setToolTipText("Load an URL and parse scores from it");
! mnuitemParseURL.addActionListener(
new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
! mnuitemParseURLActionPerformed(evt);
}
});
! mnuFile.add(mnuitemParseURL);
- mnubarMain.add(mnuFile);
mnuConfig.setMnemonic('C');
mnuConfig.setText("Configuration");
--- 198,239 ----
getContentPane().add(tabpneEvents, java.awt.BorderLayout.NORTH);
! initMenus();
! setJMenuBar(mnubarMain);
! pack();
! }
!
!
! /** Initialise the menus */
! private void initMenus() {
! initFileMenu();
! mnubarMain.add(mnuFile);
! initConfigMenu();
! mnubarMain.add(mnuConfig);
! initDebugMenu();
! mnubarMain.add(mnuDebug);
! }
!
!
! /** Initialise the debug menu */
! private void initDebugMenu() {
! mnuDebug.setMnemonic('D');
! mnuDebug.setText("Debug");
! parseBBCTExt1.setMnemonic('1');
! parseBBCTExt1.setText("Parse BBC Test 1");
! parseBBCTExt1.addActionListener(
new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
! parseBBCTExt1ActionPerformed(evt);
}
});
! mnuDebug.add(parseBBCTExt1);
! }
+ /** Initialise the config menu */
+ private void initConfigMenu() {
mnuConfig.setMnemonic('C');
mnuConfig.setText("Configuration");
***************
*** 238,271 ****
mnuConfig.add(setPaths);
- mnubarMain.add(mnuConfig);
! mnuDebug.setMnemonic('D');
! mnuDebug.setText("Debug");
! parseBBCTExt1.setMnemonic('1');
! parseBBCTExt1.setText("Parse BBC Test 1");
! parseBBCTExt1.addActionListener(
new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
! parseBBCTExt1ActionPerformed(evt);
}
});
! mnuDebug.add(parseBBCTExt1);
!
! mnubarMain.add(mnuDebug);
! setJMenuBar(mnubarMain);
! pack();
}
- //GEN-END:initComponents
-
/**
* Parse URL menu item has been selected
*
! *@param evt the event causing this action to take place
*/
private void mnuitemParseURLActionPerformed(java.awt.event.ActionEvent evt) {
--- 250,288 ----
mnuConfig.add(setPaths);
+ }
! /** Initialise the file menu */
! private void initFileMenu() {
! mnuFile.setMnemonic('F');
! mnuFile.setText("File");
! mnuItemParseFile.setMnemonic('F');
! mnuItemParseFile.setText("Parse File");
! mnuItemParseFile.addActionListener(
new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
! mnuItemParseFileActionPerformed(evt);
}
});
! mnuFile.add(mnuItemParseFile);
! mnuitemParseURL.setText("Parse URL");
! mnuitemParseURL.setToolTipText("Load an URL and parse scores from it");
! mnuitemParseURL.addActionListener(
! new java.awt.event.ActionListener() {
! public void actionPerformed(java.awt.event.ActionEvent evt) {
! mnuitemParseURLActionPerformed(evt);
! }
! });
! mnuFile.add(mnuitemParseURL);
}
/**
* Parse URL menu item has been selected
*
! *@param evt the event causing this action to take place
*/
private void mnuitemParseURLActionPerformed(java.awt.event.ActionEvent evt) {
***************
*** 282,286 ****
* Set Paths configuration item is selected
*
! *@param evt that caused this action to be performed
*/
private void setPathsActionPerformed(java.awt.event.ActionEvent evt) {
--- 299,303 ----
* Set Paths configuration item is selected
*
! *@param evt that caused this action to be performed
*/
private void setPathsActionPerformed(java.awt.event.ActionEvent evt) {
***************
*** 302,306 ****
* Parse BBC text commentary action is to be performed
*
! *@param evt the event causing this action to be performed
*/
private void parseBBCTExt1ActionPerformed(java.awt.event.ActionEvent evt) {
--- 319,323 ----
* Parse BBC text commentary action is to be performed
*
! *@param evt the event causing this action to be performed
*/
private void parseBBCTExt1ActionPerformed(java.awt.event.ActionEvent evt) {
***************
*** 324,328 ****
* Parse a file action to be performed.
*
! *@param evt the event that caused this action to be performed
*/
private void mnuItemParseFileActionPerformed(java.awt.event.ActionEvent evt) {
--- 341,345 ----
* Parse a file action to be performed.
*
! *@param evt the event that caused this action to be performed
*/
private void mnuItemParseFileActionPerformed(java.awt.event.ActionEvent evt) {
***************
*** 365,369 ****
* configuration. Scores are displayed in the GUI.
*
! *@param url the url to load
*/
private void generateScores(URL url) {
--- 382,386 ----
* configuration. Scores are displayed in the GUI.
*
! *@param url the url to load
*/
private void generateScores(URL url) {
***************
*** 403,407 ****
* Exit the Application
*
! *@param evt Description of the Parameter
*/
private void exitForm(java.awt.event.WindowEvent evt) {
--- 420,424 ----
* Exit the Application
*
! *@param evt Description of the Parameter
*/
private void exitForm(java.awt.event.WindowEvent evt) {
***************
*** 414,418 ****
/**
! *@param args the command line arguments
*/
public static void main(String args[]) {
--- 431,435 ----
/**
! *@param args the command line arguments
*/
public static void main(String args[]) {
***************
*** 430,491 ****
* to the tabbed pane displaying events.
*
! *@param evts the events to display
*/
private void populateEventTables(Events evts) {
- Enumeration evtTypes = evts.getTypes();
- // all types of events
- String strType;
- // type of events currently being processed
- ArrayList typeEvts;
- // all events of a certain type
- Event evt;
- // event currently being processed
- Enumeration enuPartNames;
- // part names of current event
- Vector columnNames;
- // table column names
- Vector row;
- // current table row
- Vector evtRows;
- // table rows for a specific event
- String strPartName;
- // name of the part being processed
- DefaultTableModel data;
- // data model for the events table
- JTable jtable;
- // the table of events
- JScrollPane scrPane;
- // the scroll pane for the table
logger.entering("org.fanfoot.gui", "populateEventTables(evts)");
tabpneEvents.removeAll();
! javax.swing.JEditorPane htmlEditorPane = new javax.swing.JEditorPane();
! htmlEditorPane.setContentType("text/html");
! tabpneEvents.add("Summary", htmlEditorPane);
! try {
! XMLTreePanel xmlTree = new XMLTreePanel();
! xmlTree.setDocument(evts.toXMLDoc());
! scrPane = new JScrollPane();
! scrPane.setViewportView(xmlTree);
! tabpneEvents.add("Events", scrPane);
! } catch(ParserConfigurationException pce) {
! // FIXME Tell the user of this error
! logger.log(Level.SEVERE, "XML Parser configuration error", pce);
}
! try {
! scores = new Scores(evts, scoringConfig);
! } catch(ScoringConfigurationException sce) {
! logger.log(Level.WARNING, "Unable to calculate scores", sce);
}
! XMLTreePanel xmlTree = new XMLTreePanel();
! xmlTree.setDocument(scores.getScoresDocument());
! scrPane = new JScrollPane();
! scrPane.setViewportView(xmlTree);
! tabpneEvents.add("Scores", scrPane);
Document docScores2HTML = null;
--- 447,539 ----
* to the tabbed pane displaying events.
*
! *@param evts the events to display
*/
private void populateEventTables(Events evts) {
logger.entering("org.fanfoot.gui", "populateEventTables(evts)");
tabpneEvents.removeAll();
+ addSummaryPane();
+ addEventsPane(evts);
+ addScoresPane(evts);
+ summaryPane.setText(createScoreSummary());
+ addEventPanes(evts);
! this.pack();
! logger.exiting("org.fanfoot.gui", "populateEventTables(evts)");
! }
!
!
! /**
! * Add individual panes to report each event type to the tabbed
! * pane.
! *
! *@param evts the events to display
! */
! private void addEventPanes(Events evts) {
! Enumeration evtTypes = evts.getTypes();// all types of events
! String strType;// type of events currently being processed
! ArrayList typeEvts;// all events of a certain type
! Vector columnNames;// table column names
! Vector evtRows;// table rows for a specific event
! DefaultTableModel data;// data model for the events table
! JTable jtable;// the table of event
!
! while(evtTypes.hasMoreElements()) {
! strType = (String) evtTypes.nextElement();
! typeEvts = evts.getEventsByType(strType);
! columnNames = new Vector();
! evtRows = new Vector();
!
! logger.finest("Processing events of type " + strType);
!
! for(int i = 0; i < typeEvts.size(); i++) {
! evtRows.add(getPartValues((Event) typeEvts.get(i), columnNames));
! }
!
! data = new DefaultTableModel(evtRows, columnNames);
! jtable = new JTable(data);
!
! JScrollPane scrPane = new JScrollPane();
! scrPane.setViewportView(jtable);
! tabpneEvents.addTab(strType, null, scrPane,
! "Display events of type " + strType);
}
+ }
!
! /**
! * Create a vector of the part values for the supplied event
! *
! *@param evt the event to process
! *@param columnNames the names of the columns we currently know
! * exist in events of this type any new column names discovered
! * will be added to this parameter
! *@return The parts value
! */
! private Vector getPartValues(Event evt, Vector columnNames) {
! Enumeration enuPartNames;// part names of the event
! String strPartName;// name of the part being processed
! Vector results = new Vector();
! enuPartNames = evt.getPartNames();
! while(enuPartNames.hasMoreElements()) {
! strPartName = (String) enuPartNames.nextElement();
! if(!columnNames.contains(strPartName)) {
! columnNames.add(strPartName);
! }
! results.add(evt.getPart(strPartName));
}
+ return results;
+ }
!
! /**
! * Create a summary of the scores and return it as a string
! *
! *@return Description of the Return Value
! */
! private String createScoreSummary() {
! String strSummary = "Unable to generate summary";
Document docScores2HTML = null;
***************
*** 497,501 ****
logger.log(Level.WARNING,
"Unable to load XSL to convert scores doc to HTML.", e);
! htmlEditorPane.setText("<h2>Error Parsing Scores</h2><p>" + e + "</p>");
}
--- 545,549 ----
logger.log(Level.WARNING,
"Unable to load XSL to convert scores doc to HTML.", e);
! strSummary = "<h2>Error Parsing Scores</h2><p>" + e + "</p>";
}
***************
*** 503,554 ****
Document htmlScores = XMLUtils.transform(scores.getScoresDocument(),
docScores2HTML);
! String strHTML = XMLUtils.xmlToString(htmlScores);
! logger.finest("HTML representation of scores is " + strHTML);
!
! htmlEditorPane.setText(strHTML);
} catch(Exception e) {
logger.log(Level.WARNING,
"Unable to convert scores document to HTML.", e);
! htmlEditorPane.setText("<h2>Error Parsing Scores</h2><p>" + e + "</p>");
}
- logger.finest("Event Types = " + evtTypes.toString());
! while(evtTypes.hasMoreElements()) {
! strType = (String) evtTypes.nextElement();
! typeEvts = evts.getEventsByType(strType);
! columnNames = new Vector();
! evtRows = new Vector();
- logger.finest("Processing events of type " + strType);
! for(int i = 0; i < typeEvts.size(); i++) {
! evt = (Event) typeEvts.get(i);
! row = new Vector();
! enuPartNames = evt.getPartNames();
! while(enuPartNames.hasMoreElements()) {
! strPartName = (String) enuPartNames.nextElement();
! if(!columnNames.contains(strPartName)) {
! columnNames.add(strPartName);
! logger.finest("Added column name " + strPartName);
! }
! row.add(evt.getPart(strPartName));
! logger.finest("Added column data " + evt.getPart(strPartName));
! }
! evtRows.add(row);
! }
- data = new DefaultTableModel(evtRows, columnNames);
- jtable = new JTable(data);
! scrPane = new JScrollPane();
! scrPane.setViewportView(jtable);
! tabpneEvents.addTab(strType, null, scrPane,
! "Display events of type " + strType);
! }
! this.pack();
! logger.exiting("org.fanfoot.gui", "populateEventTables(evts)");
}
--- 551,610 ----
Document htmlScores = XMLUtils.transform(scores.getScoresDocument(),
docScores2HTML);
! strSummary = XMLUtils.xmlToString(htmlScores);
! logger.finest("Summary of scores is " + strSummary);
} catch(Exception e) {
logger.log(Level.WARNING,
"Unable to convert scores document to HTML.", e);
! summaryPane.setText("<h2>Error Parsing Scores</h2><p>" + e + "</p>");
}
+ return strSummary;
+ }
! /** Add an HTML summary pane to the tabed pane */
! private void addSummaryPane() {
! summaryPane = new javax.swing.JEditorPane();
! summaryPane.setContentType("text/html");
! tabpneEvents.add("Summary", summaryPane);
! }
! /**
! * Add an XMLTree editor pane for the events
! *
! *@param evts The events to dispaly in the events pane
! */
! private void addEventsPane(Events evts) {
! JScrollPane scrPane = new JScrollPane();
! try {
! XMLTreePanel xmlTree = new XMLTreePanel();
! xmlTree.setDocument(evts.toXMLDoc());
! scrPane.setViewportView(xmlTree);
! tabpneEvents.add("Events", scrPane);
! } catch(ParserConfigurationException pce) {
! // FIXME Tell the user of this error
! logger.log(Level.SEVERE, "XML Parser configuration error", pce);
! }
! }
! /**
! * Add an XMLTree editor for the scores.
! *
! *@param evts the events from which to generate the scores
! */
! private void addScoresPane(Events evts) {
! JScrollPane scrPane = new JScrollPane();
! try {
! scores = new Scores(evts, scoringConfig);
! } catch(ScoringConfigurationException sce) {
! logger.log(Level.WARNING, "Unable to calculate scores", sce);
! }
! XMLTreePanel xmlTree = new XMLTreePanel();
! xmlTree.setDocument(scores.getScoresDocument());
! scrPane.setViewportView(xmlTree);
! tabpneEvents.add("Scores", scrPane);
}
***************
*** 557,561 ****
* Loaded Commentay file.
*
! *@param e Description of the Parameter
*/
public void retrievedCommentary(EventObject e) {
--- 613,617 ----
* Loaded Commentay file.
*
! *@param e Description of the Parameter
*/
public void retrievedCommentary(EventObject e) {
***************
*** 568,572 ****
/** the main menubar */
private javax.swing.JMenuBar mnubarMain;
! /** the parse BBC text menu item (used for debugging) */
private javax.swing.JMenuItem parseBBCTExt1;
/**
--- 624,628 ----
/** the main menubar */
private javax.swing.JMenuBar mnubarMain;
! /** the parse BBC text menu item (used for debugging) */
private javax.swing.JMenuItem parseBBCTExt1;
/**
***************
*** 580,592 ****
*/
private javax.swing.JTabbedPane tabpneEvents;
/** The menu item to parse a local commentary file */
private javax.swing.JMenuItem mnuItemParseFile;
/** the menu item to parse a remote commentary file */
private javax.swing.JMenuItem mnuitemParseURL;
! /** the configuration menu */
private javax.swing.JMenu mnuConfig;
! /** the file menu */
private javax.swing.JMenu mnuFile;
- // End of variables declaration//GEN-END:variables
}
--- 636,649 ----
*/
private javax.swing.JTabbedPane tabpneEvents;
+ /** The pane for displaying summary details */
+ javax.swing.JEditorPane summaryPane;
/** The menu item to parse a local commentary file */
private javax.swing.JMenuItem mnuItemParseFile;
/** the menu item to parse a remote commentary file */
private javax.swing.JMenuItem mnuitemParseURL;
! /** the configuration menu */
private javax.swing.JMenu mnuConfig;
! /** the file menu */
private javax.swing.JMenu mnuFile;
}
|