Example usage for org.joda.time LocalDate LocalDate

List of usage examples for org.joda.time LocalDate LocalDate

Introduction

In this page you can find the example usage for org.joda.time LocalDate LocalDate.

Prototype

public LocalDate(int year, int monthOfYear, int dayOfMonth) 

Source Link

Document

Constructs an instance set to the specified date and time using ISOChronology.

Usage

From source file:com.axelor.apps.hr.service.PayrollPreparationService.java

License:Open Source License

public void fillInExtraHours(PayrollPreparation payrollPreparation) {
    LocalDate fromDate = new LocalDate(payrollPreparation.getYearPeriod(), payrollPreparation.getMonthSelect(),
            1);/*from ww  w  .j av  a  2s  .  c o  m*/
    LocalDate toDate = new LocalDate(fromDate);
    toDate = toDate.dayOfMonth().withMaximumValue();
    for (ExtraHoursLine extraHoursLine : Beans.get(ExtraHoursLineRepository.class).all().filter(
            "self.user.employee = ?1 AND self.extraHours.statusSelect = 3 AND self.date BETWEEN ?2 AND ?3 AND self.payrollPreparation = null",
            payrollPreparation.getEmployee(), fromDate, toDate).fetch()) {
        payrollPreparation.addExtraHoursLineListItem(extraHoursLine);
    }
}

From source file:com.axelor.apps.production.web.OperationOrderController.java

License:Open Source License

public void chargeByMachineHours(ActionRequest request, ActionResponse response) throws AxelorException {
    List<Map<String, Object>> dataList = new ArrayList<Map<String, Object>>();
    DateTimeFormatter parser = ISODateTimeFormat.dateTime();
    LocalDateTime fromDateTime = LocalDateTime.parse(request.getContext().get("fromDateTime").toString(),
            parser);/*from   w  w  w .  ja va2 s. c o m*/
    LocalDateTime toDateTime = LocalDateTime.parse(request.getContext().get("toDateTime").toString(), parser);
    LocalDateTime itDateTime = new LocalDateTime(fromDateTime);

    if (Days.daysBetween(
            new LocalDate(fromDateTime.getYear(), fromDateTime.getMonthOfYear(), fromDateTime.getDayOfMonth()),
            new LocalDate(toDateTime.getYear(), toDateTime.getMonthOfYear(), toDateTime.getDayOfMonth()))
            .getDays() > 20) {
        throw new AxelorException(String.format(I18n.get(IExceptionMessage.CHARGE_MACHINE_DAYS)),
                IException.CONFIGURATION_ERROR);
    }

    List<OperationOrder> operationOrderListTemp = operationOrderRepo.all()
            .filter("self.plannedStartDateT <= ?2 AND self.plannedEndDateT >= ?1", fromDateTime, toDateTime)
            .fetch();
    Set<String> machineNameList = new HashSet<String>();
    for (OperationOrder operationOrder : operationOrderListTemp) {
        if (operationOrder.getWorkCenter() != null && operationOrder.getWorkCenter().getMachine() != null) {
            if (!machineNameList.contains(operationOrder.getWorkCenter().getMachine().getName())) {
                machineNameList.add(operationOrder.getWorkCenter().getMachine().getName());
            }
        }
    }
    while (!itDateTime.isAfter(toDateTime)) {
        List<OperationOrder> operationOrderList = operationOrderRepo.all()
                .filter("self.plannedStartDateT <= ?2 AND self.plannedEndDateT >= ?1", itDateTime,
                        itDateTime.plusHours(1))
                .fetch();
        Map<String, BigDecimal> map = new HashMap<String, BigDecimal>();
        for (OperationOrder operationOrder : operationOrderList) {
            if (operationOrder.getWorkCenter() != null && operationOrder.getWorkCenter().getMachine() != null) {
                String machine = operationOrder.getWorkCenter().getMachine().getName();
                int numberOfMinutes = 0;
                if (operationOrder.getPlannedStartDateT().isBefore(itDateTime)) {
                    numberOfMinutes = Minutes.minutesBetween(itDateTime, operationOrder.getPlannedEndDateT())
                            .getMinutes();
                } else if (operationOrder.getPlannedEndDateT().isAfter(itDateTime.plusHours(1))) {
                    numberOfMinutes = Minutes
                            .minutesBetween(operationOrder.getPlannedStartDateT(), itDateTime.plusHours(1))
                            .getMinutes();
                } else {
                    numberOfMinutes = Minutes.minutesBetween(operationOrder.getPlannedStartDateT(),
                            operationOrder.getPlannedEndDateT()).getMinutes();
                }
                if (numberOfMinutes > 60) {
                    numberOfMinutes = 60;
                }
                BigDecimal percentage = new BigDecimal(numberOfMinutes).multiply(new BigDecimal(100))
                        .divide(new BigDecimal(60), 2, RoundingMode.HALF_UP);
                if (map.containsKey(machine)) {
                    map.put(machine, map.get(machine).add(percentage));
                } else {
                    map.put(machine, percentage);
                }
            }
        }
        Set<String> keyList = map.keySet();
        for (String key : machineNameList) {
            if (keyList.contains(key)) {
                Map<String, Object> dataMap = new HashMap<String, Object>();
                if (Hours.hoursBetween(fromDateTime, toDateTime).getHours() > 24) {
                    dataMap.put("dateTime", (Object) itDateTime.toString("dd/MM/yyyy HH:mm"));
                } else {
                    dataMap.put("dateTime", (Object) itDateTime.toString("HH:mm"));
                }
                dataMap.put("charge", (Object) map.get(key));
                dataMap.put("machine", (Object) key);
                dataList.add(dataMap);
            } else {
                Map<String, Object> dataMap = new HashMap<String, Object>();
                if (Hours.hoursBetween(fromDateTime, toDateTime).getHours() > 24) {
                    dataMap.put("dateTime", (Object) itDateTime.toString("dd/MM/yyyy HH:mm"));
                } else {
                    dataMap.put("dateTime", (Object) itDateTime.toString("HH:mm"));
                }
                dataMap.put("charge", (Object) BigDecimal.ZERO);
                dataMap.put("machine", (Object) key);
                dataList.add(dataMap);
            }
        }

        itDateTime = itDateTime.plusHours(1);
    }

    response.setData(dataList);
}

