Example usage for com.vaadin.ui VerticalLayout setSpacing

List of usage examples for com.vaadin.ui VerticalLayout setSpacing

Introduction

In this page you can find the example usage for com.vaadin.ui VerticalLayout setSpacing.

Prototype

@Override
    public void setSpacing(boolean spacing) 

Source Link

Usage

From source file:edu.nps.moves.mmowgli.AbstractMmowgliControllerHelper.java

License:Open Source License

void handleShowActiveUsersPerServer(MenuBar mbar) {
    Object[][] oa = Mmowgli2UI.getGlobals().getSessionCountByServer();

    Window svrCountWin = new Window("Display Active Users Per Server");
    svrCountWin.setModal(true);//from  ww  w.  j  a  va  2s .c  om
    VerticalLayout layout = new VerticalLayout();
    layout.setMargin(true);
    layout.setSpacing(true);
    layout.setWidth("99%");
    svrCountWin.setContent(layout);

    GridLayout gl = new GridLayout(2, Math.max(1, oa.length));
    gl.setSpacing(true);
    gl.addStyleName("m-greyborder");
    for (Object[] row : oa) {
        Label lab = new Label();
        lab.setSizeUndefined();
        lab.setValue(row[0].toString());
        gl.addComponent(lab);
        gl.setComponentAlignment(lab, Alignment.MIDDLE_RIGHT);

        gl.addComponent(new Label(row[1].toString()));
    }
    layout.addComponent(gl);
    layout.setComponentAlignment(gl, Alignment.MIDDLE_CENTER);

    svrCountWin.setWidth("250px");
    UI.getCurrent().addWindow(svrCountWin);
    svrCountWin.center();
}

From source file:edu.nps.moves.mmowgli.AbstractMmowgliControllerHelper.java

License:Open Source License

void handleShowActiveUsersActionTL(MenuBar menubar) {
    Session session = HSess.get();/*from  w ww.j a  va  2s .  c  o m*/

    Criteria criteria = session.createCriteria(User.class);
    criteria.setProjection(Projections.rowCount());
    criteria.add(Restrictions.eq("accountDisabled", false));
    int totcount = ((Long) criteria.list().get(0)).intValue();

    // new and improved
    int count = Mmowgli2UI.getGlobals().getSessionCount();

    Window countWin = new Window("Display Active User Count");
    countWin.setModal(true);

    VerticalLayout layout = new VerticalLayout();
    layout.setMargin(true);
    layout.setSpacing(true);
    layout.setWidth("99%");
    countWin.setContent(layout);

    HorizontalLayout hl = new HorizontalLayout();
    hl.setSpacing(true);
    Label lab;
    hl.addComponent(lab = new HtmlLabel("Number of users* (including yourself)<br/>currently playing:"));
    hl.addComponent(lab = new Label());
    lab.setWidth("15px");

    Label countTf = new HtmlLabel();
    countTf.setWidth("50px");
    countTf.setValue("&nbsp;" + count);
    countTf.addStyleName("m-greyborder");
    hl.addComponent(countTf);
    hl.setComponentAlignment(countTf, Alignment.MIDDLE_LEFT);
    layout.addComponent(hl);

    layout.addComponent(new Label("* Count incremented on login, decremented on timeout or logout."));

    hl = new HorizontalLayout();
    hl.setSpacing(true);

    hl.addComponent(lab = new HtmlLabel("Total registered users:"));
    hl.addComponent(lab = new Label());
    lab.setWidth("15px");

    Label totalLab = new HtmlLabel();
    totalLab.setWidth("50px");
    totalLab.setValue("&nbsp;" + totcount);
    totalLab.addStyleName("m-greyborder");
    hl.addComponent(totalLab);
    hl.setComponentAlignment(totalLab, Alignment.MIDDLE_LEFT);
    layout.addComponent(hl);

    countWin.setWidth("325px");
    UI.getCurrent().addWindow(countWin);
    countWin.center();
}

From source file:edu.nps.moves.mmowgli.AbstractMmowgliControllerHelper.java

License:Open Source License

