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

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


   *
   * @param maxDate the max date
   */
  public void setMaxDate(Date maxDate) {
    if (maxDate != null) {
      maxDate = new DateWrapper(maxDate).resetTime().asDate();
    }
    this.maxDate = maxDate;
    update(activeDate);
    enableTodayButton();
  }
View Full Code Here


   *
   * @param minDate the minimum date
   */
  public void setMinDate(Date minDate) {
    if (minDate != null) {
      minDate = new DateWrapper(minDate).resetTime().asDate();
    }
    this.minDate = minDate;
    update(activeDate);
    enableTodayButton();
  }
View Full Code Here

  @Override
  public void setValue(Date date, boolean fireEvents) {
    if (date == null) {
      this.value = null;
      update(new DateWrapper().resetTime());
    } else {
      this.value = new DateWrapper(date).resetTime();
      update(value);
    }

    if (overElement != null) {
      appearance.onUpdateDateStyle(overElement, DateState.OVER, false);
View Full Code Here

    }
  }

  protected void onKeyEnd(NativeEvent evt) {
    if (evt.getShiftKey()) {
      setValue(new DateWrapper(activeDate.getFullYear(), 11, 31).asDate());
    } else {
      setValue(activeDate.getLastDateOfMonth().asDate(), false);
    }
  }
View Full Code Here

    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

      setValue(d);
    }
  }

  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 update(DateWrapper date) {
    DateWrapper vd = activeDate;
    activeDate = date;
    if (vd != null) {
      int days = date.getDaysInMonth();
      DateWrapper firstOfMonth = date.getFirstDayOfMonth();
      int startingPos = firstOfMonth.getDayInWeek() - startDay;

      if (startingPos <= startDay) {
        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.PREVIOUS, false);
        appearance.onUpdateDateStyle(cells[i], DateState.NEXT, false);
        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

    if (maxDateValidator == null) {
      maxDateValidator = new MaxDateValidator(maxValue);
      addValidator(maxDateValidator);
    }
    if (maxValue != null) {
      maxValue = new DateWrapper(maxValue).resetTime().asDate();
      maxDateValidator.setMaxDate(maxValue);
    }
  }
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.