package timeflow.app.ui; import timeflow.model.*; import timeflow.data.time.*; import timeflow.data.db.*; import timeflow.data.db.filter.*; import timeflow.format.field.*; import timeflow.format.file.TimeflowFormat; import javax.swing.*; import java.util.*; import java.awt.*; import java.awt.event.*; public class DateFieldPanel extends JPanel { TFModel model; int numRows; HashMap numBad=new HashMap(); private static String[] mappable={VirtualField.START, VirtualField.END}; JLabel status=new JLabel(""); FieldMap[] panels=new FieldMap[mappable.length]; JButton submit, cancel; public DateFieldPanel(TFModel model, boolean hasButtons) { this.model=model; ActDB db=model.getDB(); numRows=db.size(); ActList all=db.all(); // calculate stats. for (Field f: db.getFields(RoughTime.class)) { int bad=DBUtils.count(all, new MissingValueFilter(f)); numBad.put(f.getName(),bad); } setLayout(new BorderLayout()); JPanel top=new JPanel(); if (hasButtons) { submit=new JButton("Submit"); top.add(submit); cancel=new JButton("Cancel"); top.add(cancel); } else { JLabel about=new JLabel("Dates"); top.add(about); } top.add(status); status.setForeground(Color.red); add(top, BorderLayout.SOUTH); JPanel bottom=new JPanel(); add(bottom, BorderLayout.CENTER); bottom.setLayout(new GridLayout(mappable.length,1)); // add panels. for (int i=0; i