Example usage for com.vaadin.ui GridLayout GridLayout

List of usage examples for com.vaadin.ui GridLayout GridLayout

Introduction

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

Prototype

public GridLayout() 

Source Link

Document

Constructs an empty (1x1) grid layout that is extended as needed.

Usage

From source file:de.metas.ui.web.vaadin.window.editor.FieldEditorsContainer.java

License:Open Source License

@Override
protected Component createPanelContent() {
    return new GridLayout();
}

From source file:edu.nps.moves.mmowgli.export.BaseExporter.java

License:Open Source License

protected void getMetaStringOrCancel(final MetaListener lis, String title, final Map<String, String> params) {
    final Window dialog = new Window(title);
    final TextField[] parameterFields;

    dialog.setModal(true);//from w  w w. j  a v  a2  s. c  o m

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

    final TextArea ta = new TextArea();
    ta.setWidth("100%");
    ta.setInputPrompt("Type a description of this data, or the game which generated this data (optional)");

    ta.setImmediate(true);
    layout.addComponent(ta);

    Set<String> keySet = params.keySet();
    parameterFields = new TextField[keySet.size()];
    int i = 0;
    GridLayout pGL = new GridLayout();
    pGL.addStyleName("m-greyborder");
    pGL.setColumns(2);
    Label hdr = new HtmlLabel("<b>Parameters</b>");
    hdr.addStyleName("m-textaligncenter");
    pGL.addComponent(hdr, 0, 0, 1, 0); // top row
    pGL.setComponentAlignment(hdr, Alignment.MIDDLE_CENTER);
    pGL.setSpacing(false);
    for (String key : keySet) {
        pGL.addComponent(new HtmlLabel("&nbsp;" + key + "&nbsp;&nbsp;"));
        pGL.addComponent(parameterFields[i] = new TextField());
        parameterFields[i++].setValue(params.get(key));
    }
    if (i > 0) {
        layout.addComponent(pGL);
        layout.setComponentAlignment(pGL, Alignment.TOP_CENTER);
    }

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

    @SuppressWarnings("serial")
    Button exportButt = new Button("Export", new Button.ClickListener() {
        public void buttonClick(ClickEvent event) {
            dialog.close();

            Set<String> keySet = params.keySet();
            int i = 0;
            for (String key : keySet)
                params.put(key, parameterFields[i++].getValue().toString());

            lis.continueOrCancel(ta.getValue().toString());
        }
    });
    hl.addComponent(cancelButt);
    hl.addComponent(exportButt);
    hl.setComponentAlignment(cancelButt, Alignment.MIDDLE_RIGHT);
    hl.setExpandRatio(cancelButt, 1.0f);

    // The components added to the window are actually added to the window's
    // layout; you can use either. Alignments are set using the layout
    layout.addComponent(hl);
    dialog.setWidth("385px");
    dialog.setHeight("310px");
    hl.setWidth("100%");
    ta.setWidth("100%");
    ta.setHeight("100%");
    layout.setExpandRatio(ta, 1.0f);

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

From source file:edu.nps.moves.mmowgli.modules.actionplans.ActionPlanPageTabImages.java

License:Open Source License

@Override
public void initGui() {
    setSizeUndefined();/*from  w  ww . j av a 2s. c o  m*/
    VerticalLayout leftLay = getLeftLayout();
    leftLay.setSpacing(false);
    leftLay.setMargin(false);

    VerticalLayout flowLay = new VerticalLayout();
    flowLay.setWidth("100%");
    leftLay.addComponent(flowLay);
    flowLay.setSpacing(true);

    Label missionLab = new Label("Authors, add some images!");
    flowLay.addComponent(missionLab);
    flowLay.setComponentAlignment(missionLab, Alignment.TOP_LEFT);
    missionLab.addStyleName("m-actionplan-mission-title-text");

    ActionPlan ap = ActionPlan.getTL(apId);

    Label missionContentLab;
    if (!isMockup)
        missionContentLab = new HtmlLabel(ap.getImagesInstructions());
    else {
        Game g = Game.getTL();
        missionContentLab = new HtmlLabel(g.getDefaultActionPlanImagesText());
    }
    flowLay.addComponent(missionContentLab);
    flowLay.setComponentAlignment(missionContentLab, Alignment.TOP_LEFT);
    flowLay.addStyleName("m-actionplan-mission-content-text");

    MmowgliSessionGlobals globs = Mmowgli2UI.getGlobals();
    flowLay.addComponent(addImageButt);
    addImageButt.addStyleName("m-actionplan-addimage-butt");
    addImageButt.addStyleName("borderless");
    addImageButt.setIcon(globs.getMediaLocator().getActionPlanAddImageButt());
    addImageButt.addClickListener(new ImageAdder());
    addImageButt.setEnabled(!isReadOnly);

    flowLay.addComponent(nonAuthorLabel = new Label("Authors may add images when editing the plan."));
    nonAuthorLabel.setVisible(false);

    VerticalLayout rightLay = getRightLayout();
    rightLay.setSpacing(false);
    rightLay.setMargin(false);

    imageScroller = new Panel();
    GridLayout gridL = new GridLayout();
    gridL.setColumns(2);
    gridL.setSpacing(true);
    gridL.setMargin(new MarginInfo(true));
    imageScroller.setContent(gridL);
    imageScroller.setStyleName(Reindeer.PANEL_LIGHT); // make a transparent scroller
    imageScroller.setWidth("100%");
    imageScroller.setHeight("99%");
    setUpIndexListener(imageScroller);

    rightLay.addComponent(imageScroller);
    fillWithImagesTL();
}

From source file:edu.nps.moves.mmowgli.modules.actionplans.ActionPlanPageTabMap.java

License:Open Source License

Component buildMapFlags(VerticalLayout vl) {
    flagGrid = new GridLayout();
    vl.addComponent(flagGrid);/*from  w ww.ja  va2s  .  c  om*/
    flagGrid.setSizeUndefined();
    flagGrid.addStyleName("m-greyborder");
    flagGrid.setColumns(6);

    for (Object[] row : flagData) {
        int num = (Integer) row[0];
        String url = (String) row[1];
        if (num == -1)
            flagGrid.addComponent(MapFlag.getMapFlag(1, null, url));
        else {
            if (url.indexOf(NUMBERTAG) != -1)
                flagGrid.addComponent(MapFlag.getMapFlag(num, null, url, false));

            else if (url.indexOf(ALPHATAG) != -1)
                flagGrid.addComponent(MapFlag.getMapFlag(num, null, url, true));
        }
    }
    return flagGrid;
}

From source file:edu.nps.moves.mmowgli.modules.actionplans.ActionPlanPageTabVideos.java

License:Open Source License

@Override
public void initGui() {
    setSizeUndefined();//  w  w w  .  j  a  v a2s.c  om
    VerticalLayout leftLay = getLeftLayout();
    leftLay.setSpacing(false);
    leftLay.setMargin(false);

    VerticalLayout flowLay = new VerticalLayout();
    flowLay.setWidth("100%");
    leftLay.addComponent(flowLay);
    flowLay.setSpacing(true);

    Label missionLab = new Label("Authors, add some videos!");
    flowLay.addComponent(missionLab);
    flowLay.setComponentAlignment(missionLab, Alignment.TOP_LEFT);
    missionLab.addStyleName("m-actionplan-mission-title-text");

    ActionPlan ap = ActionPlan.getTL(apId);

    Label missionContentLab;
    if (!isMockup)
        missionContentLab = new HtmlLabel(ap.getVideosInstructions());
    else {
        Game g = Game.getTL();
        missionContentLab = new HtmlLabel(g.getDefaultActionPlanVideosText());
    }
    flowLay.addComponent(missionContentLab);
    flowLay.setComponentAlignment(missionContentLab, Alignment.TOP_LEFT);
    flowLay.addStyleName("m-actionplan-mission-content-text");

    MmowgliSessionGlobals globs = Mmowgli2UI.getGlobals();
    flowLay.addComponent(addVideoButt);
    addVideoButt.addStyleName("m-actionplan-addimage-butt");
    addVideoButt.addStyleName("borderless");
    addVideoButt.setIcon(globs.getMediaLocator().getActionPlanAddVideoButt());
    addVideoButt.addClickListener(new VideoAdder());
    addVideoButt.setEnabled(!isReadOnly);

    flowLay.addComponent(nonAuthorLabel = new Label("Authors may add videos when editing the plan."));
    nonAuthorLabel.setVisible(false);

    VerticalLayout rightLay = getRightLayout();
    rightLay.setSpacing(false);
    rightLay.setMargin(false);

    rightScroller = new Panel();
    GridLayout gridL = new GridLayout();
    gridL.setColumns(2);
    gridL.setSpacing(true);
    gridL.setMargin(new MarginInfo(true));
    rightScroller.setContent(gridL);
    rightScroller.setStyleName(Reindeer.PANEL_LIGHT); // make a transparent scroller
    rightScroller.setWidth("100%");
    rightScroller.setHeight("99%");
    setUpIndexListener(rightScroller);

    rightLay.addComponent(rightScroller);
    ;
    fillWithVideosTL();
}

From source file:edu.nps.moves.mmowgli.modules.administration.AbstractGameBuilderPanel.java

License:Open Source License

@HibernateSessionThreadLocalConstructor
public AbstractGameBuilderPanel(boolean showTestButton, boolean autoSave, GameDesignGlobals globs) {
    this.showTestButton = showTestButton;
    this.autoSave = autoSave;
    this.globals = globs;

    lines = new ArrayList<EditLine>();
    setSizeFull();/*from  ww w. j  a va 2  s.c  o  m*/
    setMargin(true);
    setSpacing(true);
    grid = new GridLayout();
    grid.setMargin(true);
    grid.setSpacing(true);
    grid.addStyleName("m-greyborder3");
    grid.addStyleName("m-greybackground");

    runningMove = Game.getTL().getCurrentMove();
}

From source file:edu.nps.moves.mmowgli.modules.administration.NewMovePhaseDialog.java

License:Open Source License

@SuppressWarnings("serial")
public NewMovePhaseDialog(Move move) {
    super("Make a new Phase for " + move.getName());
    this.moveBeingEdited = Move.getTL(move.getId());
    setSizeUndefined();//from  ww  w .  j a  v  a2  s . c  o  m
    setWidth("390px");
    VerticalLayout vLay;
    setContent(vLay = new VerticalLayout());
    vLay.setSpacing(true);
    vLay.setMargin(true);
    vLay.addComponent(new Label("Choose a descriptive name for this phase.  Suggested names are shown in the "
            + "drop down list, but any text is permitted."));

    descriptionCB = new ComboBox("Phase description");
    vLay.addComponent(descriptionCB);
    fillCombo(descriptionCB);

    descriptionCB.setInputPrompt("Choose suggested description, or enter text");
    descriptionCB.setWidth("350px");

    descriptionCB.setImmediate(true);
    descriptionCB.setNullSelectionAllowed(false);
    descriptionCB.setTextInputAllowed(true);
    descriptionCB.addValueChangeListener(new ValueChangeListener() {
        @Override
        public void valueChange(final ValueChangeEvent event) {
            // final String valueString = String.valueOf(event.getProperty().getValue());
            // Notification.show("Value changed:", valueString,
            // Type.TRAY_NOTIFICATION);
        }
    });
    vLay.addComponent(existingPhasesGLay = new GridLayout());
    existingPhasesGLay.setColumns(3);
    existingPhasesGLay.setRows(1); // to start
    existingPhasesGLay.setSpacing(true);
    existingPhasesGLay.addStyleName("m-greyborder");
    existingPhasesGLay.setCaption("Existing Phases");
    fillExistingPhases();

    HorizontalLayout buttHLay;
    vLay.addComponent(buttHLay = new HorizontalLayout());
    buttHLay.setWidth("100%");
    buttHLay.setSpacing(true);
    Label lab;
    buttHLay.addComponent(lab = new Label());
    lab.setWidth("1px");
    buttHLay.setExpandRatio(lab, 1.0f);
    buttHLay.addComponent(cancelButt = new Button("Cancel", saveCancelListener));
    buttHLay.addComponent(saveButt = new Button("Save", saveCancelListener));
}

From source file:edu.nps.moves.mmowgli.modules.registrationlogin.RegistrationPageBase.java

License:Open Source License

@SuppressWarnings("serial")
private void wereInTL(User _usr) {
    Game g = Game.getTL();//from w w w .  j  a  va  2s  .c  o  m
    if (!g.isEmailConfirmation()/* && !g.isSMSConfirmation()*/) {
        _usr.setEmailConfirmed(true); // confirmation didn't happen, but they want to login
        wereInReallyTL(_usr); // will do update
    }
    /*  else if(g.isSMSConfirmation()) {  // if both are selected, only sms is done
                
      } */
    else {
        List<String> sLis = VHibPii.getUserPiiEmails(_usr.getId());
        String email = sLis.get(0);
        final Window emailDialog = new Window("Email Confirmation");
        emailDialog.setModal(true);
        emailDialog.setClosable(false);
        VerticalLayout vLay = new VerticalLayout();
        emailDialog.setContent(vLay);
        vLay.setMargin(true);
        vLay.setSpacing(true);
        vLay.setSizeUndefined();
        vLay.setWidth("400px");

        Label message = new HtmlLabel("A confirmation email has been sent to <b>" + email + "</b>.");
        vLay.addComponent(message);

        message = new Label("Follow the link in the message "
                + "to confirm your registration and unlock your mmowgli user account.");
        vLay.addComponent(message);

        message = new HtmlLabel("Press the <b>Am I confirmed yet?</b> button " + "to play if ready.");
        vLay.addComponent(message);

        message = new HtmlLabel(
                "Alternatively, press <b>Quit -- I'll come back later</b> to login at a future time.");
        vLay.addComponent(message);

        GridLayout grid = new GridLayout();
        vLay.addComponent(grid);

        MSysOut.println(NEWUSER_CREATION_LOGS,
                "email confirmation dialog displayed, user " + _usr.getUserName());

        final Button contButt = new Button("Am I confirmed yet?", new ClickListener() {
            boolean confirmed = false;

            @Override
            @HibernateUpdate
            @HibernateUserUpdate
            public void buttonClick(ClickEvent event) {
                MSysOut.println(DEBUG_LOGS, "\"Am I confirmed?\" button handler entered");

                HSess.init();
                User u = User.getTL(userId);
                MSysOut.println(NEWUSER_CREATION_LOGS, "\"Am I confirmed?\" clicked, user " + u.getUserName());

                if (confirmed) {
                    closePopup(emailDialog);
                    wereInReallyTL(u); //  @HibernateUserUpdate //@HibernateUserRead
                    MSysOut.println(NEWUSER_CREATION_LOGS,
                            "\"Am I confirmed?\", positive confirmation, user " + u.getUserName());
                } else {
                    MSysOut.println(DEBUG_LOGS, "User.getTL() in RegistrationPageBase.wereInTL()");
                    //User locUsr = User.getTL(userId);  why necessary?
                    //if(locUsr.isEmailConfirmed()) {
                    if (u.isEmailConfirmed()) {
                        confirmed = true;
                        event.getButton().setCaption("I'm ready to play mmowgli!");
                    } else {
                        MSysOut.println(NEWUSER_CREATION_LOGS,
                                "\"Am I confirmed?\", negative confirmation, user " + u.getUserName());
                        Notification.show("Your email is not yet confirmed");
                    }
                }
                HSess.close();
            }
        });
        grid.addComponent(contButt);
        contButt.setImmediate(true);

        Button laterButt = new Button("Quit -- I'll come back later", new ClickListener() {
            @Override
            public void buttonClick(ClickEvent event) {
                MSysOut.println(DEBUG_LOGS, "\"Quit -- I'll come back later\" button handler entered");

                HSess.init();
                Mmowgli2UI.getAppUI().quitAndGoTo(GameLinks.getTL().getThanksForInterestLink());
                HSess.close();
            }
        });
        grid.addComponent(laterButt);

        Button troubleButt = new Button("Send trouble report", new ClickListener() {
            @Override
            @MmowgliCodeEntry
            @HibernateOpened
            @HibernateClosed
            public void buttonClick(ClickEvent event) // no need for HSess
            {
                MSysOut.println(DEBUG_LOGS, "\"Send trouble report\" button handler entered");

                HSess.init();
                Mmowgli2UI.getAppUI().quitAndGoTo(GameLinks.getTL().getTroubleLink());
                HSess.close();
            }
        });
        grid.addComponent(troubleButt);

        openPopupWindowInMainWindow(emailDialog, 500);

        EmailConfirmation ec = new EmailConfirmation(_usr);
        EmailConfirmation.saveTL(ec);

        String confirmUrl = buildConfirmUrl(ec);
        AppMaster.instance().getMailManager().sendEmailConfirmationTL(email, _usr.getUserName(), confirmUrl);
    } // else weren't confirmed
}

From source file:edu.nps.moves.mmowgli.modules.userprofile.DefineAwardsDialog.java

License:Open Source License

@HibernateSessionThreadLocalConstructor
public DefineAwardsDialog() {
    setCaption("Define Player Award Types");
    setModal(true);//from   www. ja v a 2  s  . co m
    setSizeUndefined();
    setWidth("700px");
    setHeight("400px");

    VerticalLayout vLay = new VerticalLayout();
    vLay.setMargin(true);
    vLay.setSpacing(true);
    vLay.setSizeFull();
    setContent(vLay);

    vLay.addComponent(new HtmlLabel("<b>This dialog is not yet functional</b>"));

    Panel p = new Panel();
    p.setWidth("99%");
    p.setHeight("100%");
    vLay.addComponent(p);
    vLay.setExpandRatio(p, 1.0f);

    gridLayout = new GridLayout();
    gridLayout.addStyleName("m-headgrid");
    gridLayout.setWidth("100%");
    p.setContent(gridLayout);
    fillPanelTL();

    HorizontalLayout buttPan = new HorizontalLayout();
    buttPan.setWidth("100%");
    buttPan.setSpacing(true);
    NativeButton addButt = new NativeButton("Add new type", new AddListener());
    NativeButton delButt = new NativeButton("Delete type", new DelListener());
    NativeButton saveButt = new NativeButton("Save", new SaveListener());
    NativeButton cancelButt = new NativeButton("Cancel", new CancelListener());
    buttPan.addComponent(addButt);
    buttPan.addComponent(delButt);

    Label lab;
    buttPan.addComponent(lab = new Label());
    buttPan.setExpandRatio(lab, 1.0f);
    buttPan.addComponent(cancelButt);
    buttPan.addComponent(saveButt);
    vLay.addComponent(buttPan);

    //temp
    saveButt.setEnabled(false);
    delButt.setEnabled(false);
}

From source file:edu.nps.moves.mmowgli.modules.userprofile.ManageAwardsDialog.java

License:Open Source License

@HibernateSessionThreadLocalConstructor
public ManageAwardsDialog(Object uId) {
    this.uId = uId;
    User u = User.getTL(uId);//from w ww. j a  v a 2  s . co m

    setCaption("Manage Awards for " + u.getUserName());
    setModal(true);
    setSizeUndefined();
    setWidth("625px");
    setHeight("400px");

    VerticalLayout vLay = new VerticalLayout();
    vLay.setMargin(true);
    vLay.setSpacing(true);
    vLay.setSizeFull();
    setContent(vLay);

    Panel p = new Panel("Award Assignments -- a check applies the award to player " + u.getUserName());
    p.setWidth("99%");
    p.setHeight("99%");
    vLay.addComponent(p);
    vLay.setExpandRatio(p, 1.0f);

    gridLayout = new GridLayout();
    gridLayout.addStyleName("m-headgrid");
    gridLayout.setWidth("100%");
    p.setContent(gridLayout);
    fillPanelTL(u); //@HibernateUserRead

    HorizontalLayout buttPan = new HorizontalLayout();
    buttPan.setWidth("100%");
    buttPan.setSpacing(true);
    NativeButton defineButt = new NativeButton("Define Award Types", new DefineListener());
    NativeButton saveButt = new NativeButton("Save", new SaveListener());
    NativeButton cancelButt = new NativeButton("Cancel", new CancelListener());

    buttPan.addComponent(defineButt);
    Label lab;
    buttPan.addComponent(lab = new Label());
    buttPan.setExpandRatio(lab, 1.0f);
    buttPan.addComponent(cancelButt);
    buttPan.addComponent(saveButt);
    vLay.addComponent(buttPan);
}