private void _postGameEvent(String title, final GameEvent.EventType typ, String buttName, boolean doWarning,
        MenuBar mbar) {/*  www.ja  va2 s .  com*/
    // Create the window...
    final Window bcastWindow = new Window(title);
    bcastWindow.setModal(true);

    VerticalLayout layout = new VerticalLayout();
    layout.setMargin(true);
    layout.setSpacing(true);
    layout.setWidth("99%");
    bcastWindow.setContent(layout);
    layout.addComponent(new Label("Compose message (255 char limit):"));
    final TextArea ta = new TextArea();
    ta.setRows(5);
    ta.setWidth("99%");
    layout.addComponent(ta);

    HorizontalLayout buttHl = new HorizontalLayout();
    final Button bcancelButt = new Button("Cancel");
    buttHl.addComponent(bcancelButt);
    Button bokButt = new Button(buttName);
    bokButt.setClickShortcut(ShortcutAction.KeyCode.ENTER, null);
    buttHl.addComponent(bokButt);
    layout.addComponent(buttHl);
    layout.setComponentAlignment(buttHl, Alignment.TOP_RIGHT);

    if (doWarning)
        layout.addComponent(new Label("Use with great deliberation!"));

    bcastWindow.setWidth("320px");
    UI.getCurrent().addWindow(bcastWindow);
    bcastWindow.setPositionX(0);
    bcastWindow.setPositionY(0);

    ta.focus();

    @SuppressWarnings("serial")
    ClickListener lis = new ClickListener() {
        @Override
        @MmowgliCodeEntry
        @HibernateOpened
        @HibernateClosed
        public void buttonClick(ClickEvent event) {
            if (event.getButton() == bcancelButt)
                ; // nothin
            else {
                // This check is now done in GameEvent.java, but should ideally prompt the user.
                String msg = ta.getValue().toString().trim();
                if (msg.length() > 0) {
                    HSess.init();
                    if (msg.length() > 255) // clamp to 255 to avoid db exception
                        msg = msg.substring(0, 254);
                    User u = Mmowgli2UI.getGlobals().getUserTL();
                    if (typ == GameEvent.EventType.GAMEMASTERNOTE)
                        GameEventLogger.logGameMasterCommentTL(msg, u);
                    else
                        GameEventLogger.logGameMasterBroadcastTL(typ, msg, u);
                    HSess.close();
                }
            }

            bcastWindow.close();
        }
    };
    bcancelButt.addClickListener(lis);
    bokButt.addClickListener(lis);
}

From source file:edu.nps.moves.mmowgli.AbstractMmowgliControllerHelper.java

License:Open Source License

public void handleShowNumberCardsActionTL(MenuBar mbar) {
    Session session = HSess.get();/* w ww. ja v  a 2s . co  m*/
    Criteria criteria = session.createCriteria(Card.class);
    criteria.setProjection(Projections.rowCount());
    int count = ((Long) criteria.list().get(0)).intValue();

    // Create the window...
    Window countWin = new Window("Display Card Count");
    countWin.setModal(true);

    VerticalLayout layout = new VerticalLayout();
    layout.setMargin(true);
    layout.setSpacing(true);
    layout.setWidth("99%");
    countWin.setContent(layout);
    HorizontalLayout hl = new HorizontalLayout();
    hl.setSpacing(true);
    Label lab;
    hl.addComponent(lab = new HtmlLabel("Number of cards played:"));
    hl.addComponent(lab = new Label());
    lab.setWidth("15px");

    Label countTf = new HtmlLabel();
    countTf.setWidth("50px");
    countTf.setValue("&nbsp;" + count);
    countTf.addStyleName("m-greyborder");
    hl.addComponent(countTf);
    hl.setComponentAlignment(countTf, Alignment.MIDDLE_LEFT);
    layout.addComponent(hl);

    countWin.setWidth("255px");
    UI.getCurrent().addWindow(countWin);
    countWin.center();
}

From source file:edu.nps.moves.mmowgli.AbstractMmowgliControllerHelper.java

License:Open Source License