From source file:com.axelor.apps.production.web.OperationOrderController.java

License:Open Source License

public void chargeByMachineDays(ActionRequest request, ActionResponse response) throws AxelorException {
    List<Map<String, Object>> dataList = new ArrayList<Map<String, Object>>();
    DateTimeFormatter parser = ISODateTimeFormat.dateTime();
    LocalDateTime fromDateTime = LocalDateTime.parse(request.getContext().get("fromDateTime").toString(),
            parser);/*from   ww w. j ava2 s . co m*/
    fromDateTime = fromDateTime.withHourOfDay(0).withMinuteOfHour(0);
    LocalDateTime toDateTime = LocalDateTime.parse(request.getContext().get("toDateTime").toString(), parser);
    toDateTime = toDateTime.withHourOfDay(23).withMinuteOfHour(59);
    LocalDateTime itDateTime = new LocalDateTime(fromDateTime);
    if (Days.daysBetween(
            new LocalDate(fromDateTime.getYear(), fromDateTime.getMonthOfYear(), fromDateTime.getDayOfMonth()),
            new LocalDate(toDateTime.getYear(), toDateTime.getMonthOfYear(), toDateTime.getDayOfMonth()))
            .getDays() > 500) {
        throw new AxelorException(String.format(I18n.get(IExceptionMessage.CHARGE_MACHINE_DAYS)),
                IException.CONFIGURATION_ERROR);
    }

    List<OperationOrder> operationOrderListTemp = operationOrderRepo.all()
            .filter("self.plannedStartDateT <= ?2 AND self.plannedEndDateT >= ?1", fromDateTime, toDateTime)
            .fetch();
    Set<String> machineNameList = new HashSet<String>();
    for (OperationOrder operationOrder : operationOrderListTemp) {
        if (operationOrder.getWorkCenter() != null && operationOrder.getWorkCenter().getMachine() != null) {
            if (!machineNameList.contains(operationOrder.getWorkCenter().getMachine().getName())) {
                machineNameList.add(operationOrder.getWorkCenter().getMachine().getName());
            }
        }
    }
    while (!itDateTime.isAfter(toDateTime)) {
        List<OperationOrder> operationOrderList = operationOrderRepo.all()
                .filter("self.plannedStartDateT <= ?2 AND self.plannedEndDateT >= ?1", itDateTime,
                        itDateTime.plusHours(1))
                .fetch();
        Map<String, BigDecimal> map = new HashMap<String, BigDecimal>();
        for (OperationOrder operationOrder : operationOrderList) {
            if (operationOrder.getWorkCenter() != null && operationOrder.getWorkCenter().getMachine() != null) {
                String machine = operationOrder.getWorkCenter().getMachine().getName();
                int numberOfMinutes = 0;
                if (operationOrder.getPlannedStartDateT().isBefore(itDateTime)) {
                    numberOfMinutes = Minutes.minutesBetween(itDateTime, operationOrder.getPlannedEndDateT())
                            .getMinutes();
                } else if (operationOrder.getPlannedEndDateT().isAfter(itDateTime.plusHours(1))) {
                    numberOfMinutes = Minutes
                            .minutesBetween(operationOrder.getPlannedStartDateT(), itDateTime.plusHours(1))
                            .getMinutes();
                } else {
                    numberOfMinutes = Minutes.minutesBetween(operationOrder.getPlannedStartDateT(),
                            operationOrder.getPlannedEndDateT()).getMinutes();
                }
                if (numberOfMinutes > 60) {
                    numberOfMinutes = 60;
                }
                int numberOfMinutesPerDay = 0;
                if (operationOrder.getWorkCenter().getMachine().getWeeklyPlanning() != null) {
                    DayPlanning dayPlanning = weeklyPlanningService.findDayPlanning(
                            operationOrder.getWorkCenter().getMachine().getWeeklyPlanning(),
                            new LocalDate(itDateTime));
                    numberOfMinutesPerDay = Minutes
                            .minutesBetween(dayPlanning.getMorningFrom(), dayPlanning.getMorningTo())
                            .getMinutes();
                    numberOfMinutesPerDay += Minutes
                            .minutesBetween(dayPlanning.getAfternoonFrom(), dayPlanning.getAfternoonTo())
                            .getMinutes();
                } else {
                    numberOfMinutesPerDay = 60 * 8;
                }
                BigDecimal percentage = new BigDecimal(numberOfMinutes).multiply(new BigDecimal(100))
                        .divide(new BigDecimal(numberOfMinutesPerDay), 2, RoundingMode.HALF_UP);
                if (map.containsKey(machine)) {
                    map.put(machine, map.get(machine).add(percentage));
                } else {
                    map.put(machine, percentage);
                }
            }
        }
        Set<String> keyList = map.keySet();
        for (String key : machineNameList) {
            if (keyList.contains(key)) {
                int found = 0;
                for (Map<String, Object> mapIt : dataList) {
                    if (mapIt.get("dateTime").equals((Object) itDateTime.toString("dd/MM/yyyy"))
                            && mapIt.get("machine").equals((Object) key)) {
                        mapIt.put("charge", new BigDecimal(mapIt.get("charge").toString()).add(map.get(key)));
                        found = 1;
                        break;
                    }

                }
                if (found == 0) {
                    Map<String, Object> dataMap = new HashMap<String, Object>();

                    dataMap.put("dateTime", (Object) itDateTime.toString("dd/MM/yyyy"));
                    dataMap.put("charge", (Object) map.get(key));
                    dataMap.put("machine", (Object) key);
                    dataList.add(dataMap);
                }
            }
        }

        itDateTime = itDateTime.plusHours(1);
    }

    response.setData(dataList);
}

