Example usage for com.google.gwt.user.client Cookies getCookie

List of usage examples for com.google.gwt.user.client Cookies getCookie

Introduction

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

Prototype

public static String getCookie(String name) 

Source Link

Document

Gets the cookie associated with the given name.

Usage

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

License:Apache License

private SectioningCookie() {
    try {//www .ja  v  a2  s  .co m
        String cookie = Cookies.getCookie("UniTime:Sectioning");
        if (cookie != null && cookie.length() > 0) {
            String[] values = cookie.split(":");
            iCourseDetails = "T".equals(values[0]);
            iShowClassNumbers = "T".equals(values.length >= 2 ? values[1] : "F");
            iRelatedSortBy = Integer.parseInt(values[2]);
            iEnrollmentFilter = EnrollmentFilter.values()[Integer.parseInt(values[3])];
            iEnrollmentSortBy = Integer.parseInt(values[4]);
            iEnrollmentSortBySubpart = values[5];
        }
    } catch (Exception e) {
    }
}

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

License:Apache License

private SectioningStatusCookie() {
    try {//ww  w  .  j ava 2 s.  c om
        String cookie = Cookies.getCookie("UniTime:StudentStatus");
        if (cookie != null) {
            String[] params = cookie.split("\\|");
            int idx = 0;
            iOnlineTab = Integer.parseInt(params[idx++]);
            iOnlineQuery = params[idx++];
            iBashTab = Integer.parseInt(params[idx++]);
            iBashQuery = params[idx++];
            for (int i = 0; i < iSortBy.length; i++)
                iSortBy[i] = Integer.parseInt(params[idx++]);
        }
    } catch (Exception e) {
    }
}

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

License:Apache License

