Example usage for com.google.gwt.user.client.ui FlexTable getFlexCellFormatter

List of usage examples for com.google.gwt.user.client.ui FlexTable getFlexCellFormatter

Introduction

In this page you can find the example usage for com.google.gwt.user.client.ui FlexTable getFlexCellFormatter.

Prototype

public FlexCellFormatter getFlexCellFormatter() 

Source Link

Document

Explicitly gets the FlexCellFormatter .

Usage

From source file:org.thechiselgroup.biomixer.client.core.ui.ActionBar.java

License:Apache License

public void addPanel(ActionBarPanel panel) {
    assert panel != null;
    assert !containsPanel(panel.getPanelId()) : "panel " + panel.getPanelId()
            + " was already registered in the ActionBar";

    FlexTable actionBarPanel = new FlexTable();
    actionBarPanel.addStyleName(CSS_ACTIONBAR_PANEL);

    Label header = new Label(panel.getTitle());
    header.addStyleName(CSS_ACTIONBAR_PANEL_HEADER);
    actionBarPanel.setWidget(0, 0, header);
    actionBarPanel.getFlexCellFormatter().setColSpan(0, 0, 2);

    SimplePanel contentPanel = new SimplePanel();
    contentPanel.add(panel.getContentWidget());
    contentPanel.addStyleName(CSS_ACTIONBAR_PANEL_CONTENT);
    actionBarPanel.setWidget(1, 0, contentPanel);

    // TODO reactivate expanders once drop down menus are available
    // actionBarPanel.setWidget(1, 1, new Image(GWT.getModuleBaseURL()
    // + "images/expander-normal.png"));
    // actionBarPanel.getCellFormatter().addStyleName(1, 1,
    // CSS_ACTIONBAR_PANEL_EXPANDER);

    actionBarPanelContainer.add(actionBarPanel);
    panelsByID.put(panel.getPanelId(), panel);
}

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 w w w .  ja  va2  s.  com
        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.sectioning.UserAuthentication.java

License:Apache License

