Example usage for com.google.gwt.user.client Window getScrollTop

List of usage examples for com.google.gwt.user.client Window getScrollTop

Introduction

In this page you can find the example usage for com.google.gwt.user.client Window getScrollTop.

Prototype

public static int getScrollTop() 

Source Link

Usage

From source file:org.unitime.timetable.gwt.client.rooms.RoomEdit.java

License:Apache License

public void show() {
    UniTimePageLabel.getInstance()// w w  w. j a  va  2s. c o m
            .setPageName(iRoom.getUniqueId() == null ? MESSAGES.pageAddRoom() : MESSAGES.pageEditRoom());
    setVisible(true);
    iLastScrollLeft = Window.getScrollLeft();
    iLastScrollTop = Window.getScrollTop();
    onShow();
    Window.scrollTo(0, 0);
    if (iGoogleMap != null && !iGoogleMapInitialized) {
        iGoogleMapInitialized = true;
        ScriptInjector.fromUrl("https://maps.google.com/maps/api/js?sensor=false&callback=setupGoogleMap")
                .setWindow(ScriptInjector.TOP_WINDOW).setCallback(new Callback<Void, Exception>() {
                    @Override
                    public void onSuccess(Void result) {
                    }

                    @Override
                    public void onFailure(Exception e) {
                        UniTimeNotifications.error(e.getMessage(), e);
                        iGoogleMap = null;
                        iGoogleMapControl = null;
                    }
                }).inject();
    } else if (iGoogleMap != null) {
        setMarker();
    }
}

From source file:org.unitime.timetable.gwt.client.rooms.RoomFeatureEdit.java

License:Apache License

public void show() {
    UniTimePageLabel.getInstance().setPageName(
            iFeature.getId() == null ? MESSAGES.pageAddRoomFeature() : MESSAGES.pageEditRoomFeature());
    setVisible(true);/*w w  w  .  jav  a2s. c  o m*/
    iLastScrollLeft = Window.getScrollLeft();
    iLastScrollTop = Window.getScrollTop();
    onShow();
    Window.scrollTo(0, 0);
}

From source file:org.unitime.timetable.gwt.client.rooms.RoomGroupEdit.java

License:Apache License

public void show() {
    UniTimePageLabel.getInstance()/*w w w  .  j  av a 2 s. co m*/
            .setPageName(iGroup.getId() == null ? MESSAGES.pageAddRoomGroup() : MESSAGES.pageEditRoomGroup());
    setVisible(true);
    iLastScrollLeft = Window.getScrollLeft();
    iLastScrollTop = Window.getScrollTop();
    onShow();
    Window.scrollTo(0, 0);
}

From source file:org.unitime.timetable.gwt.client.sectioning.EnrollmentTable.java

License:Apache License

public void showChangeLog(final ClassAssignmentInterface.Student student,
        final AsyncCallback<Boolean> callback) {
    iSectioningService.changeLog("id:" + student.getExternalId(),
            new AsyncCallback<List<ClassAssignmentInterface.SectioningAction>>() {
                @Override/*from w w w .  j  a v  a2s.  c o m*/
                public void onFailure(Throwable caught) {
                    callback.onFailure(caught);
                }

                @Override
                public void onSuccess(List<ClassAssignmentInterface.SectioningAction> logs) {
                    if (logs == null || logs.isEmpty()) {
                        callback.onSuccess(false);
                        return;
                    }

                    final UniTimeTable<ClassAssignmentInterface.SectioningAction> table = new UniTimeTable<ClassAssignmentInterface.SectioningAction>();

                    table.addRow(null, new UniTimeTableHeader(MESSAGES.colOperation()),
                            new UniTimeTableHeader(MESSAGES.colTimeStamp()),
                            new UniTimeTableHeader(MESSAGES.colResult()),
                            new UniTimeTableHeader(MESSAGES.colUser()),
                            new UniTimeTableHeader(MESSAGES.colMessage()));

                    for (ClassAssignmentInterface.SectioningAction log : logs) {
                        table.addRow(log, new TopCell(log.getOperation()),
                                new TopCell(sTSF.format(log.getTimeStamp())), new TopCell(log.getResult()),
                                new TopCell(log.getUser() == null ? "" : log.getUser()),
                                new HTML(log.getMessage() == null ? "" : log.getMessage()));
                    }
                    table.addMouseClickListener(
                            new MouseClickListener<ClassAssignmentInterface.SectioningAction>() {
                                @Override
                                public void onMouseClick(TableEvent<SectioningAction> event) {
                                    if (event.getData() != null && event.getData().getProto() != null) {
                                        final HTML widget = new HTML(event.getData().getProto());
                                        final ScrollPanel scroll = new ScrollPanel(widget);
                                        scroll.setHeight(((int) (0.8 * Window.getClientHeight())) + "px");
                                        scroll.setStyleName("unitime-ScrollPanel");
                                        final UniTimeDialogBox dialog = new UniTimeDialogBox(true, false);
                                        dialog.setWidget(scroll);
                                        dialog.setText(MESSAGES.dialogChangeMessage(student.getName()));
                                        dialog.setEscapeToHide(true);
                                        dialog.addOpenHandler(new OpenHandler<UniTimeDialogBox>() {
                                            @Override
                                            public void onOpen(OpenEvent<UniTimeDialogBox> event) {
                                                RootPanel.getBodyElement().getStyle()
                                                        .setOverflow(Overflow.HIDDEN);
                                                scroll.setHeight(Math.min(widget.getElement().getScrollHeight(),
                                                        Window.getClientHeight() * 80 / 100) + "px");
                                                dialog.setPopupPosition(
                                                        Math.max(
                                                                Window.getScrollLeft()
                                                                        + (Window.getClientWidth()
                                                                                - dialog.getOffsetWidth()) / 2,
                                                                0),
                                                        Math.max(
                                                                Window.getScrollTop()
                                                                        + (Window.getClientHeight()
                                                                                - dialog.getOffsetHeight()) / 2,
                                                                0));
                                            }
                                        });
                                        dialog.addCloseHandler(new CloseHandler<PopupPanel>() {
                                            @Override
                                            public void onClose(CloseEvent<PopupPanel> event) {
                                                table.clearHover();
                                                RootPanel.getBodyElement().getStyle()
                                                        .setOverflow(Overflow.AUTO);
                                            }
                                        });
                                        dialog.center();
                                    }
                                }
                            });
                    final UniTimeDialogBox dialog = new UniTimeDialogBox(true, false);
                    final ScrollPanel scroll = new ScrollPanel(table);
                    scroll.setHeight(((int) (0.8 * Window.getClientHeight())) + "px");
                    scroll.setStyleName("unitime-ScrollPanel");
                    dialog.setWidget(scroll);
                    dialog.setText(MESSAGES.dialogChangeLog(student.getName()));
                    dialog.setEscapeToHide(true);
                    dialog.addOpenHandler(new OpenHandler<UniTimeDialogBox>() {
                        @Override
                        public void onOpen(OpenEvent<UniTimeDialogBox> event) {
                            RootPanel.getBodyElement().getStyle().setOverflow(Overflow.HIDDEN);
                            scroll.setHeight(Math.min(table.getElement().getScrollHeight(),
                                    Window.getClientHeight() * 80 / 100) + "px");
                            dialog.setPopupPosition(
                                    Math.max(
                                            Window.getScrollLeft()
                                                    + (Window.getClientWidth() - dialog.getOffsetWidth()) / 2,
                                            0),
                                    Math.max(
                                            Window.getScrollTop()
                                                    + (Window.getClientHeight() - dialog.getOffsetHeight()) / 2,
                                            0));
                        }
                    });
                    dialog.addCloseHandler(new CloseHandler<PopupPanel>() {
                        @Override
                        public void onClose(CloseEvent<PopupPanel> event) {
                            table.clearHover();
                            RootPanel.getBodyElement().getStyle().setOverflow(Overflow.AUTO);
                        }
                    });
                    callback.onSuccess(true);
                    dialog.center();
                }
            });
}

From source file:org.unitime.timetable.gwt.client.sectioning.SectioningStatusPage.java

