Example usage for com.vaadin.ui HorizontalLayout setComponentAlignment

List of usage examples for com.vaadin.ui HorizontalLayout setComponentAlignment

Introduction

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

Prototype

@Override
    public void setComponentAlignment(Component childComponent, Alignment alignment) 

Source Link

Usage

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

License:Open Source License

public void handleShowNumberCardsActionTL(MenuBar mbar) {
    Session session = HSess.get();// w w w.j a v a2  s  .c  o  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(" " + 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

private Component makeHL(String s, int num) {
    HorizontalLayout hl = new HorizontalLayout();
    hl.setSpacing(true);//from  w  w  w  .ja  va  2s.c  om
    Label lab;
    hl.addComponent(lab = new HtmlLabel(s));
    hl.setExpandRatio(lab, 1.0f);
    Label countTf = new HtmlLabel();
    countTf.setWidth("50px");
    countTf.setValue(" " + num);
    countTf.addStyleName("m-greyborder");
    countTf.addStyleName("m-textalignright");
    hl.addComponent(countTf);
    hl.setComponentAlignment(countTf, Alignment.TOP_RIGHT);
    hl.setWidth("100%");
    return hl;
}

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 va 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.CardTable.java

License:Open Source License

@SuppressWarnings("unused")
private Component orig_buildGenAuthorColumn(Card card) {
    // IE7 can't handle fanciness:
    if (Mmowgli2UI.getGlobals().isIE7()) {
        return new Label(card.getAuthorName()); //.getAuthor().getUserName());
    }/* ww  w.  j  a v  a  2s .c o m*/

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

    User auth = card.getAuthor();

    if (auth.getAvatar() != null) {
        Embedded avatar = new Embedded(null,
                Mmowgli2UI.getGlobals().getMediaLocator().locate(auth.getAvatar().getMedia(), 32));
        avatar.setWidth("24px");
        avatar.setHeight("24px");
        hl.addComponent(avatar);
        hl.setComponentAlignment(avatar, Alignment.MIDDLE_LEFT);
        avatar.addStyleName("m-cursor-pointer");
    }
    IDButton uButt = new IDButton(auth.getUserName(), SHOWUSERPROFILECLICK, auth.getId());
    uButt.addStyleName(BaseTheme.BUTTON_LINK);
    uButt.setWidth(8.0f, Unit.EM);

    hl.addComponent(uButt);
    hl.setComponentAlignment(uButt, Alignment.MIDDLE_LEFT);

    return hl;
}

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

License:Open Source License

@Override
public void initGui() {
    setWidth(FOOTER_W);// w  w  w. j a va 2s  .  c o  m
    setHeight("130px"); //room for fouo butt//FOOTER_H);
    AbsoluteLayout mainAbsLay = new AbsoluteLayout(); // offset it from master

    mainAbsLay.setWidth(FOOTER_W);
    mainAbsLay.setHeight(FOOTER_H);
    addComponent(mainAbsLay, FOOTER_OFFSET_POS);

    MediaLocator medLoc = ((Mmowgli2UI) UI.getCurrent()).getMediaLocator();
    Embedded back = new Embedded(null, medLoc.getFooterBackground());
    mainAbsLay.addComponent(back, "top:0px;left:0px");

    HorizontalLayout outerHorLay = new HorizontalLayout();
    addComponent(outerHorLay, "top:45px;left:0px");
    outerHorLay.setWidth(FOOTER_W);
    HorizontalLayout innerHorLay = new HorizontalLayout();
    innerHorLay.setSpacing(true);
    outerHorLay.addComponent(innerHorLay);
    outerHorLay.setComponentAlignment(innerHorLay, Alignment.MIDDLE_CENTER);

    Label sp;
    innerHorLay.addComponent(aboutButt);
    innerHorLay.addComponent(pingPushLab = new HtmlLabel());
    pingPushLab.setWidth("7px");
    innerHorLay.addComponent(creditsButt);
    innerHorLay.addComponent(sp = new Label());
    sp.setWidth("7px");
    innerHorLay.addComponent(faqsButt);
    innerHorLay.addComponent(sp = new Label());
    sp.setWidth("7px");
    innerHorLay.addComponent(fixesButt);
    innerHorLay.addComponent(sp = new Label());
    sp.setWidth("7px");
    innerHorLay.addComponent(glossaryButt);
    innerHorLay.addComponent(sp = new Label());
    sp.setWidth("7px");
    innerHorLay.addComponent(reportsButt);
    innerHorLay.addComponent(sp = new Label());
    sp.setWidth("7px");
    innerHorLay.addComponent(termsButt);
    innerHorLay.addComponent(sp = new Label());
    sp.setWidth("7px");
    innerHorLay.addComponent(troubleButt);
    troubleButt.addStyleName("m-red-text");
    innerHorLay.addComponent(sp = new Label());
    sp.setWidth("7px");
    innerHorLay.addComponent(twitterButt);
    innerHorLay.addComponent(sp = new Label());
    sp.setWidth("7px");
    innerHorLay.addComponent(videosButt);

    GameLinks gl = GameLinks.getTL();
    if (gl.getFixesLink().toLowerCase().contains("armyscitech")
            || gl.getGlossaryLink().toLowerCase().contains("armyscitech")) {
        ; // This is a hack, but I don't want to pollute the db with a bogus boolean...this is a special case just for these folks.
    } else {
        HorizontalLayout hl = new HorizontalLayout();
        Label lab = null;
        hl.addComponent(lab = new HtmlLabel("Build " + MMOWGLI_BUILD_ID));
        lab.addStyleName("m-footer-servername"); //small text
        lab.setDescription(Mmowgli2UI.getGlobals().getVaadinSessionCookie());
        hl.addComponent(lab = new HtmlLabel("&nbsp;&nbsp;Vaadin " + VAADIN_BUILD_VERSION));
        lab.addStyleName("m-footer-servername"); //small text
        hl.addComponent(lab = new HtmlLabel("&nbsp;&nbsp;" + AppMaster.instance().getServerName()));
        lab.addStyleName("m-footer-servername"); //small text
        hl.setSizeUndefined();
        mainAbsLay.addComponent(hl, "bottom:3px;right:15px;");
    }

    fouoLink = Footer.buildFouoNoticeTL();
    addComponent(fouoLink, "top:92px;left:365px");
    fouoLink.setVisible(Game.getTL().isShowFouo());
}

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

License:Open Source License

@SuppressWarnings("serial")
@Override/*from w  w  w. j  a  v  a  2s.c  o  m*/
public void initGui() {
    setWidth(HEADER_W);
    setHeight(HEADER_H);
    Game g = Game.getTL();
    GameLinks gl = GameLinks.getTL();

    Embedded embedded = new Embedded(null, mediaLoc.getHeaderBackground());
    addComponent(embedded, "top:0px;left:0px");

    if (g.isActionPlansEnabled()) {
        embedded = new Embedded(null, mediaLoc.getImage("scoretext200w50h.png"));
        addComponent(embedded, "top:52px;left:63px");
        addComponent(explorPtsLab, "top:55px;left:260px");
        addComponent(implPtsLab, "top:79px;left:247px");
    } else {
        embedded = new Embedded(null, mediaLoc.getImage("scoretextoneline200w50h.png"));
        addComponent(embedded, "top:52px;left:73px");
        addComponent(explorPtsLab, "top:65px;left:205px");
    }

    Resource res = mediaLoc.getHeaderBanner(g);
    if (res != null) {
        embedded = new Embedded(null, res);
        addComponent(embedded, pos_banner);
    }
    HorizontalLayout buttHL = new HorizontalLayout();
    buttHL.setSpacing(false);
    buttHL.setMargin(false);
    buttHL.setWidth("291px");
    buttHL.setHeight("45px");
    addComponent(buttHL, "top:1px;left:687px");

    Label lab;
    boolean armyHack = gl.getFixesLink().toLowerCase().contains("armyscitech")
            || gl.getGlossaryLink().toLowerCase().contains("armyscitech");
    if (armyHack)
        buttonChars = buttonChars - 3 + 9; // Replace "Map" with "Resources
    buttHL.addComponent(lab = new Label());
    lab.setWidth("1px");
    buttHL.setExpandRatio(lab, 0.5f);
    buttHL.addComponent(leaderBoardButt);
    buttHL.setComponentAlignment(leaderBoardButt, Alignment.MIDDLE_CENTER);
    addDivider(buttHL, buttonChars);

    // Hack
    if (armyHack) { //Hack
        Link resourceLink = makeSmallLink("Resources", "", "http://futures.armyscitech.com/resources/");
        buttHL.addComponent(resourceLink);
        buttHL.setComponentAlignment(resourceLink, Alignment.MIDDLE_CENTER);
    } else {
        buttHL.addComponent(mapButt);
        buttHL.setComponentAlignment(mapButt, Alignment.MIDDLE_CENTER);
    }
    addDivider(buttHL, buttonChars);
    buttHL.addComponent(liveBlogButt);
    buttHL.setComponentAlignment(liveBlogButt, Alignment.MIDDLE_CENTER);
    addDivider(buttHL, buttonChars);
    buttHL.addComponent(learnMoreButt);
    buttHL.setComponentAlignment(learnMoreButt, Alignment.MIDDLE_CENTER);

    buttHL.addComponent(lab = new Label());
    lab.setWidth("1px");
    buttHL.setExpandRatio(lab, 0.5f);

    addComponent(playIdeaButt, pos_playIdeaButt);

    if (g.isActionPlansEnabled()) {
        addComponent(takeActionButt, pos_takeActionButt);
        toggleTakeActionButt(true); // everbody can click it me.isGameMaster());
    } else if (armyHack) {
        embedded = new Embedded(null, mediaLoc.getImage("armylogoxpntbg80w80h.png"));
        addComponent(embedded, "top:54px;left:864px");
    }

    Serializable uid = Mmowgli2UI.getGlobals().getUserID();
    refreshUser(uid, HSess.get()); // assume in vaadin transaction here

    avatar.setWidth(HEADER_AVATAR_W);
    avatar.setHeight(HEADER_AVATAR_H);
    avatar.setDescription(user_profile_tt);
    avatar.addClickListener(new MouseEvents.ClickListener() {
        @Override
        public void click(com.vaadin.event.MouseEvents.ClickEvent event) {
            userNameButt.buttonClick(new ClickEvent(userNameButt));
        }
    });
    userNameButt.setDescription(user_profile_tt);
    addComponent(userNameButt, HEADER_USERNAME_POS);
    addComponent(avatar, "top:13px;left:6px"); //HEADER_AVATAR_POS);

    searchField.setWidth("240px");
    //  searchField.setHeight("18px");    // this causes a text _area_ to be used, giving me two lines, default height is good, style removes borders
    searchField.setInputPrompt("Search");
    searchField.setImmediate(true);
    searchField.setTextChangeEventMode(TextChangeEventMode.LAZY);
    searchField.setTextChangeTimeout(5000); // ms
    searchField.addStyleName("m-header-searchfield");
    searchField.addValueChangeListener(new Property.ValueChangeListener() {
        private static final long serialVersionUID = 1L;

        @Override
        @MmowgliCodeEntry
        @HibernateOpened
        @HibernateClosed
        public void valueChange(ValueChangeEvent event) {
            HSess.init();
            handleSearchClickTL();
            HSess.close();
            /*
            searchButt.focus();  // make the white go away
            String s = event.getProperty().getValue().toString();
            if (s.length() > 0) {
              MmowgliController controller = Mmowgli2UI.getGlobals().getController();
              controller.handleEvent(SEARCHCLICK, s, searchField);
            } */
        }
    });
    searchButt.enableAction(false); // want a local listener
    searchButt.addClickListener(new ClickListener() {
        @Override
        @MmowgliCodeEntry
        @HibernateOpened
        @HibernateClosed
        public void buttonClick(ClickEvent event) {
            HSess.init();
            handleSearchClickTL();
            HSess.close();
        }
    });
    addComponent(searchField, "top:107px;left:74px"); //"top:110px;left:74px");
    addComponent(signOutButt, "top:25px;left:250px"); //"top:18px;left:250px");
    addComponent(searchButt, "top:105px;left:30px"); //"top:100px;left:180px");

    MessageUrl mu = MessageUrl.getLastTL();
    if (mu != null)
        decorateBlogHeadlinesLink(mu);
    addBlogHeadlinesLink("top:147px;left:20px");

    String headline = blogHeadlinesLink.getCaption();
    if (headline != null && headline.length() > 0) {
        // Add Window.Notification relaying the same info as the BlogHeadLinesLink
        Notification note = new Notification("Today's News", "<br/>" + headline,
                Notification.Type.WARNING_MESSAGE, true);
        note.setPosition(Position.TOP_CENTER);
        note.setDelayMsec(5 * 1000);
        // Yellow is more an attention getter
        note.setStyleName("m-blue");
        note.show(Page.getCurrent());
    }

    addComponent(callToActionButt, "top:0px;left:333px");
    /* The css has a height, width and even a background, but stupid IE will only properly size the button if an image is
     * used.  Therefore we use an a transparent png of the proper size */
    MediaLocator medLoc = Mmowgli2UI.getGlobals().getMediaLocator();
    callToActionButt.setIcon(medLoc.getEmpty353w135h());

    Move move = g.getCurrentMove();
    if (g.isShowHeaderBranding()) {
        Media brand = g.getHeaderBranding();
        if (brand != null) {
            Embedded bremb = new Embedded(null, mediaLoc.locate(brand));
            addComponent(bremb, "top:0px;left:333px");
        } else {
            brandingLab.setHeight("30px");
            setBrandingLabelText(move, g);
            addComponent(brandingLab, "top:0px;left:333px"); //HEADER_MOVETITLE_POS);  //"top:151px;left:476px";      
        }
    }
    if (move.isShowMoveBranding()) {
        moveNumLab.setValue(move.getName());
        addComponent(moveNumLab, "top:103px;left:333px");
    }
    /*    if(user != null && (user.isAdministrator() || user.isGameMaster() || user.isDesigner() )) { // has a menu
          //  fouoLink.addStyleName("m-absolutePositioning");
            addComponent(fouoLink,"top:-10px;left:400px");
        }
        else
          addComponent(fouoLink,"top:0px;left:400px");
                
        fouoLink.setVisible(g.isShowFouo());
        */
}

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

License:Open Source License

public void initGuiTL() {
    setSizeUndefined();//from   w w w.j  av a 2  s  .  c o  m
    setWidth(APPLICATION_SCREEN_WIDTH);
    setSpacing(false);

    MmowgliSessionGlobals globs = Mmowgli2UI.getGlobals();
    Label sp;

    HorizontalLayout titleHL = new HorizontalLayout();
    addComponent(titleHL);
    titleHL.setMargin(new MarginInfo(false, true, false, true)); //sides only
    titleHL.setWidth("100%");

    Component c;
    titleHL.addComponent(c = globs.getMediaLocator().getLeaderboardTitle());
    titleHL.setComponentAlignment(c, Alignment.MIDDLE_LEFT);
    titleHL.setExpandRatio(c, .5f);

    maybeShowMoveSelector(titleHL);

    tips.setStyleName(BaseTheme.BUTTON_LINK);
    tips.addStyleName("m-link-button");
    titleHL.addComponent(tips);
    titleHL.setComponentAlignment(tips, Alignment.MIDDLE_RIGHT);
    titleHL.setExpandRatio(tips, 0.5f);

    tableVLayout = new VerticalLayout();
    tableVLayout.setSizeUndefined();
    tableVLayout.setWidth(APPLICATION_SCREEN_WIDTH);
    tableVLayout.setSpacing(true);
    tableVLayout.setMargin(true);
    tableVLayout.addStyleName("m-whitepage-header");

    addComponent(tableVLayout);

    tableVLayout.addComponent(sp = new Label());
    sp.setHeight("20px"); // to fit top of background

    tableVLayout.addComponent(table = createTableTL());
    tableVLayout.setComponentAlignment(table, Alignment.TOP_CENTER);
    table.setValue(globs.getUserID());
    tableVLayout.setExpandRatio(table, 1.0f);

    /* I can't get this to properly refresh, todo
    refreshButt = new Button("Refresh");
    mainVLayout.addComponent(refreshButt);
    mainVLayout.setComponentAlignment(refreshButt, Alignment.TOP_CENTER);
            
    refreshButt.addListener(new RefreshListener());
    refreshButt.setEnabled(false);
    */
}

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

License:Open Source License

private void maybeShowMoveSelector(HorizontalLayout hl) {
    Move m = Move.getCurrentMoveTL();// w w  w.j  a  v  a2  s.c  om
    int thisMove = m.getNumber();
    if (thisMove <= 1)
        return;

    Label lab = null;
    hl.addComponent(lab = new Label("Showing scores from "));
    lab.setSizeUndefined();
    hl.setComponentAlignment(lab, Alignment.MIDDLE_CENTER);
    hl.addComponent(lab = new Label());
    lab.setWidth("5px");

    ArrayList<String> mvLst = new ArrayList<String>();
    int i = 1;
    while (i <= thisMove) {
        mvLst.add("Round " + i++);
    }
    mvLst.add(COMBINED);

    NativeSelect sel = new NativeSelect(null, mvLst);

    sel.setNullSelectionAllowed(false);
    sel.setValue("Round " + thisMove);
    sel.setImmediate(true);
    sel.addValueChangeListener(new MoveListener());

    hl.addComponent(sel);
    hl.setComponentAlignment(sel, Alignment.MIDDLE_CENTER);
}

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

License:Open Source License

@Override
public void initGui() {
    outerLayout = new VerticalLayout();
    outerLayout.setSpacing(false);/*  ww w.  j  a  v a2 s .c  o m*/
    outerLayout.setSizeUndefined();
    outerLayout.addStyleName("m-transparent");
    setContent(outerLayout);

    Label sp;
    sp = new Label();
    sp.setHeight("100px");
    outerLayout.addComponent(sp);

    HorizontalLayout headerWrapper2 = new HorizontalLayout();
    outerLayout.addComponent(headerWrapper2); // at the top
    headerWrapper2.addStyleName("m-dialog-header");
    headerWrapper2.setHeight("75px");
    headerWrapper2.setWidth("592px");
    headerWrapper2.setSpacing(false);
    headerWrapper2.setMargin(false);
    headerWrapper2.addComponent(sp = new Label()); // indent from left
    sp.setWidth("45px");

    headerHL2 = new HorizontalLayout(); // Where the title gets written
    headerHL2.setSpacing(false);
    headerHL2.setMargin(false);
    headerHL2.setHeight("75px");
    headerWrapper2.addComponent(headerHL2);
    headerWrapper2.setExpandRatio(headerHL2, 1.0f);

    cancelButt = makeCancelButton();
    cancelButt.addClickListener(new MyCancelListener());
    cancelButt.setClickShortcut(KeyCode.ESCAPE);
    headerWrapper2.addComponent(cancelButt);
    headerWrapper2.setComponentAlignment(cancelButt, Alignment.MIDDLE_CENTER);

    headerWrapper2.addComponent(sp = new Label());
    sp.setWidth("15px");

    contentVLayout = new VerticalLayout();
    contentVLayout.addStyleName("m-dialog-content");
    contentVLayout.setSizeUndefined();
    contentVLayout.setWidth("592px"); // but do the width explicitly

    outerLayout.addComponent(contentVLayout);

    Image footer = new Image(null, Mmowgli2UI.getGlobals().mediaLocator().getDialogFooterBackground());
    footer.setWidth("592px");
    footer.setHeight("36px");
    outerLayout.addComponent(footer);
}

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 .ja  va2 s  .  c  om

    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);
}