public WebProtegeDialogTextFieldValidationManager(
      ValueBoxBase<String> textBox,
      final WebProtegeDialogInlineValidator<ValueBoxBase<String>> validator) {
    this.textBox = textBox;
    this.errorLabel = new InlineLabel();
    this.validator = validator;
    textBox.addKeyUpHandler(
        new KeyUpHandler() {
          public void onKeyUp(KeyUpEvent event) {
            if (validator.shouldCheckOnKeyUp()) {
              runValidation();
            }
          }
        });
    textBox.addValueChangeHandler(
        new ValueChangeHandler<String>() {
          public void onValueChange(ValueChangeEvent<String> stringValueChangeEvent) {
            if (validator.shouldCheckOnValueChange()) {
              runValidation();
            }
          }
        });

    errorLabel.addStyleName("web-protege-red-foreground");
    errorLabel.setText("");
    errorLabel.setVisible(false);
  }
 /* (non-Javadoc)
  * @see org.ednovo.gooru.client.mvp.classpage.teach.edit.content.IsEditClassContentView#setCourseData(org.ednovo.gooru.application.shared.model.folder.FolderDo)
  */
 @Override
 public void setCourseData(FolderDo result) {
   coursePanelVisiblity(true);
   if (result != null) {
     titleLbl.setText(result.getTitle());
     titleLbl.getElement().setId(result.getGooruOid());
     titleLbl.getElement().setAttribute("alt", result.getTitle());
     titleLbl.getElement().setAttribute("title", result.getTitle());
   }
 }
 public InlineValidationResult runValidation() {
   InlineValidationResult validation = validator.getValidation(textBox);
   if (validation.isInvalid()) {
     errorLabel.setText(validation.getMessage());
     errorLabel.setVisible(true);
   } else {
     errorLabel.setText("");
     errorLabel.setVisible(false);
   }
   return validation;
 }
Пример #4
0
  public static Widget getMessage(ImageResource imageResource, String customMessage) {
    HorizontalPanel hp = new HorizontalPanel();
    hp.setSpacing(5);

    hp.add(new Image(imageResource.getSafeUri()));

    InlineLabel label = new InlineLabel(customMessage);
    label.getElement().getStyle().setFontWeight(Style.FontWeight.NORMAL);
    label.getElement().getStyle().setFloat(Style.Float.LEFT);
    hp.add(label);

    return hp;
  }
  public com.google.gwt.user.client.ui.Widget createAndBindUi(
      final com.google.gwt.requestfactory.ui.client.LoginWidget owner) {

    com.google.gwt.requestfactory.ui.client.LoginWidget_BinderImpl_GenBundle
        clientBundleFieldNameUnlikelyToCollideWithUserSpecifiedFieldOkay =
            (com.google.gwt.requestfactory.ui.client.LoginWidget_BinderImpl_GenBundle)
                GWT.create(
                    com.google.gwt.requestfactory.ui.client.LoginWidget_BinderImpl_GenBundle.class);
    com.google.gwt.requestfactory.ui.client.LoginWidget_BinderImpl_GenCss_style style =
        clientBundleFieldNameUnlikelyToCollideWithUserSpecifiedFieldOkay.style();
    com.google.gwt.dom.client.SpanElement name = null;
    java.lang.String domId0 = com.google.gwt.dom.client.Document.get().createUniqueId();
    java.lang.String domId1 = com.google.gwt.dom.client.Document.get().createUniqueId();
    com.google.gwt.user.client.ui.InlineLabel logoutLink =
        (com.google.gwt.user.client.ui.InlineLabel)
            GWT.create(com.google.gwt.user.client.ui.InlineLabel.class);
    com.google.gwt.user.client.ui.HTMLPanel f_HTMLPanel1 =
        new com.google.gwt.user.client.ui.HTMLPanel(
            "<div> <span id='"
                + domId0
                + "'>Not logged in</span> | <span id='"
                + domId1
                + "'></span> </div>");

    logoutLink.setText("Sign out");
    logoutLink.addStyleName("" + style.link() + "");

    UiBinderUtil.TempAttachment attachRecord0 = UiBinderUtil.attachToDom(f_HTMLPanel1.getElement());
    name = com.google.gwt.dom.client.Document.get().getElementById(domId0).cast();
    name.removeAttribute("id");
    com.google.gwt.user.client.Element domId1Element =
        com.google.gwt.dom.client.Document.get().getElementById(domId1).cast();
    attachRecord0.detach();
    f_HTMLPanel1.addAndReplaceElement(logoutLink, domId1Element);

    final com.google.gwt.event.dom.client.ClickHandler
        handlerMethodWithNameVeryUnlikelyToCollideWithUserFieldNames1 =
            new com.google.gwt.event.dom.client.ClickHandler() {
              public void onClick(com.google.gwt.event.dom.client.ClickEvent event) {
                owner.handleClick(event);
              }
            };
    logoutLink.addClickHandler(handlerMethodWithNameVeryUnlikelyToCollideWithUserFieldNames1);

    owner.name = name;
    clientBundleFieldNameUnlikelyToCollideWithUserSpecifiedFieldOkay.style().ensureInjected();

    return f_HTMLPanel1;
  }