public UserAuthentication(InfoPanel panel, boolean allowGuest) {
    iAllowGuest = allowGuest;/*from w  w w. j a v  a2s .com*/
    iPanel = panel;
    iPanel.setPreventDefault(true);
    iPanel.setVisible(true);
    iPanel.setText(MESSAGES.userNotAuthenticated());
    iPanel.setHint(MESSAGES.userHint());
    iPanel.setAriaLabel(ARIA.userNotAuthenticated());
    iPanel.setInfo(null);

    iDialog = new AriaDialogBox();
    iDialog.setText(MESSAGES.dialogAuthenticate());
    iDialog.setAnimationEnabled(true);
    iDialog.setAutoHideEnabled(false);
    iDialog.setGlassEnabled(true);
    iDialog.setModal(true);
    iDialog.addCloseHandler(new CloseHandler<PopupPanel>() {
        @Override
        public void onClose(CloseEvent<PopupPanel> event) {
            iUserName.setText("");
            iUserPassword.setText("");
            if (iPin != null)
                iPin.setText("");
        }
    });

    FlexTable grid = new FlexTable();
    grid.setCellPadding(5);
    grid.setCellSpacing(0);
    int row = 0;
    grid.setText(row, 0, MESSAGES.username());
    iUserName = new AriaTextBox();
    iUserName.setStyleName("gwt-SuggestBox");
    iUserName.setAriaLabel(ARIA.propUserName());
    grid.setWidget(row, 1, iUserName);
    row++;

    grid.setText(row, 0, MESSAGES.password());
    iUserPassword = new AriaPasswordTextBox();
    iUserPassword.setStyleName("gwt-SuggestBox");
    iUserPassword.setAriaLabel(ARIA.propPassword());
    grid.setWidget(row, 1, iUserPassword);
    row++;

    if (CONSTANTS.hasAuthenticationPin()) {
        grid.setText(row, 0, MESSAGES.pin());
        iPin = new AriaTextBox();
        iPin.setStyleName("gwt-SuggestBox");
        iPin.setAriaLabel(ARIA.propPinNumber());
        grid.setWidget(row, 1, iPin);
        row++;
    }

    iError = new Label();
    iError.setStyleName("unitime-ErrorMessage");
    iError.setVisible(false);
    grid.getFlexCellFormatter().setColSpan(row, 0, 2);
    grid.setWidget(row, 0, iError);
    row++;

    HorizontalPanel buttonPanelWithPad = new HorizontalPanel();
    buttonPanelWithPad.setWidth("100%");
    HorizontalPanel buttonPanel = new HorizontalPanel();
    buttonPanel.setSpacing(5);
    buttonPanelWithPad.add(buttonPanel);
    buttonPanelWithPad.setCellHorizontalAlignment(buttonPanel, HasHorizontalAlignment.ALIGN_RIGHT);

    grid.getFlexCellFormatter().setColSpan(row, 0, 2);
    grid.setWidget(row, 0, buttonPanelWithPad);
    row++;

    iLogIn = new AriaButton(MESSAGES.buttonUserLogin());
    buttonPanel.add(iLogIn);

    iSkip = new AriaButton(MESSAGES.buttonUserSkip());
    buttonPanel.add(iSkip);
    iSkip.setVisible(iAllowGuest);
    iSkip.setAriaLabel(ARIA.buttonLogInAsGuest());

    iLookupDialog = new Lookup();
    iLookupDialog.setOptions("mustHaveExternalId,source=students");
    iLookupDialog.addValueChangeHandler(new ValueChangeHandler<PersonInterface>() {
        @Override
        public void onValueChange(ValueChangeEvent<PersonInterface> event) {
            if (event.getValue() != null)
                sSectioningService.logIn("LOOKUP", event.getValue().getId(), null, sAuthenticateCallback);
        }
    });
    iLookup = new AriaButton(MESSAGES.buttonUserLookup());
    buttonPanel.add(iLookup);
    iLookup.setVisible(false);

    iSkip.addClickHandler(new ClickHandler() {
        public void onClick(ClickEvent event) {
            logIn(true);
        }
    });

    iLogIn.addClickHandler(new ClickHandler() {
        public void onClick(ClickEvent event) {
            logIn(false);
        }
    });

    iLookup.addClickHandler(new ClickHandler() {
        @Override
        public void onClick(ClickEvent event) {
            doLookup();
        }
    });

    iUserName.addKeyUpHandler(new KeyUpHandler() {
        public void onKeyUp(KeyUpEvent event) {
            if (event.getNativeKeyCode() == KeyCodes.KEY_ENTER) {
                Scheduler.get().scheduleDeferred(new ScheduledCommand() {
                    @Override
                    public void execute() {
                        iUserPassword.selectAll();
                        iUserPassword.setFocus(true);
                    }
                });
            }
            if (event.getNativeKeyCode() == KeyCodes.KEY_ESCAPE && iAllowGuest) {
                logIn(true);
            }
        }
    });

    iUserPassword.addKeyUpHandler(new KeyUpHandler() {
        public void onKeyUp(KeyUpEvent event) {
            if (event.getNativeKeyCode() == KeyCodes.KEY_ENTER) {
                logIn(false);
            }
            if (event.getNativeKeyCode() == KeyCodes.KEY_ESCAPE && iAllowGuest) {
                logIn(true);
            }
        }
    });

    iDialog.add(grid);

    ClickHandler ch = new ClickHandler() {
        public void onClick(ClickEvent event) {
            if (iLoggedIn)
                logOut();
            else
                authenticate();
        }
    };

    iPanel.setClickHandler(ch);

    sAuthenticateCallback = new AsyncCallback<String>() {
        public void onFailure(Throwable caught) {
            AriaStatus.getInstance().setText(caught.getMessage());
            iError.setText(caught.getMessage());
            iError.setVisible(true);
            iUserName.setEnabled(true);
            iUserPassword.setEnabled(true);
            if (iPin != null)
                iPin.setEnabled(true);
            iLogIn.setEnabled(true);
            iSkip.setEnabled(true);
            Scheduler.get().scheduleDeferred(new ScheduledCommand() {
                @Override
                public void execute() {
                    iUserName.selectAll();
                    iUserName.setFocus(true);
                }
            });
        }

        public void onSuccess(String result) {
            iUserName.setEnabled(true);
            iUserPassword.setEnabled(true);
            if (iPin != null)
                iPin.setEnabled(true);
            iLogIn.setEnabled(true);
            iSkip.setEnabled(true);
            iError.setVisible(false);
            iDialog.hide();
            authenticated(result);
            UserAuthenticatedEvent e = new UserAuthenticatedEvent(iGuest);
            for (UserAuthenticatedHandler h : iUserAuthenticatedHandlers)
                h.onLogIn(e);
            if (iOnLoginCommand != null)
                iOnLoginCommand.execute();
            Client.reloadMenu();
        }
    };
}

