@Override public void setEnabled(final boolean enabled) { this.enabled = enabled; for (final FormFieldComponent<PDateBox> field : fields) { field.getInput().setEnabled(enabled); } }
@Override public void removeValueChangeHandler(final PValueChangeHandler<Date> handler) { valueChangeHandlers.remove(handler); for (final FormFieldComponent<PDateBox> field : fields) { field.getInput().removeValueChangeHandler(handler); } }
@Override public void setValue(final Object value) { this.value = (Date) value; for (final FormFieldComponent<PDateBox> field : fields) { field.getInput().setValue(this.value); } }
@Override public void reset() { for (final FormFieldComponent<PDateBox> field : fields) { field.getInput().setValue(null); } value = null; }
@Override public void onValueChange(final PValueChangeEvent<Date> event) { this.value = event.getValue(); for (final FormFieldComponent<PDateBox> field : fields) { field.getInput().setValue(value); } }
@Override public void ensureDebugID(final String debugID) { this.debugID = debugID; if (fields.isEmpty()) return; for (final FormFieldComponent<PDateBox> field : fields) { field.getInput().ensureDebugId(debugID); } }
@Override public void onValueChange(final PValueChangeEvent<Date> event) { calendar = Calendar.getInstance(); calendar.setTime(event.getValue()); for (final FormFieldComponent<PDateBox> field : fields) { field.getInput().setValue(event.getValue()); } }
@Override public void setValue(final Object value) { final Date date = (Date) value; calendar = Calendar.getInstance(); calendar.setTime(date); for (final FormFieldComponent<PDateBox> field : fields) { field.getInput().setValue(date); } }
@Override public IsPWidget render(final FormField formField) { final PDateBox 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()); return dateFieldComponent; }
@Override public <H extends EventHandler> void addDomHandler(final H handler, final Type<H> type) { for (final FormFieldComponent<PDateBox> field : fields) { field.getInput().addDomHandler(handler, type); } }
@Override public void clearErrorMessage() { for (final FormFieldComponent<PDateBox> field : fields) { field.clearErrors(); } }
@Override public void addErrorMessage(final String errorMessage) { for (final FormFieldComponent<PDateBox> field : fields) { field.addErrorMessage(errorMessage); } }
@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; }