Пример #6
0
 @Override
 public void enableUserOptions(CurrentUser currentUser) {
   userOptions.setVisible(true);
   menuBar.setVisible(true);
   UserDto userDto = currentUser.getUser();
   name.setText(userDto.getFirstName());
 }
  private void openRawTab() {
    if (currentTab.equals(TABS.RAW)) return;

    String tabHandlercurrent = "inlineButtonChecked";
    String tabsContent = "tabsContent";
    String cssTabContent = "tabContent";
    String tabContentCurrent = "tabContentCurrent";

    HTML5Element tab = (HTML5Element) rawTab.getElement().cast();
    ((HTML5Element) tab.getParentElement())
        .querySelector("." + tabHandlercurrent)
        .getClassList()
        .remove(tabHandlercurrent);
    tab.getClassList().add(tabHandlercurrent);

    HTML5Element contentParent = (HTML5Element) tabContent.getParentElement();
    contentParent
        .querySelector("." + tabsContent + " ." + cssTabContent + "." + tabContentCurrent)
        .getClassList()
        .remove(tabContentCurrent);
    contentParent
        .querySelector("." + tabsContent + " ." + cssTabContent + "[data-tab=\"raw\"]")
        .getClassList()
        .add(tabContentCurrent);

    currentTab = TABS.RAW;

    if (headersCodeMirror != null) {
      headersCodeMirror.refresh();
    }
    GoogleAnalytics.sendEvent(ANALYTICS_EVENT_CATEGORY, "Tab switched", "Raw tab");
    GoogleAnalyticsApp.sendEvent(ANALYTICS_EVENT_CATEGORY, "Tab switched", "Raw tab");
  }
  private void openFormTab() {
    if (currentTab.equals(TABS.FORM)) return;

    updateForm();
    ensureFormHasRow();

    String tabHandlercurrent = "inlineButtonChecked";
    String tabsContent = "tabsContent";
    String cssTabContent = "tabContent";
    String tabContentCurrent = "tabContentCurrent";

    HTML5Element tab = (HTML5Element) formTab.getElement().cast();
    ((HTML5Element) tab.getParentElement())
        .querySelector("." + tabHandlercurrent)
        .getClassList()
        .remove(tabHandlercurrent);
    tab.getClassList().add(tabHandlercurrent);

    HTML5Element contentParent = (HTML5Element) tabContent.getParentElement();
    contentParent
        .querySelector("." + tabsContent + " ." + cssTabContent + "." + tabContentCurrent)
        .getClassList()
        .remove(tabContentCurrent);
    contentParent
        .querySelector("." + tabsContent + " ." + cssTabContent + "[data-tab=\"form\"]")
        .getClassList()
        .add(tabContentCurrent);

    currentTab = TABS.FORM;
    GoogleAnalytics.sendEvent(ANALYTICS_EVENT_CATEGORY, "Tab switched", "Form tab");
    GoogleAnalyticsApp.sendEvent(ANALYTICS_EVENT_CATEGORY, "Tab switched", "Form tab");
  }