From source file:org.vectomatic.client.rep.controller.ColorEditor.java

License:Open Source License

public ColorEditor(RepApplication app) {
    super();/*from w w  w . j av  a 2 s  .c  o m*/
    setText(app.getConstants().colorEditorPanel());

    _colors = new Color[2];
    _colors[Color.HSV] = Color.fromHSV(0, 0, 0);
    _colors[Color.RGB] = Color.fromRGB(0, 0, 0);

    _colorWell = new StyleWell();

    GradientPanel gradientPanel = new GradientPanel();
    ValuePanel valuePanel = new ValuePanel();

    _tabPanel = new TabPanel();
    _tabPanel.add(gradientPanel, app.getConstants().gradientsTab());
    _tabPanel.add(valuePanel, app.getConstants().valuesTab());
    _tabPanel.addTabListener(valuePanel);

    _okButton = new Button(app.getConstants().okButton());
    _okButton.addClickListener(this);
    _cancelButton = new Button(app.getConstants().cancelButton());
    _cancelButton.addClickListener(this);

    FlexTable table = new FlexTable();
    table.setWidget(0, 0, _tabPanel);
    table.setWidget(1, 0, _colorWell);
    table.setWidget(1, 1, _okButton);
    table.setWidget(1, 2, _cancelButton);
    table.getFlexCellFormatter().setColSpan(0, 0, 3);
    table.getColumnFormatter().setWidth(0, "120px");
    DOM.setStyleAttribute(_colorWell.getElement(), "height", "20px");
    setWidget(table);
}

From source file:org.vectomatic.client.rep.controller.LineWidthEditor.java

License:Open Source License

public LineWidthEditor(LineWidthController controller) {
    super(false, true);
    _controller = controller;//  ww  w.j  ava 2s  .  c om

    UIConstants constants = RepApplication.app._constants;
    setText(constants.lineWidthEditor());

    _lineWidthSpinner = new Spinner(1, 10, 5);
    Button okButton = new Button(constants.okButton());
    okButton.setWidth("150px");
    okButton.addClickListener(new ClickListener() {
        public void onClick(Widget sender) {
            hide();
            try {
                _controller.setLineWidth(new FloatAttributeValue(_lineWidthSpinner.getValue()));
            } catch (NumberFormatException e) {
            }
        }
    });
    Button cancelButton = new Button(constants.cancelButton());
    cancelButton.setWidth("150px");
    cancelButton.addClickListener(new ClickListener() {
        public void onClick(Widget sender) {
            hide();
        }
    });
    FlexTable layoutTable = new FlexTable();
    FlexCellFormatter cellFormatter = layoutTable.getFlexCellFormatter();
    layoutTable.setWidget(0, 0, _lineWidthSpinner);
    FlowPanel flowPanel = new FlowPanel();
    flowPanel.add(cancelButton);
    flowPanel.add(okButton);
    layoutTable.setWidget(1, 0, flowPanel);
    cellFormatter.setAlignment(1, 0, HasHorizontalAlignment.ALIGN_RIGHT, HasVerticalAlignment.ALIGN_MIDDLE);
    setWidget(layoutTable);
}

From source file:org.vectomatic.client.rep.controller.ResizeDrawingPanel.java

License:Open Source License