public SpecialRegistrationsPanel(SpecialRegistrationContext specReg) {
    addStyleName("unitime-SpecialRegistrationsPanel");
    iSpecReg = specReg;//from  www.  jav  a2  s.  co  m

    P title = new P("registrations-header");
    iWaiting = new Image(RESOURCES.loading_small());
    iWaiting.addStyleName("icon");
    iWaiting.setVisible(false);
    title.add(iWaiting);

    iOpenCloseImage = new OpenCloseSectionImage(true);
    iOpenCloseImage.addStyleName("open-close-icon");
    iOpenCloseImage.setVisible(true);
    title.add(iOpenCloseImage);

    P label = new P("title");
    label.setText(MESSAGES.dialogSpecialRegistrations());
    title.add(label);
    add(title);

    iTable = new Table<RetrieveSpecialRegistrationResponse>();
    iTable.addStyleName("registrations-table");
    iTable.setAllowSelection(true);
    iTable.setAllowMultiSelect(true);

    iAllRequestsApplied = new Label(MESSAGES.specRegAllRequestsFullyApplied());
    iAllRequestsApplied.setVisible(false);
    iAllRequestsApplied.addStyleName("all-requests-applied");
    add(iAllRequestsApplied);

    iPanel = new FocusPanel(iTable);
    iPanel.addStyleName("registrations-panel");
    add(iPanel);

    iShowAllChanges = new CheckBox(MESSAGES.checkOverridesShowAllChanges());
    String showAllChanges = Cookies.getCookie("UniTime:ShowAllChanges");
    iShowAllChanges.setValue(showAllChanges != null && SectioningCookie.getInstance().isShowAllChanges());
    iShowAllChanges.addStyleName("registrations-toggle");
    add(iShowAllChanges);

    iPanel.addKeyUpHandler(new KeyUpHandler() {
        @Override
        public void onKeyUp(KeyUpEvent event) {
            if (event.getNativeKeyCode() == KeyCodes.KEY_UP) {
                RetrieveSpecialRegistrationResponse prev = null;
                RetrieveSpecialRegistrationResponse selected = null;
                RetrieveSpecialRegistrationResponse last = null;
                for (int row = 0; row < iTable.getRowCount(); row++) {
                    RetrieveSpecialRegistrationResponse d = iTable.getData(row);
                    if (d == null)
                        continue;
                    if (iTable.isSelected(row))
                        selected = d;
                    else if (selected == null)
                        prev = d;
                    last = d;
                }
                int row = setSelected(prev == null ? last : prev);
                if (row >= 0)
                    iTable.getRowFormatter().getElement(row).scrollIntoView();
                updateAriaStatus();
                event.preventDefault();
                event.stopPropagation();
                iPanel.setFocus(true);
            } else if (event.getNativeKeyCode() == KeyCodes.KEY_DOWN) {
                RetrieveSpecialRegistrationResponse first = null;
                RetrieveSpecialRegistrationResponse selected = null;
                RetrieveSpecialRegistrationResponse next = null;
                for (int row = 0; row < iTable.getRowCount(); row++) {
                    RetrieveSpecialRegistrationResponse d = iTable.getData(row);
                    if (d == null)
                        continue;
                    if (first == null)
                        first = d;
                    if (iTable.isSelected(row))
                        selected = d;
                    else if (selected != null && next == null)
                        next = d;
                }
                int row = setSelected(next == null ? first : next);
                if (row >= 0)
                    iTable.getRowFormatter().getElement(row).scrollIntoView();
                updateAriaStatus();
                event.preventDefault();
                event.stopPropagation();
                iPanel.setFocus(true);
            } else if (event.getNativeKeyCode() == KeyCodes.KEY_ENTER
                    || event.getNativeKeyCode() == KeyCodes.KEY_SPACE) {
                if (iTable.getSelectedRow() > 0)
                    doSubmit(iTable.getData(iTable.getSelectedRow()));
                event.preventDefault();
                event.stopPropagation();
                iPanel.setFocus(true);
            } else if (event.getNativeKeyCode() == KeyCodes.KEY_DELETE) {
                if (iTable.getSelectedRow() > 0) {
                    cancel(iTable.getData(iTable.getSelectedRow()));
                }
            }
        }
    });

    iShowAllChanges.addValueChangeHandler(new ValueChangeHandler<Boolean>() {
        @Override
        public void onValueChange(ValueChangeEvent<Boolean> event) {
            SectioningCookie.getInstance().setShowAllChanges(event.getValue());
            if (iLastSaved != null)
                populate(getRegistrations(), iLastSaved);
        }
    });

    iOpenCloseImage.addValueChangeHandler(new ValueChangeHandler<Boolean>() {
        @Override
        public void onValueChange(ValueChangeEvent<Boolean> event) {
            iPanel.setVisible(event.getValue() && iTable.getRowCount() > 1);
            iAllRequestsApplied.setVisible(event.getValue() && iTable.getRowCount() <= 1);
            iShowAllChanges.setVisible(event.getValue());
            SectioningCookie.getInstance().setRequestOverridesOpened(event.getValue());
        }
    });
    label.addClickHandler(new ClickHandler() {
        @Override
        public void onClick(ClickEvent event) {
            if (iOpenCloseImage.isVisible()) {
                iOpenCloseImage.setValue(!iOpenCloseImage.getValue(), true);
            }
        }
    });

    List<UniTimeTableHeader> header = new ArrayList<UniTimeTableHeader>();
    header.add(new UniTimeTableHeader(""));
    header.add(new UniTimeTableHeader(MESSAGES.colSpecRegSubmitted()));
    header.add(new UniTimeTableHeader(MESSAGES.colSubject()));
    header.add(new UniTimeTableHeader(MESSAGES.colCourse()));
    header.add(new UniTimeTableHeader(MESSAGES.colSubpart()));
    header.add(new UniTimeTableHeader(MESSAGES.colClass()));
    header.add(new UniTimeTableHeader(MESSAGES.colLimit()));
    header.add(new UniTimeTableHeader(MESSAGES.colCredit()));
    header.add(new UniTimeTableHeader(MESSAGES.colSpecRegErrors()));
    header.add(new UniTimeTableHeader(""));
    header.add(new UniTimeTableHeader(""));
    iTable.addRow(null, header);

    iTable.addMouseClickListener(new UniTimeTable.MouseClickListener<RetrieveSpecialRegistrationResponse>() {
        @Override
        public void onMouseClick(UniTimeTable.TableEvent<RetrieveSpecialRegistrationResponse> event) {
            if (event.getData() != null)
                doSubmit(event.getData());
        }
    });

    iOpenCloseImage.setValue(SectioningCookie.getInstance().isRequestOverridesOpened());
    iPanel.setVisible(iOpenCloseImage.getValue());
    iShowAllChanges.setVisible(iOpenCloseImage.getValue());
    setVisible(false);
}

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

License:Apache License