Пример #9
0
  @Override
  public void setTasks(List<LongTask> longTasks) {
    tableView.clearRows();
    if (longTasks == null) return;

    for (LongTask task : longTasks) {
      InlineLabel avgTime = new InlineLabel(task.getAverageTime() + " days");
      if (task.getAverageTime() < 7) {
        avgTime.addStyleName("label label-info arrowed-in");
      } else if (task.getAverageTime() < 14) {
        avgTime.addStyleName("label label-warning arrowed-in");
      } else {
        avgTime.addStyleName("label label-important arrowed-in");
      }
      tableView.addRow(
          new InlineLabel(task.getTaskName()),
          new InlineLabel(task.getDocumentType()),
          new InlineLabel(task.getNoOfTasks() + " tasks"),
          avgTime);
    }
  }
Пример #10
0
  /** @see org.overlord.apiman.dt.ui.client.local.pages.AbstractPlanPage#renderPage() */
  @Override
  protected void renderPage() {
    super.renderPage();
    description.setText(planBean.getDescription());
    createdOn.setText(Formatting.formatShortDate(planBean.getCreatedOn()));
    createdBy.setText(planBean.getCreatedBy());
    String toUserHref =
        navHelper.createHrefToPage(
            UserServicesPage.class,
            MultimapUtil.fromMultiple("user", planBean.getCreatedBy())); // $NON-NLS-1$
    createdBy.setHref(toUserHref);

    version.setText(versionBean.getVersion());
    versionCreatedOn.setText(Formatting.formatShortDate(versionBean.getCreatedOn()));
    versionCreatedBy.setText(versionBean.getCreatedBy());
    toUserHref =
        navHelper.createHrefToPage(
            UserServicesPage.class,
            MultimapUtil.fromMultiple("user", versionBean.getCreatedBy())); // $NON-NLS-1$
    versionCreatedBy.setHref(toUserHref);
  }
Пример #11
0
  private TestFlows() {
    FlowPanel root = new FlowPanel();
    Util.addText(root.getElement(), "Div root");

    FlowPanel div1 = new FlowPanel();
    Util.addText(div1.getElement(), "Div1");
    root.add(div1);

    FlowPanel div2 = new FlowPanel();
    Util.addText(div2.getElement(), "Div2");
    div1.add(div2);

    InlineLabel span1 = new InlineLabel();
    span1.setText("Span1");
    div1.add(span1);

    FlowPanel anon = new FlowPanel();
    Util.addText(anon.getElement(), "Div anon");
    root.add(anon);

    FlowPanel div3 = new FlowPanel();
    Util.addText(div3.getElement(), "Div3");
    anon.add(div3);

    FlowPanel div4 = new FlowPanel();
    Util.addText(div4.getElement(), "Div4");
    div3.add(div4);

    InlineLabel span2 = new InlineLabel();
    span2.setText("Span2");
    div3.add(span2);

    Util.addText(div1.getElement(), " Div1 end");
    Util.addText(div3.getElement(), " Div3 end");
    Util.addText(anon.getElement(), " Div anon end");
    Util.addText(root.getElement(), " Div root end");

    initWidget(root);
  }
  public void setId() {
    saveBtn.setText(i18n.GL0141());
    saveBtn.getElement().setId("saveBtnId");
    saveBtn.getElement().setAttribute("alt", i18n.GL0141());
    saveBtn.getElement().setAttribute("title", i18n.GL0141());

    errorLabel.getElement().setId("errorLblId");
    saveLblText.setText(i18n.GL3426());
    saveLblText.getElement().setId("saveLblTxtId");
    saveLblText.setVisible(false);

    assignedCourse.setText(i18n.GL3440());
    courseAssigned.setText(i18n.GL3441());
    studentsNotes.setText(i18n.GL3442());
    createCourseBtn.setText(i18n.GL3443());
    lessonPacingPanel.setText(i18n.GL3444());
    minimumScrPanel.setText(i18n.GL3445());
    miniNotesPanel.setText(i18n.GL3446());
    pacingWorks.setText(i18n.GL3447());
    pacingNotes.setText(i18n.GL3448());
    assessmentsLbl.setText(i18n.GL3449());
    collectionLbl.setText(i18n.GL3450());
    contentRedirectionLbl.setText(i18n.GL3593());
  }