From source file:com.axelor.apps.project.service.ProjectPlanningService.java

License:Open Source License

public LocalDate getFromDate() {
    LocalDate todayDate = generalService.getTodayDate();
    return new LocalDate(todayDate.getYear(), todayDate.getMonthOfYear(),
            todayDate.dayOfMonth().getMinimumValue());
}

From source file:com.axelor.apps.project.service.ProjectPlanningService.java

License:Open Source License

public LocalDate getToDate() {
    LocalDate todayDate = generalService.getTodayDate();
    return new LocalDate(todayDate.getYear(), todayDate.getMonthOfYear(),
            todayDate.dayOfMonth().getMaximumValue());
}

From source file:com.axelor.csv.script.UpdateAll.java

License:Open Source License

@Transactional
public Object updatePeriod(Object bean, Map<String, Object> values) {
    try {//from w  ww.  j a  v a 2s .c o  m
        assert bean instanceof Company;
        Company company = (Company) bean;
        List<? extends Period> periods = periodRepo.all().filter("self.company.id = ?1", company.getId())
                .fetch();
        if (periods == null || periods.isEmpty()) {
            for (Year year : yearRepo.all()
                    .filter("self.company.id = ?1 AND self.typeSelect = 1", company.getId()).fetch()) {
                for (Integer month : Arrays.asList(new Integer[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12 })) {
                    Period period = new Period();
                    LocalDate dt = new LocalDate(year.getFromDate().getYear(), month, 1);
                    period.setToDate(dt.dayOfMonth().withMaximumValue());
                    period.setFromDate(dt.dayOfMonth().withMinimumValue());
                    period.setYear(year);
                    period.setStatusSelect(PeriodRepository.STATUS_OPENED);
                    period.setCompany(company);
                    period.setCode(dt.toString().split("-")[1] + "/" + year.getCode().split("_")[0] + "_"
                            + company.getName());
                    period.setName(dt.toString().split("-")[1] + '/' + year.getName());
                    periodRepo.save(period);
                }
            }
        }

        return company;
    } catch (Exception e) {
        e.printStackTrace();
    }
    return bean;
}

