Package com.sencha.gxt.core.client.util

Examples of com.sencha.gxt.core.client.util.DateWrapper


    setValue(activeDate.asDate());
  }

  protected void onKeyHome(NativeEvent evt) {
    if (evt.<XEvent> cast().getCtrlOrMetaKey()) {
      setValue(new DateWrapper(activeDate.getFullYear(), 0, 1).asDate());
    } else {
      setValue(activeDate.getFirstDayOfMonth().asDate(), false);
    }
  }
View Full Code Here


  private void handleDateClick(XElement target, String dt) {
    String[] tokens = dt.split(",");
    int year = Integer.parseInt(tokens[0]);
    int month = Integer.parseInt(tokens[1]);
    int day = Integer.parseInt(tokens[2]);
    Date d = new DateWrapper(year, month, day).asDate();
    if (d != null && !appearance.isDisabled(target.getParentElement())) {
      setValue(d);
    }
  }
View Full Code Here

    });
    monthPicker.<FxElement> cast().slideOut(Direction.UP, fx);
  }

  private void selectToday() {
    setValue(new DateWrapper().asDate());
  }
View Full Code Here

  }

  private void setCellStyle(Element cell, Date d, long sel, long min, long max) {
    long t = d.getTime();

    DateWrapper w = new DateWrapper(d);
    int year = w.getFullYear();
    int month = w.getMonth();
    int day = w.getDate();

    String dd = year + "," + month + "," + day;

    cell.getFirstChildElement().setPropertyString("dateValue", dd);
View Full Code Here

  private void showPrevMonth() {
    setValue(activeDate.addMonths(-1).asDate(), false);
  }

  private void update(DateWrapper date) {
    DateWrapper vd = activeDate;
    activeDate = date;
    if (vd != null) {
      int days = date.getDaysInMonth();
      DateWrapper firstOfMonth = date.getFirstDayOfMonth();
      int startingPos = firstOfMonth.getDayInWeek() - firstDOW;

      if (startingPos <= firstDOW) {
        startingPos += 7;
      }

      // go to previous month.
      DateWrapper pm = activeDate.addMonths(-1);
      int prevStart = pm.getDaysInMonth() - startingPos;

      days += startingPos;

      DateWrapper d = new DateWrapper(pm.getFullYear(), pm.getMonth(), prevStart).resetTime();
      today = new DateWrapper().resetTime().getTime();
      long sel = value != null ? value.resetTime().getTime() : Long.MIN_VALUE;
      long min = minDate != null ? new DateWrapper(minDate).getTime() : Long.MIN_VALUE;
      long max = maxDate != null ? new DateWrapper(maxDate).getTime() : Long.MAX_VALUE;

      int i = 0;
      for (; i < startingPos; i++) {
        appearance.onTextChange(cells[i], "" + ++prevStart);
        d = d.addDays(1);
        appearance.onUpdateDateStyle(cells[i], DateState.PREVIOUS, true);
        setCellStyle(cells[i], d.asDate(), sel, min, max);
      }
      for (; i < days; i++) {
        int intDay = i - startingPos + 1;
        appearance.onTextChange(cells[i], "" + intDay);
        d = d.addDays(1);
        appearance.onUpdateDateStyle(cells[i], DateState.ACTIVE, true);
        setCellStyle(cells[i], d.asDate(), sel, min, max);
      }
      int extraDays = 0;
      for (; i < 42; i++) {
        appearance.onTextChange(cells[i], "" + ++extraDays);
        d = d.addDays(1);
        appearance.onUpdateDateStyle(cells[i], DateState.NEXT, true);
        setCellStyle(cells[i], d.asDate(), sel, min, max);
      }
      int month = activeDate.getMonth();

      String t = constants.monthsFullStandalone()[month] + " " + activeDate.getFullYear();
View Full Code Here

  }

  private void fillStore() {
    if (!initialized) {
      this.initialized = true;
      DateWrapper min = minValue != null ? new DateWrapper(resetDate(minValue))
          : new DateWrapper(1970, 0, 1).clearTime();
      DateWrapper max = maxValue != null ? new DateWrapper(resetDate(maxValue))
          : new DateWrapper(1970, 0, 1).clearTime().addDays(1);

      store.clear();

      while (min.before(max)) {
        store.add(min.asDate());
View Full Code Here

    }
  }

  @SuppressWarnings("deprecation")
  private Date resetDate(Date date) {
    return new DateWrapper(1970, 0, 1).clearTime().addHours(date.getHours()).addMinutes(date.getMinutes()).addSeconds(
        date.getSeconds()).asDate();
  }
View Full Code Here

   * Sets the minimum date. Hours, minutes, seconds, and milliseconds are cleared.
   *
   * @param minDate the minimum date
   */
  public void setMinDate(Date minDate) {
    this.minDate = new DateWrapper(minDate).clearTime().asDate();
  }
View Full Code Here

   * Sets the max date. Hours, minutes, seconds, and milliseconds are cleared.
   *
   * @param maxDate the max date
   */
  public void setMaxDate(Date maxDate) {
    this.maxDate = new DateWrapper(maxDate).clearTime().asDate();
  }
View Full Code Here

    monthPickerOkButton = new TextButton(getMessages().okText());
    monthPickerOkButton.addSelectHandler(new SelectHandler() {
      @Override
      public void onSelect(SelectEvent event) {
        DateWrapper d = new DateWrapper(mpSelYear, mpSelMonth, 1);
        update(d);
        hideMonthPicker();
      }
    });

    monthPickerCancelButton = new TextButton(getMessages().cancelText());
    monthPickerCancelButton.addSelectHandler(new SelectHandler() {
      @Override
      public void onSelect(SelectEvent event) {
        hideMonthPicker();
      }
    });

    monthPicker = XElement.createElement("div");
    monthPicker.getStyle().setDisplay(Display.NONE);

    getElement().appendChild(monthPicker);

    cells = Util.toElementArray(appearance.getDateCells(getElement()));

    activeDate = value != null ? value : new DateWrapper();
    update(activeDate);

    new KeyNav(this) {
      @Override
      public void onKeyPress(NativeEvent evt) {
View Full Code Here

TOP

Related Classes of com.sencha.gxt.core.client.util.DateWrapper

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.