@Override public void reset() { dateBox.setValue(null); hours.setSelectedIndex(0); minutes.setSelectedIndex(0); seconds.setSelectedIndex(0); calendar = null; }
@Override public IsPWidget render(final FormField formField) { dateBox = new PDateBox(); if (debugID != null) dateBox.ensureDebugId(debugID); final FormFieldComponent<PDateBox> dateFieldComponent = new FormFieldComponent<PDateBox>(dateBox); dateFieldComponent.setCaption(caption); dateFieldComponent.getInput().setDateFormat(dateFormat); dateFieldComponent.getInput().addValueChangeHandler(this); fields.add(dateFieldComponent); addListener(dateFieldComponent.getInput()); final PHorizontalPanel horizontalPanel = new PHorizontalPanel(); horizontalPanel.add(dateFieldComponent.asWidget()); hours = new PListBox(false, false); for (int i = 0; i < 24; i++) { hours.addItem(i + "", i); } minutes = new PListBox(false, false); for (int i = 0; i < 60; i++) { minutes.addItem(i + "", i); } seconds = new PListBox(false, false); for (int i = 0; i < 60; i++) { seconds.addItem(i + "", i); } hours.addChangeHandler( new PChangeHandler() { @Override public void onChange(final PChangeEvent event) { if (calendar != null) { calendar.set(Calendar.HOUR_OF_DAY, (Integer) hours.getSelectedValue()); } } }); minutes.addChangeHandler( new PChangeHandler() { @Override public void onChange(final PChangeEvent event) { if (calendar != null) { calendar.set(Calendar.MINUTE, (Integer) minutes.getSelectedValue()); } } }); seconds.addChangeHandler( new PChangeHandler() { @Override public void onChange(final PChangeEvent event) { if (calendar != null) { calendar.set(Calendar.SECOND, (Integer) seconds.getSelectedValue()); } } }); horizontalPanel.add(new PLabel("hh")); horizontalPanel.add(hours); horizontalPanel.add(new PLabel("mm")); horizontalPanel.add(minutes); horizontalPanel.add(new PLabel("ss")); horizontalPanel.add(seconds); return horizontalPanel; }