private void init() {
    if (CONSTANTS.allowCalendarExport()) {
        iCalendar = new ImageLink();
        iCalendar.setImage(new Image(RESOURCES.calendar()));
        iCalendar.setTarget(null);/*from   ww w . j a v  a2  s  .  c  o m*/
        iCalendar.setTitle(MESSAGES.exportICalendar());
        iCalendar.setAriaLabel(MESSAGES.exportICalendar());
    }

    iAssignments = new WebTable();
    iAssignments.setHeader(new WebTable.Row(new WebTable.Cell(MESSAGES.colLock(), 1, "15px"),
            new WebTable.Cell(MESSAGES.colSubject(), 1, "40px"),
            new WebTable.Cell(MESSAGES.colCourse(), 1, "40px"),
            new WebTable.Cell(MESSAGES.colSubpart(), 1, "30px"),
            new WebTable.Cell(MESSAGES.colClass(), 1, "50px"),
            new WebTable.Cell(MESSAGES.colLimit(), 1, "30px").aria(ARIA.colLimit()),
            new WebTable.Cell(MESSAGES.colDays(), 1, "30px"), new WebTable.Cell(MESSAGES.colStart(), 1, "40px"),
            new WebTable.Cell(MESSAGES.colEnd(), 1, "40px"), new WebTable.Cell(MESSAGES.colDate(), 1, "50px"),
            new WebTable.Cell(MESSAGES.colRoom(), 1, "80px"),
            new WebTable.Cell(MESSAGES.colInstructor(), 1, "80px"),
            new WebTable.Cell(MESSAGES.colParent(), 1, "80px"),
            new WebTable.Cell(MESSAGES.colNote(), 1, "50px"),
            new WebTable.Cell(MESSAGES.colCredit(), 1, "30px"),
            (iCalendar != null ? new WebTable.WidgetCell(iCalendar, MESSAGES.colIcons(), 1, "1px")
                    : new WebTable.Cell(MESSAGES.colIcons(), 1, "1px"))));
    iAssignments.setWidth("100%");
    iAssignments.setEmptyMessage(MESSAGES.emptySchedule());

    final FlexTable vp = new FlexTable();
    vp.setCellPadding(0);
    vp.setCellSpacing(0);
    vp.setWidget(0, 0, iAssignments);
    vp.getFlexCellFormatter().setColSpan(0, 0, 3);

    iTotalCredit = new Label();
    iTotalCredit.getElement().getStyle().setMarginTop(2, Unit.PX);
    vp.setWidget(1, 0, iQuickAdd);
    vp.setWidget(1, 1, iTotalCredit);
    iShowUnassignments = new CheckBox(MESSAGES.showUnassignments());
    iShowUnassignments.getElement().getStyle().setMarginTop(2, Unit.PX);
    vp.setWidget(1, 2, iShowUnassignments);
    vp.getFlexCellFormatter().setHorizontalAlignment(1, 1, HasHorizontalAlignment.ALIGN_CENTER);
    vp.getFlexCellFormatter().setHorizontalAlignment(1, 2, HasHorizontalAlignment.ALIGN_RIGHT);
    for (int i = 0; i < 3; i++)
        vp.getFlexCellFormatter().getElement(1, i).getStyle().setWidth(33, Unit.PCT);
    iShowUnassignments.setVisible(false);
    String showUnassignments = Cookies.getCookie("UniTime:Unassignments");
    iShowUnassignments.setValue(showUnassignments == null || "1".equals(showUnassignments));

    iAssignmentGrid = new TimeGrid();
    iGridMessage = new P("unitime-TimeGridMessage");
    iGridMessage.setVisible(false);
    final P gridPanel = new P("unitime-TimeGridPanel");
    gridPanel.add(iGridMessage);
    gridPanel.add(iAssignmentGrid);

    iAssignmentTab = new AriaTabBar();
    iAssignmentTab.addTab(MESSAGES.tabClasses(), true);
    iAssignmentTab.addTab(MESSAGES.tabTimetable(), true);
    iAssignmentTab.selectTab(0);
    iAssignmentTab.addSelectionHandler(new SelectionHandler<Integer>() {
        @Override
        public void onSelection(SelectionEvent<Integer> event) {
            if (event.getSelectedItem() == 0) {
                iAssignmentPanel.setWidget(vp);
                AriaStatus.getInstance().setHTML(ARIA.listOfClasses());
            } else {
                iAssignmentPanel.setWidget(gridPanel);
                iAssignmentGrid.scrollDown();
                AriaStatus.getInstance().setHTML(ARIA.timetable());
            }
            addHistory();
            ResizeEvent.fire(StudentSectioningWidget.this, StudentSectioningWidget.this.getOffsetWidth(),
                    StudentSectioningWidget.this.getOffsetHeight());
            Scheduler.get().scheduleDeferred(new ScheduledCommand() {
                @Override
                public void execute() {
                    iAssignmentPanel.setFocus(true);
                }
            });
        }
    });
    iAssignmentPanel = new FocusPanel(vp);
    iAssignmentPanel.setStyleName("unitime-ClassScheduleTabPanel");
    iAssignmentPanel.addStyleName("unitime-FocusPanel");

    final Character classesAccessKey = UniTimeHeaderPanel.guessAccessKey(MESSAGES.tabClasses());
    final Character timetableAccessKey = UniTimeHeaderPanel.guessAccessKey(MESSAGES.tabTimetable());
    iAssignmentPanel.addKeyUpHandler(new KeyUpHandler() {
        @Override
        public void onKeyUp(KeyUpEvent event) {
            if (iAssignmentTab.getSelectedTab() == 0) {
                if (event.getNativeKeyCode() == KeyCodes.KEY_DOWN) {
                    do {
                        iAssignments.setSelectedRow(iAssignments.getSelectedRow() + 1);
                    } while (iAssignments.getRows()[iAssignments.getSelectedRow()] != null
                            && !iAssignments.getRows()[iAssignments.getSelectedRow()].isSelectable());

                    if (iAssignments.getSelectedRow() >= 0
                            && iAssignments.getSelectedRow() < iAssignments.getRows().length
                            && iAssignments.getRows()[iAssignments.getSelectedRow()] != null)
                        AriaStatus.getInstance()
                                .setHTML(ARIA.classSelected(1 + iAssignments.getSelectedRow(),
                                        iAssignments.getRowsCount(),
                                        iAssignments.getRows()[iAssignments.getSelectedRow()].getAriaLabel()));
                }
                if (event.getNativeKeyCode() == KeyCodes.KEY_UP) {
                    do {
                        iAssignments.setSelectedRow(
                                iAssignments.getSelectedRow() == 0 ? iAssignments.getRowsCount() - 1
                                        : iAssignments.getSelectedRow() - 1);
                    } while (iAssignments.getRows()[iAssignments.getSelectedRow()] != null
                            && !iAssignments.getRows()[iAssignments.getSelectedRow()].isSelectable());

                    if (iAssignments.getSelectedRow() >= 0
                            && iAssignments.getSelectedRow() < iAssignments.getRows().length
                            && iAssignments.getRows()[iAssignments.getSelectedRow()] != null)
                        AriaStatus.getInstance()
                                .setHTML(ARIA.classSelected(1 + iAssignments.getSelectedRow(),
                                        iAssignments.getRowsCount(),
                                        iAssignments.getRows()[iAssignments.getSelectedRow()].getAriaLabel()));
                }
                if (event.getNativeKeyCode() == KeyCodes.KEY_ENTER) {
                    updateHistory();
                    showSuggestionsAsync(iAssignments.getSelectedRow());
                }
            }
            int tab = -1;
            if (classesAccessKey != null && event.getNativeEvent().getCtrlKey()
                    && (event.getNativeKeyCode() == classesAccessKey
                            || event.getNativeKeyCode() == Character.toUpperCase(classesAccessKey))) {
                tab = 0;
            }
            if (timetableAccessKey != null && event.getNativeEvent().getCtrlKey()
                    && (event.getNativeKeyCode() == timetableAccessKey
                            || event.getNativeKeyCode() == Character.toUpperCase(timetableAccessKey))) {
                tab = 1;
            }
            if (tab >= 0) {
                iAssignmentTab.selectTab(tab);
                event.preventDefault();
            }
        }
    });

    iAssignmentDock = new DockPanel();
    iAssignmentDock.setStyleName("unitime-ClassSchedulePanel");
    iAssignmentDock.setSpacing(0);
    iAssignmentDock.add(iAssignmentPanel, DockPanel.SOUTH);
    iAssignmentDock.add(iAssignmentTab, DockPanel.WEST);
    iAssignmentDock.setCellWidth(iAssignmentTab, "33%");
    iAssignmentDock.setCellVerticalAlignment(iAssignmentTab, HasVerticalAlignment.ALIGN_BOTTOM);
    iAssignmentDock.setCellHorizontalAlignment(iAssignmentTab, HasHorizontalAlignment.ALIGN_LEFT);
    Roles.getTabpanelRole().set(iAssignmentDock.getElement());
    Roles.getTabpanelRole().setAriaOwnsProperty(iAssignmentDock.getElement(),
            Id.of(iAssignmentTab.getElement()));

    P header = new P("unitime-MainHeader");
    header.setHTML(MESSAGES.headerClassSchedule());
    header.getElement().getStyle().setTextAlign(TextAlign.CENTER);
    iAssignmentDock.add(header, DockPanel.CENTER);
    iAssignmentDock.setCellHorizontalAlignment(header, HasHorizontalAlignment.ALIGN_CENTER);
    iAssignmentDock.setCellWidth(header, "34%");

    P padding = new P("unitime-HeaderPadding");
    padding.setHTML("&nbsp;");
    iAssignmentDock.add(padding, DockPanel.EAST);
    iAssignmentDock.setCellWidth(padding, "33%");

    iRequests.addClickHandler(new ClickHandler() {
        public void onClick(ClickEvent event) {
            prev();
            addHistory();
        }
    });

    iReset.addClickHandler(new ClickHandler() {
        @Override
        public void onClick(ClickEvent event) {
            clearMessage();
            LoadingWidget.getInstance().show(MESSAGES.courseRequestsScheduling());
            iSectioningService.section(iOnline, iCourseRequests.getRequest(), null,
                    new AsyncCallback<ClassAssignmentInterface>() {
                        public void onFailure(Throwable caught) {
                            iStatus.error(MESSAGES.exceptionSectioningFailed(caught.getMessage()), caught);
                            LoadingWidget.getInstance().hide();
                            updateHistory();
                        }

                        public void onSuccess(ClassAssignmentInterface result) {
                            fillIn(result);
                            addHistory();
                        }
                    });
        }
    });

    iSchedule.addClickHandler(new ClickHandler() {
        public void onClick(ClickEvent event) {
            iCourseRequests.changeTip();
            clearMessage();
            iCourseRequests.validate(new AsyncCallback<Boolean>() {
                public void onSuccess(Boolean result) {
                    updateHistory();
                    if (result) {
                        if (iOnline) {
                            iSectioningService.saveRequest(iCourseRequests.getRequest(),
                                    new AsyncCallback<Boolean>() {
                                        public void onSuccess(Boolean result) {
                                            if (result) {
                                                iStatus.info(MESSAGES.saveRequestsOK());
                                            }
                                        }

                                        public void onFailure(Throwable caught) {
                                            iStatus.error(MESSAGES.saveRequestsFail(caught.getMessage()),
                                                    caught);
                                        }
                                    });
                        }
                        LoadingWidget.getInstance().show(MESSAGES.courseRequestsScheduling());
                        iSectioningService.section(iOnline, iCourseRequests.getRequest(), iLastResult,
                                new AsyncCallback<ClassAssignmentInterface>() {
                                    public void onFailure(Throwable caught) {
                                        iStatus.error(MESSAGES.exceptionSectioningFailed(caught.getMessage()),
                                                caught);
                                        LoadingWidget.getInstance().hide();
                                        updateHistory();
                                    }

                                    public void onSuccess(ClassAssignmentInterface result) {
                                        fillIn(result);
                                        addHistory();
                                    }
                                });
                    } else {
                        String error = iCourseRequests.getFirstError();
                        iStatus.error(error == null ? MESSAGES.validationFailed()
                                : MESSAGES.validationFailedWithMessage(error));
                        LoadingWidget.getInstance().hide();
                        updateHistory();
                    }
                }

                public void onFailure(Throwable caught) {
                    iStatus.error(MESSAGES.validationFailedWithMessage(caught.getMessage()), caught);
                    LoadingWidget.getInstance().hide();
                    updateHistory();
                }
            });
        }
    });

    iStartOver.addClickHandler(new ClickHandler() {
        @Override
        public void onClick(ClickEvent event) {
            if (isChanged()) {
                UniTimeConfirmationDialog.confirm(useDefaultConfirmDialog(), MESSAGES.queryLeaveChanges(),
                        new Command() {
                            @Override
                            public void execute() {
                                clearMessage();
                                clear(false);
                                iStartOver.setVisible(false);
                                iStartOver.setEnabled(false);
                                addHistory();
                                lastRequest(iSessionSelector.getAcademicSessionId(), null, true, false);
                            }
                        });
            } else {
                clearMessage();
                clear(false);
                iStartOver.setVisible(false);
                iStartOver.setEnabled(false);
                addHistory();
                lastRequest(iSessionSelector.getAcademicSessionId(), null, true, false);
            }
        }
    });

    iAssignments.addRowClickHandler(new WebTable.RowClickHandler() {
        public void onRowClick(WebTable.RowClickEvent event) {
            if (iLastResult.get(event.getRowIdx()) == null)
                return;
            updateHistory();
            showSuggestionsAsync(event.getRowIdx());
        }
    });

    iAssignmentGrid.addMeetingClickHandler(new TimeGrid.MeetingClickHandler() {
        public void onMeetingClick(TimeGrid.MeetingClickEvent event) {
            updateHistory();
            showSuggestionsAsync(event.getRowIndex());
        }
    });

    iAssignmentGrid.addPinClickHandler(new TimeGrid.PinClickHandler() {
        public void onPinClick(TimeGrid.PinClickEvent event) {
            ((HasValue<Boolean>) iAssignments.getRows()[event.getRowIndex()].getCell(0).getWidget())
                    .setValue(event.isPinChecked(), false);
            iLastResult.get(event.getRowIndex()).setPinned(event.isPinChecked());
            updateHistory();
        }
    });

    iEnroll.addClickHandler(new ClickHandler() {
        public void onClick(ClickEvent event) {
            Command enroll = new Command() {
                @Override
                public void execute() {
                    clearMessage();
                    LoadingWidget.getInstance().show(MESSAGES.waitEnroll());
                    iSectioningService.enroll(iOnline, iCourseRequests.getRequest(), iLastResult,
                            new AsyncCallback<ClassAssignmentInterface>() {
                                public void onSuccess(ClassAssignmentInterface result) {
                                    LoadingWidget.getInstance().hide();
                                    iSavedAssignment = result;
                                    iStartOver.setVisible(iSavedAssignment != null
                                            && !iSavedAssignment.getCourseAssignments().isEmpty());
                                    iStartOver.setEnabled(iSavedAssignment != null
                                            && !iSavedAssignment.getCourseAssignments().isEmpty());
                                    fillIn(result);
                                    if (result.hasRequest())
                                        iCourseRequests.setRequest(result.getRequest());
                                    if (!result.hasMessages())
                                        iStatus.info(MESSAGES.enrollOK());
                                    updateHistory();
                                    if (iEligibilityCheck != null && iEligibilityCheck
                                            .hasFlag(EligibilityFlag.RECHECK_AFTER_ENROLLMENT)) {
                                        iSectioningService.checkEligibility(iOnline,
                                                iSessionSelector.getAcademicSessionId(),
                                                iEligibilityCheck.getStudentId(), (String) null,
                                                new AsyncCallback<OnlineSectioningInterface.EligibilityCheck>() {
                                                    @Override
                                                    public void onFailure(Throwable caught) {
                                                    }

                                                    @Override
                                                    public void onSuccess(
                                                            OnlineSectioningInterface.EligibilityCheck result) {
                                                        setElibibilityCheckDuringEnrollment(result);
                                                    }
                                                });
                                    }
                                }

                                public void onFailure(Throwable caught) {
                                    LoadingWidget.getInstance().hide();
                                    iStatus.error(MESSAGES.enrollFailed(caught.getMessage()), caught);
                                    updateHistory();
                                    if (caught instanceof SectioningException) {
                                        SectioningException se = (SectioningException) caught;
                                        EligibilityCheck check = se.getEligibilityCheck();
                                        if (check != null) {
                                            setElibibilityCheckDuringEnrollment(check);
                                            if (check.hasFlag(EligibilityFlag.PIN_REQUIRED)) {
                                                if (iPinDialog == null)
                                                    iPinDialog = new PinDialog();
                                                PinDialog.PinCallback callback = new PinDialog.PinCallback() {
                                                    @Override
                                                    public void onFailure(Throwable caught) {
                                                        iStatus.error(MESSAGES.exceptionFailedEligibilityCheck(
                                                                caught.getMessage()), caught);
                                                    }

                                                    @Override
                                                    public void onSuccess(
                                                            OnlineSectioningInterface.EligibilityCheck result) {
                                                        setElibibilityCheckDuringEnrollment(result);
                                                        if (result.hasFlag(EligibilityFlag.CAN_ENROLL)
                                                                && !result.hasFlag(
                                                                        EligibilityFlag.RECHECK_BEFORE_ENROLLMENT))
                                                            iEnroll.click();
                                                    }

                                                    @Override
                                                    public void onMessage(
                                                            OnlineSectioningInterface.EligibilityCheck result) {
                                                        if (result.hasMessage()) {
                                                            iStatus.error(result.getMessage());
                                                        } else if (result.hasFlag(
                                                                OnlineSectioningInterface.EligibilityCheck.EligibilityFlag.PIN_REQUIRED)) {
                                                            iStatus.warning(MESSAGES
                                                                    .exceptionAuthenticationPinRequired());
                                                        } else {
                                                            clearMessage(false);
                                                        }
                                                    }
                                                };
                                                iPinDialog.checkEligibility(iOnline,
                                                        iSessionSelector.getAcademicSessionId(), null,
                                                        callback);
                                            }
                                        }
                                        if (se.hasSectionMessages()) {
                                            for (CourseAssignment ca : iLastAssignment.getCourseAssignments()) {
                                                for (ClassAssignment c : ca.getClassAssignments()) {
                                                    c.setError(se.getSectionMessage(c.getClassId()));
                                                }
                                            }
                                            fillIn(iLastAssignment);
                                            iStatus.error(caught.getMessage(), false);
                                        }
                                    }
                                }
                            });
                }
            };
            enroll = confirmEnrollment(enroll);
            enroll.execute();
        }
    });

    iPrint.addClickHandler(new ClickHandler() {
        public void onClick(ClickEvent event) {
            boolean allSaved = true;
            for (ClassAssignmentInterface.ClassAssignment clazz : iLastResult) {
                if (clazz != null && !clazz.isFreeTime() && !clazz.isSaved())
                    allSaved = false;
            }
            Widget w = iAssignments.getPrintWidget(0, 5, 15);
            w.setWidth("100%");
            ToolBox.print(
                    (allSaved && !isChanged() ? MESSAGES.studentSchedule()
                            : MESSAGES.studentScheduleNotEnrolled()),
                    (CONSTANTS.printReportShowUserName() ? iUserAuthentication.getUser() : ""),
                    iSessionSelector.getAcademicSessionName(), iAssignmentGrid.getPrintWidget(), w, iStatus);
        }
    });

    if (iExport != null)
        iExport.addClickHandler(new ClickHandler() {
            public void onClick(ClickEvent event) {
                ToolBox.open(iCalendar.getUrl());
            }
        });

    if (iTrackHistory) {
        History.addValueChangeHandler(new ValueChangeHandler<String>() {
            public void onValueChange(ValueChangeEvent<String> event) {
                if (!event.getValue().isEmpty()) {
                    int item = iHistory.size() - 1;
                    try {
                        item = Integer.parseInt(event.getValue());
                    } catch (NumberFormatException e) {
                    }
                    if (item < 0)
                        item = 0;
                    if (item >= iHistory.size())
                        item = iHistory.size() - 1;
                    if (item >= 0)
                        iHistory.get(item).restore();
                } else if (isChanged()) {
                    UniTimeConfirmationDialog.confirm(useDefaultConfirmDialog(), MESSAGES.queryLeaveChanges(),
                            new Command() {
                                @Override
                                public void execute() {
                                    iCourseRequests.clear();
                                    if (!iSchedule.isVisible())
                                        prev();
                                }
                            });
                }
            }
        });
    }

    iSessionSelector
            .addAcademicSessionChangeHandler(new AcademicSessionSelector.AcademicSessionChangeHandler() {
                public void onAcademicSessionChange(AcademicSessionChangeEvent event) {
                    addHistory();
                }
            });

    iSave.addClickHandler(new ClickHandler() {
        public void onClick(ClickEvent event) {
            iCourseRequests.changeTip();
            clearMessage();
            iCourseRequests.validate(new AsyncCallback<Boolean>() {
                public void onSuccess(Boolean result) {
                    updateHistory();
                    if (result) {
                        LoadingWidget.getInstance().show(MESSAGES.courseRequestsSaving());
                        iSectioningService.saveRequest(iCourseRequests.getRequest(),
                                new AsyncCallback<Boolean>() {
                                    public void onSuccess(Boolean result) {
                                        if (result) {
                                            iStatus.info(MESSAGES.saveRequestsOK());
                                        }
                                        LoadingWidget.getInstance().hide();
                                    }

                                    public void onFailure(Throwable caught) {
                                        iStatus.error(MESSAGES.saveRequestsFail(caught.getMessage()), caught);
                                        LoadingWidget.getInstance().hide();
                                    }
                                });
                    } else {
                        String error = iCourseRequests.getFirstError();
                        iStatus.error(error == null ? MESSAGES.validationFailed()
                                : MESSAGES.validationFailedWithMessage(error));
                        LoadingWidget.getInstance().hide();
                        updateHistory();
                    }
                }

                public void onFailure(Throwable caught) {
                    iStatus.error(MESSAGES.validationFailedWithMessage(caught.getMessage()), caught);
                    LoadingWidget.getInstance().hide();
                    updateHistory();
                }
            });
        }
    });

    iShowUnassignments.addValueChangeHandler(new ValueChangeHandler<Boolean>() {
        @Override
        public void onValueChange(ValueChangeEvent<Boolean> event) {
            Cookies.setCookie("UniTime:Unassignments", "1");
            fillIn(iLastAssignment);
        }
    });
}

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

