Coverage Report - com.liquidatom.derbyscore.ui.JamPointsChangeListener
 
Classes in this File Line Coverage Branch Coverage Complexity
JamPointsChangeListener
0%
0/17
0%
0/8
3.333
 
 1  
 package com.liquidatom.derbyscore.ui;
 2  
 
 3  
 import com.liquidatom.derbyscore.domain.Team;
 4  
 import java.awt.EventQueue;
 5  
 import javax.annotation.concurrent.Immutable;
 6  
 import javax.annotation.concurrent.ThreadSafe;
 7  
 import javax.swing.JSpinner;
 8  
 import javax.swing.event.ChangeEvent;
 9  
 import javax.swing.event.ChangeListener;
 10  
 
 11  
 /**
 12  
  *
 13  
  * @author Russell Francis (russ@metro-six.com)
 14  
  */
 15  
 @Immutable
 16  
 @ThreadSafe
 17  
 public class JamPointsChangeListener implements ChangeListener {
 18  
 
 19  
     final private Team team;
 20  
 
 21  
     public JamPointsChangeListener(final Team team) {
 22  0
         super();
 23  0
         if (team == null) {
 24  0
             throw new IllegalArgumentException("The parameter team must be non-null.");
 25  
         }
 26  0
         this.team = team;
 27  0
     }
 28  
 
 29  
     public void stateChanged(final ChangeEvent e) {
 30  0
         assertDispatchThread();
 31  0
         final Object eventSource = e.getSource();
 32  0
         if (eventSource != null) {
 33  0
             if (eventSource instanceof JSpinner) {
 34  0
                 final JSpinner spinner = (JSpinner)eventSource;
 35  
 
 36  0
                 team.setJamPoints(((Number)spinner.getValue()).intValue());
 37  0
             }
 38  
             else {
 39  0
                 throw new IllegalArgumentException("Unable to update the jam points based on an event generated from an " +
 40  
                         "object of type '" + eventSource.getClass().getName() + "'.");
 41  
             }
 42  
         }
 43  0
     }
 44  
 
 45  
     protected void assertDispatchThread() {
 46  0
         if (!EventQueue.isDispatchThread()) {
 47  0
             throw new IllegalStateException("This method must be invoked from within the AWT Event Dispatch Thread!");
 48  
         }
 49  0
     }
 50  
 }