public void handleShowTotalRegisteredTL(MenuBar mbar) {
    Criteria criteria = HSess.get().createCriteria(User.class);
    criteria.setProjection(Projections.rowCount());
    criteria.add(Restrictions.eq("accountDisabled", false));
    int count = ((Long) criteria.list().get(0)).intValue();

    criteria.add(Restrictions.eq("gameMaster", true));
    int gmCount = ((Long) criteria.list().get(0)).intValue();

    Criteria adminCrit = HSess.get().createCriteria(User.class);
    adminCrit.setProjection(Projections.rowCount());
    adminCrit.add(Restrictions.eq("accountDisabled", false));
    adminCrit.add(Restrictions.eq("administrator", true));
    int adminCount = ((Long) adminCrit.list().get(0)).intValue();

    // Create the window...
    Window countWin = new Window("Display Registered User Counts");
    countWin.setModal(true);// ww  w. j  a  va  2s . co m

    VerticalLayout layout = new VerticalLayout();
    layout.setMargin(true);
    layout.setSpacing(true);
    layout.setWidth("99%");
    countWin.setContent(layout);
    layout.addComponent(makeHL("Number of registered players:", count));
    layout.addComponent(makeHL("Number of registered game masters:", gmCount));
    layout.addComponent(makeHL("Number of registered game administrators:", adminCount));
    layout.addComponent(makeHL("Total, excluding disabled accounts:", count + gmCount + adminCount));

    countWin.setWidth("415px");
    UI.getCurrent().addWindow(countWin);
    countWin.center();
}

From source file:edu.nps.moves.mmowgli.AbstractMmowgliControllerHelper.java

License:Open Source License

public void handleLoginLimitActionTL() {
    // Create the window...
    final Window loginWin = new Window("Change Session Login Limit");
    loginWin.setModal(true);// ww w .j  av a2  s  .c  om

    VerticalLayout layout = new VerticalLayout();
    loginWin.setContent(layout);
    layout.setMargin(true);
    layout.setSpacing(true);
    layout.setWidth("99%");
    HorizontalLayout hl = new HorizontalLayout();
    hl.setSpacing(true);
    hl.addComponent(new Label("Max users to be logged in"));
    final TextField utf = new TextField();
    utf.setColumns(10);

    final int oldVal = Game.getTL().getMaxUsersOnline();
    utf.setValue("" + oldVal);
    hl.addComponent(utf);

    layout.addComponent(hl);

    HorizontalLayout buttHl = new HorizontalLayout();
    // LLListener llis = new LLListener(loginWin);
    final Button cancelButt = new Button("Cancel");
    buttHl.addComponent(cancelButt);
    final Button okButt = new Button("Save");
    buttHl.addComponent(okButt);
    layout.addComponent(buttHl);
    layout.setComponentAlignment(buttHl, Alignment.TOP_RIGHT);

    layout.addComponent(new Label("Use with great deliberation!"));

    loginWin.setWidth("320px");
    UI.getCurrent().addWindow(loginWin);
    loginWin.center();

    @SuppressWarnings("serial")
    ClickListener llis = new ClickListener() {
        @Override
        public void buttonClick(ClickEvent event) {
            if (event.getButton() == cancelButt) {
            } else if (event.getButton() == okButt) {
                HSess.init();
                try {
                    int i = Integer.parseInt(utf.getValue().toString());
                    Game g = Game.getTL();
                    g.setMaxUsersOnline(i);
                    Game.updateTL();
                    GameEventLogger.logLoginLimitChangeTL(oldVal, i);
                } catch (Throwable t) {
                    Notification.show("Error", "Invalid integer", Notification.Type.ERROR_MESSAGE);
                    HSess.close();
                    return;
                }
                HSess.close();
            }
            loginWin.close();
        }
    };
    cancelButt.addClickListener(llis);
    okButt.addClickListener(llis);
}

From source file:edu.nps.moves.mmowgli.AbstractMmowgliControllerHelper.java

License:Open Source License