Пример #13
0
  /**
   * Sets a new {@link ListFilter} to be shown.
   *
   * @param listFilter new {@link ListFilter}
   */
  public void setListFilter(ListFilter listFilter) {
    if (listFilter == null) {
      listFilter = new ListFilter();
    }

    ListFiltersConstants constants = I18n.getListFiltersConstants();

    ReadState read = ReadState.get(listFilter.getRead());
    readState.setText(constants.getString("readState_" + read.name()));

    Date fromDate = listFilter.getStartFrom();
    if (fromDate != null) {
      fromLabel.setVisible(true);
      from.setVisible(true);
      from.setValue(fromDate);
    } else {
      fromLabel.setVisible(false);
      from.setVisible(false);
    }

    Date toDate = listFilter.getEndTo();
    if (toDate != null) {
      toLabel.setVisible(true);
      to.setVisible(true);
      to.setValue(toDate);
    } else {
      toLabel.setVisible(false);
      to.setVisible(false);
    }

    ListFilterOrder order = listFilter.getOrder();
    if (order == null) {
      order = ListFilterOrder.getDefault();
    }

    ordered.setText(constants.getString("listFilterOrder_" + order.name()));
  }
Пример #14
0
 // Display the information in the model object
 private void display() {
   songNameDisplayLabel.setText(model.getName());
 }
Пример #15
0
  public Tab(String name, boolean isClosable) {
    initWidget(uiBinder.createAndBindUi(this));

    nameLabel.setText(name);
    closeButton.setVisible(isClosable);
  }