public ResizeDrawingPanel(final ResizeController resizeController) {
    super(false, true);
    UIConstants constants = RepApplication.app._constants;
    setText(constants.dimensionsPanel());
    Label widthLabel = new Label(constants.widthLabel());
    _widthSpinner = new Spinner(1, 1024, 100);
    Label heightLabel = new Label(constants.heightLabel());
    _heightSpinner = new Spinner(1, 1024, 100);
    FlexTable contentTable = new FlexTable();
    contentTable.setWidget(0, 0, widthLabel);
    contentTable.setWidget(0, 1, _widthSpinner);
    contentTable.setWidget(1, 0, heightLabel);
    contentTable.setWidget(1, 1, _heightSpinner);

    Button okButton = new Button(constants.okButton());
    okButton.setWidth("150px");
    okButton.addClickListener(new ClickListener() {
        public void onClick(Widget sender) {
            resizeController.resize(_widthSpinner.getValue(), _heightSpinner.getValue());
            hide();// w w w.  j  a v  a 2 s  .  c  o  m
        }
    });
    Button cancelButton = new Button(constants.cancelButton());
    cancelButton.setWidth("150px");
    cancelButton.addClickListener(new ClickListener() {
        public void onClick(Widget sender) {
            hide();
        }
    });
    FlexTable layoutTable = new FlexTable();
    FlexCellFormatter cellFormatter = layoutTable.getFlexCellFormatter();
    layoutTable.setWidget(0, 0, contentTable);
    FlowPanel flowPanel = new FlowPanel();
    flowPanel.add(cancelButton);
    flowPanel.add(okButton);
    layoutTable.setWidget(1, 0, flowPanel);
    cellFormatter.setAlignment(1, 0, HasHorizontalAlignment.ALIGN_RIGHT, HasVerticalAlignment.ALIGN_MIDDLE);
    setWidget(layoutTable);
}

From source file:org.vectomatic.client.rep.view.PaletteEditor.java

License:Open Source License

public PaletteEditor(RepApplication app, ColorEditor colorEditor, PlainColorMenu menu) {
    super();/* w  w  w.  ja v  a2s  .c o  m*/
    _app = app;
    setText(_app.getConstants().paletteEditorPanel());
    _palettes = _app.getPalettes();
    _colorEditor = colorEditor;
    _menu = menu;

    _newPaletteButton = new Button(_app.getConstants().newPaletteButton(), new ClickListener() {
        public void onClick(Widget sender) {
            newPalette();
        }
    });
    _newPaletteButton.setWidth("100%");

    _clonePaletteButton = new Button(_app.getConstants().clonePaletteButton(), new ClickListener() {
        public void onClick(Widget sender) {
            clonePalette();
        }
    });
    _clonePaletteButton.setWidth("100%");

    _deletePaletteButton = new Button(_app.getConstants().deletePaletteButton(), new ClickListener() {
        public void onClick(Widget sender) {
            deletePalette();
        }
    });
    _deletePaletteButton.setWidth("100%");

    _editColorButton = new Button(_app.getConstants().editColorButton(), new ClickListener() {
        public void onClick(Widget sender) {
            editColor();
        }
    });
    _editColorButton.setWidth("100%");

    _newColorButton = new Button(_app.getConstants().newColorButton(), new ClickListener() {
        public void onClick(Widget sender) {
            newColor();
        }
    });
    _newColorButton.setWidth("100%");

    _deleteColorButton = new Button(_app.getConstants().deleteColorButton(), new ClickListener() {
        public void onClick(Widget sender) {
            deleteColor();
        }
    });
    _deleteColorButton.setWidth("100%");

    _closeButton = new Button(_app.getConstants().closeButton(), new ClickListener() {
        public void onClick(Widget sender) {
            close();
        }
    });
    _closeButton.setWidth("100%");

    _paletteList = new ListBox();
    _paletteList.setWidth("100%");
    _paletteList.setHeight("100%");
    _paletteList.setVisibleItemCount(5);
    for (int i = 0, size = _palettes.size(); i < size; i++) {
        _paletteList.addItem(_palettes.getPalette(i).getName());
    }

    _paletteName = new TextBox();
    _paletteName.setWidth("100%");
    _paletteName.setMaxLength(32);
    _paletteName.addChangeListener(new ChangeListener() {
        public void onChange(Widget sender) {
            if (_paletteName.getText().length() > 0) {
                _paletteWidget.getPalette().setName(_paletteName.getText());
                _paletteList.setItemText(_paletteList.getSelectedIndex(), _paletteName.getText());
            } else {
                _paletteName.setText(_paletteWidget.getPalette().getName());
            }
        }
    });
    _paletteList.addChangeListener(this);
    _paletteWidget = new PaletteWidget(null, _colorEditor);
    if (_palettes.size() > 0) {
        _paletteList.setSelectedIndex(0);
        onChange(_paletteList);
    }
    FlexTable table = new FlexTable();
    table.setWidget(0, 0, _paletteList);
    table.setWidget(0, 1, new Label(_app.getConstants().paletteNameLabel()));
    table.setWidget(1, 0, _paletteName);
    ScrollPanel scrollPanel = new ScrollPanel(_paletteWidget);
    scrollPanel.setWidth("195px");
    scrollPanel.setHeight("125px");
    table.setWidget(2, 0, scrollPanel);
    table.setWidget(3, 0, _newPaletteButton);
    table.setWidget(3, 1, _newColorButton);
    table.setWidget(4, 0, _clonePaletteButton);
    table.setWidget(4, 1, _editColorButton);
    table.setWidget(5, 0, _deletePaletteButton);
    table.setWidget(5, 1, _deleteColorButton);
    table.setWidget(6, 1, _closeButton);
    table.getFlexCellFormatter().setRowSpan(0, 0, 3);
    table.getColumnFormatter().setWidth(0, "195px");
    table.getColumnFormatter().setWidth(1, "195px");
    setWidget(table);
}

