List of usage examples for com.vaadin.ui VerticalLayout 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.actionplans.MediaSubWindow.java
License:Open Source License
public MediaSubWindow(Resource res) { setCaption("Action Plan Image"); setModal(true);/*w w w . j a v a2s .com*/ setWidth("640px"); setHeight("480px"); TabSheet tabs = new TabSheet(); tabs.setSizeFull(); setContent(tabs); Panel pan = new Panel(); tabs.addTab(pan, "Fit Window"); pan.setSizeFull(); VerticalLayout layout = new VerticalLayout(); pan.setContent(layout); layout.setSizeFull(); layout.addStyleName("m-background-lightgrey"); layout.setMargin(false); image = new ScaleImage(); image.setSizeFull(); image.setSource(res); layout.addComponent(image); layout.setComponentAlignment(image, Alignment.MIDDLE_CENTER); layout.setExpandRatio(image, 1.0f); tabs.addTab(buildNestedImage(res), "Actual Size"); }
From source file:edu.nps.moves.mmowgli.modules.actionplans.MediaSubWindow.java
License:Open Source License
private Component buildNestedImage(Resource res) { VerticalLayout content = new MVerticalLayout().withMargin(false).withFullHeight().withFullWidth(); content.addStyleName("m-background-lightgrey"); Label sp;/*w w w .j a v a 2 s.c om*/ content.addComponent(sp = new Label()); content.setExpandRatio(sp, 0.5f); Component comp = buildNestedHL(res); content.addComponent(comp); content.setComponentAlignment(comp, Alignment.MIDDLE_CENTER); content.addComponent(sp = new Label()); content.setExpandRatio(sp, 0.5f); return content; }
From source file:edu.nps.moves.mmowgli.modules.actionplans.RfeDialog.java
License:Open Source License
@HibernateSessionThreadLocalConstructor @SuppressWarnings("serial") public RfeDialog(Object aplnId) { this.apId = aplnId; setCaption("Request for Expertise"); setModal(true);/*from w w w. j a va 2s .c o m*/ setSizeUndefined(); setWidth("500px"); setHeight("400px"); VerticalLayout vLay = new VerticalLayout(); setContent(vLay); vLay.setMargin(true); vLay.setSpacing(true); vLay.setSizeFull(); IDButton searchButt = new IDButton("Option 1: Search for players with needed expertise", SEARCHCLICK, null); searchButt.enableAction(false); // do manually searchButt.addClickListener(new SearchListener()); vLay.addComponent(searchButt); VerticalLayout nuts = new VerticalLayout(); vLay.addComponent(nuts); nuts.setSizeFull(); vLay.setExpandRatio(nuts, 1.0f); Label lab; /*vLay*/nuts.addComponent(lab = new Label("Option 2: Post help-wanted notice to action plan")); lab.addStyleName("m-font-bold11"); final VerticalLayout helpWantedPan = new VerticalLayout(); /*vLay*/nuts.addComponent(helpWantedPan); helpWantedPan.addStyleName("m-greyborder"); helpWantedPan.setWidth("99%"); helpWantedPan.setHeight("99%"); helpWantedPan.setSpacing(true); helpWantedPan.setMargin(true); /*vLay*/nuts.setExpandRatio(helpWantedPan, 1.0f); helpWantedTA = new TextArea("Current posting"); helpWantedTA.setWidth("100%"); helpWantedTA.setHeight("100%"); helpWantedTA.setNullRepresentation(""); helpWantedPan.addComponent(helpWantedTA); helpWantedPan.setExpandRatio(helpWantedTA, 1.0f); HorizontalLayout buttLay = new HorizontalLayout(); helpWantedPan.addComponent(buttLay); buttLay.setSpacing(true); buttLay.setWidth("100%"); buttLay.addComponent(lab = new Label()); lab.setWidth("10px"); clearButt = new Button("Clear"); buttLay.addComponent(clearButt); clearButt.addClickListener(clearButtLis = new ClickListener() { @Override @MmowgliCodeEntry @HibernateOpened @HibernateClosed public void buttonClick(ClickEvent event) { HSess.init(); ActionPlan ap = ActionPlan.getTL(apId); helpWantedTA.setValue(null); if (null != ap.getHelpWanted()) { ap.setHelpWanted(null); ActionPlan.updateTL(ap); Notification notif = new Notification("Cleared"); notif.setDelayMsec(3000); notif.show(Page.getCurrent()); GameEventLogger.logHelpWantedTL(ap); notifyAuthorsOfChangeTL(ap); } HSess.close(); } }); buttLay.addComponent(lab = new Label()); buttLay.setExpandRatio(lab, 1.0f); postButt = new Button("Post"); buttLay.addComponent(postButt); postButt.addClickListener(new ClickListener() { @Override @MmowgliCodeEntry @HibernateOpened @HibernateClosed public void buttonClick(ClickEvent event) { Object val = helpWantedTA.getValue(); if (val == null || val.toString().length() <= 0) { clearButtLis.buttonClick(event); return; } HSess.init(); String s = val.toString(); ActionPlan ap = ActionPlan.getTL(apId); if (s == null ? ap.getHelpWanted() != null : !s.equals(ap.getHelpWanted())) { ap.setHelpWanted(s); ActionPlan.updateTL(ap); Notification notif = new Notification("Posted"); notif.setDelayMsec(3000); notif.show(Page.getCurrent()); GameEventLogger.logHelpWantedTL(ap); notifyAuthorsOfChangeTL(ap); } HSess.close(); } }); buttLay.addComponent(lab = new Label()); lab.setWidth("10px"); helpWantedPan.addComponent(lab = new Label()); lab.setHeight("10px"); IDButton troubleButt = new IDButton("Option 3: Post Trouble Report", POSTTROUBLECLICK, null); troubleButt.enableAction(false); // managed manually troubleButt.addClickListener(new TroubleListener()); vLay.addComponent(troubleButt); Button closeButt = new Button("Close"); vLay.addComponent(closeButt); closeButt.addClickListener(new CloseListener()); vLay.setComponentAlignment(closeButt, Alignment.MIDDLE_RIGHT); ActionPlan ap = ActionPlan.getTL(apId); String s = ap.getHelpWanted(); helpWantedTA.setValue(s); }
From source file:edu.nps.moves.mmowgli.modules.administration.SessionReportWindow.java
License:Open Source License
public SessionReportWindow(String caption) { super(caption); setWidth("700px"); setHeight("400px"); VerticalLayout vLay = new VerticalLayout(); vLay.setSizeFull();// w ww. j a va 2 s.c o m setContent(vLay); String header = AppMaster.instance().getSessionReportHeader(); String[] _headerArr = header.split("\t"); widestRowSize = _headerArr.length; String svrName = AppMaster.instance().getServerName(); int idx; if ((idx = svrName.indexOf('.')) != -1) svrName = svrName.substring(0, idx); String me = AppMaster.instance().getLocalNodeReportRaw().toString(); me = svrName + "\n" + me; String[][] localReport = parseReport(me); String all = AppMaster.instance().getCompletePlayerReportRaw().toString(); String[][] remoteReports = parseReport(all); String[] headerArr; if (widestRowSize > _headerArr.length) { headerArr = new String[widestRowSize]; Arrays.fill(headerArr, " "); for (int i = 0; i < _headerArr.length; i++) headerArr[i] = _headerArr[i]; } else headerArr = _headerArr; table = new Table(); table.setSizeFull(); for (int col = 0; col < headerArr.length; col++) { if (col == 0) table.addContainerProperty(headerArr[col], Label.class, null); else table.addContainerProperty(headerArr[col], String.class, null); } addReportToTable(headerArr, localReport); addReportToTable(headerArr, remoteReports); vLay.addComponent(makeTopSummary(localReport, remoteReports)); vLay.addComponent(table); vLay.setExpandRatio(table, 1.0f); }
From source file:edu.nps.moves.mmowgli.modules.administration.VipListManager.java
License:Open Source License
private void showAddDialogOrCancel(final DoneListener lis) { dialog = new Window("Add to VIP list"); dialog.setModal(true);/*from ww w . j av a 2 s .c o m*/ dialog.setWidth("400px"); dialog.setHeight("350px"); VerticalLayout layout = new VerticalLayout(); dialog.setContent(layout); layout.setMargin(true); layout.setSpacing(true); layout.setSizeFull(); List<String> rtypes = Arrays.asList(new String[] { EMAILTYPE, DOMAINTYPE }); radios = new OptionGroup("Select type", rtypes); radios.setNullSelectionAllowed(false); // user can not 'unselect' radios.select("Emails"); // select this by default radios.setImmediate(false); // don't send the change to the server at once layout.addComponent(radios); final TextArea ta = new TextArea(); //ta.setColumns(40); ta.setSizeFull(); ta.setInputPrompt( "Type or paste a tab-, comma- or space-separated list of emails or domains. For domains, " + "use forms such as \"army.mil\", \"nmci.navy.mil\", \"ucla.edu\", \"gov\", etc."); layout.addComponent(ta); 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 addButt = new Button("Add", new Button.ClickListener() { public void buttonClick(ClickEvent event) { String[] returnArr = null; String result = ta.getValue().toString(); if (result == null || result.length() <= 0) returnArr = null; else if ((returnArr = parseIt(result)) == null) return; dialog.close(); lis.continueOrCancel(returnArr); } }); hl.addComponent(cancelButt); hl.addComponent(addButt); 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); hl.setWidth("100%"); ta.setWidth("100%"); ta.setHeight("100%"); layout.setExpandRatio(ta, 1.0f); UI.getCurrent().addWindow(dialog); dialog.center(); }
From source file:edu.nps.moves.mmowgli.modules.administration.VipListManager.java
License:Open Source License
@SuppressWarnings({ "unchecked", "serial" }) private void showViewOrDelete(final DeleteListener lis) { dialog = new Window("View / Delete VIPs"); dialog.setModal(true);/* w ww .j ava 2 s .co m*/ VerticalLayout layout = new VerticalLayout(); dialog.setContent(layout); layout.setMargin(true); layout.setSpacing(true); layout.setSizeFull(); List<VipPii> vLis = VHibPii.getAllVips(); vipListSelect = new ListSelect("Select items to delete"); StringBuffer sb = new StringBuffer(); // for popup vipListSelect.addStyleName("m-greyborder"); String lf = System.getProperty("line.separator"); for (int i = 0; i < vLis.size(); i++) { VipPii v; vipListSelect.addItem(v = vLis.get(i)); sb.append(v.getEntry()); sb.append(lf); } if (sb.length() > 0) sb.setLength(sb.length() - 1); // last space vipListSelect.setNullSelectionAllowed(true); vipListSelect.setMultiSelect(true); vipListSelect.setImmediate(true); vipListSelect.addValueChangeListener(new VipSelectListener()); layout.addComponent(vipListSelect); Label copyPopupList = new HtmlLabel("<pre>" + sb.toString() + "</pre>"); Panel p = new Panel(); VerticalLayout lay = new VerticalLayout(); p.setContent(lay); lay.addComponent(copyPopupList); p.setWidth("400px"); p.setHeight("300px"); PopupView popup = new PopupView("Display list as copyable text", p); popup.setHideOnMouseOut(false); if (sb.length() <= 0) popup.setEnabled(false); layout.addComponent(popup); layout.setComponentAlignment(popup, Alignment.MIDDLE_CENTER); HorizontalLayout hl = new HorizontalLayout(); hl.setSpacing(true); Button cancelButt = new Button("Cancel", new Button.ClickListener() { public void buttonClick(ClickEvent event) { dialog.close(); lis.continueOrCancel(null); } }); deleteButt = new Button("Delete & Close", new Button.ClickListener() { public void buttonClick(ClickEvent event) { Set<VipPii> set = (Set<VipPii>) vipListSelect.getValue(); if (set.size() <= 0) set = null; dialog.close(); lis.continueOrCancel(set); } }); deleteButt.setEnabled(false); hl.addComponent(cancelButt); hl.addComponent(deleteButt); 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("300px"); dialog.setHeight("350px"); hl.setWidth("100%"); vipListSelect.setWidth("99%"); vipListSelect.setHeight("99%"); layout.setExpandRatio(vipListSelect, 1.0f); UI.getCurrent().addWindow(dialog); dialog.center(); }
From source file:edu.nps.moves.mmowgli.modules.cards.CardChainPage.java
License:Open Source License
private void addChildListsTL() { MovePhase phase = MovePhase.getCurrentMovePhaseTL(); Set<CardType> allowedTypes = phase.getAllowedCards(); followOnTypes = new ArrayList<CardType>(); for (CardType ct : allowedTypes) if (!ct.isIdeaCard()) // "idea/initiating" is the opposite of followon followOnTypes.add(ct);//from www .j a v a 2 s .c om Collections.sort(followOnTypes, new Comparator<CardType>() { @Override public int compare(CardType arg0, CardType arg1) { return (int) (arg0.getDescendantOrdinal() - arg1.getDescendantOrdinal()); } }); columnVLs = new ArrayList<VerticalLayout>(followOnTypes.size()); for (int i = 0; i < followOnTypes.size(); i++) { VerticalLayout vl = new VerticalLayout(); vl.setSpacing(true); columnVLs.add(vl); listsHL.addComponent(vl); } Card card = Card.getTL(cardId); Card parent = card.getParentCard(); VerticalLayout spacerVL = new VerticalLayout(); if (parent != null) { topHL.addComponent(spacerVL); topHL.setExpandRatio(spacerVL, 1.0f); spacerVL.setWidth("100%"); parentSumm = CardSummary.newCardSummarySmallTL(parent.getId()); spacerVL.addComponent(parentSumm); parentSumm.initGui(); spacerVL.setComponentAlignment(parentSumm, Alignment.MIDDLE_CENTER); parentSumm.setCaption("Parent Card"); parentSumm.addStyleName("m-parent-card-summary"); } else { topHL.addComponent(spacerVL); topHL.setExpandRatio(spacerVL, 1.0f); spacerVL.setWidth("100%"); gotoTopLevelButt.setStyleName("m-gotoTopLevelButton"); gotoTopLevelButt.setDescription(idea_dash_tt); gotoTopLevelButt.setId(PLAY_AN_IDEA_BLUE_BUTTON); gotoTopLevelButt.setDescription("Show two top-level card rows"); spacerVL.addComponent(gotoTopLevelButt); spacerVL.setComponentAlignment(gotoTopLevelButt, Alignment.MIDDLE_CENTER); } if (isGameMaster) { spacerVL.addComponent(cardMarkingPanel); spacerVL.setComponentAlignment(cardMarkingPanel, Alignment.BOTTOM_LEFT); } cardLg = CardLarge.newCardLargeTL(card.getId()); topHL.addComponent(cardLg); cardLg.initGuiTL(); VerticalLayout buttVL = new VerticalLayout(); buttVL.setHeight("100%"); topHL.addComponent(buttVL); topHL.setComponentAlignment(buttVL, Alignment.MIDDLE_CENTER); topHL.setExpandRatio(buttVL, 1.0f); Label spacer = new Label(); buttVL.addComponent(spacer); buttVL.setExpandRatio(spacer, 1.0f); buttVL.addComponent(gotoIdeaDashButt); gotoIdeaDashButt.setStyleName("m-gotoIdeaDashboardButton"); gotoIdeaDashButt.setDescription(idea_dash_tt); gotoIdeaDashButt.setId(GO_TO_IDEA_DASHBOARD_BUTTON); buttVL.setComponentAlignment(gotoIdeaDashButt, Alignment.MIDDLE_CENTER); buttVL.addComponent(chainButt); chainButt.setStyleName("m-viewCardChainButton"); chainButt.setDescription(view_chain_tt); buttVL.setComponentAlignment(chainButt, Alignment.MIDDLE_CENTER); spacer = new Label(); buttVL.addComponent(spacer); buttVL.setExpandRatio(spacer, 1.0f); int col = -1; for (CardType ct : followOnTypes) { col++; VerticalLayout columnV = columnVLs.get(col); CardSummaryListHeader lstHdr = CardSummaryListHeader.newCardSummaryListHeader(ct, card); lstHdr.addNewCardListener(this); columnV.addComponent(lstHdr); lstHdr.initGui(); } listFollowers_oobTL(card.getId()); // gets current vaadin transaction session }
From source file:edu.nps.moves.mmowgli.modules.cards.IdeaDashboardTabPanel.java
License:Open Source License
protected void buildCardTable() { VerticalLayout vLay = new VerticalLayout(); vLay.setWidth("95%"); vLay.setHeight("100%"); getRightLayout().addComponent(vLay); vLay.addComponent(makeTableHeaders()); Panel pan = new Panel(); pan.setWidth("99%"); pan.setHeight("99%"); pan.setStyleName(Reindeer.PANEL_LIGHT); vLay.addComponent(pan);/*w w w . j a v a 2 s. c o m*/ vLay.setExpandRatio(pan, 1.0f); // all of it VerticalLayout tableLay; pan.setContent(tableLay = new VerticalLayout()); pan.addStyleName("m-greyborder"); tableLay.setWidth("99%"); List<Card> cards = getCardList(); for (Card c : cards) { if (confirmCard(c)) { CardSummaryLine csl; tableLay.addComponent(csl = new CardSummaryLine(c.getId())); csl.initGui(); csl.setWidth("98%"); } } }
From source file:edu.nps.moves.mmowgli.modules.gamemaster.AddAuthorEventHandler.java
License:Open Source License
@SuppressWarnings("serial") public static void inviteAuthorsToActionPlan() { final Window win = new Window("Choose Action Plan"); win.setWidth("600px"); win.setHeight("500px"); VerticalLayout layout = new VerticalLayout(); win.setContent(layout);/* ww w. ja v a2 s . c o m*/ layout.setMargin(true); layout.setSpacing(true); layout.setSizeFull(); final ActionPlanTable apt = new ActionPlanTable() { @Override public ItemClickListener getItemClickListener() { return new ItemClickListener() { public void itemClick(ItemClickEvent event) { } }; // null listener } }; apt.setMultiSelect(false); apt.setPageLength(10); apt.setSizeFull(); layout.addComponent(apt); layout.setExpandRatio(apt, 1.0f); HorizontalLayout buttHL = new HorizontalLayout(); layout.addComponent(buttHL); buttHL.setWidth("100%"); buttHL.setSpacing(true); Label sp; buttHL.addComponent(sp = new Label()); sp.setWidth("1px"); buttHL.setExpandRatio(sp, 1.0f); Button selectButton = new Button("Select"); buttHL.addComponent(selectButton); Button cancelButton = new Button("Cancel"); buttHL.addComponent(cancelButton); UI.getCurrent().addWindow(win); win.center(); selectButton.addClickListener(new ClickListener() { @Override @MmowgliCodeEntry @HibernateOpened @HibernateClosed public void buttonClick(ClickEvent event) { win.close(); Object o = apt.getValue(); if (o != null) { HSess.init(); inviteAuthorsToActionPlanTL(o); HSess.close(); } } }); cancelButton.addClickListener(new ClickListener() { @Override public void buttonClick(ClickEvent event) { win.close(); } }); }
From source file:edu.nps.moves.mmowgli.modules.gamemaster.SetBlogHeadlineWindow.java
License:Open Source License
@Override public void attach() { Panel p = new Panel(); setContent(p);//from w ww . j a v a 2 s . c o m p.setSizeFull(); VerticalLayout layout = new VerticalLayout(); layout.addStyleName("m-blogheadline"); layout.setMargin(true); layout.setSpacing(true); layout.setSizeFull(); p.setContent(layout); layout.addComponent(infoLab = new Label( "Game masters can communicate with players throughout the game. Add a new headling, tooltip and link here.")); layout.addComponent(textLab = new Label("Enter headline:")); textTF = new TextField(); textTF.setInputPrompt("Enter new headline or choose from previous ones below"); textTF.setWidth("100%"); textTF.addStyleName("m-blogtextfield"); layout.addComponent(textTF); layout.addComponent(toolTipLab = new Label("Enter headline tooltip:")); toolTipTF = new TextField(); toolTipTF.setWidth("100%"); layout.addComponent(toolTipTF); layout.addComponent(urlLab = new Label("Enter blog entry url:")); urlTF = new TextField(); urlTF.setWidth("100%"); layout.addComponent(urlTF); table = new Table("Previous headlines"); table.setSizeFull(); table.setImmediate(true); table.setColumnExpandRatio("date", 1); table.setColumnExpandRatio("text", 1); table.setColumnExpandRatio("tooltip", 1); table.setColumnExpandRatio("url", 1); table.setSelectable(true); table.setMultiSelect(true); // return whole pojo table.addItemClickListener(this); table.setContainerDataSource(MessageUrl.getContainer()); layout.addComponent(table); layout.addComponent(nullCheckBox); nullCheckBox.addValueChangeListener(new CBListener()); HorizontalLayout buttHl = new HorizontalLayout(); buttHl.setSpacing(true); buttHl.addComponent(cancelButt); buttHl.addComponent(okButt); layout.addComponent(buttHl); layout.setComponentAlignment(buttHl, Alignment.TOP_RIGHT); layout.setExpandRatio(table, 1.0f); // gets all setWidth("675px"); setHeight("455px"); }