public void handleDumpEmailsTL() {
    final TextField tf;

    final Window dialog = new Window("Filter Player Email Dump");
    dialog.setModal(true);/*  w w w.j a  v a 2  s .c  om*/

    VerticalLayout layout = new VerticalLayout();
    dialog.setContent(layout);
    layout.setMargin(true);
    layout.setSpacing(true);

    final OptionGroup radios = new OptionGroup(null, Arrays.asList(opts));
    layout.addComponent(radios);

    layout.addComponent(tf = new MTextField().withWidth("50%"));
    tf.setCaption("value");

    Label lab;

    layout.addComponent(lab = new Label());
    lab.setHeight("10px");

    radios.setNullSelectionAllowed(false); // user can not 'unselect'
    radios.select(allp); // select this by default
    radios.setImmediate(false); // don't send the change to the server at once
    radios.setMultiSelect(false);

    HorizontalLayout hl = new HorizontalLayout();
    hl.setSpacing(true);
    @SuppressWarnings("serial")
    Button cancelButt = new Button("Cancel", new Button.ClickListener() {
        public void buttonClick(ClickEvent event) {
            dialog.close();
        }
    });

    @SuppressWarnings("serial")
    Button addButt = new Button("Dump", new Button.ClickListener() {
        public void buttonClick(ClickEvent event) {
            Float val = null;
            String valS = "";
            boolean parseError = false;
            try {
                val = Float.parseFloat(tf.getValue());
                valS = formatter.valueToString(val);
            } catch (Exception ex) {
                parseError = true;
            }

            HSess.init();
            Object sel = radios.getValue();
            Criteria crit = null;
            String windowTitle = "";
            boolean isExpl = true;
            if (sel == allp) {
                crit = HSess.get().createCriteria(User.class);
                windowTitle = new String("All users");
                isExpl = true;
                if (parseError) {
                    Notification.show("Value ignored", Notification.Type.WARNING_MESSAGE);
                    System.out.println("Tried to show a Notification");
                }
            } else if (sel == grex) {
                crit = getExplorationGreaterThanTL(val);
                windowTitle = "Users with exploration points greater than " + valS;
                isExpl = true;
            } else if (sel == lsex) {
                crit = getExplorationLessThanTL(val);
                windowTitle = "Users with exploration points less than " + valS;
                isExpl = true;
            } else if (sel == grim) {
                crit = getImplementationGreaterThanTL(val);
                windowTitle = "Users with implementation points greater than " + valS;
                isExpl = false;
            } else if (sel == lsim) {
                crit = getImplementationLessThanTL(val);
                windowTitle = "Users with implementation points less than " + valS;
                isExpl = false;
            }

            if (crit != null) {
                @SuppressWarnings("unchecked")
                List<User> lis = (List<User>) crit.list();
                StringBuilder sb = new StringBuilder();
                handleEmailListNoHeader(lis, sb, isExpl);

                String title = windowTitle + " - " + UUID.randomUUID();
                BrowserWindowOpener.openWithInnerHTML(sb.toString(), title, "_blank");
            } else {
                Notification.show("Invalid value", Notification.Type.ERROR_MESSAGE);
                HSess.close();
                return;
            }

            dialog.close();
            HSess.close();
        }
    });

    hl.addComponent(cancelButt);
    hl.addComponent(addButt);
    hl.setComponentAlignment(cancelButt, Alignment.MIDDLE_RIGHT);
    hl.setExpandRatio(cancelButt, 1.0f);

    layout.addComponent(hl);

    hl.setWidth("100%");

    layout.addComponent(lab = new Label());
    layout.setExpandRatio(lab, 1.0f);

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

From source file:edu.nps.moves.mmowgli.components.AvatarChooser.java

License:Open Source License

@SuppressWarnings("serial")
@Override//from w w w  .j  a  v  a 2 s  .c o  m
public void initGui() {
    VerticalLayout mainLayout = new VerticalLayout();
    mainLayout.setSizeFull();
    mainLayout.setMargin(true); //test
    mainLayout.setSpacing(true);
    MediaLocator medLoc = Mmowgli2UI.getGlobals().getMediaLocator();
    Label sp;
    setContent(mainLayout);

    Panel p = new Panel(imgLay = new HorizontalLayout());
    imgLay.setSpacing(true);

    p.setWidth("100%");
    mainLayout.addComponent(p);

    Collection<?> lis = Avatar.getContainer().getItemIds();
    avIdArr = new Object[lis.size()];

    int idx = 0;

    for (Object id : lis) {
        avIdArr[idx++] = id;
        if (initSelectedID == null)
            initSelectedID = id; // sets first one
        Avatar a = Avatar.getTL(id);
        Image em = new Image(null, medLoc.locate(a.getMedia()));
        em.setWidth("95px");
        em.setHeight("95px");
        em.addClickListener(new ImageClicked());

        if (id.equals(initSelectedID)) {
            em.addStyleName("m-orangeborder5");
            lastSel = em;
        } else
            em.addStyleName("m-greyborder5");
        imgLay.addComponent(em);
    }

    butts = new HorizontalLayout();
    butts.setWidth("100%");
    butts.setSpacing(true);
    mainLayout.addComponent(butts);

    butts.addComponent(sp = new Label());
    sp.setWidth("1px");
    butts.setExpandRatio(sp, 1.0f);

    NativeButton cancelButt = new NativeButton();
    medLoc.decorateCancelButton(cancelButt);
    butts.addComponent(cancelButt);

    NativeButton selectButt = new NativeButton();
    medLoc.decorateSelectButton(selectButt);
    butts.addComponent(selectButt);

    butts.addComponent(sp = new Label(""));
    sp.setWidth("20px");

    mainLayout.addComponent(sp = new Label(""));
    sp.setHeight("1px");
    mainLayout.setExpandRatio(sp, 1.0f);
    ;

    cancelButt.addClickListener(new ClickListener() {
        @Override
        @MmowgliCodeEntry
        public void buttonClick(ClickEvent event) {
            cancelClick();
        }
    });
    selectButt.addClickListener(new ClickListener() {
        @Override
        @MmowgliCodeEntry
        public void buttonClick(ClickEvent event) {
            selectClick();
        }
    });
}

From source file:edu.nps.moves.mmowgli.components.MmowgliDialogContent.java

License:Open Source License

private void doHeaderWrapper() {
    Label sp;// w  w  w.  ja  v  a2  s  .c o  m
    VerticalLayout titleWrapper = new VerticalLayout();
    titleWrapper.setSpacing(false);
    titleWrapper.setMargin(false);
    titleWrapper.setHeight("75px");
    titleWrapper.setWidth("100%");//("460px"); //"504px"); //"592px");
    headerWrapper.addComponent(titleWrapper);
    headerWrapper.setExpandRatio(titleWrapper, 1.0f);
    //    titleWrapper.addComponent(sp=new Label());
    //    sp.setHeight("25px");

    header = new HorizontalLayout(); // Where the title gets written
    header.setSpacing(false);
    header.setMargin(false);
    header.setHeight("55px");
    header.setWidth("100%");
    header.addStyleName("m-transparent");
    titleWrapper.addComponent(header);
    titleWrapper.setComponentAlignment(header, Alignment.MIDDLE_CENTER);
    headerWrapper.addComponent(sp = new Label());
    sp.setWidth("25px"); //"50px");

    cancelButt = makeCancelButton();
    cancelButt.setClickShortcut(KeyCode.ESCAPE);

    headerWrapper.addComponent(cancelButt);//, "top:9px;left:504px");
    headerWrapper.setComponentAlignment(cancelButt, Alignment.MIDDLE_CENTER);
}

From source file:edu.nps.moves.mmowgli.components.SendMessageWindow.java

License:Open Source License

@HibernateSessionThreadLocalConstructor
public SendMessageWindow(List<String> emails) {
    super("A message to mmowgli followers");

    this.emails = emails;

    setModal(true);/* www . j a  v a 2s .  co m*/
    VerticalLayout layout = new VerticalLayout();
    setContent(layout);
    layout.setMargin(true);
    layout.setSpacing(true);
    layout.setWidth("100%");
    layout.setHeight("100%");

    Label lab = new Label(makeString(emails));
    lab.setCaption("To: (other addresses hidden from each recipient)");
    lab.setDescription(lab.getValue().toString());
    lab.addStyleName("m-nowrap");
    //   lab.setHeight("100%"); // makes label clip
    lab.addStyleName("m-greyborder");
    layout.addComponent(lab);

    subjTf = new TextField();
    subjTf.setCaption("Subject:");
    subjTf.setWidth("100%");

    Game game = Game.getTL();
    String acronym = game.getAcronym();
    acronym = acronym == null ? "" : acronym + " ";
    subjTf.setValue("Message from " + acronym + "Mmowgli");
    layout.addComponent(subjTf);

    ta = new TextArea();
    ta.setCaption("Content: (may include HTML tags)");
    ta.setRows(10);
    ta.setColumns(50);
    ta.setWidth("100%");
    ta.setHeight("100%");
    ta.setInputPrompt("Type message here");
    layout.addComponent(ta);
    layout.setExpandRatio(ta, 1.0f);
    HorizontalLayout buttHL = new HorizontalLayout();
    buttHL.setSpacing(true);

    ClickListener closeListener = new SignupsWindowCloser(this);
    cancelButt = new Button("Cancel", closeListener);
    buttHL.addComponent(cancelButt);

    sendButt = new Button("Send", closeListener);
    sendButt.addClickListener(closeListener);
    buttHL.addComponent(sendButt);

    layout.addComponent(buttHL);
    layout.setComponentAlignment(buttHL, Alignment.MIDDLE_RIGHT);
    setWidth("650px");
    setHeight("500px");
    UI.getCurrent().addWindow(this);
    ta.focus();
}