From source file:org.vectomatic.client.rep.view.Spinner.java

License:Open Source License

public Spinner(int min, int max, int value) {
    _min = min;/*from   www . j a  v  a 2 s.  c  om*/
    _max = max;
    _value = value;
    _box = new TextBox();
    int length = 1 + (int) ((Math.log(_max) / Math.log(10)));
    _box.setMaxLength(length);
    _box.setVisibleLength(length);
    _box.addChangeListener(new ChangeListener() {
        public void onChange(Widget sender) {
            try {
                int value = Integer.parseInt(_box.getText());
                if (value >= _min && value <= _max) {
                    _value = value;
                }
            } catch (NumberFormatException e) {
            }
            update();
        }
    });
    _addButton = new PushButton(RepApplication.app._icons.upIcon().createImage());
    _addButton.setStyleName("spinner-button");
    _addButton.addClickListener(new ClickListener() {
        public void onClick(Widget sender) {
            add();
        }
    });
    _subButton = new PushButton(RepApplication.app._icons.downIcon().createImage());
    _subButton.setStyleName("spinner-button");
    _subButton.addClickListener(new ClickListener() {
        public void onClick(Widget sender) {
            sub();
        }
    });
    FlexTable table = new FlexTable();
    table.setWidget(0, 0, _box);
    table.setWidget(0, 1, _addButton);
    table.setWidget(1, 0, _subButton);
    table.getFlexCellFormatter().setRowSpan(0, 0, 2);
    table.setCellSpacing(0);
    setWidget(table);
    update();
}

From source file:org.vectomatic.client.rep.view.WarningPanel.java

License:Open Source License

public WarningPanel() {
    super(false, true);
    UIConstants constants = RepApplication.app._constants;
    setText(constants.warning());//  ww w  .j ava 2  s .c o m
    _warningLabel = new Label();
    _warningLabel.setWidth("400px");
    _warningButton = new Button();
    _warningButton.setWidth("150px");
    Button cancelButton = new Button(constants.cancelButton());
    cancelButton.setWidth("150px");
    cancelButton.addClickListener(new ClickListener() {
        public void onClick(Widget sender) {
            hide();
        }
    });
    FlexTable layoutTable = new FlexTable();
    FlexCellFormatter cellFormatter = layoutTable.getFlexCellFormatter();
    layoutTable.setWidget(0, 0, _warningLabel);
    FlowPanel flowPanel = new FlowPanel();
    flowPanel.add(cancelButton);
    flowPanel.add(_warningButton);
    layoutTable.setWidget(1, 0, flowPanel);
    cellFormatter.setAlignment(1, 0, HasHorizontalAlignment.ALIGN_RIGHT, HasVerticalAlignment.ALIGN_MIDDLE);
    setWidget(layoutTable);
}

