Coverage Report - org.homeunix.thecave.buddi.view.dialogs.schedule.EveryXDaysCard
 
Classes in this File Line Coverage Branch Coverage Complexity
EveryXDaysCard
57%
11/19
N/A
1.5
 
 1  
 /*
 2  
  * Created on Aug 18, 2007 by wyatt
 3  
  */
 4  
 package org.homeunix.thecave.buddi.view.dialogs.schedule;
 5  
 
 6  
 import java.awt.Dimension;
 7  
 import java.awt.FlowLayout;
 8  
 
 9  
 import javax.swing.JLabel;
 10  
 
 11  
 import org.homeunix.thecave.buddi.i18n.BuddiKeys;
 12  
 import org.homeunix.thecave.buddi.model.ScheduledTransaction;
 13  
 import org.homeunix.thecave.buddi.plugin.api.util.TextFormatter;
 14  
 
 15  
 import ca.digitalcave.moss.swing.MossDecimalField;
 16  
 import ca.digitalcave.moss.swing.MossPanel;
 17  
 
 18  
 public class EveryXDaysCard extends MossPanel implements ScheduleCard {
 19  
         public static final long serialVersionUID = 0;
 20  
         
 21  
         private final MossDecimalField howFrequently;
 22  
         
 23  
         public EveryXDaysCard() {
 24  1165
                 super(true);
 25  1165
                 howFrequently = new MossDecimalField(7, false, 0);        
 26  1165
                 howFrequently.setPreferredSize(new Dimension(100, howFrequently.getPreferredSize().height));
 27  1165
                 open();
 28  1165
         }
 29  
         
 30  
         @Override
 31  
         public void init() {
 32  1165
                 super.init();
 33  
 
 34  1165
                 this.setLayout(new FlowLayout(FlowLayout.LEFT));
 35  1165
                 this.add(new JLabel(TextFormatter.getTranslation(BuddiKeys.AND_REPEATING_EVERY)));
 36  1165
                 this.add(howFrequently);
 37  1165
                 this.add(new JLabel(TextFormatter.getTranslation(BuddiKeys.DAYS)));
 38  1165
         }
 39  
         
 40  
         public int getScheduleDay() {
 41  
                 try {
 42  0
                         return Integer.parseInt(howFrequently.getText());
 43  
                 }
 44  0
                 catch (RuntimeException re){}
 45  0
                 catch (Exception e){}
 46  0
                 return 7;        //If we can't parse it, return 7.  TODO This is stupid, do some error handling at the component level
 47  
         }
 48  
         
 49  
         public int getScheduleWeek() {
 50  0
                 return 0;
 51  
         }
 52  
         
 53  
         public int getScheduleMonth() {
 54  0
                 return 0;
 55  
         }
 56  
         
 57  
         public void loadSchedule(ScheduledTransaction s) {
 58  0
                 howFrequently.setText(s.getScheduleDay() + "");
 59  0
         }
 60  
 }