From source file:com.creditcloud.wealthproduct.model.utils.WealthProductCalculator.java

/**
 * @deprecated analyze???//from  w w w.j av a  2 s  .com
 *
 * @param asOfDate
 * @param nextKMonth
 * @return
 */
public static LocalDate countDueDate(final LocalDate asOfDate, int nextKMonth) {
    final int[][] leap = { { 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 },
            { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 } };
    int year = asOfDate.getYear();
    int month = asOfDate.getMonthOfYear();
    int day = asOfDate.getDayOfMonth();
    int i = ((year % 4 == 0 && year % 100 != 0) || (year % 400 == 0)) ? 0 : 1;
    int nextYear = year + (month + nextKMonth - 1) / 12;
    int nextMonth = (month + nextKMonth - 1) % 12;
    int j = ((nextYear % 4 == 0 && nextYear % 100 != 0) || (nextYear % 400 == 0)) ? 0 : 1;
    int maxNextDay = leap[j][nextMonth];
    int maxCurrentDay = leap[i][month - 1];
    LocalDate local;
    if (day < maxCurrentDay && day < maxNextDay) {
        local = new LocalDate(nextYear, nextMonth + 1, day);
    } else {
        local = new LocalDate(nextYear, nextMonth + 1, maxNextDay);
    }
    return local;
}

From source file:com.creditcloud.wealthproduct.model.utils.WealthProductCalculator.java

/**
 * ???./* www  .ja v  a2s.  c o m*/
 *
 * @param amount
 * @param duration
 * @param rate             2400 means 24.00%
 * @param method
 * @param asOfDate         ?131?: 228(29)?331?430
 * @param period           
 * @param repayDateOfMonth 
 * @return
 */
