@Override
 public void setLoading(boolean isLoading) {
   if (isLoading) {
     aLoadMore.addStyleName("hide");
     divPreloader.removeClassName("hide");
   } else {
     divPreloader.addClassName("hide");
     aLoadMore.removeStyleName("hide");
   }
 }
Beispiel #2
0
  @Override
  public void onPlaceChange(PlaceChangeEvent event) {
    Place newPlace = event.getNewPlace();

    // select the link corresponding to the place
    for (Link link : links) {
      if (link.isPlaceMatchLink(newPlace)) {
        link.getLink().addStyleName(res.style().menuLinkSelected());
      } else {
        link.getLink().removeStyleName(res.style().menuLinkSelected());
      }
    }

    // clear the source list because we are going to update it with the raw source file
    // corresponding to the new
    // place
    sourceList.clear();

    if (newPlace instanceof PlaceWithSources) {
      exampleLink.setVisible(true);
      sourceLink.setVisible(true);

      PlaceWithSources<?> place = (PlaceWithSources<?>) newPlace;

      sourceList.addItem("Example", place.getSourceFilename());

      String[] rawFilenames = place.getRawSourceFilenames();

      if (null != rawFilenames && rawFilenames.length > 0) {
        // add the raw source files to the list and show the list
        String text = sourceLink.getText();
        if (!text.endsWith(":")) {
          sourceLink.setText(text + ":");
        }
        sourceList.setVisible(true);
        int indexRawSource = 0;
        // starting at 1 because the first item is the example
        int i = 1;
        for (String filename : rawFilenames) {
          sourceList.addItem(filename, filename);
          if (place.isRawSource() && filename.equals(place.getFilename())) {
            indexRawSource = i;
          }
          i++;
        }
        sourceList.setSelectedIndex(indexRawSource);
      } else {
        // no raw source file, we hide the list
        String text = sourceLink.getText();
        if (text.endsWith(":")) {
          sourceLink.setText(text.substring(0, text.length() - 1));
        }
        sourceList.setVisible(false);
      }

      if (null == place.getFilename()) {
        sourceLink.removeStyleName(res.style().sourceLinkSelected());
        exampleLink.addStyleName(res.style().sourceLinkSelected());
        container.getElement().getStyle().clearBackgroundColor();
        container.getElement().getStyle().clearProperty("border");
      } else {
        exampleLink.removeStyleName(res.style().sourceLinkSelected());
        sourceLink.addStyleName(res.style().sourceLinkSelected());
        container.getElement().getStyle().setBackgroundColor("#eee");
        container.getElement().getStyle().setProperty("border", "1px solid #c3c3c3");
      }
    } else {
      // should not happen
      exampleLink.setVisible(false);
      sourceLink.setVisible(false);
      sourceList.setVisible(false);
    }
  }