List of usage examples for com.vaadin.ui VerticalLayout setComponentAlignment
@Override public void setComponentAlignment(Component childComponent, Alignment alignment)
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);/* w ww . j a v a 2 s.c o m*/ 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.PlayAnIdeaPage2.java
License:Open Source License
@Override public void initGui() { setSpacing(true);// w w w. ja v a 2s .c o m Label lab = new Label(); lab.setWidth(CALLTOACTION_HOR_OFFSET_STR); addComponent(lab); MovePhase phase = MovePhase.getCurrentMovePhaseTL(); String playTitle = phase.getPlayACardTitle(); if (playTitle != null && playTitle.length() > 0) { addComponent(lab = new Label(playTitle)); setComponentAlignment(lab, Alignment.TOP_CENTER); lab.addStyleName("m-calltoaction-playprompt"); } AbsoluteLayout mainAbsL = new AbsoluteLayout(); mainAbsL.setWidth(PAIP_WIDTH); mainAbsL.setHeight("675px"); addComponent(mainAbsL); // do this at the bottom so z order is top: mainAbsL.addComponent(topHL = new HorizontalLayout(),"top:0px;left:0px"); topHL = new HorizontalLayout(); topHL.addComponent(leftAbsL = new AbsoluteLayout()); topHL.addComponent(rightAbsL = new AbsoluteLayout()); leftAbsL.setWidth(PAIP_HALFWIDTH); rightAbsL.setWidth(PAIP_HALFWIDTH); leftAbsL.setHeight(PAIP_TOP_HEIGHT); rightAbsL.setHeight(PAIP_TOP_HEIGHT); GameLinks gl = GameLinks.getTL(); final String howToPlayLink = gl.getHowToPlayLink(); if (howToPlayLink != null && howToPlayLink.length() > 0) { howToPlayButt = new NativeButton(null); BrowserWindowOpener bwo = new BrowserWindowOpener(howToPlayLink); bwo.setWindowName(MmowgliConstants.PORTALTARGETWINDOWNAME); bwo.extend(howToPlayButt); } else if (mockupOnly) howToPlayButt = new NativeButton(null); else howToPlayButt = new IDNativeButton(null, HOWTOPLAYCLICK); leftAbsL.addComponent(howToPlayButt, HOWTO_POS); leftType = CardType.getCurrentPositiveIdeaCardTypeTL(); leftAbsL.addComponent(poshdr = CardSummaryListHeader.newCardSummaryListHeader(leftType, mockupOnly, null), POS_POS); poshdr.initGui(); poshdr.addNewCardListener(newCardListener); if (mockupOnly) gotoDashboardButt = new NativeButton(null); else gotoDashboardButt = new IDNativeButton(null, IDEADASHBOARDCLICK); rightAbsL.addComponent(gotoDashboardButt, GOTO_POS); rightType = CardType.getCurrentNegativeIdeaCardTypeTL(); rightAbsL.addComponent(neghdr = CardSummaryListHeader.newCardSummaryListHeader(rightType, mockupOnly, null), NEG_POS); neghdr.initGui(); neghdr.addNewCardListener(newCardListener); howToPlayButt.setStyleName("m-howToPlayButton"); gotoDashboardButt.setStyleName("m-gotoIdeaDashboardButton"); // end of top gui VerticalLayout bottomVLay = new VerticalLayout(); mainAbsL.addComponent(bottomVLay, "top:200px;left:0px"); mainAbsL.addComponent(topHL, "top:0px;left:0px"); // doing this at the bottom so z order is top: HorizontalLayout hLay = buildLabelPopupRow(leftType.getTitle(), topNewCardLabel = new Label("new card played")); bottomVLay.addComponent(hLay); bottomVLay.setComponentAlignment(hLay, Alignment.MIDDLE_LEFT); User me = Mmowgli2UI.getGlobals().getUserTL(); topholder = new HorizontalCardDisplay(new Dimension(CARDWIDTH, CARDHEIGHT), NUMCARDS, me, mockupOnly, "top"); bottomVLay.addComponent(topholder); ; topholder.initGui(); bottomVLay.addComponent(lab = new Label()); lab.setHeight("10px"); hLay = buildLabelPopupRow(rightType.getTitle(), bottomNewCardLabel = new Label("new card played")); bottomVLay.addComponent(hLay); bottomVLay.setComponentAlignment(hLay, Alignment.MIDDLE_LEFT); bottomholder = new HorizontalCardDisplay(new Dimension(CARDWIDTH, CARDHEIGHT), NUMCARDS, me, mockupOnly, "bottom"); bottomVLay.addComponent(bottomholder); bottomholder.initGui(); MCacheManager cMgr = AppMaster.instance().getMcache(); if (mockupOnly) { addCardsTL(topholder, cMgr.getPositiveIdeaCardsCurrentMove()); addCardsTL(bottomholder, cMgr.getNegativeIdeaCardsCurrentMove()); } else { Game g = Game.getTL(); if (g.isShowPriorMovesCards() || me.isAdministrator()) { addCardsTL(topholder, cMgr.getAllPositiveIdeaCards()); addCardsTL(bottomholder, cMgr.getAllNegativeIdeaCards()); } else if (!g.isShowPriorMovesCards()) { addCardsTL(topholder, cMgr.getPositiveUnhiddenIdeaCardsCurrentMove()); addCardsTL(bottomholder, cMgr.getNegativeUnhiddenIdeaCardsCurrentMove()); } } }
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);/* ww w. j ava 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"); }
From source file:edu.nps.moves.mmowgli.modules.gamemaster.UserAdminPanel.java
License:Open Source License
public void initGuiTL() { setWidth(APPLICATION_SCREEN_WIDTH);//from w w w . j a v a2 s .c o m setHeight("100%"); setSpacing(false); HorizontalLayout titleHL = new HorizontalLayout(); addComponent(titleHL); Label lab; titleHL.addComponent(lab = new Label()); lab.setWidth("20px"); VerticalLayout tableVLayout = new VerticalLayout(); tableContainer = tableVLayout; tableVLayout.setWidth(APPLICATION_SCREEN_WIDTH); tableVLayout.setHeight("900px"); tableVLayout.setSpacing(true); tableVLayout.addStyleName("m-whitepage-header"); addComponent(tableVLayout); tableVLayout.addComponent(lab = new Label()); lab.setHeight("20px"); tableVLayout.addComponent( lab = new HtmlLabel("<span style='margin-left:40px;color:red;'>" + WARNING_LABEL + "</span>")); lab.addStyleName("m-text-align-center"); tableVLayout.addComponent( new HtmlLabel("<span style='margin-left:40px;'>" + getNumberUsersLabelTL() + "</span>")); tableVLayout.addComponent( new HtmlLabel("<span style='margin-left:40px;'>" + getNumberOnlineLabel() + "</span>")); tableVLayout.addComponent( new HtmlLabel("<span style='margin-left:40px;'>" + getNumberGameMastersTL() + "</span>")); tableVLayout.addComponent( new HtmlLabel("<span style='margin-left:40px;'>" + getNumberCardsLabelTL() + "</span>")); tableVLayout .addComponent(new HtmlLabel("<span style='margin-left:40px;'>Double click a row to edit</span>")); tableVLayout.addComponent(lab = new HtmlLabel( "<center><b><span style='font-size:175%'>Player Administration</span></b></center>")); HorizontalLayout srchHL = buildSearchRow(); tableVLayout.addComponent(srchHL); tableVLayout.setComponentAlignment(srchHL, Alignment.MIDDLE_CENTER); table = createTable(lastTableFiller = new SimpleTableFiller()); table.setCaption(null); addTableToLayout(Mmowgli2UI.getGlobals().getUserID()); }
From source file:edu.nps.moves.mmowgli.modules.registrationlogin.PasswordResetPopup.java
License:Open Source License
@SuppressWarnings("serial") public PasswordResetPopup(Button.ClickListener listener, String uname) { setCaption("Password Reset"); VerticalLayout vLay = new VerticalLayout(); vLay.setSpacing(true);//from w ww . j a v a2 s . c om vLay.setMargin(true); setContent(vLay); vLay.addComponent(new HtmlLabel( "<center>Please fill in your player name and/or email address<br/>to initiate a password reset.</center>")); // Use an actual form widget here for data binding and error display. FormLayout formLay = new FormLayout(); formLay.setSizeUndefined(); formLay.setSpacing(true); formLay.addStyleName("m-login-form"); // to allow styling contents (v-textfield) vLay.addComponent(formLay); vLay.setComponentAlignment(formLay, Alignment.TOP_CENTER); formLay.addComponent(userIDTf = new TextField("Player name:")); userIDTf.addStyleName("m-dialog-textfield"); userIDTf.setWidth("85%"); userIDTf.setTabIndex(100); // Help out a little here userIDTf.setValue(uname == null ? "" : uname); formLay.addComponent(emailTf = new TextField("Email:")); emailTf.addStyleName("m-dialog-textfield"); emailTf.setWidth("85%"); emailTf.setTabIndex(101); HorizontalLayout hl = new HorizontalLayout(); hl.setSpacing(true); hl.setMargin(false); hl.setWidth("100%"); vLay.addComponent(hl); Label lab; hl.addComponent(lab = new Label()); hl.setExpandRatio(lab, 1.0f); Button cancelButt = new Button("Cancel"); hl.addComponent(cancelButt); cancelButt.addClickListener(new ClickListener() { @Override public void buttonClick(ClickEvent event) { getUI().setScrollTop(0); getUI().removeWindow(PasswordResetPopup.this); } }); cancelButt.setClickShortcut(ShortcutAction.KeyCode.ESCAPE); Button continueButt = new Button("Continue"); hl.addComponent(continueButt); continueButt.addClickListener(PasswordResetPopup.this); continueButt.setClickShortcut(ShortcutAction.KeyCode.ENTER); emailTf.focus(); }
From source file:edu.nps.moves.mmowgli.modules.registrationlogin.RegistrationPageBase.java
License:Open Source License
@Override public void initGui() { setWidth("988px"); // same width as included panel setHeight(BIGGESTWINDOW_HEIGHT_S); // try to handle making the popup miss the video Instrumentation.addInstrumentation(this); Game game = Game.getTL();/* w ww . jav a2s .c o m*/ MovePhase phase = game.getCurrentMove().getCurrentMovePhase(); HorizontalLayout outerLayout = new HorizontalLayout(); outerLayout.setSpacing(true); addComponent(outerLayout); outerLayout.setWidth("988px"); setExpandRatio(outerLayout, 1); Label spacer; outerLayout.addComponent(baseVLayout = new VerticalLayout()); baseVLayout.setWidth("988px"); outerLayout.setComponentAlignment(baseVLayout, Alignment.TOP_CENTER); baseVLayout.setSpacing(true); // This is just to give us a hidden widget to update to keep push channel alive through Akamai outerLayout.addComponent(pushPingLab = new HtmlLabel("")); pushPingLab.setWidth("5px"); String headingStr = phase.getOrientationCallToActionText(); String summaryStr = phase.getOrientationHeadline(); String textStr = phase.getOrientationSummary(); Media vid = phase.getOrientationVideo(); vidPan = new VideoWithRightTextPanel(vid, headingStr, summaryStr, textStr, null); vidPan.setLargeText(true); baseVLayout.addComponent(vidPan); vidPan.initGui(); HorizontalLayout bottomHLayout = new HorizontalLayout(); bottomHLayout.addComponent(spacer = new Label()); // special spacer bottomHLayout.setExpandRatio(spacer, 1.0f); Label[] spacers = new Label[5]; Label lab; int numButts = 0; // Email signup button //----------------------- if (phase.isSignupButtonShow()) { VerticalLayout signupVL = new VerticalLayout(); signupVL.setHeight("50px"); signupVL.setMargin(false); if (mockupOnly) signupVL.addComponent(signupButt = new NativeButton(null)); // no handler else signupVL.addComponent(signupButt = new NativeButton(null, this)); signupButt.addStyleName("signupbutton"); signupButt.setEnabled(phase.isSignupButtonEnabled()); Mmowgli2UI.getGlobals().mediaLocator().decorateImageButton(signupButt, phase.getSignupButtonIcon()); signupVL.setComponentAlignment(signupButt, Alignment.MIDDLE_CENTER); signupVL.addComponent(lab = new Label()); lab.setHeight("1px"); signupVL.setExpandRatio(lab, 1.0f); signupVL.addComponent(lab = new HtmlLabel(phase.getSignupButtonSubText())); lab.addStyleName("m-text-align-center"); signupButt.setDescription(phase.getSignupButtonToolTip()); lab.setDescription(phase.getSignupButtonToolTip()); lab.setEnabled(phase.isSignupButtonEnabled()); signupVL.setComponentAlignment(lab, Alignment.MIDDLE_CENTER); bottomHLayout.addComponent(signupVL); numButts++; } // New player reg button //---------------------- if (phase.isNewButtonShow()) { if (numButts > 0) bottomHLayout.addComponent(spacers[numButts] = new Label()); VerticalLayout newButtVL = new VerticalLayout(); newButtVL.setHeight("50px"); newButtVL.setMargin(false); if (mockupOnly) newButtVL.addComponent(imNewButt = new NativeButton(null)); // no handler else newButtVL.addComponent(imNewButt = new NativeButton(null, this)); imNewButt.setEnabled(phase.isNewButtonEnabled()); imNewButt.addStyleName("newuserbutton"); Mmowgli2UI.getGlobals().mediaLocator().decorateImageButton(imNewButt, phase.getNewButtonIcon()); newButtVL.setComponentAlignment(imNewButt, Alignment.MIDDLE_CENTER); newButtVL.addComponent(lab = new Label()); lab.setHeight("1px"); newButtVL.setExpandRatio(lab, 1.0f); /* boolean gameRO = game.isReadonly(); boolean gameClamped = game.isRegisteredLogonsOnly(); imNewButt.setEnabled(!gameRO & !gameClamped); // Label lab; if (gameRO) { newButtVL.addComponent(lab = new Label("No new player accounts, for now")); // "Player registration is currently closed")); // //"Sorry, no more new players")); String s; lab.setDescription(s = "New player accounts will open when game play starts"); imNewButt.setDescription(s); } else if (gameClamped) newButtVL.addComponent(lab = new Label("The game is full, please retry later")); // "Sorry, no more new players")); else newButtVL.addComponent(lab = new Label("You can get started in 2 minutes...")); */ newButtVL.addComponent(lab = new HtmlLabel(phase.getNewButtonSubText())); newButtVL.setComponentAlignment(lab, Alignment.MIDDLE_CENTER); lab.addStyleName("m-text-align-center"); lab.setEnabled(phase.isNewButtonEnabled()); imNewButt.setDescription(phase.getNewButtonToolTip()); lab.setDescription(phase.getNewButtonToolTip()); newButtVL.setComponentAlignment(lab, Alignment.MIDDLE_CENTER); bottomHLayout.addComponent(newButtVL); numButts++; } // Existing player button //----------------------- if (phase.isLoginButtonShow()) { if (numButts > 0) bottomHLayout.addComponent(spacers[numButts] = new Label()); VerticalLayout rightButtVL = new VerticalLayout(); rightButtVL.setHeight("50px"); rightButtVL.setMargin(false); if (mockupOnly) rightButtVL.addComponent(imRegisteredButt = new NativeButton(null)); // no handler else rightButtVL.addComponent(imRegisteredButt = new NativeButton(null, this)); imRegisteredButt.addStyleName("loginbutton"); imRegisteredButt.setEnabled(phase.isLoginButtonEnabled()); Mmowgli2UI.getGlobals().mediaLocator().decorateImageButton(imRegisteredButt, phase.getLoginButtonIcon()); rightButtVL.setComponentAlignment(imRegisteredButt, Alignment.MIDDLE_CENTER); rightButtVL.addComponent(lab = new Label()); lab.setHeight("1px"); rightButtVL.setExpandRatio(lab, 1.0f); rightButtVL.addComponent(lab = new HtmlLabel(phase.getLoginButtonSubText())); lab.addStyleName("m-text-align-center"); lab.setEnabled(phase.isLoginButtonEnabled()); rightButtVL.setComponentAlignment(lab, Alignment.MIDDLE_CENTER); imRegisteredButt.setDescription(phase.getLoginButtonToolTip()); lab.setDescription(phase.getLoginButtonToolTip()); bottomHLayout.addComponent(rightButtVL); numButts++; checkQuickCACLoginTL(); } // Guest signup button //----------------------- if (phase.isGuestButtonShow()) { if (numButts > 0) bottomHLayout.addComponent(spacers[numButts] = new Label()); VerticalLayout guestButtVL = new VerticalLayout(); guestButtVL.setHeight("50px"); guestButtVL.setMargin(false); if (mockupOnly) guestButtVL.addComponent(guestButt = new NativeButton(null)); else guestButtVL.addComponent(guestButt = new NativeButton(null, this)); guestButt.addStyleName("guestbutton"); guestButt.setEnabled(phase.isGuestButtonEnabled()); Mmowgli2UI.getGlobals().mediaLocator().decorateImageButton(guestButt, phase.getGuestButtonIcon()); guestButtVL.setComponentAlignment(guestButt, Alignment.MIDDLE_CENTER); guestButtVL.addComponent(lab = new Label()); lab.setHeight("1px"); guestButtVL.setExpandRatio(lab, 1.0f); guestButtVL.addComponent(lab = new HtmlLabel(phase.getGuestButtonSubText())); lab.addStyleName("m-text-align-center"); guestButtVL.setComponentAlignment(lab, Alignment.MIDDLE_CENTER); guestButt.setDescription(phase.getGuestButtonToolTip()); lab.setDescription(phase.getGuestButtonToolTip()); lab.setEnabled(phase.isGuestButtonEnabled()); bottomHLayout.addComponent(guestButtVL); numButts++; } for (int i = 0; i < numButts; i++) if (spacers[i] != null) spacers[i].setWidth(BUTTON_SPACING[numButts]); bottomHLayout.addComponent(spacer = new Label()); // special spacer bottomHLayout.setExpandRatio(spacer, 1.0f); baseVLayout.addComponent(bottomHLayout); baseVLayout.setComponentAlignment(bottomHLayout, Alignment.TOP_CENTER); lab = new HtmlLabel( "<center>Each MMOWGLI game is independent.<br> You need a new account for every game. </center>"); lab.setSizeUndefined(); lab.addStyleName("m-margintop-20"); lab.addStyleName("m-greyborder"); lab.addStyleName("m-background-white"); lab.addStyleName("m-opacity-75"); baseVLayout.addComponent(lab); baseVLayout.setComponentAlignment(lab, Alignment.MIDDLE_CENTER); String troubleUrl = GameLinks.getTL().getTroubleLink(); Link lnk = new Link("Trouble signing in?", new ExternalResource(troubleUrl)); baseVLayout.addComponent(lnk); lnk.setTargetName(PORTALTARGETWINDOWNAME); lnk.setTargetBorder(BorderStyle.DEFAULT); lnk.addStyleName("m-margin-top-20"); baseVLayout.setComponentAlignment(lnk, Alignment.MIDDLE_CENTER); //checkUserLimits(); done from app entry point }
From source file:edu.nps.moves.mmowgli.modules.userprofile.ChangeEmailDialog.java
License:Open Source License
@SuppressWarnings("serial") public ChangeEmailDialog(EmailPacket pkt) { this.packet = pkt; // this.uid=uid; //User user = DBGet.getUser(uid); setCaption("Change Email"); setModal(true);/*from ww w.ja v a2 s . co m*/ setWidth("350px"); //setHeight("200px"); VerticalLayout vLay = new VerticalLayout(); setContent(vLay); FormLayout fLay = new FormLayout(); oldEmail = new TextField("Current Email", pkt.original);//user.getEmailAddresses().toString()); //oldPw.setColumns(20); oldEmail.setWidth("99%"); fLay.addComponent(oldEmail); newEmail = new TextField("New Email"); newEmail.setWidth("99%"); fLay.addComponent(newEmail); newEmail2 = new TextField("Confirm Email"); newEmail2.setWidth("99%"); fLay.addComponent(newEmail2); vLay.addComponent(fLay); HorizontalLayout buttLay = new HorizontalLayout(); buttLay.setSpacing(true); vLay.addComponent(buttLay); vLay.setComponentAlignment(buttLay, Alignment.TOP_RIGHT); MediaLocator mLoc = Mmowgli2UI.getGlobals().getMediaLocator(); NativeButton cancelButt = new NativeButton(); mLoc.decorateCancelButton(cancelButt); buttLay.addComponent(cancelButt); buttLay.setComponentAlignment(cancelButt, Alignment.BOTTOM_RIGHT); // Label sp; // buttLay.addComponent(sp = new Label()); // sp.setWidth("30px"); saveButt = new NativeButton(); //app.globs().mediaLocator().decorateSaveButton(saveButt); //"save" mLoc.decorateOkButton(saveButt); //"ok" buttLay.addComponent(saveButt); buttLay.setComponentAlignment(saveButt, Alignment.BOTTOM_RIGHT); // buttLay.addComponent(sp = new Label()); // sp.setWidth("5px"); cancelButt.addClickListener(new ClickListener() { @Override public void buttonClick(ClickEvent event) { UI.getCurrent().removeWindow(ChangeEmailDialog.this); } }); saveButt.addClickListener(new ClickListener() { @Override public void buttonClick(ClickEvent event) { String oldTry = oldEmail.getValue().toString(); if (!packet.original.equals(oldTry)) { Notification.show("Error", "This should never show", Notification.Type.ERROR_MESSAGE); return; } String check = newEmail2.getValue().toString(); String newStr = newEmail.getValue().toString(); if (check == null || !newStr.trim().equals(check.trim())) { Notification.show("Error", "Emails do not match", Notification.Type.ERROR_MESSAGE); return; } EmailValidator v = new EmailValidator(""); if (newStr == null || !v.isValid(newStr)) { Notification.show("Error", "Please enter a valid email", Notification.Type.ERROR_MESSAGE); return; } packet.updated = newStr.trim(); if (saveListener != null) saveListener.buttonClick(event); UI.getCurrent().removeWindow(ChangeEmailDialog.this); } }); }
From source file:edu.nps.moves.mmowgli.modules.userprofile.ChangePasswordDialog.java
License:Open Source License
@SuppressWarnings("serial") public ChangePasswordDialog(PasswordPacket pkt) { this.packet = pkt; setCaption("Change Password"); setModal(true);/*from w w w . j a v a 2 s . c om*/ setWidth("350px"); VerticalLayout vLay = new VerticalLayout(); setContent(vLay); FormLayout fLay = new FormLayout(); oldPw = new PasswordField("Current"); //oldPw.setColumns(20); oldPw.setWidth("99%"); fLay.addComponent(oldPw); newPw = new PasswordField("New"); newPw.setWidth("99%"); fLay.addComponent(newPw); newPw2 = new PasswordField("New again"); newPw2.setWidth("99%"); fLay.addComponent(newPw2); vLay.addComponent(fLay); HorizontalLayout buttLay = new HorizontalLayout(); buttLay.setSpacing(true); vLay.addComponent(buttLay); vLay.setComponentAlignment(buttLay, Alignment.TOP_RIGHT); MediaLocator mLoc = Mmowgli2UI.getGlobals().getMediaLocator(); NativeButton cancelButt = new NativeButton(); mLoc.decorateCancelButton(cancelButt); buttLay.addComponent(cancelButt); buttLay.setComponentAlignment(cancelButt, Alignment.BOTTOM_RIGHT); // Label sp; // buttLay.addComponent(sp = new Label()); // sp.setWidth("30px"); saveButt = new NativeButton(); //app.globs().mediaLocator().decorateSaveButton(saveButt); //"save" mLoc.decorateOkButton(saveButt); //"ok" buttLay.addComponent(saveButt); buttLay.setComponentAlignment(saveButt, Alignment.BOTTOM_RIGHT); // buttLay.addComponent(sp = new Label()); // sp.setWidth("5px"); cancelButt.addClickListener(new ClickListener() { @Override public void buttonClick(ClickEvent event) { UI.getCurrent().removeWindow(ChangePasswordDialog.this); } }); saveButt.addClickListener(new ClickListener() { @Override public void buttonClick(ClickEvent event) { String oldTry = oldPw.getValue().toString(); StrongPasswordEncryptor spe = new StrongPasswordEncryptor(); if (!spe.checkPassword(oldTry, packet.original)) { Notification.show("Error", "Existing password incorrect", Notification.Type.ERROR_MESSAGE); return; } String newStr = newPw.getValue().toString(); if (newStr == null || newStr.length() < 6) { Notification.show("Error", "Enter a password of at least six characters", Notification.Type.ERROR_MESSAGE); return; } String check = newPw2.getValue().toString(); if (check == null || !newStr.trim().equals(check.trim())) { Notification.show("Error", "Passwords do not match", Notification.Type.ERROR_MESSAGE); return; } packet.updated = newStr.trim(); if (saveListener != null) saveListener.buttonClick(event); UI.getCurrent().removeWindow(ChangePasswordDialog.this); } }); }
From source file:edu.nps.moves.mmowgli.modules.userprofile.UserProfileMyIdeasPanel2.java
License:Open Source License
@Override public void initGui() { super.initGui(); VerticalLayout leftLayout = getLeftLayout(); leftLayout.setSpacing(true);/*from w w w . ja v a 2s.com*/ getLeftLabel().setValue(""); //"Click on the links below to display lists of cards in play."); int i = leftLayout.getComponentIndex(getLeftLabel()) + 1; // start adding from here Label sp; String possessive = "my"; String capPossessive = "My"; if (!userIsMe) possessive = capPossessive = userName + "'s"; leftLayout.addComponent(allRow = makeCheckRow(allButt = makeButt("All " + possessive + " ideas")), i++); setCheck(allRow, true); leftLayout.setComponentAlignment(allRow, Alignment.MIDDLE_LEFT); leftLayout.addComponent( buildsRow = makeCheckRow(buildsButt = makeButt("Builds on " + possessive + " ideas")), i++); setCheck(buildsRow, false); leftLayout.addComponent(favsRow = makeCheckRow(favsButt = makeButt(capPossessive + " favorite ideas")), i++); setCheck(favsRow, false); leftLayout.addComponent(profileRow = makeCheckRow(profileButt = makeButt(capPossessive + " idea profile")), i++); setCheck(profileRow, false); getRightLayout().addComponent(sp = new Label()); sp.setHeight("20px"); showAllMyIdeas(); }
From source file:edu.nps.moves.mmowgli.modules.userprofile.UserProfileMyIdeasPanel2.java
License:Open Source License
private Component createTable(HbnContainer<Card> cntnr, Object nullComponent) { Collection<?> ids = cntnr.getItemIds(); if (ids.size() <= 0) { if (nullComponent instanceof String) { VerticalLayout vl = new VerticalLayout(); vl.setWidth("670px"); Label lab;//from ww w .ja v a 2s . co m vl.addComponent(lab = new Label((String) nullComponent)); lab.addStyleName("m-userprofile-tabpanel-font"); lab.setSizeUndefined(); // prevents 100% w vl.setComponentAlignment(lab, Alignment.TOP_CENTER); vl.addComponent(lab = new Label()); vl.setExpandRatio(lab, 1.0f); return vl; } return buildNoIdeasYet(); } Table tab = new CardTableSimple(null, cntnr); tab.setPageLength(40); tab.addStyleName("m-greyborder"); return tab; }