Пример #16
0
  /**
   * This constructor uses the SearchHandler of the new SearchPageUnified. This will be the default
   * constructor after development of the new feature is finished.
   *
   * @param isUnified
   */
  public ResultsView(boolean isUnified) {
    super();
    this.setStylePrimaryName(STYLE.resultsView());
    contentPanel = getContentPanel();
    bookViewMap = new HashMap<Book, ResultsBookView>();
    unPickables = new HashSet<Book>();

    com.bookspicker.client.view.SearchPageUnified.SearchHandler searchHandler =
        new com.bookspicker.client.view.SearchPageUnified.SearchHandler();

    searchTextBox = new SuggestionTextBox(classSuggestionString);
    searchTextBox.setVisibleLength(40);

    autoCompleteBox = new BpSuggestBox(BpOracle.getInstance(), searchTextBox);
    autoCompleteBox.addSelectionHandler(
        new SelectionHandler<Suggestion>() {

          @Override
          public void onSelection(SelectionEvent<Suggestion> event) {
            if (event.getSelectedItem() instanceof BpOracleSuggestion) {
              BpOracleSuggestion bpSuggestion = (BpOracleSuggestion) event.getSelectedItem();
              autoCompleteBox.setSavedQuery(bpSuggestion.getQueryString());
            }
          }
        });

    autoCompleteBox.addValueChangeHandler(
        new ValueChangeHandler<String>() {

          @Override
          public void onValueChange(ValueChangeEvent<String> event) {
            autoCompleteBox.cleanSavedQuery();
          }
        });

    searchTextBox.reset();
    autoCompleteBox.setLimit(8);
    autoCompleteBox.setWidth("25em");
    autoCompleteBox.setAutoSelectEnabled(true);

    if (SearchPage.AUTO_COMPLETE) {
      searchTextBox.addKeyPressHandler(searchHandler);
      searchTextBox.addKeyDownHandler(searchHandler);
      autoCompleteBox.addSelectionHandler(searchHandler);
      searchBox.setWidget(0, 0, autoCompleteBox);
    } else {
      searchTextBox.addKeyPressHandler(searchHandler);
      searchBox.setWidget(0, 0, searchTextBox);
    }
    searchBox.setStylePrimaryName(STYLE.searchBox());

    InlineLabel searchButton = new InlineLabel("Search");
    searchButton.setStylePrimaryName(STYLE.bpYellowButton());
    searchButton.addStyleName(STYLE.searchButton());
    searchButton.addStyleDependentName(STYLE.bpYellowButton());
    searchButton.addClickHandler(searchHandler);
    searchBox.setWidget(0, 1, searchButton);

    loadingIcon = new Image(Resources.INSTANCE.loadingIconSmall());
    loadingIcon.setStylePrimaryName(STYLE.loadingIcon());
    loadingIcon.addStyleName(STYLE.loadingIconHidden());
    searchBox.setWidget(0, 2, loadingIcon);

    SimplePanel searchWrapper = new SimplePanel();
    searchWrapper.setStylePrimaryName(STYLE.searchBoxWrapper());
    searchWrapper.setWidget(searchBox);
    contentPanel.add(searchWrapper);

    results.setStylePrimaryName(STYLE.resultsList());

    contentPanel.add(results);
  }
Пример #17
0
 @Override
 public void setRemainCount(String text) {
   remainCount.setText(text);
 }
  /** Construct a new widget with headers editor. */
  public RequestHeadersWidget() {
    initWidget(GWT.<Binder>create(Binder.class).createAndBindUi(this));

    loadCodeMirrorForHeaders();

    //
    // Initialize Suggest Oracle for headers
    //
    suggestOracle = new HeadersSuggestOracle("request");
    headersRawInput.addKeyUpHandler(
        new KeyUpHandler() {
          @Override
          public void onKeyUp(KeyUpEvent event) {
            updateHeadersRawData(headersRawInput.getValue());
          }
        });

    headersRawInput.addValueChangeHandler(
        new ValueChangeHandler<String>() {

          @Override
          public void onValueChange(ValueChangeEvent<String> event) {
            String headers = event.getValue();
            if (!RequestHeadersParser.isValidHeaderString(headers)) {
              errorInfo.setVisible(true);
            } else {
              errorInfo.setVisible(false);
            }
          }
        });

    rawTab.addClickHandler(
        new ClickHandler() {
          @Override
          public void onClick(ClickEvent event) {
            openRawTab();
          }
        });
    rawTab.addMouseOverHandler(
        new MouseOverHandler() {
          @Override
          public void onMouseOver(MouseOverEvent event) {
            HTML5Element tab = (HTML5Element) rawTab.getElement().cast();
            if (!tab.getClassList().contains("inlineButtonChecked"))
              tab.getClassList().add("inlineButtonHover");
          }
        });
    rawTab.addMouseOutHandler(
        new MouseOutHandler() {
          @Override
          public void onMouseOut(MouseOutEvent event) {
            HTML5Element tab = (HTML5Element) rawTab.getElement().cast();
            if (!tab.getClassList().contains("inlineButtonHover"))
              tab.getClassList().remove("inlineButtonHover");
          }
        });
    formTab.addClickHandler(
        new ClickHandler() {
          @Override
          public void onClick(ClickEvent event) {
            openFormTab();
          }
        });
    formTab.addMouseOverHandler(
        new MouseOverHandler() {
          @Override
          public void onMouseOver(MouseOverEvent event) {
            HTML5Element tab = (HTML5Element) formTab.getElement().cast();
            if (!tab.getClassList().contains("inlineButtonChecked"))
              tab.getClassList().add("inlineButtonHover");
          }
        });
    formTab.addMouseOutHandler(
        new MouseOutHandler() {
          @Override
          public void onMouseOut(MouseOutEvent event) {
            HTML5Element tab = (HTML5Element) formTab.getElement().cast();
            if (tab.getClassList().contains("inlineButtonHover"))
              tab.getClassList().remove("inlineButtonHover");
          }
        });

    BoundaryChangeEvent.register(
        RestClient.getClientFactory().getEventBus(),
        new BoundaryChangeEvent.Handler() {
          @Override
          public void onChange(String boundary) {
            ArrayList<RequestHeader> list = RequestHeadersParser.stringToHeaders(headersData);
            boolean found = false;
            for (RequestHeader header : list) {
              if (header.getName().toLowerCase().equals("content-type")) {
                header.setValue("multipart/form-data; boundary=" + boundary);
                found = true;
                break;
              }
            }
            if (!found) {
              list.add(
                  new RequestHeader("Content-Type", "multipart/form-data; boundary=" + boundary));
            }
            updateHeadersRawData(RequestHeadersParser.headersListToString(list));
            headersRawInput.setValue(headersData, true);

            if (currentTab.equals(TABS.FORM)) {
              updateForm();
            }
          }
        });
  }
