package net.sf.lab3f.gwt.hmchooser.client;
import java.util.Date;
import java.sql.Timestamp;
import com.google.gwt.user.client.ui.HorizontalPanel;
import com.google.gwt.user.client.ui.ListBox;
import com.google.gwt.user.client.ui.Label;
import net.sf.lab3f.gwt.calendar.client.Constants;
public class Main extends HorizontalPanel{
private ListBox hh = new ListBox();
private ListBox mm = new ListBox();
private net.sf.lab3f.gwt.calendar.client.Main calendar;
public Main(net.sf.lab3f.gwt.calendar.client.Main cw){
super();
calendar = cw;
Constants cnst = (Constants) com.google.gwt.core.client.GWT.create(Constants.class);
hh.addStyleDependentName("hmPeeker");
mm.addStyleDependentName("hmPeeker");
Label hl = new Label(cnst.hours());
Label ml = new Label(cnst.minutes());
hl.addStyleDependentName("hmPeeker");
ml.addStyleDependentName("hmPeeker");
this.setStyleName("hmPeeker");
for(int i = 0; i < 24; i++)hh.addItem(i < 10 ? "0" + i : "" + i);
for(int i = 0; i < 60; i++)mm.addItem(i < 10 ? "0" + i : "" + i);
add(hh);
add(hl);
add(mm);
add(ml);
}
public void markAsEnd(){
hh.setSelectedIndex(23);
mm.setSelectedIndex(59);
}
public Timestamp getTimestamp(){
return new Timestamp(getDate().getTime());
}
public Date getDate(){
Date d = calendar.getDate();
d.setHours (hh.getSelectedIndex());
d.setMinutes(mm.getSelectedIndex());
return d;
}
}