License:Apache License

public SectioningStatusPage(boolean online) {
    iOnline = online;/*from  ww w .  j a v a 2  s. c  om*/

    iPanel = new VerticalPanel();
    iSectioningPanel = new VerticalPanel();

    iFilterPanel = new HorizontalPanel();
    iFilterPanel.setSpacing(3);

    Label filterLabel = new Label(MESSAGES.filter());
    iFilterPanel.add(filterLabel);
    iFilterPanel.setCellVerticalAlignment(filterLabel, HasVerticalAlignment.ALIGN_MIDDLE);

    iFilter = new SectioningStatusFilterBox(online);
    iFilterPanel.add(iFilter);

    iSearch = new Button(MESSAGES.buttonSearch());
    iSearch.setAccessKey('s');
    iSearch.addStyleName("unitime-NoPrint");
    iFilterPanel.add(iSearch);
    iFilterPanel.setCellVerticalAlignment(iSearch, HasVerticalAlignment.ALIGN_TOP);

    iLoadingImage = new Image(RESOURCES.loading_small());
    iLoadingImage.setVisible(false);
    iFilterPanel.add(iLoadingImage);
    iFilterPanel.setCellVerticalAlignment(iLoadingImage, HasVerticalAlignment.ALIGN_MIDDLE);

    iSectioningPanel.add(iFilterPanel);
    iSectioningPanel.setCellHorizontalAlignment(iFilterPanel, HasHorizontalAlignment.ALIGN_CENTER);

    iCourseTable = new UniTimeTable<EnrollmentInfo>();
    iStudentTable = new UniTimeTable<StudentInfo>();
    iLogTable = new UniTimeTable<SectioningAction>();

    VerticalPanel courseTableWithHint = new VerticalPanel();
    courseTableWithHint.add(iCourseTable);
    iCourseTableHint = new HTML(MESSAGES.sectioningStatusReservationHint());
    iCourseTableHint.setStyleName("unitime-Hint");
    courseTableWithHint.add(iCourseTableHint);
    courseTableWithHint.setCellHorizontalAlignment(iCourseTableHint, HasHorizontalAlignment.ALIGN_RIGHT);

    VerticalPanel studentTableWithHint = new VerticalPanel();
    studentTableWithHint.add(iStudentTable);
    iStudentTableHint = new HTML(MESSAGES.sectioningStatusPriorityHint());
    iStudentTableHint.setStyleName("unitime-Hint");
    studentTableWithHint.add(iStudentTableHint);
    studentTableWithHint.setCellHorizontalAlignment(iStudentTableHint, HasHorizontalAlignment.ALIGN_RIGHT);

    iTabPanel = new UniTimeTabPanel();
    iTabPanel.add(courseTableWithHint, MESSAGES.tabEnrollments(), true);
    iTabPanel.selectTab(0);
    iTabPanel.add(studentTableWithHint, MESSAGES.tabStudents(), true);
    iTabPanel.setVisible(false);

    iTabPanel.addSelectionHandler(new SelectionHandler<Integer>() {
        @Override
        public void onSelection(SelectionEvent<Integer> event) {
            iTabIndex = event.getSelectedItem();
            loadDataIfNeeded();
        }
    });

    iTabPanelWithFocus = new FocusPanel(iTabPanel);
    iTabPanelWithFocus.setStyleName("unitime-FocusPanel");
    iSectioningPanel.add(iTabPanelWithFocus);

    iTabPanelWithFocus.addKeyUpHandler(new KeyUpHandler() {
        public void onKeyUp(KeyUpEvent event) {
            if (event.getNativeEvent().getCtrlKey()
                    && (event.getNativeKeyCode() == 'e' || event.getNativeKeyCode() == 'E')) {
                iTabPanel.selectTab(0);
                event.preventDefault();
            }
            if (event.getNativeEvent().getCtrlKey()
                    && (event.getNativeKeyCode() == 's' || event.getNativeKeyCode() == 'S')) {
                iTabPanel.selectTab(1);
                event.preventDefault();
            }
            if (event.getNativeEvent().getCtrlKey()
                    && (event.getNativeKeyCode() == 'l' || event.getNativeKeyCode() == 'L')) {
                iTabPanel.selectTab(2);
                event.preventDefault();
            }
        }
    });

    iSectioningPanel.setWidth("100%");

    iPanel.add(iSectioningPanel);

    iError = new HTML();
    iError.setStyleName("unitime-ErrorMessage");
    iError.setVisible(false);
    iPanel.add(iError);
    iPanel.setCellHorizontalAlignment(iError, HasHorizontalAlignment.ALIGN_CENTER);

    initWidget(iPanel);

    iSearch.addClickHandler(new ClickHandler() {
        public void onClick(ClickEvent event) {
            loadData();
        }
    });

    iFilter.addKeyUpHandler(new KeyUpHandler() {
        public void onKeyUp(KeyUpEvent event) {
            if (event.getNativeKeyCode() == KeyCodes.KEY_ENTER) {
                if (iFilter.getValue().equals(iLastFilterOnEnter) && !iFilter.getValue().equals(iCourseFilter))
                    loadData();
                else
                    iLastFilterOnEnter = iFilter.getValue();
            }
        }
    });

    iCourseTable.addMouseClickListener(new MouseClickListener<ClassAssignmentInterface.EnrollmentInfo>() {
        @Override
        public void onMouseClick(final TableEvent<EnrollmentInfo> event) {
            if (event.getData() == null || event.getData().getCourseId() == null)
                return; // header or footer
            iCourseTable.clearHover();
            setLoading(true);
            final Long id = (event.getData().getConfigId() == null ? event.getData().getOfferingId()
                    : -event.getData().getClazzId());
            iError.setVisible(false);
            if (event.getData().getConfigId() == null)
                LoadingWidget.getInstance().show(MESSAGES.loadingEnrollments(
                        MESSAGES.course(event.getData().getSubject(), event.getData().getCourseNbr())));
            else
                LoadingWidget.getInstance()
                        .show(MESSAGES.loadingEnrollments(
                                MESSAGES.clazz(event.getData().getSubject(), event.getData().getCourseNbr(),
                                        event.getData().getSubpart(), event.getData().getClazz())));
            if (iOnline) {
                iSectioningService.canApprove(id, new AsyncCallback<List<Long>>() {
                    @Override
                    public void onSuccess(final List<Long> courseIdsCanApprove) {
                        iSectioningService.findEnrollments(iOnline, iCourseFilter, iCourseFilterRequest,
                                event.getData().getCourseId(), event.getData().getClazzId(),
                                new AsyncCallback<List<Enrollment>>() {
                                    @Override
                                    public void onFailure(Throwable caught) {
                                        LoadingWidget.getInstance().hide();
                                        UniTimeNotifications.error(caught);
                                        setLoading(false);
                                        iError.setHTML(caught.getMessage());
                                        iError.setVisible(true);
                                        ToolBox.checkAccess(caught);
                                    }

                                    @Override
                                    public void onSuccess(List<Enrollment> result) {
                                        LoadingWidget.getInstance().hide();
                                        setLoading(false);
                                        iEnrollmentTable.clear();
                                        iEnrollmentTable.setId(id);
                                        iEnrollmentTable.populate(result, courseIdsCanApprove);
                                        if (event.getData().getConfigId() == null)
                                            iEnrollmentDialog.setText(MESSAGES.titleEnrollments(
                                                    MESSAGES.course(event.getData().getSubject(),
                                                            event.getData().getCourseNbr())));
                                        else
                                            iEnrollmentDialog.setText(MESSAGES.titleEnrollments(MESSAGES.clazz(
                                                    event.getData().getSubject(),
                                                    event.getData().getCourseNbr(),
                                                    event.getData().getSubpart(), event.getData().getClazz())));
                                        iEnrollmentDialog.center();
                                    }
                                });
                    }

                    @Override
                    public void onFailure(Throwable caught) {
                        LoadingWidget.getInstance().hide();
                        UniTimeNotifications.error(caught);
                        setLoading(false);
                        iError.setHTML(caught.getMessage());
                        iError.setVisible(true);
                        ToolBox.checkAccess(caught);
                    }
                });
            } else {
                iSectioningService.findEnrollments(iOnline, iCourseFilter, iCourseFilterRequest,
                        event.getData().getCourseId(), event.getData().getClazzId(),
                        new AsyncCallback<List<Enrollment>>() {
                            @Override
                            public void onFailure(Throwable caught) {
                                LoadingWidget.getInstance().hide();
                                UniTimeNotifications.error(caught);
                                setLoading(false);
                                iError.setHTML(caught.getMessage());
                                iError.setVisible(true);
                                ToolBox.checkAccess(caught);
                            }

                            @Override
                            public void onSuccess(List<Enrollment> result) {
                                LoadingWidget.getInstance().hide();
                                setLoading(false);
                                iEnrollmentTable.clear();
                                iEnrollmentTable.setId(id);
                                iEnrollmentTable.populate(result, null);
                                if (event.getData().getConfigId() == null)
                                    iEnrollmentDialog.setText(MESSAGES.titleEnrollments(MESSAGES.course(
                                            event.getData().getSubject(), event.getData().getCourseNbr())));
                                else
                                    iEnrollmentDialog.setText(MESSAGES.titleEnrollments(MESSAGES.clazz(
                                            event.getData().getSubject(), event.getData().getCourseNbr(),
                                            event.getData().getSubpart(), event.getData().getClazz())));
                                iEnrollmentDialog.center();
                            }
                        });
            }
        }
    });

    iStudentTable.addMouseClickListener(new MouseClickListener<StudentInfo>() {
        @Override
        public void onMouseClick(final TableEvent<StudentInfo> event) {
            if (event.getData() == null || event.getData().getStudent() == null)
                return; // header or footer
            iStudentTable.clearHover();
            LoadingWidget.getInstance()
                    .show(MESSAGES.loadingEnrollment(event.getData().getStudent().getName()));
            iError.setVisible(false);
            iEnrollmentTable.showStudentSchedule(event.getData().getStudent(), new AsyncCallback<Boolean>() {
                @Override
                public void onFailure(Throwable caught) {
                    LoadingWidget.getInstance().hide();
                    iError.setHTML(caught.getMessage());
                    iError.setVisible(true);
                }

                @Override
                public void onSuccess(Boolean result) {
                    LoadingWidget.getInstance().hide();
                }
            });
        }
    });

    iLogTable.addMouseClickListener(new MouseClickListener<ClassAssignmentInterface.SectioningAction>() {
        @Override
        public void onMouseClick(TableEvent<SectioningAction> event) {
            if (event.getData() != null && event.getData().getProto() != null) {
                final HTML widget = new HTML(event.getData().getProto());
                final ScrollPanel scroll = new ScrollPanel(widget);
                scroll.setHeight(((int) (0.8 * Window.getClientHeight())) + "px");
                scroll.setStyleName("unitime-ScrollPanel");
                final UniTimeDialogBox dialog = new UniTimeDialogBox(true, false);
                dialog.setWidget(scroll);
                dialog.setText(MESSAGES.dialogChangeMessage(event.getData().getStudent().getName()));
                dialog.setEscapeToHide(true);
                dialog.addOpenHandler(new OpenHandler<UniTimeDialogBox>() {
                    @Override
                    public void onOpen(OpenEvent<UniTimeDialogBox> event) {
                        RootPanel.getBodyElement().getStyle().setOverflow(Overflow.HIDDEN);
                        scroll.setHeight(Math.min(widget.getElement().getScrollHeight(),
                                Window.getClientHeight() * 80 / 100) + "px");
                        dialog.setPopupPosition(
                                Math.max(Window.getScrollLeft()
                                        + (Window.getClientWidth() - dialog.getOffsetWidth()) / 2, 0),
                                Math.max(
                                        Window.getScrollTop()
                                                + (Window.getClientHeight() - dialog.getOffsetHeight()) / 2,
                                        0));
                    }
                });
                dialog.addCloseHandler(new CloseHandler<PopupPanel>() {
                    @Override
                    public void onClose(CloseEvent<PopupPanel> event) {
                        iLogTable.clearHover();
                        RootPanel.getBodyElement().getStyle().setOverflow(Overflow.AUTO);
                    }
                });
                dialog.center();
            }
        }
    });

    History.addValueChangeHandler(new ValueChangeHandler<String>() {
        @Override
        public void onValueChange(ValueChangeEvent<String> event) {
            iCourseTable.clearTable();
            iStudentTable.clearTable();
            iLogTable.clearTable();
            if (event.getValue().endsWith("@")) {
                iFilter.setValue(event.getValue().substring(0, event.getValue().length() - 1));
                iTabPanel.selectTab(1);
            } else if (event.getValue().endsWith("$")) {
                iFilter.setValue(event.getValue().substring(0, event.getValue().length() - 1));
                iTabPanel.selectTab(2);
            } else {
                iFilter.setValue(event.getValue());
                if (iTabIndex != 0)
                    iTabPanel.selectTab(0);
                else
                    loadData();
            }
        }
    });

    iEnrollmentTable = new EnrollmentTable(false, iOnline);
    iEnrollmentScroll = new ScrollPanel(iEnrollmentTable);
    iEnrollmentScroll.setHeight(((int) (0.8 * Window.getClientHeight())) + "px");
    iEnrollmentScroll.setStyleName("unitime-ScrollPanel");
    iEnrollmentDialog = new UniTimeDialogBox(true, false);
    iEnrollmentDialog.setEscapeToHide(true);
    iEnrollmentDialog.setWidget(iEnrollmentScroll);
    iEnrollmentDialog.addOpenHandler(new OpenHandler<UniTimeDialogBox>() {
        @Override
        public void onOpen(OpenEvent<UniTimeDialogBox> event) {
            RootPanel.getBodyElement().getStyle().setOverflow(Overflow.HIDDEN);
            iEnrollmentScroll.setHeight(Math.min(iEnrollmentTable.getElement().getScrollHeight(),
                    Window.getClientHeight() * 80 / 100) + "px");
            iEnrollmentDialog.setPopupPosition(
                    Math.max(Window.getScrollLeft()
                            + (Window.getClientWidth() - iEnrollmentDialog.getOffsetWidth()) / 2, 0),
                    Math.max(Window.getScrollTop()
                            + (Window.getClientHeight() - iEnrollmentDialog.getOffsetHeight()) / 2, 0));
        }
    });
    iEnrollmentTable.getHeader().addButton("close", MESSAGES.buttonClose(), new ClickHandler() {
        @Override
        public void onClick(ClickEvent event) {
            iEnrollmentDialog.hide();
        }
    });

    iEnrollmentDialog.addCloseHandler(new CloseHandler<PopupPanel>() {
        @Override
        public void onClose(CloseEvent<PopupPanel> event) {
            RootPanel.getBodyElement().getStyle().setOverflow(Overflow.AUTO);
        }
    });

    if (iOnline) {
        iSectioningService.getProperties(null, new AsyncCallback<SectioningProperties>() {
            @Override
            public void onSuccess(SectioningProperties result) {
                iProperties = result;
                if (iProperties.isChangeLog())
                    iTabPanel.add(iLogTable, MESSAGES.tabChangeLog(), true);
                checkLastQuery();
            }

            @Override
            public void onFailure(Throwable caught) {
                iError.setHTML(caught.getMessage());
                iError.setVisible(true);
            }
        });
    } else {
        checkLastQuery();
    }

    iStatus = new UniTimeWidget<ListBox>(new ListBox());
    iStatus.getWidget().addItem("");
    iStatus.getWidget().setSelectedIndex(0);

    iSectioningService.lookupStudentSectioningStates(new AsyncCallback<Map<String, String>>() {

        @Override
        public void onFailure(Throwable caught) {
        }

        @Override
        public void onSuccess(Map<String, String> result) {
            iStates = result;
            for (final String ref : new TreeSet<String>(iStates.keySet())) {
                iStatus.getWidget().addItem(iStates.get(ref), ref);
            }
            for (int i = 0; i < iStatus.getWidget().getItemCount(); i++) {
                if ("Cancelled".equalsIgnoreCase(iStatus.getWidget().getValue(i))) {
                    iStatus.getWidget().setSelectedIndex(i);
                    break;
                }
            }
        }
    });

    iSubject = new UniTimeTextBox(512, 473);
    iSubject.setText(MESSAGES.defaulSubject());
    iCC = new UniTimeTextBox(512, 473);
    iMessage = new TextArea();
    iMessage.setStyleName("unitime-TextArea");
    iMessage.setVisibleLines(10);
    iMessage.setCharacterWidth(80);

}