License:Apache License

private SolverCookie() {
    try {// w  w  w .  j a  v  a2s .c o  m
        String cookie = Cookies.getCookie("UniTime:Solver");
        if (cookie != null) {
            String[] params = cookie.split("\\|");
            int idx = 0;
            iLogLevel = Integer.valueOf(params[idx++]);
            iTimeGridFilter = "1".equals(params[idx++]);
            iAssignedClassesFilter = "1".equals(params[idx++]);
            iAssignedClassesSort = Integer.parseInt(params[idx++]);
            iNotAssignedClassesFilter = "1".equals(params[idx++]);
            iNotAssignedClassesSort = Integer.parseInt(params[idx++]);
            iSelectedAssignmentsSort = Integer.parseInt(params[idx++]);
            iConflictingAssignmentsSort = Integer.parseInt(params[idx++]);
            iSuggestionsSort = Integer.parseInt(params[idx++]);
            iPlacementsSort = Integer.parseInt(params[idx++]);
            iShowSuggestions = "1".equals(params[idx++]);
            iShowConflicts = "1".equals(params[idx++]);
            iConflictsSort = Integer.parseInt(params[idx++]);
            iShowAllStudentConflicts = "1".equals(params[idx++]);
            iShowAllDistributionConflicts = "1".equals(params[idx++]);
            iShowCBS = "1".equals(params[idx++]);
            iShowCBSFilter = "1".equals(params[idx++]);
            iSolutionChangesFilter = "1".equals(params[idx++]);
            iSolutionChangesSort = Integer.parseInt(params[idx++]);
            iAssignmentHistoryFilter = "1".equals(params[idx++]);
            iAssignmentHistorySort = Integer.parseInt(params[idx++]);
            iListSolutionsSort = Integer.parseInt(params[idx++]);
            iSuggestionsFilter = params[idx++];
        }
    } catch (Exception e) {
    }
}