public static WealthProductRepaymentDetail analyze(final BigDecimal amount, final Duration duration,
        final int rate, final RepaymentMethod method, final LocalDate asOfDate, final RepaymentPeriod period,
        final int repayDateOfMonth) {
    if (period == null) {
        return analyze(amount, duration, rate, method, asOfDate);
    }
    if (repayDateOfMonth == 0) {
        return analyze(amount, duration, rate, method, asOfDate, period);
    }
    if (!method.isExtensible()) {
        throw new IllegalArgumentException(method + "is not extensible repayment.");
    }
    if (!method.equals(BulletRepayment)) {//???
        //periodRepaymentMethod???
        ValidateResult validateResult = validatePeriodAndDuration(period, duration);
        if (!validateResult.isSuccess()) {
            throw new IllegalArgumentException(validateResult.getMessage());
        }
    }
    WealthProductRepaymentDetail result = null;

    //principal
    BigDecimal principal = amount;
    //now get rates
    BigDecimal rateYear = new BigDecimal(rate).divide(rateScale, mc);
    BigDecimal rateMonth = rateYear.divide(monthsPerYear, mc);
    BigDecimal ratePeriod = rateMonth.multiply(new BigDecimal(period.getMonthsOfPeriod()));

    //??
    int fixDays = repayDateOfMonth - asOfDate.getDayOfMonth();
    int fixMonth = asOfDate.getMonthOfYear() - 1;
    //31??31?
    LocalDate fixAsOfDate = new LocalDate(asOfDate.getYear(), 1, repayDateOfMonth);
    if (fixDays < 0) {
        fixAsOfDate = fixAsOfDate.plusMonths(1);
    }

    //dealing with different methods
    BigDecimal interest, amortizedInterest, amortizedPrincipal, outstandingPrincipal;

    int tenure;
    switch (method) {
    case BulletRepayment:
        //???
        analyze(amount, duration, rate, method, asOfDate);
        break;
    case MonthlyInterest: //period?
        tenure = duration.getTotalMonths() / period.getMonthsOfPeriod();
        amortizedInterest = principal.multiply(ratePeriod).setScale(2, NumberConstant.ROUNDING_MODE);
        interest = amortizedInterest.multiply(new BigDecimal(tenure));
        //create result
        result = new WealthProductRepaymentDetail(principal, interest, duration, method,
                new ArrayList<Repayment>());

        //add amortized items
        for (int i = 0; i < tenure; i++) {
            if (i < tenure - 1) { //only interest, no principal
                result.getRepayments()
                        .add(new Repayment(ZERO, amortizedInterest, principal, DateUtils.offset(fixAsOfDate,
                                new Duration(0, (i + 1) * period.getMonthsOfPeriod() + fixMonth, 0))));
            } else { //last ONE we pay off the principal as well as interest
                result.getRepayments().add(new Repayment(principal, amortizedInterest, ZERO,
                        DateUtils.offset(asOfDate, new Duration(0, (i + 1) * period.getMonthsOfPeriod(), 0))));
            }
        }
        break;
    case EqualInstallment: //period??
        //times of repayments in months
        tenure = (duration.getYears() * 12 + duration.getMonths()) / period.getMonthsOfPeriod();
        BigDecimal[] is = new BigDecimal[tenure + 1];
        for (int i = 0; i <= tenure; i++) {
            is[i] = ratePeriod.add(ONE).pow(i);
        }
        BigDecimal baseInterest = principal.multiply(ratePeriod);
        //calc installment
        BigDecimal installment = baseInterest.multiply(is[tenure]).divide(is[tenure].subtract(ONE), mc);
        installment = installment.setScale(2, NumberConstant.ROUNDING_MODE);
        //reset total interest
        interest = ZERO;
        //create WealthProductRepaymentDetail
        result = new WealthProductRepaymentDetail(principal, interest, duration, method,
                new ArrayList<Repayment>());
        //deal with amortized items
        outstandingPrincipal = principal;
        for (int i = 0; i < tenure; i++) {
            amortizedInterest = baseInterest.subtract(installment, mc).multiply(is[i]).add(installment, mc)
                    .setScale(2, NumberConstant.ROUNDING_MODE);
            amortizedPrincipal = installment.subtract(amortizedInterest);
            outstandingPrincipal = outstandingPrincipal.subtract(amortizedPrincipal);
            if (i == tenure - 1) { //last ONE we need to fix the rounding error and let the oustanding principal be ZERO
                result.getRepayments().add(new Repayment(amortizedPrincipal.add(outstandingPrincipal),
                        amortizedInterest, ZERO,
                        DateUtils.offset(asOfDate, new Duration(0, (i + 1) * period.getMonthsOfPeriod(), 0))));
            } else {
                result.getRepayments()
                        .add(new Repayment(amortizedPrincipal, amortizedInterest, outstandingPrincipal,
                                DateUtils.offset(fixAsOfDate,
                                        new Duration(0, (i + 1) * period.getMonthsOfPeriod() + fixMonth, 0))));
            }
            interest = interest.add(amortizedInterest);
        }
        //fix interest
        result.setInterest(interest);
        break;
    case EqualPrincipal: //period?
        //times of repayments in months
        tenure = (duration.getYears() * 12 + duration.getMonths()) / period.getMonthsOfPeriod();
        //calc amortized principal first
        amortizedPrincipal = principal.divide(new BigDecimal(tenure), mc).setScale(2,
                NumberConstant.ROUNDING_MODE);
        //calc by each month
        BigDecimal[] interests = new BigDecimal[tenure];
        BigDecimal[] outstandingPrincipals = new BigDecimal[tenure];
        outstandingPrincipal = principal;
        interest = ZERO;
        for (int i = 0; i < tenure; i++) {
            interests[i] = outstandingPrincipal.multiply(ratePeriod, mc).setScale(2,
                    NumberConstant.ROUNDING_MODE);
            interest = interest.add(interests[i]);
            outstandingPrincipal = outstandingPrincipal.subtract(amortizedPrincipal);
            outstandingPrincipals[i] = outstandingPrincipal;
        }
        //create WealthProductRepaymentDetail
        result = new WealthProductRepaymentDetail(principal, interest, duration, method,
                new ArrayList<Repayment>());
        //deal with amortized items
        for (int i = 0; i < tenure; i++) {
            if (i == tenure - 1) {
                result.getRepayments().add(new Repayment(amortizedPrincipal.add(outstandingPrincipals[i]),
                        interests[i], ZERO,
                        DateUtils.offset(asOfDate, new Duration(0, (i + 1) * period.getMonthsOfPeriod(), 0))));
            } else {
                result.getRepayments()
                        .add(new Repayment(amortizedPrincipal, interests[i], outstandingPrincipals[i],
                                DateUtils.offset(fixAsOfDate,
                                        new Duration(0, (i + 1) * period.getMonthsOfPeriod() + fixMonth, 0))));
            }
        }
        break;
    case EqualInterest: //period?
        //times of repayments in months
        tenure = (duration.getYears() * 12 + duration.getMonths()) / period.getMonthsOfPeriod();
        //calc amortized principal and interest
        amortizedPrincipal = principal.divide(new BigDecimal(tenure), mc).setScale(2,
                NumberConstant.ROUNDING_MODE);
        amortizedInterest = principal.multiply(ratePeriod).setScale(2, NumberConstant.ROUNDING_MODE);
        interest = amortizedInterest.multiply(new BigDecimal(tenure), mc).setScale(2,
                NumberConstant.ROUNDING_MODE);
        //create WealthProductRepaymentDetail
        result = new WealthProductRepaymentDetail(principal, interest, duration, method,
                new ArrayList<Repayment>());
        //deal with amortized items
        outstandingPrincipal = principal;
        for (int i = 0; i < tenure; i++) {
            outstandingPrincipal = outstandingPrincipal.subtract(amortizedPrincipal);
            if (i == tenure - 1) {
                result.getRepayments().add(new Repayment(amortizedPrincipal.add(outstandingPrincipal),
                        amortizedInterest, ZERO,
                        DateUtils.offset(asOfDate, new Duration(0, (i + 1) * period.getMonthsOfPeriod(), 0))));
            } else {
                result.getRepayments()
                        .add(new Repayment(amortizedPrincipal, amortizedInterest, outstandingPrincipal,
                                DateUtils.offset(fixAsOfDate,
                                        new Duration(0, (i + 1) * period.getMonthsOfPeriod() + fixMonth, 0))));
            }
        }
        break;
    }

    return result;
}

