Пример #1
0
 @Override
 public void detach() {
   super.detach();
   ui.removeLoginListener(loginListener);
   ui.clearMap();
 }
Пример #2
0
  @Override
  public void enter(ViewChangeEvent event) {

    List<Mark> marks = Mark.loadAll();

    final User user = ui.getCurrentUser();
    boolean bustsOnMap = false;

    for (int i = marks.size() - 1; i >= 0; i--) {
      final Mark m = marks.get(i);

      if (!m.isApproved()) {
        if (user.isAdmin()) {
          CustomLayout layout = new CustomLayout("suggested-mark-row");
          Button title = new Button(marks.get(i).getTitle());
          title.setStyleName("mark-title");
          final int id = marks.get(i).getId();
          title.addClickListener(
              new Button.ClickListener() {

                public void buttonClick(ClickEvent event) {
                  UI.getCurrent().getNavigator().navigateTo("suggestedmark/" + id);
                  // Notification.show("Title clicked");
                }
              });
          layout.addComponent(title, "suggested-mark-row-title");
          marksList.addComponent(layout);
          hasVisibleSuggestedMarks = true;
        }
        continue;
      }

      CustomLayout layout = new CustomLayout("mark-row");

      // Button to show BustsSubview with Busts under the clicked Mark
      int count = m.getBusts().size();
      Button title = new Button(marks.get(i).getTitle() + " (" + count + ")");
      title.setStyleName("mark-title");
      final int id = marks.get(i).getId();
      title.addClickListener(
          new Button.ClickListener() {

            public void buttonClick(ClickEvent event) {
              UI.getCurrent().getNavigator().navigateTo("busts/" + id + "/");
              // Notification.show("Title clicked");
            }
          });

      final Label voteCount = new Label((int) m.getVoteCount() + "");
      voteCount.setStyleName("vote-count");

      // Button to give upvote to Mark
      final Button upvoteButton = new VoteButton(m, VoteButton.Type.UP);
      upvoteButton.addClickListener(
          new Button.ClickListener() {
            @Override
            public void buttonClick(ClickEvent event) {
              voteCount.setValue((int) m.getVoteCount() + "");
            }
          });

      // Button to give downvote to Mark
      final Button downvoteButton = new VoteButton(m, VoteButton.Type.DOWN);
      downvoteButton.addClickListener(
          new Button.ClickListener() {
            @Override
            public void buttonClick(ClickEvent event) {
              voteCount.setValue((int) m.getVoteCount() + "");
            }
          });

      layout.addComponent(upvoteButton, "mark-row-upvote-arrow");
      layout.addComponent(voteCount, "mark-row-vote-count");
      layout.addComponent(downvoteButton, "mark-row-downvote-arrow");
      layout.addComponent(title, "mark-row-title");

      marksList.addComponent(layout);

      if (!bustsOnMap && count > 0) {
        ui.showBusts(marks.get(i));
        bustsOnMap = true;
      }
    }

    loginListener.login(null); // force login actions
  }
Пример #3
0
 @Override
 public void attach() {
   super.attach();
   ui.addLoginListener(loginListener);
 }