From source file:org.unitime.timetable.gwt.client.widgets.CourseFinderMultipleCourses.java

License:Apache License

private void selectLastTab() {
    try {//from  www  .ja  v  a  2s .  c o m
        int tab = Integer.valueOf(Cookies.getCookie("UniTime:CourseFinderCourses"));
        if (tab >= 0
                || tab < iCourseDetailsTabBar.getTabCount() && tab != iCourseDetailsTabBar.getSelectedTab())
            iCourseDetailsTabBar.selectTab(tab, true);
        else
            iCourseDetailsTabBar.selectTab(0, true);
    } catch (Exception e) {
        iCourseDetailsTabBar.selectTab(0, true);
    }
}

From source file:org.vaadin.dontpush.widgetset.client.SocketApplicationConnection.java

License:Apache License

private AtmosphereClient getWebSocket() {
    if (this.ws == null) {
        // if timed out or not started, create websocket to server
        String url = getConfiguration().getApplicationUri() + "UIDL/";
        if (url.startsWith("/")) {
            String hostPageBaseURL = GWT.getHostPageBaseURL();
            String[] split = hostPageBaseURL.split("\\/\\/");
            String host = split[1].substring(0, split[1].indexOf("/"));
            String protoAndHost = split[0] + "//" + host;
            url = protoAndHost + url;//from   w  w w  .j a  v  a  2  s  .  c o  m
        }

        String cmid = Cookies.getCookie("OZONE_CM_ID");
        url += cmid + "/" + getConfiguration().getInitialWindowName();
        VConsole.log(url);

        boolean tryWithWebsockets = BrowserInfo.get().isWebkit();
        VConsole.log("Creating atmosphere client...");
        /*
         * Ask atmosphere guys to fix this. Automatic degrading from
         * websockets don't work in others but webkit.
         */
        this.ws = new AtmosphereClient(url, null, _cb, tryWithWebsockets);
        VConsole.log("...starting...");
        this.ws.start();
    }
    return this.ws;
}

