List of usage examples for com.vaadin.ui NativeButton addClickListener
public Registration addClickListener(ClickListener listener)
From source file:edu.nps.moves.mmowgli.modules.cards.CardChainPage.java
License:Open Source License
@HibernateRead private GhostVerticalLayoutWrapper makeCardMarkingPanelTL() { GhostVerticalLayoutWrapper wrapper = new GhostVerticalLayoutWrapper(); VerticalLayout vl = new VerticalLayout(); vl.setSpacing(true);// w w w .ja va2 s. co m wrapper.ghost_setContent(vl); Label lab = new HtmlLabel("<b><i>Game Master Actions</i></b>"); vl.addComponent(lab); vl.setComponentAlignment(lab, Alignment.MIDDLE_CENTER); NativeButton editCardButt = new NativeButton("Edit Card"); editCardButt.addStyleName(BaseTheme.BUTTON_LINK); editCardButt.addClickListener(new EditCardTextListener()); vl.addComponent(editCardButt); markingRadioGroup = new OptionGroup(null); markingRadioGroup.setMultiSelect(false); markingRadioGroup.setImmediate(true); markingRadioGroup.setDescription("Only game masters may change."); vl.addComponent(markingRadioGroup); NativeButton clearButt = new NativeButton("clear card marking"); clearButt.addStyleName(BaseTheme.BUTTON_LINK); vl.addComponent(clearButt); clearButt.addClickListener(new MarkingClearListener()); Collection<?> markings = CardMarking.getContainer().getItemIds(); CardMarking hiddencm = null; for (Object o : markings) { CardMarking cm = CardMarking.getTL(o); if (cm == CardMarkingManager.getHiddenMarking()) hiddencm = cm; else if (cm == CardMarkingManager.getNoChildrenMarking()) ; // todo enable with game switch else markingRadioGroup.addItem(cm); } if (hiddencm != null) markingRadioGroup.addItem(hiddencm); Card card = Card.getTL(cardId); // feb refactor DBGet.getCardTL(cardId); vl.addComponent(lab = new Label()); lab.setHeight("5px"); NativeButton newActionPlanButt = new IDNativeButton("create action plan from this card", CARDCREATEACTIONPLANCLICK, cardId); newActionPlanButt.addStyleName(BaseTheme.BUTTON_LINK); vl.addComponent(newActionPlanButt); if (Mmowgli2UI.getGlobals().getUserTL().isTweeter()) { String tweet = TWEETBUTTONEMBEDDED_0 + buildTweet(card) + TWEETBUTTONEMBEDDED_1; Label tweeter = new HtmlLabel(tweet); tweeter.setHeight(TWEETBUTTON_HEIGHT); tweeter.setWidth(TWEETBUTTON_WIDTH); vl.addComponent(tweeter); } return wrapper; }
From source file:edu.nps.moves.mmowgli.modules.cards.CardChainTreeTablePopup.java
License:Open Source License
@HibernateSessionThreadLocalConstructor public CardChainTreeTablePopup(Object rootId, boolean modal, boolean wantSaveButton) { super(null);/*from w w w. j a v a 2 s . c o m*/ setWidth("600px"); setHeight("400px"); addStyleName("m-noborder"); // V7 difference super.initGui(); selectedId = tempSelectedId = rootId; setModal(modal); setListener(this); setResizable(true); setTitleString("Card chain"); saveClicked = false; contentVLayout.setSpacing(true); treeT = new CardChainTree(rootId, false, !modal); if (rootId == null) { setTitleString("Card chains"); // instead, do some creative backgrounding to pseudo select children of a card, treeT.setMultiSelect(true); } //treeT.setSizeFull(); treeT.setWidth("99%"); treeT.setHeight("99%"); treeT.addItemClickListener((ItemClickListener) this); treeT.addStyleName("m-greyborder"); contentVLayout.addComponent(treeT); contentVLayout.setComponentAlignment(treeT, Alignment.MIDDLE_CENTER); contentVLayout.setExpandRatio(treeT, 1.0f); /* todo...the saved data was never being retrieved, should pass it back to create action plan panel */ if (wantSaveButton) { // need a save button HorizontalLayout hl = new HorizontalLayout(); hl.setWidth("100%"); contentVLayout.addComponent(hl); Label lab; hl.addComponent(lab = new Label()); hl.setExpandRatio(lab, 1.0f); NativeButton saveButt = new NativeButton(); hl.addComponent(saveButt); saveButt.setIcon(Mmowgli2UI.getGlobals().getMediaLocator().getSaveButtonIcon()); saveButt.setWidth("45px"); //38px"); saveButt.setHeight("16px"); saveButt.addStyleName("borderless"); saveButt.addClickListener(saveListener = new SaveListener()); saveButt.setClickShortcut(KeyCode.ENTER); hl.addComponent(lab = new Label()); lab.setWidth("30px"); contentVLayout.addComponent(hl); } }
From source file:edu.nps.moves.mmowgli.modules.registrationlogin.RegistrationPageAgreement.java
License:Open Source License
public RegistrationPageAgreement(Button.ClickListener listener) { super(listener); super.initGui(); setTitleString(getTitle()); //"User Agreement 1"); contentVLayout.setSpacing(true);//from w ww . j ava 2 s . c om Label lab = new HtmlLabel(getLabelText()); //"First, please confirm your willingness to meet game requirements. I also confirm that I am at least 18 years of age."); lab.addStyleName(topLabelStyle); contentVLayout.addComponent(lab); HorizontalLayout hlayout = new HorizontalLayout(); contentVLayout.addComponent(hlayout); hlayout.setSpacing(true); hlayout.setWidth("100%"); hlayout.addStyleName(labelStyle); String readUrl = getReadUrlTL(); if (readUrl != null) { Link readLink = new Link("Read", new ExternalResource(getReadUrlTL())); //REGISTRATIONCONSENTURL)); readLink.setTargetName("_agreements"); readLink.setTargetBorder(BorderStyle.DEFAULT); readLink.setDescription("Opens in new window/tab"); hlayout.addComponent(readLink); readLink.setSizeUndefined(); hlayout.setComponentAlignment(readLink, Alignment.MIDDLE_LEFT); } lab = new HtmlLabel(getReadLabel()); //"<i>Consent to Participate in Anonymous Survey</i>"); lab.setSizeUndefined(); hlayout.addComponent(lab); hlayout.setSizeUndefined(); hlayout.setComponentAlignment(lab, Alignment.TOP_LEFT); contentVLayout.addComponent(lab = new Label()); lab.setHeight("15px"); HorizontalLayout hl = new HorizontalLayout(); hl.setWidth("98%"); //"100%"); contentVLayout.addComponent(hl); hl.addComponent(lab = new Label()); lab.setWidth("20px"); NativeButton rejectButt = new NativeButton(); hl.addComponent(rejectButt); rejectButt.setStyleName("m-rejectNoThanksButton"); // Mmowgli2UI.getGlobals().mediaLocator().decorateDialogRejectButton(rejectButt); rejectButt.addClickListener(new RejectListener()); hl.addComponent(lab = new Label()); hl.setExpandRatio(lab, 1.0f); NativeButton continueButt = new NativeButton(); hl.addComponent(continueButt); //Mmowgli2UI.getGlobals().mediaLocator().decorateDialogAcceptAndContinueButton(continueButt); continueButt.setStyleName("m-acceptAndContinueButton"); continueButt.addClickListener(new MyContinueListener()); continueButt.setClickShortcut(KeyCode.ENTER); }
From source file:edu.nps.moves.mmowgli.modules.registrationlogin.RegistrationPageAgreementCombo.java
License:Open Source License
public RegistrationPageAgreementCombo(Button.ClickListener listener) { super(listener); super.initGui(); setTitleString("User Agreement"); contentVLayout.setSpacing(true);//from w w w . ja v a2s .c o m Label lab = new Label("I confirm my willingness to meet game requirements:"); lab.addStyleName(topLabelStyle); contentVLayout.addComponent(lab); // First contentVLayout.addComponent(lab = new Label()); lab.setHeight("5px"); // space contentVLayout.addComponent(lab = new HtmlLabel( "First, I confirm that I am at least 18 years of age, I have been informed of risks<br/>and benefits, and I consent to participate.")); lab.addStyleName(labelStyle); HorizontalLayout hlayout = new HorizontalLayout(); contentVLayout.addComponent(hlayout); hlayout.setSpacing(true); hlayout.setWidth("100%"); hlayout.addStyleName(labelStyle); // First read hlayout.addComponent(lab = new HtmlLabel(" ")); lab.setHeight("10px"); GameLinks gl = GameLinks.getTL(); Link readLink = new Link("Read", new ExternalResource(gl.getInformedConsentLink())); //REGISTRATIONCONSENTURL)); readLink.setTargetName("_agreements"); readLink.setTargetBorder(BorderStyle.DEFAULT); readLink.setDescription("Opens in new window/tab"); hlayout.addComponent(readLink); readLink.setSizeUndefined(); lab = new HtmlLabel("<i>Informed Consent to Participate in Research</i>"); lab.setSizeUndefined(); hlayout.addComponent(lab); hlayout.setSizeUndefined(); // Second contentVLayout.addComponent(lab = new Label()); lab.setHeight("5px"); // space lab = new HtmlLabel( "Second, I understand that <b style='color:red;'>no classified or sensitive information can be<br/>posted</b> to the game since participation is open. Violation of this policy may<br/>lead to serious consequences."); lab.addStyleName(labelStyle); contentVLayout.addComponent(lab); hlayout = new HorizontalLayout(); contentVLayout.addComponent(hlayout); hlayout.setSpacing(true); hlayout.setWidth("100%"); hlayout.addStyleName(labelStyle); // Second read hlayout.addComponent(lab = new HtmlLabel(" ")); readLink = new Link("Read", new ExternalResource(gl.getUserAgreementLink())); readLink.setTargetName("_agreements"); readLink.setTargetBorder(BorderStyle.DEFAULT); readLink.setDescription("Opens in new window/tab"); hlayout.addComponent(readLink); readLink.setSizeUndefined(); lab = new HtmlLabel("<i>Department of Defense Social Media User Agreement</i>"); lab.setSizeUndefined(); hlayout.addComponent(lab); hlayout.setSizeUndefined(); // Third contentVLayout.addComponent(lab = new Label()); lab.setHeight("5px"); // space lab = new HtmlLabel( "Third, the official language of the MMOWGLI game is English. Other languages<br/>are not supported in order to ensure that player postings are appropriate."); lab.addStyleName(labelStyle); contentVLayout.addComponent(lab); contentVLayout.addComponent(lab = new Label()); lab.setHeight("15px"); HorizontalLayout hl = new HorizontalLayout(); hl.setWidth("100%"); contentVLayout.addComponent(hl); hl.addComponent(lab = new Label()); lab.setWidth("20px"); NativeButton rejectButt = new NativeButton(); hl.addComponent(rejectButt); rejectButt.setStyleName("m-rejectNoThanksButton"); //new way rejectButt.addClickListener(new RejectListener()); hl.addComponent(lab = new Label()); hl.setExpandRatio(lab, 1.0f); NativeButton continueButt = new NativeButton(); hl.addComponent(continueButt); continueButt.setStyleName("m-acceptAndContinueButton"); // new way continueButt.addClickListener(new MyContinueListener()); continueButt.setClickShortcut(KeyCode.ENTER); }
From source file:edu.nps.moves.mmowgli.modules.registrationlogin.RegistrationPagePopupSecond.java
License:Open Source License
public RegistrationPagePopupSecond(Button.ClickListener listener, Long uId) { super(listener); super.initGui(); localUserId = uId;//from ww w. j a va 2 s . c o m setTitleString("Tell us about you"); contentVLayout.setSpacing(true); Label sp; contentVLayout.addComponent(sp = new Label()); sp.setHeight("20px"); Label header = new HtmlLabel( "<center>Affiliation category and location are optional and are displayed to other game players.</center>"); // and help you</center>"); header.addStyleName("m-dialog-label-noindent"); contentVLayout.addComponent(header); contentVLayout.setComponentAlignment(header, Alignment.TOP_CENTER); HorizontalLayout horL = new HorizontalLayout(); horL.setSpacing(false); horL.setWidth("100%"); contentVLayout.addComponent(horL); horL.addComponent(sp = new Label()); sp.setWidth("20px"); // Use an actual form widget here for data binding and error display. formLay = new FormLayout(); formLay.addStyleName("m-login-form"); // to allow styling contents (v-textfield) formLay.setSizeUndefined(); horL.addComponent(formLay); horL.setExpandRatio(formLay, 1.0f); formLay.addComponent(affilCombo = new BoundAffiliationCombo("Affiliation:")); affilCombo.setValue(affilCombo.getItemIds().toArray()[0]); // Tried to get this to be editable....needs more work formLay.addComponent(locTf = new TextField("Location:")); locTf.setColumns(31); locTf.setInputPrompt("optional"); locTf.addStyleName("m-noleftmargin"); Label lab; contentVLayout.addComponent(lab = new HtmlLabel(warning)); lab.addStyleName(labelStyle); HorizontalLayout hl = new HorizontalLayout(); hl.setWidth("100%"); contentVLayout.addComponent(hl); hl.addComponent(lab = new Label()); hl.setExpandRatio(lab, 1.0f); NativeButton continueButt = new NativeButton(null); continueButt.setStyleName("m-continueButton"); hl.addComponent(continueButt); continueButt.addClickListener(new JoinListener()); continueButt.setClickShortcut(KeyCode.ENTER); hl.addComponent(lab = new Label()); lab.setWidth("20px"); // don't run off the end }
From source file:edu.nps.moves.mmowgli.modules.registrationlogin.RegistrationPageSecondPermissionPopup.java
License:Open Source License
@HibernateSessionThreadLocalConstructor public RegistrationPageSecondPermissionPopup(Button.ClickListener listener) { super(listener); super.initGui(); Game g = Game.getTL();/*from w ww.j a v a 2s. co m*/ setTitleString(g.getSecondLoginPermissionPageTitle()); contentVLayout.setSpacing(true); Label lab; contentVLayout.addComponent(lab = new Label()); lab.setHeight("15px"); lab = new HtmlLabel(g.getSecondLoginPermissionPageText()); lab.setWidth("82%"); lab.addStyleName(labelStyle); contentVLayout.addComponent(lab); HorizontalLayout hl = new HorizontalLayout(); hl.setWidth("98%"); contentVLayout.addComponent(hl); hl.addComponent(lab = new Label()); lab.setWidth("20px"); NativeButton rejectButt = new NativeButton(); hl.addComponent(rejectButt); rejectButt.setStyleName("m-rejectNoThanksButton"); rejectButt.addClickListener(new RejectListener()); hl.addComponent(lab = new Label()); hl.setExpandRatio(lab, 1.0f); NativeButton continueButt = new NativeButton(); hl.addComponent(continueButt); continueButt.setStyleName("m-acceptAndContinueButton"); continueButt.addClickListener(new MyContinueListener()); continueButt.setClickShortcut(KeyCode.ENTER); }
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 w w w.j a va2s . com 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);//w w w . j a va2 s .c o m 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
Button makeButt(String s) { NativeButton b = new NativeButton(s); b.setStyleName(BaseTheme.BUTTON_LINK); b.addStyleName("m-link-button"); b.addStyleName("borderless"); b.addClickListener(this); return b;// ww w . j ava2 s .c o m }
From source file:edu.nps.moves.mmowgli.modules.userprofile.UserProfileMyMailPanel.java
License:Open Source License
@Override public void initGui() { super.initGui(); String left = "Players can choose to receive messages in-game or externally (or both or neither).<br/><br/>Player messages are private and" + " actual email identities are hidden.<br/><br/>You can find another player's profile by clicking on their name or using the search" + " feature. Then you may send a message to that player by clicking on the " + "<i>Send player private email</i> link.<br/><br/>If this link is not present or is disabled, then the player has opted " + "to receive neither email nor in-game messages.<br/><br/>"; getLeftLabel().setValue(left);// w w w . j av a 2s. co m if (!userIsMe) { User u = User.getTL(uid); if (u.isOkEmail() || u.isOkGameMessages()) { final NativeButton sendEmailButt = new NativeButton("Send private mail to this user"); sendEmailButt.addStyleName(BaseTheme.BUTTON_LINK); sendEmailButt.addStyleName("m-userProfile3-sendmail-button"); Label sp; VerticalLayout vl = getRightLayout(); vl.setSizeUndefined(); vl.setWidth("100%"); vl.addComponent(sp = new Label()); sp.setHeight("50px"); vl.addComponent(sendEmailButt); vl.setComponentAlignment(sendEmailButt, Alignment.MIDDLE_CENTER); vl.addComponent(sp = new Label()); sp.setHeight("1px"); vl.setExpandRatio(sp, 1.0f); sendEmailButt.addClickListener(new ClickListener() { private static final long serialVersionUID = 1L; @Override @MmowgliCodeEntry @HibernateOpened @HibernateClosed public void buttonClick(ClickEvent event) { HSess.init(); User u = User.getTL(uid); if (u.isOkEmail() || u.isOkGameMessages()) // redundant here new SendMessageWindow(u, imAdminOrGameMaster); else Notification.show("Sorry", "Player " + u.getUserName() + " does not receive mail.", Notification.Type.WARNING_MESSAGE); HSess.close(); } }); } return; } VerticalLayout rightVL = getRightLayout(); rightVL.setSizeUndefined(); rightVL.setWidth("100%"); getLeftAddedVerticalLayout() .addComponent(showButt = new ToggleLinkButton("View all", "View unhidden only", null)); //,ttArray)); showButt.addOnListener(new ViewAllListener()); showButt.addOffListener(new ViewUnhiddenOnlyListener()); showButt.setToolTips("Temporarily show all messages, including those marked \"hidden\"", "Temporarily hide messages marked \"hidden\""); Label sp; rightVL.addComponent(sp = new Label()); sp.setHeight("10px"); rightVL.addComponent(mailPanel); User me = Mmowgli2UI.getGlobals().getUserTL(); Set<Message> msgs = me.getGameMessages(); if (msgs.size() > 0) { Message[] msgsAr = new Message[msgs.size()]; msgsAr = msgs.toArray(msgsAr); // avoid concurrent mod int num = msgsAr.length;// .size(); int n = num; for (Message m : msgsAr) { addOneMessage(m, n--, num, null); } } }