コード例 #1
0
    private static Div generateCompletionShade(IDatesMapper datesMapper, LimitingResourceQueueElement queueElement) {

        int workableHours = queueElement
                .getLimitingResourceQueue()
                .getResource()
                .getCalendar()
                .getCapacityOn(PartialDay.wholeDay(queueElement.getEndDate()))
                .roundToHours();

        Long shadeWidth = (24 - workableHours) *
                DatesMapperOnInterval.MILISECONDS_PER_HOUR / datesMapper.getMilisecondsPerPixel();

        Long lShadeLeft = (workableHours - queueElement.getEndHour()) *
                DatesMapperOnInterval.MILISECONDS_PER_HOUR / datesMapper.getMilisecondsPerPixel();

        int shadeLeft = lShadeLeft.intValue() + shadeWidth.intValue();

        Div notWorkableHoursShade = new Div();

        notWorkableHoursShade.setContext("");
        notWorkableHoursShade.setSclass("limiting-completion");
        notWorkableHoursShade.setStyle("left: " + shadeLeft + "px; width: " + shadeWidth.intValue() + "px;");

        return notWorkableHoursShade;
    }
コード例 #2
0
    private static Component generateProgressBar(IDatesMapper datesMapper, LimitingResourceQueueElement queueElement) {

        DateAndHour advancementEndDate = getAdvanceEndDate(queueElement);

        if ( advancementEndDate == null ) {
            return null;
        }

        Duration durationBetween = new Duration(
                queueElement.getStartTime().toDateTime().getMillis(), advancementEndDate.toDateTime().getMillis());

        Div progressBar = new Div();

        if ( !queueElement.getStartDate().isEqual(advancementEndDate.getDate()) ) {
            progressBar.setWidth(datesMapper.toPixels(durationBetween) + "px");
            progressBar.setSclass("queue-progress-bar");
        }

        return progressBar;
    }
コード例 #3
0
 private static int getStartPixels(IDatesMapper datesMapper, LimitingResourceQueueElement queueElement) {
     return datesMapper.toPixelsAbsolute(
             queueElement.getStartDate().toDateTimeAtStartOfDay().getMillis() +
                     queueElement.getStartHour() * DatesMapperOnInterval.MILISECONDS_PER_HOUR);
 }
コード例 #4
0
 private static int getDeadlinePixels(IDatesMapper datesMapper, LocalDate deadlineDate) {
     // Deadline date is considered inclusively
     return datesMapper.toPixelsAbsolute(deadlineDate.plusDays(1).toDateTimeAtStartOfDay().getMillis());
 }
コード例 #5
0
 private static int getWidthPixels(IDatesMapper datesMapper, LimitingResourceQueueElement queueElement) {
     return datesMapper.toPixels(queueElement.getLengthBetween());
 }
コード例 #6
0
    private static QueueTask createDivForElement(IDatesMapper datesMapper, LimitingResourceQueueElement queueElement) {

        final Task task = queueElement.getResourceAllocation().getTask();
        final OrderElement order = getRootOrder(task);

        QueueTask result = new QueueTask(queueElement);
        String cssClass = "queue-element";
        result.setTooltiptext(createTooltiptext(queueElement));

        int startPixels = getStartPixels(datesMapper, queueElement);
        result.setLeft(forCSS(startPixels));

        if ( startPixels < 0 ) {
            cssClass += " truncated-start ";
        }

        int taskWidth = getWidthPixels(datesMapper, queueElement);

        if ( (startPixels + taskWidth) > datesMapper.getHorizontalSize() ) {
            taskWidth = datesMapper.getHorizontalSize() - startPixels;
            cssClass += " truncated-end ";
        } else {
            result.appendChild(generateNonWorkableShade(datesMapper, queueElement));
        }
        result.setWidth(forCSS(taskWidth));

        LocalDate deadlineDate = task.getDeadline();
        boolean isOrderDeadline = false;

        if ( deadlineDate == null ) {

            Date orderDate = order.getDeadline();

            if ( orderDate != null ) {

                deadlineDate = LocalDate.fromDateFields(orderDate);
                isOrderDeadline = true;

            }
        }

        if ( deadlineDate != null ) {

            int deadlinePosition = getDeadlinePixels(datesMapper, deadlineDate);

            if ( deadlinePosition < datesMapper.getHorizontalSize() ) {
                Div deadline = new Div();
                deadline.setSclass(isOrderDeadline ? "deadline order-deadline" : "deadline");
                deadline.setLeft((deadlinePosition - startPixels - DEADLINE_MARK_HALF_WIDTH) + "px");
                result.appendChild(deadline);
                result.appendChild(generateNonWorkableShade(datesMapper, queueElement));
            }

            if ( deadlineDate.isBefore(queueElement.getEndDate()) ) {
                cssClass += " unmet-deadline ";
            }
        }

        result.setClass(cssClass);
        result.appendChild(generateCompletionShade(datesMapper, queueElement));
        Component progressBar = generateProgressBar(datesMapper, queueElement);

        if ( progressBar != null ) {
            result.appendChild(progressBar);
        }

        return result;
    }