/** * Updates the auto hide partner from the parent widget. * * <p>If there is any invalid user input the parent widget should not be closed automatically. * * <p> */ protected void updateCloseBehavior() { if (isEnabled()) { if (!m_isValidTime && isValidTime()) { m_isValidTime = true; m_popup.setAutoHideEnabled(true); } else if (m_isValidTime && !isValidTime()) { m_isValidTime = false; m_popup.setAutoHideEnabled(false); } if (!m_isValidDateBox && isValideDateBox()) { m_isValidDateBox = true; if (m_autoHideParent != null) { m_autoHideParent.removeAutoHidePartner(RootPanel.getBodyElement().getParentElement()); } } else if (m_isValidDateBox && !isValideDateBox()) { m_isValidDateBox = false; if (m_autoHideParent != null) { m_autoHideParent.addAutoHidePartner(RootPanel.getBodyElement().getParentElement()); } } } }
/** Create a new date box widget with the date time picker. */ public CmsDateBox() { initWidget(uiBinder.createAndBindUi(this)); m_popup = new CmsPopup(); m_ampmGroup = new CmsRadioButtonGroup(); m_am.setText(Messages.get().key(Messages.GUI_DATE_AM_0)); m_am.setGroup(m_ampmGroup); m_pm.setText(Messages.get().key(Messages.GUI_DATE_PM_0)); m_pm.setGroup(m_ampmGroup); if (!CmsDateConverter.is12HourPresentation()) { m_pm.setVisible(false); m_am.setVisible(false); } CmsDateBoxHandler dateBoxHandler = new CmsDateBoxHandler(); m_picker.addValueChangeHandler(dateBoxHandler); m_box.addBlurHandler(dateBoxHandler); m_box.addClickHandler(dateBoxHandler); m_box.addKeyPressHandler(dateBoxHandler); m_am.addClickHandler(dateBoxHandler); m_pm.addClickHandler(dateBoxHandler); m_time.addClickHandler(dateBoxHandler); m_time.addBlurHandler(dateBoxHandler); m_time.addKeyPressHandler(dateBoxHandler); m_time.addFocusHandler(dateBoxHandler); m_popup.add(m_dateTimePanel); m_popup.setWidth(0); m_popup.setModal(true); m_popup.removePadding(); m_popup.setBackgroundColor( I_CmsLayoutBundle.INSTANCE.constants().css().backgroundColorDialog()); m_popup.addCloseHandler(dateBoxHandler); m_popup.addAutoHidePartner(m_box.getElement()); m_popup.setAutoHideEnabled(true); }