Clover coverage report - Alipes Project - 0.1
Coverage timestamp: Sat Sep 10 2005 21:25:58 BST
file stats: LOC: 167   Methods: 8
NCLOC: 76   Classes: 1
 
 Source file Conditionals Statements Methods TOTAL
StatusFrame.java 0% 0% 0% 0%
coverage
 1    /*
 2    * $Id: StatusFrame.java,v 1.2 2004/05/21 23:36:28 johndavidtaylor Exp $
 3    * Created on Feb 25, 2004 by John Taylor jdt@roe.ac.uk .
 4    *
 5    */
 6    package org.abraracourcix.alipes.listeners.status;
 7    import java.awt.BorderLayout;
 8    import java.util.Collection;
 9    import java.util.HashMap;
 10    import java.util.Iterator;
 11    import java.util.Map;
 12    import javax.swing.BorderFactory;
 13    import javax.swing.JLabel;
 14    import org.abraracourcix.alipes.common.Event;
 15    import org.abraracourcix.alipes.listeners.Listener;
 16    import org.abraracourcix.alipes.listeners.status.StatusListener.ResourceInfo;
 17    /**
 18    * GUI status display. Tied closely to StatusListener
 19    * @author jdt
 20    *
 21    */
 22    public final class StatusFrame extends javax.swing.JFrame implements Listener {
 23    /**
 24    * Commons logger
 25    */
 26    private static final org.apache.commons.logging.Log log =
 27    org.apache.commons.logging.LogFactory.getLog(StatusFrame.class);
 28    /**
 29    * The actual class doing the listening
 30    */
 31    private StatusListener statusListener;
 32    /** Creates new form StatusFrame */
 33  0 public StatusFrame() {
 34  0 log.debug("StatusFrame created");
 35  0 initComponents();
 36  0 log.debug("StatusFrame initialised");
 37    }
 38    /**
 39    * If we know that an event is *BAD*, we could report it in red, for
 40    * example. This is simply a map of statuses to colours.
 41    */
 42    private Map knownEventColours = new HashMap();
 43    /**
 44    * Register the one and only statusListener that this frame receives events
 45    * from
 46    *
 47    * @param statusListener
 48    * The statusListener
 49    */
 50  0 public void registerStatusListener(StatusListener statusListener) {
 51  0 this.statusListener = statusListener;
 52    }
 53    /**
 54    * This method is called from within the constructor to initialize the
 55    * form. WARNING: Do NOT modify this code. The content of this method is
 56    * always regenerated by the Form Editor.
 57    */
 58  0 private void initComponents() {
 59  0 titleLbl = new javax.swing.JLabel();
 60  0 textPane = new javax.swing.JTextPane();
 61  0 addWindowListener(new java.awt.event.WindowAdapter() {
 62  0 public void windowClosing(java.awt.event.WindowEvent evt) {
 63  0 exitForm(evt);
 64    }
 65    });
 66  0 titleLbl.setText("Status");
 67  0 getContentPane().add(titleLbl, java.awt.BorderLayout.NORTH);
 68  0 textPane.setBorder(
 69    new javax.swing.border.LineBorder(new java.awt.Color(0, 0, 0)));
 70  0 getContentPane().add(textPane, java.awt.BorderLayout.CENTER);
 71  0 lastEventLbl = new JLabel("Pending..................");
 72  0 lastEventLbl.setBorder(
 73    BorderFactory.createTitledBorder("Most recent change"));
 74  0 getContentPane().add(lastEventLbl, BorderLayout.SOUTH);
 75  0 pack();
 76    }
 77    /**
 78    * Exit the Application
 79    *
 80    * @param evt
 81    * the event closing the form
 82    */
 83  0 private void exitForm(final java.awt.event.WindowEvent evt) {
 84  0 System.exit(0);
 85    }
 86    /**
 87    * Fire up the frame @TODO consider deletion
 88    *
 89    * @param args
 90    * ignored
 91    */
 92  0 public static void main(final String[] args) {
 93  0 new StatusFrame().show();
 94    }
 95    // Variables declaration - do not modify
 96    /**
 97    * GUI components
 98    */
 99    private javax.swing.JTextPane textPane;
 100    /**
 101    * GUI components
 102    */
 103    private javax.swing.JLabel titleLbl;
 104    /**
 105    * GUI components
 106    */
 107    private javax.swing.JLabel lastEventLbl;
 108    // End of variables declaration
 109    /**
 110    * if an event occurs we need to update
 111    *
 112    * @see org.abraracourcix.alipes.listeners.Listener#eventOccurred(org.abraracourcix.alipes.common.Event,
 113    * java.lang.Object)
 114    */
 115  0 public void eventOccurred(final Event event, final Object resource) {
 116  0 log.debug("Event: "+event+", Resource "+resource);
 117  0 if (statusListener != null) {
 118  0 final Map statuses = statusListener.getStatuses();
 119    //@TODO do better than this
 120  0 final Collection resources = statuses.keySet();
 121  0 final Iterator it = resources.iterator();
 122  0 final StringBuffer text = new StringBuffer();
 123  0 while (it.hasNext()) {
 124  0 final Object resourceObj = it.next();
 125  0 final String resourceName = resourceObj.toString();
 126  0 final ResourceInfo info = (ResourceInfo) statuses.get(resourceObj);
 127  0 final String resourceStatus = info.getEvent().toString();
 128  0 final String time = info.getDate().toString();
 129  0 text.append(
 130    resourceName + ": " + resourceStatus + " @ " + time + "\n");
 131    }
 132  0 textPane.setText(text.toString());
 133  0 lastEventLbl.setText(resource.toString());
 134    }
 135    }
 136    /**
 137    * Set a map associating Events with colours
 138    *
 139    * @param knownStatusColours
 140    * The knownEventColours to set.
 141    */
 142  0 public void setKnownEventColours(final Map knownStatusColours) {
 143  0 this.knownEventColours = knownStatusColours;
 144    }
 145    }
 146    /*
 147    * $Log: StatusFrame.java,v $
 148    * Revision 1.2 2004/05/21 23:36:28 johndavidtaylor
 149    * A bit of tidying...but still not ready.
 150    *
 151    * Revision 1.1 2004/03/18 15:23:22 johndavidtaylor
 152    * Copied across from incubation in beanpeeler
 153    *
 154    * Revision 1.4 2004/03/14 18:49:14 johndavidtaylor
 155    * corrected comments
 156    *
 157    * Revision 1.3 2004/03/11 15:46:35 johndavidtaylor
 158    * Applied coding standards
 159    * Revision 1.2 2004/03/08 20:16:45 johndavidtaylor
 160    * refactored to new package name
 161    *
 162    * Revision 1.1 2004/03/08 19:58:25 johndavidtaylor Initial commit -transfer
 163    * from previous repository
 164    *
 165    * Revision 1.1 2004/03/02 23:04:37 jdt new
 166    *
 167    */