From source file:org.wannatrak.client.MapController.java

License:Apache License

public void showSubjects(Set<Long> subjects, String fromDaysAgo, String fromHour, String fromMinute,
        String toDaysAgo, String toHour, String toMinute, boolean showErrors, boolean updateOnlyNew) {
    final Set<Long> subjectsToShow;

    if (updateOnlyNew) {
        subjectsToShow = new HashSet<Long>(subjects);

        for (Iterator<Long> it = layers.keySet().iterator(); it.hasNext();) {
            Long subjectId = it.next();
            if (!subjects.contains(subjectId)) {
                layers.get(subjectId).setMap(null);
                it.remove();//from w w w . j  av a  2 s  . com
            }
        }
    } else {
        subjectsToShow = subjects;
    }

    for (final Long subjectId : subjectsToShow) {
        mediator.showSublectLoading(subjectId);

        String url = "http://" + Window.Location.getHost() + "/show?subjectId=" + subjectId + "&sessionId="
                + Cookies.getCookie("JSESSIONID") + "&hfrom=" + fromHour + "&mfrom=" + fromMinute + "&dfrom="
                + fromDaysAgo + "&hto=" + toHour + "&mto=" + toMinute + "&dto=" + toDaysAgo + "&valid="
                + !showErrors + "&format="
                + DateTimeFormat.getMediumDateTimeFormat().getPattern().replaceAll(" ", "_SPACE_")
                + "&tzoffset=" + new Date().getTimezoneOffset() + "&nocache=" + Random.nextInt();
        options.setPreserveViewport(!updateOnlyNew);
        KmlLayer route = KmlLayer.newInstance(url, options);
        route.setMap(mapWidget);

        layers.put(subjectId, route);
        mediator.hideSubjectLoading(subjectId);
    }
}

From source file:org.waveprotocol.box.webclient.client.WaveWebSocketClient.java

License:Apache License

@Override
public void onConnect() {
    connected = ConnectState.CONNECTED;/* w  w w .  j  av  a2 s . c  o m*/
    connectedAtLeastOnce = true;

    // Sends the session cookie to the server via an RPC to work around browser bugs.
    // See: http://code.google.com/p/wave-protocol/issues/detail?id=119
    String token = Cookies.getCookie(JETTY_SESSION_TOKEN_NAME);
    if (token != null) {
        ProtocolAuthenticateJsoImpl auth = ProtocolAuthenticateJsoImpl.create();
        auth.setToken(token);
        send(MessageWrapper.create(sequenceNo++, "ProtocolAuthenticate", auth));
    }

    // Flush queued messages.
    while (!messages.isEmpty() && connected == ConnectState.CONNECTED) {
        send(messages.poll());
    }

    ClientEvents.get().fireEvent(new NetworkStatusEvent(ConnectionStatus.CONNECTED));
}

From source file:rtdc.web.client.impl.GwtStorage.java

License:Open Source License

/**
 * {@inheritDoc}
 */
@Override
public String retrieve(String key) {
    return Cookies.getCookie(key);
}