From source file:org.unitime.timetable.gwt.client.sectioning.SuggestionsBox.java

License:Apache License

public SuggestionsBox(TimeGrid.ColorProvider color, boolean online) {
    super(true, false);

    iOnline = online;/*from   w w  w .  j  a v a 2  s .c  om*/

    setText("Alternatives");
    setAnimationEnabled(true);
    setAutoHideEnabled(true);
    setGlassEnabled(true);
    setModal(false);

    VerticalPanel suggestionPanel = new VerticalPanel();
    suggestionPanel.setSpacing(5);

    iFilterPanel = new HorizontalPanelWithHint(new HTML(MESSAGES.suggestionsFilterHint(), false));
    iFilterPanel.setSpacing(3);

    Label filterLabel = new Label("Filter:");
    iFilterPanel.add(filterLabel);
    iFilterPanel.setCellVerticalAlignment(filterLabel, HasVerticalAlignment.ALIGN_MIDDLE);

    iFilter = new AriaTextBox();
    iFilter.setStyleName("gwt-SuggestBox");
    iFilter.getElement().getStyle().setWidth(600, Unit.PX);
    iFilter.getElement().getStyle().setHeight(26, Unit.PX);
    iFilterPanel.add(iFilter);

    HTML ariaDescription = new HTML(MESSAGES.suggestionsFilterHint(), false);
    ariaDescription.setStyleName("unitime-AriaHiddenLabel");
    ariaDescription.getElement().setId(DOM.createUniqueId());
    iFilterPanel.add(ariaDescription);
    Roles.getTextboxRole().setAriaDescribedbyProperty(iFilter.getElement(),
            Id.of(ariaDescription.getElement()));

    iSearch = new AriaButton(MESSAGES.buttonSearch());
    iFilterPanel.add(iSearch);
    iFilterPanel.setCellVerticalAlignment(iSearch, HasVerticalAlignment.ALIGN_MIDDLE);

    iQuickDrop = new AriaButton();
    iFilterPanel.add(iQuickDrop);
    iFilterPanel.setCellVerticalAlignment(iQuickDrop, HasVerticalAlignment.ALIGN_MIDDLE);
    iQuickDrop.setVisible(false);
    iQuickDrop.setEnabled(false);
    iQuickDrop.addClickHandler(new ClickHandler() {
        @Override
        public void onClick(ClickEvent event) {
            hide();
            if (iAssignment == null || iAssignment.isFreeTime()) {
                fireQuickDropEvent();
            } else {
                UniTimeConfirmationDialog.confirm(iUseGwtConfirmations,
                        MESSAGES.confirmQuickDrop(
                                MESSAGES.course(iAssignment.getSubject(), iAssignment.getCourseNbr())),
                        new Command() {
                            @Override
                            public void execute() {
                                fireQuickDropEvent();
                            }
                        });
            }
        }

        protected void fireQuickDropEvent() {
            QuickDropEvent e = new QuickDropEvent(iAssignment);
            for (QuickDropHandler h : iQuickDropHandlers)
                h.onQuickDrop(e);
        }
    });

    suggestionPanel.add(iFilterPanel);
    suggestionPanel.setCellHorizontalAlignment(iFilterPanel, HasHorizontalAlignment.ALIGN_CENTER);

    iSuggestions = new WebTable();
    iSuggestions.setHeader(new WebTable.Row(new WebTable.Cell("", 1, "10px"),
            new WebTable.Cell(MESSAGES.colSubject(), 1, "50px"),
            new WebTable.Cell(MESSAGES.colCourse(), 1, "50px"),
            new WebTable.Cell(MESSAGES.colSubpart(), 1, "40px"),
            new WebTable.Cell(MESSAGES.colClass(), 1, "40px"),
            new WebTable.Cell(MESSAGES.colTime(), 1, "75px").aria(ARIA.colTimeCurrent()),
            new WebTable.Cell("", 1, "1px").aria(ARIA.colTimeNew()),
            new WebTable.Cell(MESSAGES.colDate(), 1, "50px").aria(ARIA.colDateCurrent()),
            new WebTable.Cell("", 1, "1px").aria(ARIA.colDateNew()),
            new WebTable.Cell(MESSAGES.colRoom(), 1, "50px").aria(ARIA.colRoomCurrent()),
            new WebTable.Cell("", 1, "1px").aria(ARIA.colRoomNew()),
            new WebTable.Cell(MESSAGES.colInstructor(), 1, "100px"),
            new WebTable.Cell(MESSAGES.colParent(), 1, "50px"),
            new WebTable.Cell(MESSAGES.colIcons(), 1, "10px")));
    iSuggestions.setSelectSameIdRows(true);
    iSuggestions.setEmptyMessage(MESSAGES.suggestionsLoading());
    iSuggestions.setWidth("100%");
    iSuggestionsScroll = new ScrollPanel(iSuggestions);
    iSuggestionsScroll.getElement().getStyle().setHeight(400, Unit.PX);
    iSuggestionsScroll.setStyleName("unitime-ScrollPanel");
    suggestionPanel.add(iSuggestionsScroll);

    iLegend = new HTML();
    iLegend.setStyleName("unitime-SuggestionsLegend");
    suggestionPanel.add(iLegend);
    suggestionPanel.setCellHorizontalAlignment(iLegend, HasHorizontalAlignment.ALIGN_CENTER);

    iMessages = new HTML();
    iMessages.setStyleName("unitime-SuggestionsMessage");
    suggestionPanel.add(iMessages);
    suggestionPanel.setCellHorizontalAlignment(iMessages, HasHorizontalAlignment.ALIGN_CENTER);

    iCallback = new AsyncCallback<Collection<ClassAssignmentInterface>>() {
        public void onFailure(Throwable caught) {
            iSuggestions.clearData(true);
            iSuggestions.setEmptyMessage("<font color='red'>" + caught.getMessage() + "</font>");
            iMessages.setHTML("");
            LoadingWidget.getInstance().hide();
            center();
            AriaStatus.getInstance().setHTML(caught.getMessage());
        }

        protected String room(ClassAssignmentInterface.ClassAssignment clazz) {
            if (clazz == null)
                return null;
            if (clazz.hasRoom())
                return clazz.getRooms(", ");
            if (clazz.getClassId() != null)
                return MESSAGES.noRoom();
            return "";
        }

        protected String dates(ClassAssignmentInterface.ClassAssignment clazz) {
            if (clazz == null)
                return null;
            if (clazz.hasDatePattern())
                return clazz.getDatePattern();
            if (clazz.getClassId() != null)
                return MESSAGES.noDate();
            return "";
        }

        protected String time(ClassAssignmentInterface.ClassAssignment clazz) {
            if (clazz == null)
                return null;
            return clazz.getTimeString(CONSTANTS.shortDays(), CONSTANTS.useAmPm(), MESSAGES.arrangeHours());
        }

        public void onSuccess(Collection<ClassAssignmentInterface> result) {
            iResult = (ArrayList<ClassAssignmentInterface>) result;
            iMessages.setHTML("");
            String ariaStatus = null;

            if (result.isEmpty()) {
                iSuggestions.clearData(true);
                if (iFilter.getText().isEmpty()) {
                    iSuggestions.setEmptyMessage(MESSAGES.suggestionsNoAlternative(iSource));
                    ariaStatus = ARIA.suggestionsNoAlternative(iSource);

                } else {
                    iSuggestions.setEmptyMessage(
                            MESSAGES.suggestionsNoAlternativeWithFilter(iSource, iFilter.getText()));
                    ariaStatus = ARIA.suggestionsNoAlternativeWithFilter(iSource, iFilter.getText());
                }
                LoadingWidget.getInstance().hide();
                center();
            } else {
                ArrayList<WebTable.Row> rows = new ArrayList<WebTable.Row>();
                int lastSize = 0;
                int suggestionId = 0;
                for (ClassAssignmentInterface suggestion : result) {
                    if (suggestion.hasMessages())
                        iMessages.setHTML(suggestion.getMessages("<br>"));
                    if (suggestion.getCourseAssignments().isEmpty()) {
                        suggestionId++;
                        continue;
                    }
                    for (ClassAssignmentInterface.CourseAssignment course : suggestion.getCourseAssignments()) {
                        ArrayList<ClassAssignmentInterface.ClassAssignment> sameCourse = new ArrayList<ClassAssignmentInterface.ClassAssignment>();
                        if (!course.isFreeTime()) {
                            for (ClassAssignmentInterface.ClassAssignment x : iCurrent) {
                                if (x == null)
                                    continue;
                                if (course.getCourseId().equals(x.getCourseId()))
                                    sameCourse.add(x);
                            }
                        } else {
                            ClassAssignmentInterface.ClassAssignment clazz = course.getClassAssignments()
                                    .get(0);
                            for (ClassAssignmentInterface.ClassAssignment x : iCurrent) {
                                if (x == null)
                                    continue;
                                if (x.isFreeTime()
                                        && x.getDaysString(CONSTANTS.shortDays())
                                                .equals(clazz.getDaysString(CONSTANTS.shortDays()))
                                        && x.getStart() == clazz.getStart()
                                        && x.getLength() == clazz.getLength())
                                    sameCourse.add(x);
                            }
                        }
                        boolean selected = false;
                        if (iAssignment != null && iAssignment.isFreeTime() && course.isFreeTime()
                                && course.getClassAssignments().get(0).getDaysString(CONSTANTS.shortDays())
                                        .equals(iAssignment.getDaysString(CONSTANTS.shortDays()))
                                && course.getClassAssignments().get(0).getStart() == iAssignment.getStart()
                                && course.getClassAssignments().get(0).getLength() == iAssignment.getLength())
                            selected = true;
                        if (iAssignment != null && !iAssignment.isFreeTime() && !iAssignment.isAssigned()
                                && iAssignment.getCourseId().equals(course.getCourseId()))
                            selected = true;
                        if (course.isAssigned()) {
                            int clazzIdx = 0;
                            Long selectClassId = null;
                            String selectSubpart = null;
                            if (iAssignment != null && iAssignment.getSubpartId() != null
                                    && iAssignment.getCourseId().equals(course.getCourseId())) {
                                for (ClassAssignmentInterface.ClassAssignment clazz : course
                                        .getClassAssignments()) {
                                    if (iAssignment.getSubpartId().equals(clazz.getSubpartId()))
                                        selectClassId = clazz.getClassId();
                                }
                                if (selectClassId == null)
                                    for (ClassAssignmentInterface.ClassAssignment clazz : course
                                            .getClassAssignments()) {
                                        if (iAssignment.getSubpart().equals(clazz.getSubpart()))
                                            selectSubpart = clazz.getSubpart();
                                    }
                                if (selectClassId == null && selectSubpart == null)
                                    selected = true;
                            }
                            if (iAssignment == null && !course.isFreeTime()) {
                                boolean found = false;
                                for (ClassAssignmentInterface.ClassAssignment x : iCurrent) {
                                    if (x != null && course.getCourseId().equals(x.getCourseId())) {
                                        found = true;
                                        break;
                                    }
                                }
                                if (!found)
                                    selected = true;
                            }
                            clazz: for (ClassAssignmentInterface.ClassAssignment clazz : course
                                    .getClassAssignments()) {
                                if (selectClassId != null)
                                    selected = selectClassId.equals(clazz.getClassId());
                                if (selectSubpart != null)
                                    selected = selectSubpart.equals(clazz.getSubpart());
                                ClassAssignmentInterface.ClassAssignment old = null;
                                for (ClassAssignmentInterface.ClassAssignment x : iCurrent) {
                                    if (x == null)
                                        continue;
                                    if (course.isFreeTime()) {
                                        if (x.isFreeTime() && x.isCourseAssigned()
                                                && x.getDaysString(CONSTANTS.shortDays())
                                                        .equals(clazz.getDaysString(CONSTANTS.shortDays()))
                                                && x.getStart() == clazz.getStart()
                                                && x.getLength() == clazz.getLength())
                                            continue clazz;
                                    } else {
                                        if (clazz.getCourseId().equals(x.getCourseId())
                                                && clazz.getClassId().equals(x.getClassId()))
                                            continue clazz; // the exact same assignment
                                        if (clazz.getCourseId().equals(x.getCourseId())
                                                && clazz.getSubpartId().equals(x.getSubpartId())) {
                                            old = x;
                                            break;
                                        }
                                    }
                                }
                                if (old == null && clazzIdx < sameCourse.size())
                                    old = sameCourse.get(clazzIdx);
                                if (old == null && sameCourse.size() == 1 && !sameCourse.get(0).isAssigned())
                                    old = sameCourse.get(0);

                                WebTable.IconsCell icons = new WebTable.IconsCell();
                                if (clazz != null && clazz.isSaved())
                                    icons.add(RESOURCES.saved(),
                                            MESSAGES.saved(
                                                    MESSAGES.clazz(clazz.getSubject(), clazz.getCourseNbr(),
                                                            clazz.getSubpart(), clazz.getSection())));
                                if (course.isLocked())
                                    icons.add(RESOURCES.courseLocked(), MESSAGES
                                            .courseLocked(course.getSubject() + " " + course.getCourseNbr()));
                                if (clazz != null && clazz.isOfHighDemand())
                                    icons.add(RESOURCES.highDemand(), MESSAGES.highDemand(clazz.getExpected(),
                                            clazz.getAvailableLimit()));
                                if (clazz != null && clazz.hasNote())
                                    icons.add(RESOURCES.note(), clazz.getNote());
                                if (clazz != null && clazz.hasOverlapNote())
                                    icons.add(RESOURCES.overlap(), clazz.getOverlapNote());
                                if (clazz.isCancelled())
                                    icons.add(RESOURCES.cancelled(),
                                            MESSAGES.classCancelled(
                                                    MESSAGES.clazz(clazz.getSubject(), clazz.getCourseNbr(),
                                                            clazz.getSubpart(), clazz.getSection())));

                                final WebTable.Row row = new WebTable.Row(
                                        new WebTable.Cell(rows.size() == lastSize ? suggestionId + "." : ""),
                                        new WebTable.Cell(clazzIdx > 0 ? ""
                                                : course.isFreeTime() ? MESSAGES.freeTimeSubject()
                                                        : course.getSubject())
                                                                .aria(clazzIdx == 0 ? ""
                                                                        : course.isFreeTime()
                                                                                ? MESSAGES.freeTimeSubject()
                                                                                : course.getSubject()),
                                        new WebTable.Cell(clazzIdx > 0 ? ""
                                                : course.isFreeTime() ? MESSAGES.freeTimeCourse()
                                                        : course.getCourseNbr(CONSTANTS.showCourseTitle()))
                                                                .aria(clazzIdx == 0 ? ""
                                                                        : course.isFreeTime()
                                                                                ? MESSAGES.freeTimeCourse()
                                                                                : course.getCourseNbr(CONSTANTS
                                                                                        .showCourseTitle())),
                                        new WebTable.Cell(compare(old == null ? null : old.getSubpart(),
                                                clazz == null ? null : clazz.getSubpart(), CmpMode.SINGLE,
                                                selected, clazz == null)),
                                        new WebTable.Cell(compare(old == null ? null : old.getSection(),
                                                clazz == null ? null : clazz.getSection(), CmpMode.SINGLE,
                                                selected, clazz == null)),
                                        new WebTable.Cell(compare(time(old), time(clazz), CmpMode.BOTH_OLD,
                                                selected, clazz == null)),
                                        new WebTable.Cell(compare(time(old), time(clazz), CmpMode.BOTH_NEW,
                                                selected, clazz == null)),
                                        new WebTable.Cell(compare(dates(old), dates(clazz), CmpMode.BOTH_OLD,
                                                selected, clazz == null)),
                                        new WebTable.Cell(compare(dates(old), dates(clazz), CmpMode.BOTH_NEW,
                                                selected, clazz == null)),
                                        (clazz != null && clazz.hasDistanceConflict()
                                                ? new WebTable.IconCell(RESOURCES.distantConflict(),
                                                        MESSAGES.backToBackDistance(clazz.getBackToBackRooms(),
                                                                clazz.getBackToBackDistance()),
                                                        compare(room(old), room(clazz), CmpMode.BOTH_OLD,
                                                                selected, clazz == null))
                                                : new WebTable.Cell(compare(room(old), room(clazz),
                                                        CmpMode.BOTH_OLD, selected, clazz == null))),
                                        new WebTable.Cell(compare(room(old), room(clazz), CmpMode.BOTH_NEW,
                                                selected, clazz == null)),
                                        new WebTable.InstructorCell(
                                                clazz == null ? null : clazz.getInstructors(),
                                                clazz == null ? null : clazz.getInstructorEmails(), ", "),
                                        new WebTable.Cell(compare(old == null ? null : old.getParentSection(),
                                                clazz == null ? null : clazz.getParentSection(), CmpMode.SINGLE,
                                                selected, clazz == null)),
                                        icons);
                                String style = (selected ? "text-blue" : "")
                                        + (lastSize > 0 && rows.size() == lastSize ? " top-border-solid"
                                                : clazzIdx == 0 && !rows.isEmpty() ? " top-border-dashed" : "");
                                row.setId(String.valueOf(suggestionId));
                                for (WebTable.Cell cell : row.getCells())
                                    cell.setStyleName(style.trim());
                                row.getCell(0).setStyleName(
                                        (lastSize > 0 && rows.size() == lastSize ? "top-border-solid" : ""));
                                rows.add(row);
                                row.setAriaLabel(ARIA.assigned((course.isFreeTime()
                                        ? MESSAGES.course(MESSAGES.freeTimeSubject(), MESSAGES.freeTimeCourse())
                                        : MESSAGES.clazz(clazz.getSubject(), clazz.getCourseNbr(),
                                                clazz.getSubpart(), clazz.getSection()))
                                        + " " + clazz.getTimeStringAria(CONSTANTS.longDays(),
                                                CONSTANTS.useAmPm(), ARIA.arrangeHours())
                                        + " " + clazz.getRooms(", ")));
                                clazzIdx++;
                            }
                        } else {
                            if (sameCourse.isEmpty() || !sameCourse.get(0).isCourseAssigned())
                                continue;
                            for (int idx = 0; idx < sameCourse.size(); idx++) {
                                ClassAssignmentInterface.ClassAssignment old = sameCourse.get(idx);
                                ClassAssignmentInterface.ClassAssignment clazz = null;

                                WebTable.IconsCell icons = new WebTable.IconsCell();
                                if (old != null && old.isSaved())
                                    icons.add(RESOURCES.saved(), MESSAGES.saved(MESSAGES.clazz(old.getSubject(),
                                            old.getCourseNbr(), old.getSubpart(), old.getSection())));
                                if (course.isLocked())
                                    icons.add(RESOURCES.courseLocked(), MESSAGES
                                            .courseLocked(course.getSubject() + " " + course.getCourseNbr()));
                                if (old != null && old.isOfHighDemand())
                                    icons.add(RESOURCES.highDemand(),
                                            MESSAGES.highDemand(old.getExpected(), old.getAvailableLimit()));
                                if (old != null && old.hasNote())
                                    icons.add(RESOURCES.note(), old.getNote());
                                if (old != null && old.isCancelled())
                                    icons.add(RESOURCES.cancelled(),
                                            MESSAGES.classCancelled(MESSAGES.clazz(old.getSubject(),
                                                    old.getCourseNbr(), old.getSubpart(), old.getSection())));

                                WebTable.Row row = new WebTable.Row(
                                        new WebTable.Cell(rows.size() == lastSize ? suggestionId + "." : ""),
                                        new WebTable.Cell(idx > 0 ? ""
                                                : course.isFreeTime() ? MESSAGES.freeTimeSubject()
                                                        : course.getSubject())
                                                                .aria(idx == 0 ? ""
                                                                        : course.isFreeTime()
                                                                                ? MESSAGES.freeTimeSubject()
                                                                                : course.getSubject()),
                                        new WebTable.Cell(idx > 0 ? ""
                                                : course.isFreeTime() ? MESSAGES.freeTimeCourse()
                                                        : course.getCourseNbr(CONSTANTS.showCourseTitle()))
                                                                .aria(idx == 0 ? ""
                                                                        : course.isFreeTime()
                                                                                ? MESSAGES.freeTimeCourse()
                                                                                : course.getCourseNbr(CONSTANTS
                                                                                        .showCourseTitle())),
                                        new WebTable.Cell(compare(old == null ? null : old.getSubpart(),
                                                clazz == null ? null : clazz.getSubpart(), CmpMode.SINGLE,
                                                false, clazz == null)),
                                        new WebTable.Cell(compare(old == null ? null : old.getSection(),
                                                clazz == null ? null : clazz.getSection(), CmpMode.SINGLE,
                                                false, clazz == null)),
                                        //new WebTable.Cell(compare(old == null ? null : old.getLimitString(), clazz == null ? null : clazz.getLimitString(), false)),
                                        new WebTable.Cell(compare(time(old), time(clazz), CmpMode.BOTH_OLD,
                                                false, clazz == null)),
                                        new WebTable.Cell(compare(time(old), time(clazz), CmpMode.BOTH_NEW,
                                                false, clazz == null)),
                                        new WebTable.Cell(compare(dates(old), dates(clazz), CmpMode.BOTH_OLD,
                                                false, clazz == null)),
                                        new WebTable.Cell(compare(dates(old), dates(clazz), CmpMode.BOTH_NEW,
                                                false, clazz == null)),
                                        (old != null && old.hasDistanceConflict()
                                                ? new WebTable.IconCell(RESOURCES.distantConflict(),
                                                        MESSAGES.backToBackDistance(old.getBackToBackRooms(),
                                                                old.getBackToBackDistance()),
                                                        compare(room(old), room(clazz), CmpMode.BOTH_OLD, false,
                                                                clazz == null))
                                                : new WebTable.Cell(compare(room(old), room(clazz),
                                                        CmpMode.BOTH_OLD, false, clazz == null))),
                                        new WebTable.Cell(compare(room(old), room(clazz), CmpMode.BOTH_NEW,
                                                false, clazz == null)),
                                        //new WebTable.Cell(compare(old == null ? null : old.getInstructors(", "), clazz == null ? null : clazz.getInstructors(", "), true)),
                                        new WebTable.InstructorCell(old == null ? null : old.getInstructors(),
                                                old == null ? null : old.getInstructorEmails(), ", "),
                                        new WebTable.Cell(compare(old == null ? null : old.getParentSection(),
                                                clazz == null ? null : clazz.getParentSection(), CmpMode.SINGLE,
                                                false, clazz == null)),
                                        icons);
                                row.setId(String.valueOf(suggestionId));
                                String style = "text-red"
                                        + (lastSize > 0 && rows.size() == lastSize ? " top-border-solid"
                                                : idx == 0 && !rows.isEmpty() ? " top-border-dashed" : "");
                                for (WebTable.Cell cell : row.getCells())
                                    cell.setStyleName(style);
                                row.getCell(0).setStyleName(
                                        (lastSize > 0 && rows.size() == lastSize ? "top-border-solid" : ""));
                                row.setAriaLabel(ARIA.unassigned((course.isFreeTime()
                                        ? MESSAGES.course(MESSAGES.freeTimeSubject(), MESSAGES.freeTimeCourse())
                                        : MESSAGES.clazz(old.getSubject(), old.getCourseNbr(), old.getSubpart(),
                                                old.getSection()))
                                        + " " + old.getTimeStringAria(CONSTANTS.longDays(), CONSTANTS.useAmPm(),
                                                ARIA.arrangeHours())
                                        + " " + old.getRooms(", ")));
                                rows.add(row);
                            }
                        }
                    }
                    Long lastCourseId = null;
                    current: for (ClassAssignmentInterface.ClassAssignment old : iCurrent) {
                        if (old == null || old.isFreeTime())
                            continue;
                        for (ClassAssignmentInterface.CourseAssignment course : suggestion
                                .getCourseAssignments()) {
                            if (old.getCourseId().equals(course.getCourseId()))
                                continue current;
                        }
                        ClassAssignmentInterface.ClassAssignment clazz = null;

                        WebTable.IconsCell icons = new WebTable.IconsCell();
                        if (old != null && old.isSaved())
                            icons.add(RESOURCES.saved(), MESSAGES.saved(MESSAGES.clazz(old.getSubject(),
                                    old.getCourseNbr(), old.getSubpart(), old.getSection())));
                        if (old != null && old.isOfHighDemand())
                            icons.add(RESOURCES.highDemand(),
                                    MESSAGES.highDemand(old.getExpected(), old.getAvailableLimit()));
                        if (old != null && old.hasNote())
                            icons.add(RESOURCES.note(), old.getNote());
                        if (old != null && old.isCancelled())
                            icons.add(RESOURCES.cancelled(),
                                    MESSAGES.classCancelled(MESSAGES.clazz(old.getSubject(), old.getCourseNbr(),
                                            old.getSubpart(), old.getSection())));

                        WebTable.Row row = new WebTable.Row(
                                new WebTable.Cell(rows.size() == lastSize ? suggestionId + "." : ""),
                                new WebTable.Cell(old.getCourseId().equals(lastCourseId) ? ""
                                        : old.isFreeTime() ? MESSAGES.freeTimeSubject() : old.getSubject())
                                                .aria(!old.getCourseId().equals(lastCourseId) ? ""
                                                        : old.isFreeTime() ? MESSAGES.freeTimeSubject()
                                                                : old.getSubject()),
                                new WebTable.Cell(old.getCourseId().equals(lastCourseId) ? ""
                                        : old.isFreeTime() ? MESSAGES.freeTimeCourse()
                                                : old.getCourseNbr(CONSTANTS.showCourseTitle()))
                                                        .aria(!old.getCourseId().equals(lastCourseId) ? ""
                                                                : old.isFreeTime() ? MESSAGES.freeTimeCourse()
                                                                        : old.getCourseNbr(
                                                                                CONSTANTS.showCourseTitle())),
                                new WebTable.Cell(compare(old == null ? null : old.getSubpart(),
                                        clazz == null ? null : clazz.getSubpart(), CmpMode.SINGLE, false,
                                        clazz == null)),
                                new WebTable.Cell(compare(old == null ? null : old.getSection(),
                                        clazz == null ? null : clazz.getSection(), CmpMode.SINGLE, false,
                                        clazz == null)),
                                //new WebTable.Cell(compare(old == null ? null : old.getLimitString(), clazz == null ? null : clazz.getLimitString(), false)),
                                new WebTable.Cell(compare(time(old), time(clazz), CmpMode.BOTH_OLD, false,
                                        clazz == null)),
                                new WebTable.Cell(compare(time(old), time(clazz), CmpMode.BOTH_NEW, false,
                                        clazz == null)),
                                new WebTable.Cell(compare(dates(old), dates(clazz), CmpMode.BOTH_OLD, false,
                                        clazz == null)),
                                new WebTable.Cell(compare(dates(old), dates(clazz), CmpMode.BOTH_NEW, false,
                                        clazz == null)),
                                (old != null && old.hasDistanceConflict()
                                        ? new WebTable.IconCell(RESOURCES.distantConflict(),
                                                MESSAGES.backToBackDistance(old.getBackToBackRooms(),
                                                        old.getBackToBackDistance()),
                                                compare(room(old), room(clazz), CmpMode.BOTH_OLD, false,
                                                        clazz == null))
                                        : new WebTable.Cell(compare(room(old), room(clazz), CmpMode.BOTH_OLD,
                                                false, clazz == null))),
                                new WebTable.Cell(compare(room(old), room(clazz), CmpMode.BOTH_NEW, false,
                                        clazz == null)),
                                //new WebTable.Cell(compare(old == null ? null : old.getInstructors(", "), clazz == null ? null : clazz.getInstructors(", "), true)),
                                new WebTable.InstructorCell(old == null ? null : old.getInstructors(),
                                        old == null ? null : old.getInstructorEmails(), ", "),
                                new WebTable.Cell(compare(old == null ? null : old.getParentSection(),
                                        clazz == null ? null : clazz.getParentSection(), CmpMode.SINGLE, false,
                                        clazz == null)),
                                icons);
                        row.setId(String.valueOf(suggestionId));
                        String style = "text-red"
                                + (lastSize > 0 && rows.size() == lastSize ? " top-border-solid"
                                        : !old.getCourseId().equals(lastCourseId) && !rows.isEmpty()
                                                ? " top-border-dashed"
                                                : "");
                        for (WebTable.Cell cell : row.getCells())
                            cell.setStyleName(style);
                        row.getCell(0).setStyleName(
                                (lastSize > 0 && rows.size() == lastSize ? " top-border-solid" : ""));
                        row.setAriaLabel(ARIA.unassigned((old.isFreeTime()
                                ? MESSAGES.course(MESSAGES.freeTimeSubject(), MESSAGES.freeTimeCourse())
                                : MESSAGES.clazz(old.getSubject(), old.getCourseNbr(), old.getSubpart(),
                                        old.getSection()))
                                + " " + old.getTimeStringAria(CONSTANTS.longDays(), CONSTANTS.useAmPm(),
                                        ARIA.arrangeHours())
                                + " " + old.getRooms(", ")));
                        rows.add(row);
                        lastCourseId = old.getCourseId();
                    }
                    lastSize = rows.size();
                    suggestionId++;
                }
                WebTable.Row[] rowArray = new WebTable.Row[rows.size()];
                int idx = 0;
                for (WebTable.Row row : rows)
                    rowArray[idx++] = row;
                iSuggestions.setData(rowArray);
                if (rows.isEmpty()) {
                    if (iFilter.getText().isEmpty()) {
                        iSuggestions.setEmptyMessage(MESSAGES.suggestionsNoAlternative(iSource));
                        ariaStatus = ARIA.suggestionsNoAlternative(iSource);
                    } else {
                        iSuggestions.setEmptyMessage(
                                MESSAGES.suggestionsNoAlternativeWithFilter(iSource, iFilter.getText()));
                        ariaStatus = ARIA.suggestionsNoAlternativeWithFilter(iSource, iFilter.getText());
                    }
                    if (!iMessages.getHTML().isEmpty()) {
                        iSuggestions.setEmptyMessage(iMessages.getHTML());
                        ariaStatus += "<br>" + iMessages.getHTML();
                        iMessages.setHTML("");
                    }
                } else {
                    ariaStatus = ARIA.showingAlternatives(Integer.valueOf(rows.get(rows.size() - 1).getId()),
                            iSource);
                }
                LoadingWidget.getInstance().hide();
                center();
                if (ariaStatus != null)
                    AriaStatus.getInstance().setHTML(ariaStatus);
                Scheduler.get().scheduleDeferred(new ScheduledCommand() {
                    public void execute() {
                        iFilter.setFocus(true);
                    }
                });
            }
        }
    };

    iSuggestions.addRowClickHandler(new WebTable.RowClickHandler() {
        public void onRowClick(RowClickEvent event) {
            ClassAssignmentInterface suggestion = iResult.get(Integer.parseInt(event.getRow().getId()));
            SuggestionSelectedEvent e = new SuggestionSelectedEvent(suggestion);
            for (SuggestionSelectedHandler h : iSuggestionSelectedHandlers)
                h.onSuggestionSelected(e);
            hide();
            if (iCustomCallback != null)
                iCustomCallback.onSuccess(suggestion);
        }
    });

    iFilter.addKeyDownHandler(new KeyDownHandler() {
        @Override
        public void onKeyDown(KeyDownEvent event) {
            if (event.getNativeEvent().getKeyCode() == KeyCodes.KEY_ENTER) {
                if (iSuggestions.getSelectedRow() >= 0) {
                    ClassAssignmentInterface suggestion = iResult.get(
                            Integer.parseInt(iSuggestions.getRows()[iSuggestions.getSelectedRow()].getId()));
                    SuggestionSelectedEvent e = new SuggestionSelectedEvent(suggestion);
                    for (SuggestionSelectedHandler h : iSuggestionSelectedHandlers)
                        h.onSuggestionSelected(e);
                    hide();
                    if (iCustomCallback != null)
                        iCustomCallback.onSuccess(suggestion);
                } else {
                    LoadingWidget.getInstance().show(MESSAGES.suggestionsLoading());
                    iSectioningService.computeSuggestions(iOnline, iRequest, iCurrent, iIndex,
                            iFilter.getText(), iCallback);
                }
            }
        }
    });

    iSearch.addClickHandler(new ClickHandler() {
        @Override
        public void onClick(ClickEvent event) {
            LoadingWidget.getInstance().show(MESSAGES.suggestionsLoading());
            iSectioningService.computeSuggestions(iOnline, iRequest, iCurrent, iIndex, iFilter.getText(),
                    iCallback);
        }
    });

    iGrid = new TimeGrid(color);
    iHint = new PopupPanel();
    iHint.setStyleName("unitime-SuggestionsHint");
    iHideHint = new Timer() {
        @Override
        public void run() {
            if (iHint.isShowing())
                iHint.hide();

        }
    };

    iSuggestions.addRowOverHandler(new WebTable.RowOverHandler() {
        @Override
        public void onRowOver(final WebTable.RowOverEvent event) {
            iHideHint.cancel();

            if (iHint.isShowing() && event.getRow().getId().equals(iHintId))
                return;

            if (!event.getRow().getId().equals(iHintId)) {
                ClassAssignmentInterface suggestion = iResult.get(Integer.parseInt(event.getRow().getId()));
                int index = 0;
                iGrid.clear(false);
                for (ClassAssignmentInterface.CourseAssignment course : suggestion.getCourseAssignments()) {
                    for (ClassAssignmentInterface.ClassAssignment clazz : course.getClassAssignments()) {
                        if (clazz.isFreeTime()) {
                            CourseRequestInterface.FreeTime ft = new CourseRequestInterface.FreeTime();
                            ft.setLength(clazz.getLength());
                            ft.setStart(clazz.getStart());
                            for (int d : clazz.getDays())
                                ft.addDay(d);
                            iGrid.addFreeTime(ft);
                        } else if (clazz.isAssigned()) {
                            iGrid.addClass(clazz, index++);
                        }
                    }
                }
                TimeGrid w = (TimeGrid) iGrid.getPrintWidget();
                w.addStyleName("unitime-SuggestionsHintWidget");
                iHint.setWidget(new SimplePanel(w));
                iHint.setSize((w.getWidth() / 2) + "px", (w.getHeight() / 2) + "px");
                iHintId = event.getRow().getId();
            }

            iHint.setPopupPositionAndShow(new PopupPanel.PositionCallback() {
                @Override
                public void setPosition(int offsetWidth, int offsetHeight) {
                    Element tr = iSuggestions.getTable().getRowFormatter().getElement(event.getRowIdx());
                    boolean top = (tr.getAbsoluteBottom() - Window.getScrollTop() + 30 + offsetHeight > Window
                            .getClientHeight());
                    iHint.setPopupPosition(
                            Math.max(
                                    Math.min(event.getEvent().getClientX() + 15,
                                            tr.getAbsoluteRight() - offsetWidth - 15),
                                    tr.getAbsoluteLeft() + 15),
                            top ? tr.getAbsoluteTop() - offsetHeight - 30 : tr.getAbsoluteBottom() + 30);
                }
            });
        }
    });

    iSuggestions.addRowOutHandler(new WebTable.RowOutHandler() {
        @Override
        public void onRowOut(WebTable.RowOutEvent event) {
            if (iHint.isShowing())
                iHideHint.schedule(500);
        }
    });

    iSuggestions.addRowMoveHandler(new WebTable.RowMoveHandler() {
        @Override
        public void onRowMove(WebTable.RowMoveEvent event) {
            if (iHint.isShowing()) {
                if (event.getRowIdx() < 0) {
                    iHint.hide();
                    return;
                }
                Element tr = iSuggestions.getTable().getRowFormatter().getElement(event.getRowIdx());
                boolean top = (tr.getAbsoluteBottom() - Window.getScrollTop() + 30
                        + iHint.getOffsetHeight() > Window.getClientHeight());
                iHint.setPopupPosition(
                        Math.max(
                                Math.min(event.getEvent().getClientX() + 15,
                                        tr.getAbsoluteRight() - iHint.getOffsetWidth() - 15),
                                tr.getAbsoluteLeft() + 15),
                        top ? tr.getAbsoluteTop() - iHint.getOffsetHeight() - 30 : tr.getAbsoluteBottom() + 30);

            }
        }
    });

    addCloseHandler(new CloseHandler<PopupPanel>() {
        @Override
        public void onClose(CloseEvent<PopupPanel> event) {
            if (iHint.isShowing())
                iHint.hide();
            iHideHint.cancel();
            RootPanel.getBodyElement().getStyle().setOverflow(Overflow.AUTO);
            iFilterPanel.hideHint();
        }
    });

    setWidget(suggestionPanel);
}