From source file:org.vectomatic.svg.edu.client.Intro.java

License:Open Source License

public void onModuleLoad2() {
    CommonBundle.INSTANCE.css().ensureInjected();
    final FlexTable table = new FlexTable();
    table.setBorderWidth(0);/*from  ww  w. ja  v  a2  s . c o m*/
    table.setCellSpacing(5);
    table.setStyleName(css.gameTable());

    table.setWidget(0, 0, Game.DOTS.getImage());
    table.setWidget(1, 0, Game.DOTS.getRule());
    table.getCellFormatter().setAlignment(0, 0, HasHorizontalAlignment.ALIGN_CENTER,
            HasVerticalAlignment.ALIGN_MIDDLE);
    table.getCellFormatter().setAlignment(1, 0, HasHorizontalAlignment.ALIGN_CENTER,
            HasVerticalAlignment.ALIGN_MIDDLE);

    table.setWidget(0, 1, Game.MAZE.getImage());
    table.setWidget(1, 1, Game.MAZE.getRule());
    table.getCellFormatter().setAlignment(0, 1, HasHorizontalAlignment.ALIGN_CENTER,
            HasVerticalAlignment.ALIGN_MIDDLE);
    table.getCellFormatter().setAlignment(1, 1, HasHorizontalAlignment.ALIGN_CENTER,
            HasVerticalAlignment.ALIGN_MIDDLE);

    table.setWidget(2, 0, Game.PUSH.getImage());
    table.setWidget(3, 0, Game.PUSH.getRule());
    table.getCellFormatter().setAlignment(2, 0, HasHorizontalAlignment.ALIGN_CENTER,
            HasVerticalAlignment.ALIGN_MIDDLE);
    table.getCellFormatter().setAlignment(3, 0, HasHorizontalAlignment.ALIGN_CENTER,
            HasVerticalAlignment.ALIGN_MIDDLE);

    table.setWidget(2, 1, Game.PUZZLE.getImage());
    table.setWidget(3, 1, Game.PUZZLE.getRule());
    table.getCellFormatter().setAlignment(2, 1, HasHorizontalAlignment.ALIGN_CENTER,
            HasVerticalAlignment.ALIGN_MIDDLE);
    table.getCellFormatter().setAlignment(3, 1, HasHorizontalAlignment.ALIGN_CENTER,
            HasVerticalAlignment.ALIGN_MIDDLE);

    final LicenseBox licenseBox = new LicenseBox();
    Anchor licenseAnchor = new Anchor();
    licenseAnchor.setText(EduConstants.INSTANCE.license());
    licenseAnchor.addClickHandler(new ClickHandler() {

        @Override
        public void onClick(ClickEvent event) {
            licenseBox.box.center();
            licenseBox.box.show();
        }

    });
    table.setWidget(4, 0, licenseAnchor);
    table.getFlexCellFormatter().setColSpan(4, 0, 2);
    table.getCellFormatter().setAlignment(4, 0, HasHorizontalAlignment.ALIGN_CENTER,
            HasVerticalAlignment.ALIGN_MIDDLE);
    ResizeHandler resizeHandler = new ResizeHandler() {

        @Override
        public void onResize(ResizeEvent event) {
            float w = Window.getClientWidth() * 0.45f;
            float h = Window.getClientHeight() * 0.3f;
            for (int i = 0; i < 4; i += 2) {
                for (int j = 0; j < 2; j++) {
                    SVGImage svgImage = (SVGImage) table.getWidget(i, j);
                    svgImage.getSvgElement().getStyle().setSVGProperty("width", Float.toString(w));
                    svgImage.getSvgElement().getStyle().setSVGProperty("height", Float.toString(h));
                }
            }
            GWT.log(w + "x" + h);
        }

    };
    Window.addResizeHandler(resizeHandler);
    resizeHandler.onResize(null);
    RootPanel.get(ID_UIROOT).add(table);
    confirmBox = ConfirmBox.createConfirmBox(table);
}