コード例 #1
0
 @Override
 public void onClick(ClickEvent event) {
   Widget sender = (Widget) event.getSource();
   if (prevMBtn.equals(sender)) {
     setCursorDate(
         GWTCSimpleDatePicker.increaseMonth(getCursorDate(), isMonthInRange(-1 * monthStep)));
   } else if (nextMBtn.equals(sender)) {
     setCursorDate(GWTCSimpleDatePicker.increaseMonth(getCursorDate(), isMonthInRange(monthStep)));
   } else if (prevYBtn.equals(sender)) {
     setCursorDate(GWTCSimpleDatePicker.increaseMonth(getCursorDate(), isMonthInRange(-12)));
   } else if (nextYBtn.equals(sender)) {
     setCursorDate(GWTCSimpleDatePicker.increaseMonth(getCursorDate(), isMonthInRange(12)));
   } else if (todayBtn.equals(sender)) {
     setCursorDate(new Date());
   } else if (helpBtn.equals(sender)) {
     helpDlg.alert(helpStr.replaceAll("\\n", "<br/>"));
   } else if (closeBtn.equals(sender)) {
     hide();
   } else {
     super.onClick(event);
   }
   refresh();
 }
コード例 #2
0
 /**
  * Set the zIndex value.
  *
  * @param z
  */
 public void setZIndex(int z) {
   if (calendarDlg != null) {
     DOM.setStyleAttribute(calendarDlg.getElement(), "zIndex", String.valueOf(z));
     helpDlg.setZIndex(z + 1);
   }
 }
コード例 #3
0
  /**
   * Creates the calendar instance based in the configuration provided.
   *
   * <p>Options can be passed joining these using the or bit wise operator
   *
   * <ul>
   *   <li>CONFIG_DIALOG show as modal dialog
   *   <li>CONFIG_ROUNDED_BOX wrap with a rounded-corner box
   *   <li>CONFIG_NO_AUTOHIDE don't autohide dialog when the user click out of the picker
   *   <li>CONFIG_NO_ANIMATION don't animate the dialog box when it is showed/hidden
   *   <li>CONFIG_NO_ANIMATION don't animate the dialog box when it is showed/hidden
   *   <li>CONFIG_BACKGROUND show a semitransparent background covering all the document
   *   <li>CONFIG_FLAT_BUTTONS use native Buttons instead of GWTCButton also add the dependent class
   *       'flat'
   *   <li>CONFIG_STANDARD_BUTTONS use native browser Buttons instead of GWTCButton
   * </ul>
   */
  public void initialize(int config) {

    int buttonsType = config & CONFIG_FLAT_BUTTONS | config & CONFIG_STANDARD_BUTTONS;
    helpBtn = createButton(buttonsType, "?", this);
    closeBtn = createButton(buttonsType, "x", this);
    todayBtn = createButton(buttonsType, "-", this);
    prevMBtn = createButton(buttonsType, "\u003c", this);
    prevYBtn = createButton(buttonsType, "\u00AB", this);
    nextMBtn = createButton(buttonsType, "\u003e", this);
    nextYBtn = createButton(buttonsType, "\u00BB", this);

    if ((config & CONFIG_DIALOG) == CONFIG_DIALOG) {
      int opt = 0;
      if ((config & CONFIG_ROUNDED_BOX) == CONFIG_ROUNDED_BOX) {
        opt |= GWTCModalBox.OPTION_ROUNDED_FLAT;
      }
      if ((config & CONFIG_BACKGROUND) != CONFIG_BACKGROUND) {
        opt |= GWTCModalBox.OPTION_DISABLE_BACKGROUND;
        if ((config & CONFIG_NO_AUTOHIDE) == CONFIG_NO_AUTOHIDE) {
          opt |= GWTCModalBox.OPTION_DISABLE_AUTOHIDE;
        }
      }
      calendarDlg = new GWTCModalBox(opt);
      calendarDlg.setAnimationEnabled((config & CONFIG_NO_ANIMATION) != CONFIG_NO_ANIMATION);

      outer = calendarDlg;
      initWidget(new DockPanel());

      setStyleName(styleName);
      addStyleDependentName(StyleDialog);
      setZIndex(999);
    } else {
      if ((config & CONFIG_ROUNDED_BOX) == CONFIG_ROUNDED_BOX) {
        outer = new GWTCBox(GWTCBox.STYLE_FLAT);
      } else {
        outer = new VerticalPanel();
      }
      String s = outer.getStyleName();
      initWidget(outer);
      setStyleName(styleName);
      addStyleDependentName(StyleEmbeded);
      if (s != null && s.length() > 0) addStyleName(s);
    }

    helpDlg.addStyleName(StyleHelp);
    navButtonsTop.setStyleName(StyleCButtonsTop);
    navButtonsBottom.setStyleName(StyleCButtonsBottom);
    calendarGrid.setStyleName(StyleMonthGrid);
    navButtonsTop.setWidth("100%");
    calendarGrid.setWidth("100%");
    navButtonsBottom.setWidth("100%");

    if ((config & CONFIG_ROUNDED_BOX) == CONFIG_ROUNDED_BOX) addStyleDependentName(StyleBox);
    else addStyleDependentName(StyleNoBox);

    if ((config & CONFIG_DIALOG) != CONFIG_DIALOG) closeBtn.setVisible(false);

    monthSelectorHeader.setAnimationEnabled(true);

    outer.add(navButtonsTop);
    outer.add(calendarGrid);
    outer.add(navButtonsBottom);

    drawDatePickerWidget();
    refresh();

    DOM.sinkEvents(outer.getElement(), Event.ONMOUSEOVER | Event.ONMOUSEOUT | Event.ONCLICK);
    DOM.setStyleAttribute(outer.getElement(), "cursor", "default");
    DOM.setElementAttribute(monthMenu.getElement(), "align", "center");
  }