From source file:com.einzig.ipst2.parse.GetMailTask.java

License:Open Source License

/**
 * Get the last date email was parsed//from   w w  w  .  jav a2  s  .  c o m
 *
 * @param dateStr String representation of the last parse date
 * @return Date the email was parsed if previously parsed, otherwise the date Ingress launched
 */
private LocalDate getLastParseDate(String dateStr) {
    LocalDate d;
    try {
        d = DATE_FORMATTER.parseLocalDate(dateStr);
    } catch (IllegalArgumentException e) {
        d = new LocalDate(2012, 10, 15);
    }
    return d;
}

From source file:com.esofthead.mycollab.module.project.view.assignments.gantt.GanttExt.java

License:Open Source License

public GanttExt() {
    this.setTimeZone(TimeZone.getTimeZone("Atlantic/Reykjavik"));
    this.setImmediate(true);
    minDate = new LocalDate(2100, 1, 1);
    maxDate = new LocalDate(1970, 1, 1);
    this.setResizableSteps(true);
    this.setMovableSteps(true);
    this.setHeight((Page.getCurrent().getBrowserWindowHeight() - 270) + "px");
    beanContainer = new GanttItemContainer();

    this.addClickListener(new Gantt.ClickListener() {
        @Override//from  w ww .  jav a2 s. co m
        public void onGanttClick(Gantt.ClickEvent event) {
            if (CurrentProjectVariables.canWrite(ProjectRolePermissionCollections.TASKS)) {
                StepExt step = (StepExt) event.getStep();
                getUI().addWindow(new QuickEditGanttItemWindow(GanttExt.this, step.getGanttItemWrapper()));
            }
        }
    });

    this.addMoveListener(new Gantt.MoveListener() {
        private static final long serialVersionUID = 1L;

        @Override
        public void onGanttMove(MoveEvent event) {
            if (CurrentProjectVariables.canWrite(ProjectRolePermissionCollections.TASKS)) {
                updateTasksInfoByResizeOrMove((StepExt) event.getStep(), event.getStartDate(),
                        event.getEndDate());
            }
        }
    });

    this.addResizeListener(new Gantt.ResizeListener() {
        private static final long serialVersionUID = 1L;

        @Override
        public void onGanttResize(ResizeEvent event) {
            if (CurrentProjectVariables.canWrite(ProjectRolePermissionCollections.TASKS)) {
                updateTasksInfoByResizeOrMove((StepExt) event.getStep(), event.getStartDate(),
                        event.getEndDate());
            }
        }
    });
}