From source file:org.unitime.timetable.gwt.client.solver.AssignedClassesPage.java

License:Apache License

public static void __search() {
    final int left = Window.getScrollLeft();
    final int top = Window.getScrollTop();
    AssignedClassesPage page = (AssignedClassesPage) RootPanel.get("UniTimeGWT:Body").getWidget(0);
    page.search(new AsyncCallback<Boolean>() {
        @Override// w w  w  . j av  a2s .  c o  m
        public void onFailure(Throwable caught) {
        }

        @Override
        public void onSuccess(Boolean result) {
            if (result)
                Window.scrollTo(left, top);
        }
    });
}

From source file:org.unitime.timetable.gwt.client.solver.AssignmentHistoryPage.java

License:Apache License

public static void __search() {
    final int left = Window.getScrollLeft();
    final int top = Window.getScrollTop();
    AssignmentHistoryPage page = (AssignmentHistoryPage) RootPanel.get("UniTimeGWT:Body").getWidget(0);
    page.search(new AsyncCallback<Boolean>() {
        @Override// w ww . j  a v a 2  s  .  c  o m
        public void onFailure(Throwable caught) {
        }

        @Override
        public void onSuccess(Boolean result) {
            if (result)
                Window.scrollTo(left, top);
        }
    });
}

From source file:org.unitime.timetable.gwt.client.solver.NotAssignedClassesPage.java

License:Apache License

public static void __search() {
    final int left = Window.getScrollLeft();
    final int top = Window.getScrollTop();
    NotAssignedClassesPage page = (NotAssignedClassesPage) RootPanel.get("UniTimeGWT:Body").getWidget(0);
    page.search(new AsyncCallback<Boolean>() {
        @Override/*from w  w  w  .ja v a 2 s.  c  o  m*/
        public void onFailure(Throwable caught) {
        }

        @Override
        public void onSuccess(Boolean result) {
            if (result)
                Window.scrollTo(left, top);
        }
    });
}

From source file:org.unitime.timetable.gwt.client.solver.SolutionChangesPage.java

License:Apache License

public static void __search() {
    final int left = Window.getScrollLeft();
    final int top = Window.getScrollTop();
    SolutionChangesPage page = (SolutionChangesPage) RootPanel.get("UniTimeGWT:Body").getWidget(0);
    page.search(new AsyncCallback<Boolean>() {
        @Override/*from  w w  w . j  a v a  2s .c o m*/
        public void onFailure(Throwable caught) {
        }

        @Override
        public void onSuccess(Boolean result) {
            if (result)
                Window.scrollTo(left, top);
        }
    });
}