Package com.extjs.gxt.ui.client.util

Examples of com.extjs.gxt.ui.client.util.DateWrapper


    setWidth(177);

    cells = Util.toElementArray(el().select("table.x-date-inner tbody td"));
    textNodes = Util.toElementArray(el().select("table.x-date-inner tbody span"));

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

    if (GXT.isAriaEnabled()) {
      String[] tags = new String[] {"table", "tbody", "tr", "td"};
      for (int i = 0; i < tags.length; i++) {
View Full Code Here


  private void handleDateClick(El 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 && !target.getParent().hasStyleName("x-date-disabled")) {
      setValue(d);
    }
  }
View Full Code Here

    }

  }

  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() {
    update(activeDate.addMonths(-1));
  }

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

      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++) {
        fly(textNodes[i]).update("" + ++prevStart);
        d = d.addDays(1);
        cells[i].setClassName("x-date-prevday");
        if (GXT.isAriaEnabled()) {
          cells[i].setAttribute("aria-disabled", "true");
        }
        setCellStyle(cells[i], d.asDate(), sel, min, max);
      }
      for (; i < days; i++) {
        int intDay = i - startingPos + 1;
        fly(textNodes[i]).update("" + intDay);
        d = d.addDays(1);
        cells[i].setClassName("x-date-active");
        setCellStyle(cells[i], d.asDate(), sel, min, max);
      }
      int extraDays = 0;
      for (; i < 42; i++) {
        fly(textNodes[i]).update("" + ++extraDays);
        d = d.addDays(1);
        cells[i].setClassName("x-date-nextday");
        if (GXT.isAriaEnabled()) {
          cells[i].setAttribute("aria-disabled", "true");
        }
        setCellStyle(cells[i], d.asDate(), sel, min, max);
      }

      int month = activeDate.getMonth();

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

   * @param date the date
   * @return the matching model or null if no match
   */
  public Time findModel(Date date) {
    if (!initialized) initList();
    DateWrapper w = new DateWrapper();
    DateWrapper w2 = new DateWrapper(date);

    w = w.clearTime();
    w = w.addHours(w2.getHours());
    w = w.addMinutes(w2.getMinutes());

    long l = w.getTime();

    List<Time> times = store.getModels();
    for (int i = 0; i < times.size(); i++) {
      Time t1 = store.getAt(i);
      Time t2 = store.getAt(i + 1);

      long l1 = t1.getDate().getTime();
      long l2;

      if (t2 == null) {
        DateWrapper temp = new DateWrapper();
        temp = temp.clearTime();
        temp = temp.addMinutes(t1.getMinutes() + increment);
        temp = temp.addHours(t1.getHour());
        l2 = temp.asDate().getTime();
      } else {
        l2 = t2.getDate().getTime();
      }

      if (l >= l1 && l < l2) {
View Full Code Here

   * @param hours the hours
   * @param minutes the minutes
   * @return the matching model or null if no match
   */
  public Time findModel(int hours, int minutes) {
    DateWrapper w = new DateWrapper();
    w = w.clearTime();
    w = w.addHours(hours);
    w = w.addMinutes(minutes);
    return findModel(w.asDate());
  }
View Full Code Here

  @Override
  protected void initList() {
    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);

    List<Time> times = new ArrayList<Time>();
    while (min.before(max)) {
      times.add(new Time(min.asDate(), getFormat().format(min.asDate())));
      min = min.addMinutes(increment);
View Full Code Here

      getInputEl().dom.setAttribute("title", getMessages().getAriaText());
    }
  }

  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

   *
   * @param maxValue the max value
   */
  public void setMaxValue(Date maxValue) {
    if (maxValue != null) {
      maxValue = new DateWrapper(maxValue).resetTime().asDate();
    }
    this.maxValue = maxValue;
  }
View Full Code Here

TOP

Related Classes of com.extjs.gxt.ui.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.