List of usage examples for com.vaadin.ui HorizontalLayout setExpandRatio
public void setExpandRatio(Component component, float ratio)
This method is used to control how excess space in layout is distributed among components.
From source file:edu.nps.moves.mmowgli.modules.userprofile.EditAwardTypeDialog.java
License:Open Source License
@SuppressWarnings("serial") private EditAwardTypeDialog(AwardType awt, EditAwardResultListener lis) { Object sessKey = HSess.checkInit(); listener = lis;//from ww w .j a v a2s . c om awardType = awt; setCaption("Edit Award Type"); setModal(true); setWidth("450px"); VerticalLayout vLay = new VerticalLayout(); setContent(vLay); vLay.setMargin(true); vLay.setSpacing(true); vLay.addStyleName("m-greybackground"); FormLayout formLay; vLay.addComponent(formLay = new FormLayout()); formLay.setSizeFull(); formLay.addComponent( nameTF = new MTextField("Award Title").withFullWidth().withNullRepresentation("required field")); nameTF.setRequired(true); nameTF.setRequiredError("Required field"); nameTF.setSizeFull(); formLay.addComponent( descTF = new MTextField("Description").withFullWidth().withNullRepresentation("required field")); descTF.setRequired(true); descTF.setRequiredError("Required field"); Label sp; formLay.addComponent(hLay55 = new HorizontalLayout()); hLay55.setWidth("100%"); hLay55.setCaption("55x55 pixel icon"); hLay55.setSpacing(true); hLay55.addComponent(lab55 = new HtmlLabel("<i>image name</i>")); hLay55.setComponentAlignment(lab55, Alignment.MIDDLE_CENTER); hLay55.addComponent(butt55 = new NativeButton("Choose 55x55 image")); hLay55.setComponentAlignment(butt55, Alignment.MIDDLE_CENTER); hLay55.addComponent(sp = new Label()); hLay55.setExpandRatio(sp, 1.0f); hLay55.addComponent(image55 = new Image(null)); image55.setWidth("55px"); image55.setHeight("55px"); image55.addStyleName("m-greyborder3"); formLay.addComponent(hLay300 = new HorizontalLayout()); hLay300.setWidth("100%"); hLay300.setCaption("300x300 pixel icon"); hLay300.setSpacing(true); hLay300.addComponent(lab300 = new HtmlLabel("<i>image name</i>")); hLay300.setComponentAlignment(lab300, Alignment.MIDDLE_CENTER); hLay300.addComponent(butt300 = new NativeButton("Choose 300x300 image")); hLay300.setComponentAlignment(butt300, Alignment.MIDDLE_CENTER); hLay300.addComponent(sp = new Label()); hLay300.setExpandRatio(sp, 1.0f); hLay300.addComponent(image300 = new Image(null)); image300.setWidth("55px"); image300.setHeight("55px"); image300.addStyleName("m-greyborder3"); ClickListener chooseIconListener = new ClickListener() { boolean is55 = false; @Override public void buttonClick(ClickEvent event) { is55 = (event.getButton() == butt55); String txt = (is55 ? pix55text : pix300text); InstallImageResultListener lis = new InstallImageResultListener() { @Override public void doneTL(MediaImage mimg) { Media m = null; if (mimg != null) m = mimg.media; if (m != null) { MediaLocator mediaLoc = Mmowgli2UI.getGlobals().getMediaLocator(); String handle = m.getHandle(); if (handle != null && handle.trim().length() <= 0) handle = null; if (is55) { media55 = m; if (handle == null) { m.setHandle("55x55"); Media.updateTL(m); } lab55.setValue(m.getUrl()); image55.setSource(mediaLoc.locate(m)); } else { media300 = m; if (handle == null) { m.setHandle("300x300"); Media.updateTL(m); } lab300.setValue(m.getUrl()); image300.setSource(mediaLoc.locate(m)); } } } }; InstallImageDialog.show(txt, lis, is55 ? pix55filter : pix300filter); } }; butt55.addClickListener(chooseIconListener); butt300.addClickListener(chooseIconListener); HorizontalLayout buttHL = new HorizontalLayout(); vLay.addComponent(buttHL); buttHL.setWidth("100%"); buttHL.addComponent(sp = new Label()); sp.setWidth("1px"); buttHL.setExpandRatio(sp, 1.0f); buttHL.addComponent(new NativeButton("Cancel", new ClickListener() { @Override public void buttonClick(ClickEvent event) { awardType = null; doneHereTL(); } })); buttHL.addComponent(new NativeButton("Close", new ClickListener() { @Override public void buttonClick(ClickEvent event) { String title = nameTF.getValue().trim(); String description = descTF.getValue().trim(); if (title.length() <= 0 || description.length() <= 0 || media300 == null || media55 == null) { Notification.show("All fields must be completed", Notification.Type.ERROR_MESSAGE); return; } HSess.init(); boolean save = false; if (awardType == null) { awardType = new AwardType(); save = true; } awardType.setName(nameTF.getValue().trim()); awardType.setDescription(descTF.getValue().trim()); awardType.setIcon300x300(media300); awardType.setIcon55x55(media55); if (save) HSess.get().save(awardType); else HSess.get().update(awardType); doneHereTL(); HSess.close(); } })); HSess.checkClose(sessKey); }
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 w w. ja v a 2 s . c o 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); }
From source file:edu.nps.moves.mmowgli.modules.userprofile.UserProfileMyIdeasPanel2.java
License:Open Source License
HorizontalLayout makeCheckRow(Button butt) { HorizontalLayout hl = new HorizontalLayout(); hl.setSizeUndefined();/*from www. j a v a2 s . com*/ hl.addStyleName("m-userprofile-linkbuttons"); hl.setMargin(false); hl.setSpacing(false); if (checkMarkRes == null) checkMarkRes = Mmowgli2UI.getGlobals().getMediaLocator().getCheckMark12px(); Embedded embedded = new Embedded(null, checkMarkRes); embedded.setWidth("12px"); if (butt == buildsButt) embedded.setVisible(false); hl.addComponent(embedded); hl.addComponent(butt); hl.setExpandRatio(butt, 1.0f); return hl; }
From source file:edu.nps.moves.mmowgli.modules.userprofile.UserProfileMyIdeasPanel2.java
License:Open Source License
private Component buildNoIdeasYet() { if (!userIsMe) { Label lab = new Label("No idea cards yet"); lab.addStyleName("m-userprofile-tabpanel-font"); return lab; }/*from ww w . jav a2 s . c o m*/ HorizontalLayout hl = new HorizontalLayout(); hl.setSpacing(true); hl.setMargin(true); hl.setWidth("100%"); Label lab; hl.addComponent(lab = new Label("No idea cards yet")); lab.addStyleName("m-userprofile-tabpanel-font"); lab.setSizeUndefined(); hl.setExpandRatio(lab, 0.5f); hl.setComponentAlignment(lab, Alignment.TOP_RIGHT); hl.addComponent(lab = new Label()); lab.setWidth("30px"); IDNativeButton butt = new IDNativeButton("Play a card now", MmowgliEvent.PLAYIDEACLICK); butt.setStyleName(BaseTheme.BUTTON_LINK); butt.addStyleName("m-link-button-18"); hl.addComponent(butt); hl.setExpandRatio(butt, 0.5f); hl.setComponentAlignment(butt, Alignment.TOP_LEFT); return hl; }
From source file:edu.nps.moves.mmowgli.modules.userprofile.UserProfileTabPanel.java
License:Open Source License
protected HorizontalLayout makeTableHeaders() { HorizontalLayout titleHL = new HorizontalLayout(); titleHL.setSpacing(true);/*from w w w .j av a2 s . c om*/ titleHL.setWidth("100%"); Label lab; lab = buildTitleLabel(titleHL, "<center>Creation<br/>Date</center>"); lab.setWidth(4.0f, Sizeable.Unit.EM); lab = buildTitleLabel(titleHL, "<center>Card<br/>Type</center>"); lab.setWidth(6.0f, Sizeable.Unit.EM); lab = buildTitleLabel(titleHL, "Text"); titleHL.setExpandRatio(lab, 1.0f); lab = buildTitleLabel(titleHL, "Author"); lab.setWidth(8.0f, Sizeable.Unit.EM); return titleHL; }
From source file:edu.nps.moves.mmowgliMobile.ui.CardRenderer2.java
License:Open Source License
public void setMessage(FullEntryView2 mView, ListEntry message, ListView2 messageList, AbstractOrderedLayout layout) {/* w w w.j av a 2 s . c o m*/ Object key = HSess.checkInit(); CardListEntry wc = (CardListEntry) message; Card c = wc.getCard(); CardType typ = c.getCardType(); layout.removeAllComponents(); layout.setSpacing(true); VerticalLayout cardLay = new VerticalLayout(); cardLay.addStyleName("m-card-render"); cardLay.setWidth("98%"); //100%"); cardLay.setSpacing(true); layout.addComponent(cardLay); HorizontalLayout horl = new HorizontalLayout(); horl.addStyleName("m-card-header"); String stl = CardStyler.getCardBaseStyle(typ); horl.addStyleName(stl); horl.addStyleName(CardStyler.getCardTextColorOverBaseStyle(typ)); horl.setMargin(true); horl.setWidth("100%"); Label lbl = new Label(typ.getTitle());//c.getText()); horl.addComponent(lbl); lbl = new Label("" + getPojoId(message)); lbl.addStyleName("m-text-align-right"); horl.addComponent(lbl); cardLay.addComponent(horl); horl = new HorizontalLayout(); horl.setWidth("100%"); horl.setMargin(true); cardLay.addComponent(horl); lbl = new Label(c.getText()); horl.addComponent(lbl); horl = new HorizontalLayout(); horl.addStyleName("m-card-footer"); horl.setMargin(true); horl.setWidth("100%"); horl.addComponent(lbl = new Label("")); lbl.setWidth("5px"); Image img = new Image(); img.setSource(mediaLocator.locate(c.getAuthor().getAvatar().getMedia())); img.setWidth("30px"); img.setHeight("30px"); horl.addComponent(img); // horl.addComponent(lbl=new Label(c.getAuthorName())); // lbl.setWidth("100%"); // lbl.addStyleName("m-text-align-center"); // horl.setComponentAlignment(lbl, Alignment.MIDDLE_CENTER); // horl.setExpandRatio(lbl, 1.0f); Button authButt = new MyButton(c.getAuthorName(), c, mView); authButt.setStyleName(BaseTheme.BUTTON_LINK); authButt.setWidth("100%"); horl.addComponent(authButt); horl.setComponentAlignment(authButt, Alignment.MIDDLE_CENTER); horl.setExpandRatio(authButt, 1.0f); horl.addComponent(lbl = new HtmlLabel(formatter.format(message.getTimestamp()))); lbl.setWidth("115px"); ; lbl.addStyleName("m-text-align-right"); horl.setComponentAlignment(lbl, Alignment.MIDDLE_CENTER); cardLay.addComponent(horl); // lbl = new Hr(); // layout.addComponent(lbl); lbl = new Label("Child Cards"); layout.addComponent(lbl); lbl.addStyleName("m-text-center"); // lbl = new Hr(); // layout.addComponent(lbl); horl = new HorizontalLayout(); horl.setSpacing(true); horl.setMargin(true); horl.setWidth("100%"); layout.addComponent(horl); horl.addComponent( makeChildGroupButton("Expand", (CardListEntry) message, CardType.getExpandTypeTL(), messageList)); horl.addComponent( makeChildGroupButton("Counter", (CardListEntry) message, CardType.getCounterTypeTL(), messageList)); horl.addComponent( makeChildGroupButton("Adapt", (CardListEntry) message, CardType.getAdaptTypeTL(), messageList)); horl.addComponent( makeChildGroupButton("Explore", (CardListEntry) message, CardType.getExploreTypeTL(), messageList)); HSess.checkClose(key); }
From source file:edu.nps.moves.mmowgliMobile.ui.UserRenderer2.java
License:Open Source License
public void setMessage(FullEntryView2 mView, ListEntry message, ListView2 messageList, AbstractOrderedLayout layout) {// ww w . ja va 2 s . c om // messageList can be null if coming in from ActionPlan Object key = HSess.checkInit(); UserListEntry wu = (UserListEntry) message; User u = wu.getUser(); layout.removeAllComponents(); HorizontalLayout hlay = new HorizontalLayout(); layout.addComponent(hlay); hlay.addStyleName("m-userview-top"); hlay.setWidth("100%"); hlay.setMargin(true); hlay.setSpacing(true); Image img = new Image(); img.addStyleName("m-ridgeborder"); img.setSource(mediaLocator.locate(u.getAvatar().getMedia())); img.setWidth("90px"); img.setHeight("90px"); hlay.addComponent(img); hlay.setComponentAlignment(img, Alignment.MIDDLE_CENTER); Label lab; hlay.addComponent(lab = new Label()); lab.setWidth("5px"); VerticalLayout vlay = new VerticalLayout(); vlay.setSpacing(true); hlay.addComponent(vlay); hlay.setComponentAlignment(vlay, Alignment.MIDDLE_LEFT); vlay.setWidth("100%"); hlay.setExpandRatio(vlay, 1.0f); HorizontalLayout horl = new HorizontalLayout(); horl.setSpacing(false); vlay.addComponent(horl); vlay.setComponentAlignment(horl, Alignment.BOTTOM_LEFT); horl.addComponent(lab = new Label("name")); lab.addStyleName("m-user-top-label"); //light-text"); horl.addComponent(lab = new HtmlLabel(" " + u.getUserName())); lab.addStyleName("m-user-top-value"); horl = new HorizontalLayout(); horl.setSpacing(false); vlay.addComponent(horl); vlay.setComponentAlignment(horl, Alignment.TOP_LEFT); horl.addComponent(lab = new Label("level")); lab.addStyleName("m-user-top-label"); //light-text"); Level lev = u.getLevel(); if (u.isGameMaster()) { Level l = Level.getLevelByOrdinal(Level.GAME_MASTER_ORDINAL, HSess.get()); if (l != null) lev = l; } horl.addComponent(lab = new HtmlLabel(" " + lev.getDescription())); lab.addStyleName("m-user-top-value"); GridLayout gLay = new GridLayout(); // gLay.setHeight("155px"); // won't size properly gLay.setMargin(true); gLay.addStyleName("m-userview-mid"); gLay.setColumns(2); gLay.setRows(11); gLay.setSpacing(true); gLay.setWidth("100%"); gLay.setColumnExpandRatio(1, 1.0f); layout.addComponent(gLay); addRow(gLay, "user ID:", "" + getPojoId(message)); addRow(gLay, "location:", u.getLocation()); addRow(gLay, "expertise:", u.getExpertise()); addRow(gLay, "affiliation:", u.getAffiliation()); addRow(gLay, "date registered:", formatter.format(u.getRegisterDate())); gLay.addComponent(new Hr(), 0, 5, 1, 5); Container cntr = new CardsByUserContainer<Card>(u); // expects ThreadLocal session to be setup numCards = cntr.size(); addRow(gLay, "cards played:", "" + numCards); cntr = new ActionPlansByUserContainer<Card>(u); // expects ThreadLocal session to be setup numAps = cntr.size(); addRow(gLay, "action plans:", "" + numAps); gLay.addComponent(new Hr(), 0, 8, 1, 8); addRow(gLay, "exploration points:", "" + u.getBasicScore()); addRow(gLay, "innovation points:", "" + u.getInnovationScore()); cardListener = new CardLis(u, mView); apListener = new AppLis(u, mView); layout.addComponent(makeButtons()); HSess.checkClose(key); }
From source file:edu.nps.moves.mmowgliMobile.ui.UserRenderer2.java
License:Open Source License
private Component makeButtons() { HorizontalLayout horl = new HorizontalLayout(); horl.setWidth("100%"); horl.setSpacing(true);/*w ww .j a v a 2 s .c om*/ Label lab; horl.addComponent(lab = new Label("")); horl.setExpandRatio(lab, 0.5f); Button cardsButt = new Button("Cards"); horl.addComponent(cardsButt); Button apButt = new Button("Action Plans"); horl.addComponent(apButt); horl.addComponent(lab = new Label("")); horl.setExpandRatio(lab, 0.5f); cardsButt.addStyleName("m-author-button"); apButt.addStyleName("m-author-button"); cardsButt.addClickListener(cardListener); apButt.addClickListener(apListener); cardsButt.setEnabled(numCards > 0); apButt.setEnabled(numAps > 0); return horl; }
From source file:edu.nps.moves.security.PasswordResetUI.java
License:Open Source License
private void handleChangeTL(User user) { this.user = user; Game g = Game.getTL();//w w w. j a va2 s .c om String brand = g.getCurrentMove().getTitle(); Page.getCurrent().setTitle("Password reset for " + brand + " mmowgli"); HorizontalLayout hLay = new HorizontalLayout(); hLay.setMargin(true); hLay.setWidth("100%"); setContent(hLay); GameLinks gl = GameLinks.getTL(); String blog = gl.getBlogLink(); Label lab; hLay.addComponent(lab = new Label()); hLay.setExpandRatio(lab, 0.5f); VerticalLayout vl = new VerticalLayout(); hLay.addComponent(vl); vl.setWidth(bannerWidthPx); hLay.addComponent(lab = new Label()); hLay.setExpandRatio(lab, 0.5f); vl.addStyleName("m-greyborder"); vl.setMargin(true); vl.setSpacing(true); vl.addComponent(lab = new HtmlLabel("")); lab.addStyleName("m-font-21-bold"); lab.setSizeUndefined(); vl.setComponentAlignment(lab, Alignment.MIDDLE_CENTER); StringBuilder sb = new StringBuilder(); sb.append(thanksHdr1); sb.append(blog); sb.append(thanksHdr2); sb.append(brand); sb.append(thanksHdr3); lab.setValue(sb.toString()); vl.addComponent(lab = new HtmlLabel("")); lab.setHeight("15px"); vl.setComponentAlignment(lab, Alignment.MIDDLE_CENTER); FormLayout fLay = new FormLayout(); fLay.setSizeUndefined(); fLay.addStyleName("m-login-form"); // to allow styling contents (v-textfield) vl.addComponent(fLay); vl.setComponentAlignment(fLay, Alignment.MIDDLE_CENTER); newPw = new PasswordField("New Password"); newPw.setWidth("99%"); fLay.addComponent(newPw); newPw2 = new PasswordField("Again, please"); newPw2.setWidth("99%"); fLay.addComponent(newPw2); HorizontalLayout buttLay = new HorizontalLayout(); buttLay.setSpacing(true); vl.addComponent(buttLay); vl.setComponentAlignment(buttLay, Alignment.TOP_CENTER); NativeButton cancelButt = new NativeButton(); cancelButt.setStyleName("m-cancelButton"); buttLay.addComponent(cancelButt); buttLay.setComponentAlignment(cancelButt, Alignment.BOTTOM_RIGHT); saveButt = new NativeButton(); saveButt.setClickShortcut(ShortcutAction.KeyCode.ENTER); saveButt.setStyleName("m-continueButton"); //m-saveChangesButton"); buttLay.addComponent(saveButt); buttLay.setComponentAlignment(saveButt, Alignment.BOTTOM_RIGHT); cancelButt.addClickListener(this); saveButt.addClickListener(this); }
From source file:es.mdef.clientmanager.ui.GestionClientesUI.java
License:Apache License
private Component getMenuTitleComponent() { final HorizontalLayout top = new HorizontalLayout(); top.setWidth("100%"); top.setDefaultComponentAlignment(Alignment.MIDDLE_LEFT); top.addStyleName("valo-menu-title"); final Label title = new Label("<h3><strong>Gestión de clientes</strong></h3>", ContentMode.HTML); title.setSizeUndefined();//from ww w .j ava 2 s. c om top.addComponent(title); top.setExpandRatio(title, 1); return top; }