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.kit.dama.ui.repo.components.PaginationPanel.java
License:Apache License
/** * Build the navigation layout including the appropriate buttons to navigate * through the pagination pages./*from ww w . j a v a 2 s . c om*/ * * @return The navigation layout component. */ private HorizontalLayout buildNavigationComponent() { HorizontalLayout result = new HorizontalLayout(); //add "JumpToFirstPage" button final NativeButton first = new NativeButton(); first.setIcon(new ThemeResource("img/16x16/beginning.png")); first.setDescription("First Page"); first.addClickListener(new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { currentPage = 0; updatePage(); } }); //add "PreviousPage" button final NativeButton prev = new NativeButton(); prev.setIcon(new ThemeResource("img/16x16/prev.png")); prev.setDescription("Previous Page"); prev.addClickListener(new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { if (currentPage > 0) { currentPage--; updatePage(); } } }); //add "NextPage" button final NativeButton next = new NativeButton(); next.setDescription("Next Page"); next.setIcon(new ThemeResource("img/16x16/next.png")); next.addClickListener(new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { if (currentPage + 1 < overallPages) { currentPage++; updatePage(); } } }); //add "JumpToLastPage" button final NativeButton last = new NativeButton(); last.setDescription("Last Page"); last.setIcon(new ThemeResource("img/16x16/end.png")); last.addClickListener(new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { currentPage = overallPages - 1; updatePage(); } }); //enable/disable buttons depending on the current page if (overallPages == 0) { first.setEnabled(false); prev.setEnabled(false); next.setEnabled(false); last.setEnabled(false); } else { first.setEnabled(!(currentPage == 0) || !(overallPages < 2)); prev.setEnabled(!(currentPage == 0) || !(overallPages < 2)); next.setEnabled(!(currentPage == overallPages - 1) || !(overallPages < 2)); last.setEnabled(!(currentPage == overallPages - 1) || !(overallPages < 2)); } Label leftFiller = new Label(); result.addComponent(leftFiller); result.setExpandRatio(leftFiller, 1.0f); result.addComponent(first); result.addComponent(prev); int start = currentPage - 5; start = (start < 0) ? 0 : start; int end = start + 10; end = (end > overallPages) ? overallPages : end; if (end - start < 10 && overallPages > 10) { start = end - 10; } if (overallPages == 0) { Label noEntryLabel = new Label("<i>No entries</i>", ContentMode.HTML); //noEntryLabel.setWidth("80px"); noEntryLabel.setSizeUndefined(); result.addComponent(noEntryLabel); result.setComponentAlignment(noEntryLabel, Alignment.MIDDLE_CENTER); } //build the actual page entries for (int i = start; i < end; i++) { if (i == currentPage) { //the current page is marked with a special style Label pageLink = new Label("<b>" + Integer.toString(i + 1) + "</b>", ContentMode.HTML); pageLink.setStyleName("currentpage"); pageLink.setWidth("15px"); result.addComponent(pageLink); result.setComponentAlignment(pageLink, Alignment.MIDDLE_CENTER); } else { //otherwise normal links are added, click-events are handled via LayoutClickListener Link pageLink = new Link(Integer.toString(i + 1), null); result.addComponent(pageLink); result.setComponentAlignment(pageLink, Alignment.MIDDLE_CENTER); } } //add right navigation buttons result.addComponent(next); result.addComponent(last); //...and fill the remaining space Label rightFiller = new Label(); result.addComponent(rightFiller); result.setExpandRatio(rightFiller, 1.0f); result.setSpacing(true); //put everything ot the middle result.setComponentAlignment(first, Alignment.MIDDLE_CENTER); result.setComponentAlignment(prev, Alignment.MIDDLE_CENTER); result.setComponentAlignment(next, Alignment.MIDDLE_CENTER); result.setComponentAlignment(last, Alignment.MIDDLE_CENTER); //add layout click listener to be able to navigate by clicking the single pages result.addLayoutClickListener(new LayoutEvents.LayoutClickListener() { @Override public void layoutClick(LayoutEvents.LayoutClickEvent event) { // Get the child component which was clicked Component child = event.getChildComponent(); if (child == null) { // Not over any child component } else // Over a child component { if (child instanceof Link) { } } } }); //finalize result.setWidth("100%"); result.setHeight("25px"); return result; }
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);/* w w w.j a va 2s . c o m*/ 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);/*from ww w. ja va 2 s .c o m*/ 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.CardSummary.java
License:Open Source License
@SuppressWarnings("serial") public void initGui(Session sess) { setHeight(heightStr);// www .j av a2s . c o m setWidth(widthStr); addStyleName("m-cursor-pointer"); // pointer when over me, because I'm clickable if (bckgrndResource != null) { backImg = new Embedded(null, bckgrndResource); addComponent(backImg, "top:0px;left:0px"); } if (!isFactCard) { String hdrTxt = card.getCardType().getSummaryHeader(); header.setDescription(hdrTxt); if (hdrTxt != null && hdrTxt.length() > 0) { //if(hdrTxt.length()>=15) { // hdrTxt = hdrTxt.substring(0, 15).trim()+"..."; // } header.setValue(hdrTxt); header.setWidth(headerWidthStr); header.setHeight(headerHeightStr); addComponent(header, headerPositionStr); header.addStyleName(headerStyleStr); header.addStyleName(textColorStyleStr); header.addStyleName("m-cursor-pointer"); } if (starGreyResource != null && starRedResource != null) { Set<Card> favs = me.getFavoriteCards(); if (favs != null && favs.contains(card)) { star.setIcon(starRedResource); } else { star.setIcon(starGreyResource); } addComponent(star, starPositionStr); if (!mockupOnly) star.addClickListener(new StarClick()); star.addStyleName("borderless"); star.setDescription("Mark or unmark as a favorite of yours"); } } idLab.setWidth(idLabWidthStr); idLab.setHeight(idLabHeightStr); idLab.setValue("" + card.getId()); idLab.addStyleName(idLabStyleStr); idLab.addStyleName("m-text-align-right"); addComponent(idLab, idLabPositionStr); content.setWidth(contentWidthStr); content.setHeight(contentHeightStr); addComponent(content, contentPositionStr); content.addStyleName(contentStyle); if (card.isHidden()) content.addStyleName(hiddenStyle); // red "HIDDEN" text background content.setValue(formatText(card.getText())); content.addStyleName("m-cursor-pointer"); content.setDescription(card.getText()); if (!isFactCard) { /* We shouldn't have to be setting widths on the components within this horizontal layout. The * fact that we do is, I think, related to the absolutelayout parent. Get rid of that and we might * be able to yank the .setwidth, setheight stuff. */ HorizontalLayout hLay = new HorizontalLayout(); hLay.setMargin(false); hLay.setHeight(userHeightStr); hLay.setWidth(userDateWidthStr); addComponent(hLay, userDatePositionStr); user.setValue(card.getAuthorName()); //.getAuthor().getUserName()); hLay.addComponent(user); user.setWidth(userWidthStr); user.setHeight(userHeightStr); user.addStyleName(userStyle); user.addStyleName("m-cursor-pointer"); Label sp; hLay.addComponent(sp = new Label()); sp.setWidth("1px"); hLay.setExpandRatio(sp, 1.0f); dateLab.setValue(dateFormatter.format(card.getCreationDate())); hLay.addComponent(dateLab); dateLab.setHeight(userHeightStr); dateLab.setWidth(null); //dateWidthStr); dateLab.addStyleName(userStyle); } if (card.getCreatedInMove().getId() != Move.getCurrentMove(sess).getId()) { Label lab = new Label(card.getCreatedInMove().getName()); lab.addStyleName(moveStyleStr); lab.setWidth(moveWidthStr); lab.setHeight(moveHeightStr); addComponent(lab, movePositionStr); } // Listen for layout click events if (!mockupOnly) this.addLayoutClickListener(new LayoutClickListener() { @MmowgliCodeEntry @HibernateOpened @HibernateRead public void layoutClick(LayoutClickEvent event) { HSess.init(); Component c = event.getChildComponent(); Card card = Card.getTL(cardId); if (c == star) { //Let the starlistener below handle it } else if (c == user) { AppEvent evt = new AppEvent(CARDAUTHORCLICK, CardSummary.this, card.getAuthor().getId()); Mmowgli2UI.getGlobals().getController().miscEventTL(evt); } else { //if (c == content) { AppEvent evt = new AppEvent(CARDCLICK, CardSummary.this, card.getId()); Mmowgli2UI.getGlobals().getController().miscEventTL(evt); } HSess.close(); } }); }
From source file:edu.nps.moves.mmowgli.components.Header.java
License:Open Source License
@SuppressWarnings("serial") @Override// w ww . j av a 2s .com 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();/*w w w. ja v a2s . 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.MmowgliDialog.java
License:Open Source License
@Override public void initGui() { outerLayout = new VerticalLayout(); outerLayout.setSpacing(false);/*from ww w .j a va 2s . 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.components.MmowgliDialogContent.java
License:Open Source License
public void initGui() { addComponent(leftVL);/*from ww w.ja va2 s. co m*/ leftVL.setSizeFull(); setExpandRatio(leftVL, 1.0f); leftVL.addComponent(headerWrapper); headerWrapper.addStyleName("m-mmowglidialog2-header"); headerWrapper.setHeight("75px"); headerWrapper.setWidth("100%"); doHeaderWrapper(); HorizontalLayout midHL = new HorizontalLayout(); leftVL.addComponent(midHL); leftVL.setExpandRatio(midHL, 1.0f); midHL.setHeight("100%"); midHL.setWidth("100%"); midHL.addComponent(leftEdge); leftEdge.setHeight("100%"); leftEdge.setWidth("10px"); midHL.addComponent(contentVLayout); contentVLayout.addStyleName("m-mmowglidialog2-middle"); contentVLayout.setSizeFull(); midHL.setExpandRatio(contentVLayout, 1.0f); // gets it all leftVL.addComponent(footer); footer.setWidth("100%"); footer.setHeight("36px"); addComponent(rightShadowVL); rightShadowVL.setHeight("100%"); rightShadowVL.setWidth("28px"); rightShadowVL.addComponent(rightEdge); rightEdge.setHeight("100%"); rightEdge.setWidth("28px"); // rightEdge.addStyleName("m-clip-overflow"); rightShadowVL.setExpandRatio(rightEdge, 1.0f); rightShadowVL.addComponent(corner); }
From source file:edu.nps.moves.mmowgli.components.SignupsTable.java
License:Open Source License
@SuppressWarnings("serial") public static void showDialog(String title) { final Button bulkMailButt = new Button("Initiate bulk mail job sending to filtered list"); final Button emailButt = new Button("Compose email"); emailButt.setDescription("Opens editing dialog to compose an email message to the selected individuals"); final Button displayButt = new Button("Display as plain text"); Button closeButt;/* w w w. j a v a 2 s . c o m*/ final SignupsTable tab = new SignupsTable(null, null, new ValueChangeListener() // selected { @Override public void valueChange(com.vaadin.data.Property.ValueChangeEvent event) { emailButt.setEnabled(true); } }); final Window dialog = new Window(title); dialog.setWidth("950px"); dialog.setHeight("650px"); VerticalLayout vl = new VerticalLayout(); dialog.setContent(vl); vl.setSizeFull(); vl.setMargin(true); vl.setSpacing(true); addFilterCheckBoxes(vl); vl.addComponent(new Label("Individuals who have established game accounts are shown faintly")); tab.setSizeFull(); vl.addComponent(tab); vl.setExpandRatio(tab, 1.0f); HorizontalLayout buttHL = new HorizontalLayout(); buttHL.setSpacing(true); buttHL.addComponent(bulkMailButt); bulkMailButt.setImmediate(true); ; Label lab = new Label(""); buttHL.addComponent(lab); buttHL.setExpandRatio(lab, 1.0f); buttHL.addComponent(emailButt); emailButt.setImmediate(true); buttHL.addComponent(displayButt); displayButt.setImmediate(true); buttHL.addComponent(closeButt = new Button("Close")); closeButt.setImmediate(true); emailButt.setEnabled(false); closeButt.addClickListener(new ClickListener() { @Override public void buttonClick(ClickEvent event) { dialog.close(); } }); emailButt.addClickListener(new ClickListener() { @SuppressWarnings("rawtypes") @Override public void buttonClick(ClickEvent event) { HSess.init(); Set set = (Set) tab.getValue(); ArrayList<String> emails = new ArrayList<String>(set.size()); Iterator itr = set.iterator(); while (itr.hasNext()) { QueryWrapper wrap = (QueryWrapper) itr.next(); emails.add(wrap.getEmail()); } new SendMessageWindow(emails); HSess.close(); } }); displayButt.addClickListener(new ClickListener() { @Override @MmowgliCodeEntry @HibernateOpened @HibernateClosed public void buttonClick(ClickEvent event) { HSess.init(); dumpSignupsTL(); HSess.close(); } }); bulkMailButt.addClickListener(new ClickListener() { @Override public void buttonClick(ClickEvent event) { BulkMailHandler.showDialog((QueryContainer) tab.getContainerDataSource()); } }); vl.addComponent(buttHL); vl.setComponentAlignment(buttHL, Alignment.MIDDLE_RIGHT); UI.getCurrent().addWindow(dialog); dialog.center(); }
From source file:edu.nps.moves.mmowgli.components.VideoWithRightTextPanel.java
License:Open Source License
public void initGui() { addStyleName("m-calltoaction-novideo"); // m-calltoaction"); // puts up background setMargin(false);/*ww w . j a v a2 s . c om*/ setSpacing(false); setWidth("988px"); Label lab; addComponent(lab = new Label()); lab.setHeight("41px"); HorizontalLayout horLay = new HorizontalLayout(); horLay.setSpacing(false); horLay.setMargin(false); horLay.setWidth("100%"); addComponent(horLay); horLay.addComponent(lab = new Label()); lab.setWidth("38px"); if (vidMedia != null && vidMedia.getUrl() != null && vidMedia.getUrl().trim().length() > 0) { if (vidMedia.getType() == MediaType.YOUTUBE) { try { Flash ytp = new Flash(); ytp.setSource(new ExternalResource("https://www.youtube.com/v/" + vidMedia.getUrl())); ytp.setParameter("allowFullScreen", "true"); ytp.setParameter("showRelated", "false"); ytp.setWidth(539.0f, Unit.PIXELS); //VID_W_PX,Unit.PIXELS); ytp.setHeight(342.0f, Unit.PIXELS); //VID_H_PX,Unit.PIXELS); player = ytp; } catch (Exception ex) { System.err.println("Exception instantiating YouTubePlayer: " + ex.getClass().getSimpleName() + ": " + ex.getLocalizedMessage()); } } else { System.err.println("Bad media file in VideoWithRightTextPanel"); player = new Label("missing video"); } VerticalLayout plyrLinkWrap = new VerticalLayout(); plyrLinkWrap.setMargin(false); plyrLinkWrap.setSpacing(true); plyrLinkWrap.setSizeUndefined(); VerticalLayout playerVL = new VerticalLayout(); //AbsoluteLayout(); playerVL.setWidth("539px"); playerVL.setHeight("342px"); playerVL.addStyleName("m-boxshadow-5"); playerVL.addComponent(player); plyrLinkWrap.addComponent(playerVL); Link link = getAlternateVideoLink(vidMedia); if (link != null) { plyrLinkWrap.addComponent(link); plyrLinkWrap.setComponentAlignment(link, Alignment.BOTTOM_CENTER); } horLay.addComponent(plyrLinkWrap); horLay.addComponent(lab = new Label()); lab.setWidth("22px"); } VerticalLayout rightColVLayout = new VerticalLayout(); horLay.addComponent(rightColVLayout); horLay.setExpandRatio(rightColVLayout, 1.0f); horLay.addComponent(lab = new Label()); lab.setWidth("35px"); rightColVLayout.setSpacing(true); if (headerImg != null) { // Image takes priority over text rightColVLayout.addComponent(headerImg); } else { headingLab = new HtmlLabel(heading); if (largerText) headingLab.addStyleName("m-orientation-heading"); else headingLab.addStyleName("m-calltoaction-thesituation-heading"); rightColVLayout.addComponent(headingLab); } summaryLab = new HtmlLabel(summary); if (largerText) summaryLab.addStyleName("m-orientation-summary"); else summaryLab.addStyleName("m-calltoaction-thesituation-summary"); rightColVLayout.addComponent(summaryLab); // text = text.replace("\n", "<br/><br/>"); // pure html with <p> tags seems to work well textLab = new HtmlLabel(text); if (largerText) textLab.addStyleName("m-orientation-text"); else textLab.addStyleName("m-calltoaction-thesituation-text"); rightColVLayout.addComponent(textLab); // Move 2, no room /* * if (promptImg != null) { // Image priority over text rightColVLayout.addComponent(promptImg); } else if (prompt != null){ promptLab = new Label(prompt); * promptLab.setContentMode(Label.CONTENT_XHTML); if(largerText) promptLab.addStyleName("m-orientation-prompt"); else * promptLab.addStyleName("m-calltoaction-thesituation-prompt"); rightColVLayout.addComponent(promptLab); } */ // spacer so background doesn't look cut-off addComponent(lab = new Label()); lab.setHeight("25px"); }