Beispiel #1
0
  /**
   * Returns the time text field value as string.
   *
   * <p>
   *
   * @return the time text field value as string
   */
  private String getTimeText() {

    String timeAsString = m_time.getText().trim();
    if (CmsDateConverter.is12HourPresentation()) {
      if (!(timeAsString.contains(CmsDateConverter.AM)
          || timeAsString.contains(CmsDateConverter.PM))) {
        if (m_am.isChecked()) {
          timeAsString = timeAsString + " " + CmsDateConverter.AM;
        } else {
          timeAsString = timeAsString + " " + CmsDateConverter.PM;
        }
      }
    }
    return timeAsString;
  }
Beispiel #2
0
  /** 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);
  }