Пример #19
0
 public Header(String userName, String userIdS, String logoutUrl) {
   initWidget(binder.createAndBindUi(this));
   userNickname.setText(userName);
   userId.setDefaultValue(userIdS);
   signOutLink.setHref(logoutUrl);
 }
Пример #20
0
 public void useAppLogo(boolean useLogo) {
   appNameImage.setVisible(useLogo);
   appNameLabel.setVisible(!useLogo);
 }
Пример #21
0
 public void setAppName(String appName) {
   appNameLabel.setText(appName);
 }
Пример #22
0
 @Override
 public void setTitle(String text) {
   title.setText(text);
 }
Пример #23
0
  public void setResponse(SurveyResponse surveyResponse, ElementHandlerCallback callback) {
    date.setText(surveyResponse.getResponseDate().toString());
    campaign.setText(surveyResponse.getCampaignName());
    survey.setText(surveyResponse.getSurveyName());
    username.setText(surveyResponse.getUserName());
    NumberFormat locationFormat = NumberFormat.getFormat("####.000");
    String latString = locationFormat.format(surveyResponse.getLatitude());
    String longString = locationFormat.format(surveyResponse.getLongitude());
    location.setText(latString + ", " + longString);

    for (PromptResponse promptResponse : surveyResponse.getPromptResponses()) {
      Widget responseDisplayWidget = null;
      switch (promptResponse.getPromptType()) {
        case PHOTO:
          String raw = promptResponse.getResponseRaw();
          if (raw.equals("SKIPPED") || raw.equals("NOT_DISPLAYED")) {
            responseDisplayWidget = new HTML(raw);
          } else {
            // generate urls for thumbnail and full sized photo and pass to widget
            String thumbUrl =
                AwUrlBasedResourceUtils.getImageUrl(
                    promptResponse.getResponseRaw(),
                    surveyResponse.getUserName(),
                    surveyResponse.getCampaignId(),
                    AwUrlBasedResourceUtils.ImageSize.SMALL);
            final String fullSizedImageUrl =
                AwUrlBasedResourceUtils.getImageUrl(
                    promptResponse.getResponseRaw(),
                    surveyResponse.getUserName(),
                    surveyResponse.getCampaignId(),
                    AwUrlBasedResourceUtils.ImageSize.ORIGINAL);
            Image img = new Image(thumbUrl);
            img.setStyleName(style.promptImage());

            // Locking in the width and height here stops the Image from resizing on image
            // load which causes the InfoWindow to refresh and flicker
            img.setPixelSize(AwConstants.MAPS_THUMBNAIL_WIDTH, AwConstants.MAPS_THUMBNAIL_HEIGHT);

            // Let's the calling code do whatever with the image, specifically used to avoid
            // dependencies
            // on the google maps API
            if (callback != null) {
              callback.addingElement(img.getElement(), fullSizedImageUrl);
            }

            FlowPanel panel = new FlowPanel();
            panel.add(img);
            responseDisplayWidget = panel;
          }
          break;
          // TODO: special case timestamp?
        default:
          // anything other than a photo, just copy it verbatim
          responseDisplayWidget = new HTML(promptResponse.getResponsePrepared());
          break;
      }

      // set up and style question
      HTML question = new HTML(promptResponse.getText());
      question.setStyleName(style.promptQuestion());

      // add style to response
      responseDisplayWidget.setStyleName(style.promptResponse());

      // add question and response to styled div
      FlowPanel panel = new FlowPanel();
      panel.setStyleName(style.prompt());
      panel.add(question);
      panel.add(responseDisplayWidget);

      // add the whole thing to prompt list
      prompts.add(panel);
    }
  }
