Ejemplo n.º 1
0
      @Override
      @HibernateUserRead
      public void step2() {
        CardType ct = CardType.getTL(ctId);
        Date dt = new Date();
        Card c = new Card(txt, ct, dt);
        c.setCreatedInMove(Move.getCurrentMoveTL());
        c.setAuthor(User.getTL(author.getId())); // fresh
        if (newCardListener != null) newCardListener.cardCreatedTL(c);

        content.setValue("");
        content.setInputPrompt("Enter text for another card.");
        closeDrawer();

        resetCoroutine(); // for another click
      }
Ejemplo n.º 2
0
    @SuppressWarnings("serial")
    @HibernateRead
    private void adminSwitchAuthorsTL(Button butt, final CardPlayHandler coroutine) {
      ArrayList<User> meLis = new ArrayList<User>(1);
      meLis.add(coroutine.author);
      User me = User.getTL(Mmowgli2UI.getGlobals().getUserID());

      final AddAuthorDialog dial = new AddAuthorDialog(meLis, true);
      StringBuilder sb = new StringBuilder("As adminstrator, <b>");
      sb.append(me.getUserName());
      sb.append("</b>, you may choose another player to be card author.");
      dial.infoLabel.setValue(sb.toString());
      dial.setCaption("Select Proxy Author");
      dial.setMultiSelect(false);
      dial.cancelButt.setCaption("Use myself");
      dial.addButt.setCaption("Use selected");

      // Rearrange buttons, add real cancel butt.
      // -------------------
      HorizontalLayout buttonHL = dial.getButtonHorizontalLayout();
      Iterator<Component> itr = buttonHL.iterator();
      Vector<Component> v = new Vector<Component>();
      while (itr.hasNext()) {
        Component component = itr.next();
        if (component instanceof Button) v.add(component);
      }
      buttonHL.removeAllComponents();
      itr = v.iterator();
      while (itr.hasNext()) {
        buttonHL.addComponent(itr.next());
      }
      Label sp = null;
      buttonHL.addComponent(sp = new Label());
      sp.setWidth("1px");
      buttonHL.setExpandRatio(sp, 1.0f);

      Button cancelButt = null;
      buttonHL.addComponent(cancelButt = new Button("Cancel"));
      cancelButt.addClickListener(
          new ClickListener() {
            @Override
            public void buttonClick(ClickEvent event) {
              UI.getCurrent().removeWindow(dial); // dial.getParent().removeWindow(dial);
              coroutine.resetCoroutine();
            }
          });
      // -------------------

      dial.selectItemAt(0);
      dial.addListener(
          new CloseListener() {
            @Override
            @MmowgliCodeEntry
            @HibernateOpened
            @HibernateClosed
            @HibernateUserRead
            public void windowClose(CloseEvent e) {
              HSess.init();
              if (dial.addClicked) {
                Object o = dial.getSelected();

                if (o instanceof User) {
                  coroutine.author = (User) o;
                } else if (o instanceof QuickUser) {
                  QuickUser qu = (QuickUser) o;
                  coroutine.author = User.getTL(qu.id);
                }
              }
              coroutine.run(); // finish up
              HSess.close();
            }
          });

      UI.getCurrent().addWindow(dial);
      dial.center();
    }