Пример #24
0
 public void setUserName(String userName) {
   userNameLabel.setText(userName);
 }
Пример #25
0
  /**
   * Display the events for the cell located at <code>column</code>, <code>row</code>
   *
   * @param row
   * @param column
   * @param date
   * @param currentMonth
   */
  private void drawEvents(int row, int column, final Date date) {
    final FlexTable grid = (FlexTable) getWidget();

    // final VerticalPanel cell = (VerticalPanel) grid.getWidget(row,
    // column);
    final FlowPanel cell = (FlowPanel) grid.getWidget(row, column);

    if (cell == null)
      throw new NullPointerException(
          "The specified cell (" + row + ',' + column + ") doesn't exist.");

    // Displaying events
    final TreeSet<Event> sortedEvents =
        new TreeSet<Event>(
            new Comparator<Event>() {

              @Override
              public int compare(Event o1, Event o2) {
                int compare = 0;

                if (o1 == null && o2 == null) return 0;
                else if (o2 == null) return 1;
                else if (o1 == null) return -1;

                if (compare == 0 && o1.getDtstart() != null && o2.getDtstart() != null) {
                  long o1Start = o1.getDtstart().getTime();
                  long o2Start = o2.getDtstart().getTime();

                  if (o1Start < o2Start) compare = -1;
                  else if (o1Start > o2Start) compare = 1;
                }

                if (compare == 0 && o1.getSummary() != null && o2.getSummary() != null)
                  compare = o1.getSummary().compareTo(o2.getSummary());

                return compare;
              }
            });

    for (final Calendar calendar : calendars) {
      final Map<Date, List<Event>> eventMap = normalize(calendar);

      final List<Event> events = eventMap.get(date);

      if (events != null) {
        sortedEvents.addAll(events);
      }
    }

    final Iterator<Event> iterator = sortedEvents.iterator();
    for (int i = 0; iterator.hasNext() && i < eventLimit; i++) {
      final Event event = iterator.next();

      final ClickableFlowPanel flowPanel = new ClickableFlowPanel();
      flowPanel.addStyleName("calendar-event");

      boolean fullDayEvent = false;

      final StringBuilder eventDate = new StringBuilder();
      eventDate.append(hourFormatter.format(event.getDtstart()));
      if (event.getDtend() != null) {
        eventDate.append(" ");
        eventDate.append(hourFormatter.format(event.getDtend()));

        if (event.getDtstart().getDate() != event.getDtend().getDate()
            || event.getDtstart().getMonth() != event.getDtend().getMonth()
            || event.getDtstart().getYear() != event.getDtend().getYear()) {
          fullDayEvent = true;
          flowPanel.addStyleName("calendar-fullday-event");
        }
      }

      final InlineLabel dateLabel = new InlineLabel(eventDate.toString());
      dateLabel.addStyleName("calendar-event-date");

      final InlineLabel eventLabel = new InlineLabel(event.getSummary());
      eventLabel.addStyleName("calendar-event-label");

      if (fullDayEvent)
        flowPanel.addStyleName("calendar-fullday-event-" + event.getParent().getStyle());
      else eventLabel.addStyleName("calendar-event-" + event.getParent().getStyle());

      if (!fullDayEvent) flowPanel.add(dateLabel);
      flowPanel.add(eventLabel);

      final DecoratedPopupPanel detailPopup = new DecoratedPopupPanel(true);

      final Grid popupContent = new Grid(event.getParent().isEditable() ? 5 : 3, 1);
      popupContent.setText(0, 0, event.getSummary());
      popupContent.getCellFormatter().addStyleName(0, 0, "calendar-popup-header");

      if (!fullDayEvent) {
        popupContent.getCellFormatter().addStyleName(1, 0, "calendar-popup-date");
        popupContent
            .getCellFormatter()
            .addStyleName(1, 0, "calendar-event-" + event.getParent().getStyle());
        popupContent.setText(1, 0, eventDate.toString());
      } else popupContent.setText(1, 0, "");

      if (event.getDescription() != null && !"".equals(event.getDescription())) {
        popupContent.getCellFormatter().addStyleName(2, 0, "calendar-popup-description");
        popupContent.setText(2, 0, event.getDescription());
      } else popupContent.setText(2, 0, "");

      if (event.getParent().isEditable()
          && ProfileUtils.isGranted(authentication, GlobalPermissionEnum.EDIT_PROJECT_AGENDA)) {

        final Anchor editAnchor = new Anchor(I18N.CONSTANTS.calendarEditEvent());
        editAnchor.addClickHandler(
            new ClickHandler() {

              @Override
              public void onClick(ClickEvent clickEvent) {
                delegate.edit(event, CalendarWidget.this);
              }
            });

        final Anchor deleteAnchor = new Anchor(I18N.CONSTANTS.calendarDeleteEvent());
        deleteAnchor.addClickHandler(
            new ClickHandler() {

              @Override
              public void onClick(ClickEvent clickEvent) {
                delegate.delete(event, CalendarWidget.this);
                detailPopup.hide();
              }
            });

        popupContent.setWidget(3, 0, editAnchor);
        popupContent.setWidget(4, 0, deleteAnchor);
      }

      detailPopup.setWidget(popupContent);

      flowPanel.addClickHandler(
          new ClickHandler() {

            @Override
            public void onClick(ClickEvent event) {
              final int left = flowPanel.getAbsoluteLeft() - 10;
              final int bottom = Window.getClientHeight() - flowPanel.getAbsoluteTop();

              detailPopup.setWidth((getCellWidth(CELL_DEFAULT_WIDTH) + 20) + "px");

              // Show the popup
              detailPopup.setPopupPositionAndShow(
                  new PositionCallback() {

                    @Override
                    public void setPosition(int offsetWidth, int offsetHeight) {
                      detailPopup.getElement().getStyle().setPropertyPx("left", left);
                      detailPopup.getElement().getStyle().setProperty("top", "");
                      detailPopup.getElement().getStyle().setPropertyPx("bottom", bottom);
                    }
                  });
            }
          });

      cell.add(flowPanel);
    }

    if (eventLimit != UNDEFINED && sortedEvents.size() > eventLimit) {
      final Anchor eventLabel = new Anchor("\u25BC");
      final Date thisDate = new Date(date.getTime());
      eventLabel.addClickHandler(
          new ClickHandler() {

            @Override
            public void onClick(ClickEvent event) {
              startDate = thisDate;
              setDisplayMode(DisplayMode.WEEK);
            }
          });
      eventLabel.addStyleName("calendar-event-limit");
      cell.add(eventLabel);
    }
  }