List of usage examples for com.vaadin.ui PasswordField PasswordField
public PasswordField()
From source file:edu.kit.dama.ui.commons.util.UIUtils7.java
License:Apache License
/** * Create a password field with the provided properties. In addition, the * returned password field won't allow to set 'null' values by the user and * has no null-representation. As this is a password field, no input prompt is * shown. The height of the text field is left to the default value * ('undefined').//from w w w .j av a 2 s . co m * * @param pCaption The field caption. * @param pWidth The field width (e.g. 100% or 60px). * @param pImmediate The value of the 'immediate' flag. * @param pMinLength The min. string length of the text field. The content can * be checked during validation. * @param pMaxLength The max. string length of the text field. The content can * be checked during validation. * * @return The text field */ public static PasswordField factoryPasswordField(String pCaption, String pWidth, boolean pImmediate, int pMinLength, int pMaxLength) { PasswordField theField = new PasswordField(); theField.setCaption(pCaption); theField.setImmediate(pImmediate); theField.setWidth(pWidth); theField.setNullSettingAllowed(false); theField.setNullRepresentation(""); StringLengthValidator val; if (pMinLength > 0) { val = new StringLengthValidator("The content length of this text field must be between " + pMinLength + " and " + pMaxLength + " characters."); val.setMinLength(pMinLength); } else { val = new StringLengthValidator( "The maximum content length of this text field is " + pMaxLength + " characters."); } val.setMaxLength(pMaxLength); theField.addValidator(val); return theField; }
From source file:edu.nps.moves.mmowgli.modules.registrationlogin.LoginPopup.java
License:Open Source License
public LoginPopup(Button.ClickListener listener, boolean guest) { super(listener); super.initGui(); if (guest) {//w ww . ja va 2 s.c om @SuppressWarnings("unchecked") List<User> lis = (List<User>) HSess.get().createCriteria(User.class) .add(Restrictions.eq("viewOnly", true)).add(Restrictions.eq("accountDisabled", false)).list(); if (lis.size() > 0) { for (User u : lis) { if (u.getUserName().toLowerCase().equals("guest")) { userID = u.getId(); return; } } } // If here, the guest logon is enabled, but no userID named guest is marked "viewOnly", continue and let // caller realize what happened } setTitleString("Sign in please."); contentVLayout.setSpacing(true); Label lab = new Label(); lab.setHeight("20px"); contentVLayout.addComponent(lab); VerticalLayout lay = new VerticalLayout(); contentVLayout.addComponent(lay); contentVLayout.setComponentAlignment(lay, Alignment.TOP_CENTER); lay.addComponent(lab = new Label("Player name:")); lab.addStyleName("m-dialog-label"); lay.addComponent(userIDTf = new TextField()); userIDTf.setColumns(35); userIDTf.setTabIndex(100); userIDTf.setId(USER_NAME_TEXTBOX); userIDTf.addStyleName("m-dialog-entryfield"); lay.addComponent(lab = new Label()); lab.setHeight("15px"); lay.addComponent(lab = new Label("Password:")); lab.addStyleName("m-dialog-label"); lay.addComponent(passwordTf = new PasswordField()); passwordTf.setColumns(35); passwordTf.setTabIndex(101); passwordTf.setId(USER_PASSWORD_TEXTBOX); passwordTf.addStyleName("m-dialog-entryfield"); HorizontalLayout hl = new HorizontalLayout(); hl.setWidth("100%"); contentVLayout.addComponent(hl); hl.addComponent(lab = new Label()); hl.setExpandRatio(lab, 1.0f); continueButt = new NativeButton(); continueButt.setId(LOGIN_CONTINUE_BUTTON); hl.addComponent(continueButt); Mmowgli2UI.getGlobals().mediaLocator().decorateDialogContinueButton(continueButt); continueButt.addClickListener(new MyContinueListener()); continueButt.setClickShortcut(KeyCode.ENTER); // Password reset HorizontalLayout h2 = new HorizontalLayout(); h2.setWidth("100%"); contentVLayout.addComponent(h2); h2.addComponent(lab = new Label()); h2.setExpandRatio(lab, 01.0f); pwResetButt = new NativeButton("Forgot password or player name?"); pwResetButt.addStyleName("m-signin-forgotButton"); h2.addComponent(pwResetButt); pwResetButt.addClickListener(new MyForgotLoginInfoListener()); userIDTf.focus(); // won't do it FocusHack.focus(userIDTf); // will do it }
From source file:fi.semantum.strategia.Utils.java
License:Open Source License
public static void modifyAccount(final Main main) { final Database database = main.getDatabase(); FormLayout content = new FormLayout(); content.setSizeFull();//from ww w. j a v a 2s . co m final Label l = new Label(main.account.getId(database)); l.setCaption("Kyttjn nimi:"); l.setWidth("100%"); content.addComponent(l); final TextField tf = new TextField(); tf.setWidth("100%"); tf.addStyleName(ValoTheme.TEXTFIELD_SMALL); tf.addStyleName(ValoTheme.TEXTFIELD_BORDERLESS); tf.setCaption("Kyttjn nimi:"); tf.setId("loginUsernameField"); tf.setValue(main.account.getText(database)); content.addComponent(tf); final TextField tf2 = new TextField(); tf2.setWidth("100%"); tf2.addStyleName(ValoTheme.TEXTFIELD_SMALL); tf2.addStyleName(ValoTheme.TEXTFIELD_BORDERLESS); tf2.setCaption("Shkpostiosoite:"); tf2.setId("loginUsernameField"); tf2.setValue(main.account.getEmail()); content.addComponent(tf2); final PasswordField pf = new PasswordField(); pf.setCaption("Vanha salasana:"); pf.addStyleName(ValoTheme.TEXTFIELD_SMALL); pf.addStyleName(ValoTheme.TEXTFIELD_BORDERLESS); pf.setWidth("100%"); pf.setId("loginPasswordField"); content.addComponent(pf); final PasswordField pf2 = new PasswordField(); pf2.setCaption("Uusi salasana:"); pf2.addStyleName(ValoTheme.TEXTFIELD_SMALL); pf2.addStyleName(ValoTheme.TEXTFIELD_BORDERLESS); pf2.setWidth("100%"); pf2.setId("loginPasswordField"); content.addComponent(pf2); final PasswordField pf3 = new PasswordField(); pf3.setCaption("Uusi salasana uudestaan:"); pf3.addStyleName(ValoTheme.TEXTFIELD_SMALL); pf3.addStyleName(ValoTheme.TEXTFIELD_BORDERLESS); pf3.setWidth("100%"); pf3.setId("loginPasswordField"); content.addComponent(pf3); final Label err = new Label("Vr kyttjtunnus tai salasana"); err.addStyleName(ValoTheme.LABEL_FAILURE); err.addStyleName(ValoTheme.LABEL_TINY); err.setVisible(false); content.addComponent(err); HorizontalLayout buttons = new HorizontalLayout(); buttons.setSpacing(true); buttons.setMargin(false); Button apply = new Button("Tee muutokset"); buttons.addComponent(apply); final Window dialog = Dialogs.makeDialog(main, "450px", "480px", "Kyttjtilin asetukset", "Poistu", content, buttons); apply.addClickListener(new Button.ClickListener() { private static final long serialVersionUID = 1992235622970234624L; public void buttonClick(ClickEvent event) { String valueHash = Utils.hash(pf.getValue()); if (!valueHash.equals(main.account.getHash())) { err.setValue("Vr salasana"); err.setVisible(true); return; } if (pf2.isEmpty()) { err.setValue("Tyhj salasana ei kelpaa"); err.setVisible(true); return; } if (!pf2.getValue().equals(pf3.getValue())) { err.setValue("Uudet salasanat eivt tsm"); err.setVisible(true); return; } main.account.text = tf.getValue(); main.account.email = tf2.getValue(); main.account.hash = Utils.hash(pf2.getValue()); Updates.update(main, true); main.removeWindow(dialog); } }); }
From source file:gui.views.LoginView.java
public void setUp() { // Ein Neuer Kommentar fr Git. this.setSizeFull(); final TextField userlogin = new TextField(); userlogin.setCaption("Username"); final PasswordField password = new PasswordField(); password.setCaption("Passwort"); VerticalLayout layout = new VerticalLayout(); layout.addComponent(userlogin);//from w ww. jav a2s .c om layout.addComponent(password); Panel panel = new Panel("BitteLogin-Daten eingeben"); this.addComponent(panel); this.setComponentAlignment(panel, Alignment.MIDDLE_CENTER); panel.setContent(layout); Button buttonLogin = new Button("Login", FontAwesome.SEARCH); layout.addComponent(buttonLogin); layout.setComponentAlignment(buttonLogin, Alignment.MIDDLE_CENTER); panel.setSizeUndefined(); buttonLogin.addClickListener(new ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { String user = userlogin.getValue(); String pw = password.getValue(); LoginControl.controllogin(user, pw); } }); }
From source file:info.magnolia.ui.form.field.PasswordFields.java
License:Open Source License
/** * Create a {@link CustomField} based on a {@link VerticalLayout}. * The layout is composed by://w ww. j av a 2 s . com * - {@link PasswordField}. * if verification: * - {@link Label} (verificationMessage). * - {@link PasswordField}. */ public PasswordFields(boolean verification, String verificationMessage, String verificationErrorMessage) { layout = new VerticalLayout(); passwordField = new PasswordField(); passwordField.setNullRepresentation(""); passwordField.setWidth("100%"); this.verification = verification; this.verificationErrorMessage = verificationErrorMessage; this.verificationMessage = verificationMessage; if (this.verification) { verificationField = new PasswordField(); verificationField.setNullRepresentation(""); verificationField.setWidth("100%"); } initContent(); }
From source file:it.vige.greenarea.bpm.custom.ui.LoginPanel.java
License:Apache License
private void addInputField() { VerticalLayout layout = new VerticalLayout(); layout.setSpacing(true);//from w w w .ja v a 2s . c o m layout.setWidth(100, UNITS_PERCENTAGE); loginPanel.addComponent(layout); Panel textFieldPanel = new Panel(); // Hack: actionHandlers can only be // attached to panels or windows textFieldPanel.addStyleName(PANEL_LIGHT); textFieldPanel.setContent(new VerticalLayout()); textFieldPanel.setWidth(100, UNITS_PERCENTAGE); layout.addComponent(textFieldPanel); layout.setExpandRatio(textFieldPanel, 1.0f); Label labelUserName = new Label(i18nManager.getMessage(USER_NAME_TITLE)); labelUserName.addStyleName(LABEL_SMALL); userNameInputField = new TextField(); userNameInputField.setWidth(100, UNITS_PERCENTAGE); Label labelPassword = new Label(i18nManager.getMessage(PASSWORD_TITLE)); labelPassword.addStyleName(LABEL_SMALL); passwordInputField = new PasswordField(); passwordInputField.setWidth(100, UNITS_PERCENTAGE); textFieldPanel.addComponent(labelUserName); textFieldPanel.addComponent(userNameInputField); textFieldPanel.addComponent(labelPassword); textFieldPanel.addComponent(passwordInputField); // Hack to catch keyboard 'enter' textFieldPanel.addActionHandler(new Handler() { private static final long serialVersionUID = 6928598745792215505L; public void handleAction(Action action, Object sender, Object target) { login(userNameInputField.getValue().toString(), passwordInputField.getValue().toString()); } public Action[] getActions(Object target, Object sender) { return new Action[] { new ShortcutAction("enter", ENTER, null) }; } }); Button loginButton = new Button(i18nManager.getMessage(LOGIN)); layout.addComponent(loginButton); layout.setComponentAlignment(loginButton, MIDDLE_LEFT); loginButton.addListener(new ClickListener() { private static final long serialVersionUID = 7781253151592188006L; public void buttonClick(ClickEvent event) { login(userNameInputField.getValue().toString(), passwordInputField.getValue().toString()); } }); }
From source file:lu.uni.lassy.excalibur.examples.icrash.dev.web.java.views.AdminAuthView.java
License:Open Source License
public AdminAuthView() { setSizeFull();// w ww .ja v a 2 s . c om VerticalLayout header = new VerticalLayout(); header.setSizeFull(); HorizontalLayout content = new HorizontalLayout(); content.setSizeFull(); addComponents(header, content); setExpandRatio(header, 1); setExpandRatio(content, 6); welcomeText.setValue("<h1>Welcome to the iCrash Administrator console!</h1>"); welcomeText.setContentMode(ContentMode.HTML); welcomeText.setSizeUndefined(); header.addComponent(welcomeText); header.setComponentAlignment(welcomeText, Alignment.MIDDLE_CENTER); Panel controlPanel = new Panel("Administrator control panel"); controlPanel.setSizeUndefined(); Panel addCoordPanel = new Panel("Create a new coordinator"); addCoordPanel.setSizeUndefined(); Panel messagesPanel = new Panel("Administrator messages"); messagesPanel.setWidth("580px"); Table adminMessagesTable = new Table(); adminMessagesTable.setContainerDataSource(actAdmin.getMessagesDataSource()); adminMessagesTable.setColumnWidth("inputEvent", 180); adminMessagesTable.setSizeFull(); VerticalLayout controlLayout = new VerticalLayout(controlPanel); controlLayout.setSizeFull(); controlLayout.setMargin(false); controlLayout.setComponentAlignment(controlPanel, Alignment.TOP_CENTER); VerticalLayout coordOperationsLayout = new VerticalLayout(addCoordPanel); coordOperationsLayout.setSizeFull(); coordOperationsLayout.setMargin(false); coordOperationsLayout.setComponentAlignment(addCoordPanel, Alignment.TOP_CENTER); /******************************************/ coordOperationsLayout.setVisible(true); // main layout in the middle addCoordPanel.setVisible(false); // ...which contains the panel "Create a new coordinator" /******************************************/ HorizontalLayout messagesExternalLayout = new HorizontalLayout(messagesPanel); VerticalLayout messagesInternalLayout = new VerticalLayout(adminMessagesTable); messagesExternalLayout.setSizeFull(); messagesExternalLayout.setMargin(false); messagesExternalLayout.setComponentAlignment(messagesPanel, Alignment.TOP_CENTER); messagesInternalLayout.setMargin(false); messagesInternalLayout.setSizeFull(); messagesInternalLayout.setComponentAlignment(adminMessagesTable, Alignment.TOP_CENTER); messagesPanel.setContent(messagesInternalLayout); TextField idCoordAdd = new TextField(); TextField loginCoord = new TextField(); PasswordField pwdCoord = new PasswordField(); Label idCaptionAdd = new Label("ID"); Label loginCaption = new Label("Login"); Label pwdCaption = new Label("Password"); idCaptionAdd.setSizeUndefined(); idCoordAdd.setSizeUndefined(); loginCaption.setSizeUndefined(); loginCoord.setSizeUndefined(); pwdCaption.setSizeUndefined(); pwdCoord.setSizeUndefined(); Button validateNewCoord = new Button("Validate"); validateNewCoord.setClickShortcut(KeyCode.ENTER); validateNewCoord.setStyleName(ValoTheme.BUTTON_PRIMARY); GridLayout addCoordinatorLayout = new GridLayout(2, 4); addCoordinatorLayout.setSpacing(true); addCoordinatorLayout.setMargin(true); addCoordinatorLayout.setSizeFull(); addCoordinatorLayout.addComponents(idCaptionAdd, idCoordAdd, loginCaption, loginCoord, pwdCaption, pwdCoord); addCoordinatorLayout.addComponent(validateNewCoord, 1, 3); addCoordinatorLayout.setComponentAlignment(idCaptionAdd, Alignment.MIDDLE_LEFT); addCoordinatorLayout.setComponentAlignment(idCoordAdd, Alignment.MIDDLE_LEFT); addCoordinatorLayout.setComponentAlignment(loginCaption, Alignment.MIDDLE_LEFT); addCoordinatorLayout.setComponentAlignment(loginCoord, Alignment.MIDDLE_LEFT); addCoordinatorLayout.setComponentAlignment(pwdCaption, Alignment.MIDDLE_LEFT); addCoordinatorLayout.setComponentAlignment(pwdCoord, Alignment.MIDDLE_LEFT); addCoordPanel.setContent(addCoordinatorLayout); content.addComponents(controlLayout, coordOperationsLayout, messagesExternalLayout); content.setComponentAlignment(messagesExternalLayout, Alignment.TOP_CENTER); content.setComponentAlignment(controlLayout, Alignment.TOP_CENTER); content.setComponentAlignment(messagesExternalLayout, Alignment.TOP_CENTER); content.setExpandRatio(controlLayout, 20); content.setExpandRatio(coordOperationsLayout, 10); content.setExpandRatio(messagesExternalLayout, 28); Button addCoordinator = new Button("Add coordinator"); Button deleteCoordinator = new Button("Delete coordinator"); addCoordinator.addStyleName(ValoTheme.BUTTON_HUGE); deleteCoordinator.addStyleName(ValoTheme.BUTTON_HUGE); logoutBtn.addStyleName(ValoTheme.BUTTON_HUGE); VerticalLayout buttons = new VerticalLayout(); buttons.setMargin(true); buttons.setSpacing(true); buttons.setSizeFull(); buttons.setDefaultComponentAlignment(Alignment.MIDDLE_CENTER); controlPanel.setContent(buttons); buttons.addComponents(addCoordinator, deleteCoordinator, logoutBtn); /******* DELETE COORDINATOR PANEL BEGIN *********/ Label idCaptionDel = new Label("ID"); TextField idCoordDel = new TextField(); Panel delCoordPanel = new Panel("Delete a coordinator"); coordOperationsLayout.addComponent(delCoordPanel); delCoordPanel.setVisible(false); coordOperationsLayout.setComponentAlignment(delCoordPanel, Alignment.TOP_CENTER); delCoordPanel.setSizeUndefined(); GridLayout delCoordinatorLayout = new GridLayout(2, 2); delCoordinatorLayout.setSpacing(true); delCoordinatorLayout.setMargin(true); delCoordinatorLayout.setSizeFull(); Button deleteCoordBtn = new Button("Delete"); deleteCoordBtn.setClickShortcut(KeyCode.ENTER); deleteCoordBtn.setStyleName(ValoTheme.BUTTON_PRIMARY); delCoordinatorLayout.addComponents(idCaptionDel, idCoordDel); delCoordinatorLayout.addComponent(deleteCoordBtn, 1, 1); delCoordinatorLayout.setComponentAlignment(idCaptionDel, Alignment.MIDDLE_LEFT); delCoordinatorLayout.setComponentAlignment(idCoordDel, Alignment.MIDDLE_LEFT); delCoordPanel.setContent(delCoordinatorLayout); /******* DELETE COORDINATOR PANEL END *********/ /************************************************* MAIN BUTTONS LOGIC BEGIN *************************************************/ addCoordinator.addClickListener(event -> { if (!addCoordPanel.isVisible()) { delCoordPanel.setVisible(false); addCoordPanel.setVisible(true); idCoordAdd.focus(); } else addCoordPanel.setVisible(false); }); deleteCoordinator.addClickListener(event -> { if (!delCoordPanel.isVisible()) { addCoordPanel.setVisible(false); delCoordPanel.setVisible(true); idCoordDel.focus(); } else delCoordPanel.setVisible(false); }); /************************************************* MAIN BUTTONS LOGIC END *************************************************/ /************************************************* ADD COORDINATOR FORM LOGIC BEGIN *************************************************/ validateNewCoord.addClickListener(event -> { String currentURL = Page.getCurrent().getLocation().toString(); int strIndexCreator = currentURL.lastIndexOf(AdministratorLauncher.adminPageName); String iCrashURL = currentURL.substring(0, strIndexCreator); String googleShebang = "#!"; String coordURL = iCrashURL + CoordinatorServlet.coordinatorsName + googleShebang; try { sys.oeAddCoordinator(new DtCoordinatorID(new PtString(idCoordAdd.getValue())), new DtLogin(new PtString(loginCoord.getValue())), new DtPassword(new PtString(pwdCoord.getValue()))); // open new browser tab with the newly created coordinator console... // "_blank" instructs the browser to open a new tab instead of a new window... // unhappily not all browsers interpret it correctly, // some versions of some browsers might still open a new window instead (notably Firefox)! Page.getCurrent().open(coordURL + idCoordAdd.getValue(), "_blank"); } catch (Exception e) { e.printStackTrace(); } idCoordAdd.setValue(""); loginCoord.setValue(""); pwdCoord.setValue(""); idCoordAdd.focus(); }); /************************************************* ADD COORDINATOR FORM LOGIC END *************************************************/ /************************************************* DELETE COORDINATOR FORM LOGIC BEGIN *************************************************/ deleteCoordBtn.addClickListener(event -> { IcrashSystem sys = IcrashSystem.getInstance(); try { sys.oeDeleteCoordinator(new DtCoordinatorID(new PtString(idCoordDel.getValue()))); } catch (Exception e) { e.printStackTrace(); } idCoordDel.setValue(""); idCoordDel.focus(); }); /************************************************* DELETE COORDINATOR FORM LOGIC END *************************************************/ }
From source file:me.uni.emuseo.view.settings.password.PasswordFormLayout.java
License:Open Source License
protected void init2() { @SuppressWarnings("unchecked") List<String>[] fields = new List[] { Arrays.asList("oldPassword", "newPassword", "newPasswordRetype") }; FieldConfiguratorCaptionImpl fieldConfiguratorCaptionImpl = new FieldConfiguratorCaptionImpl() .setNullRepresentation("").setWidth(300).put("oldPassword", "Stare haso") .put("newPassword", "Nowe haso").put("newPasswordRetype", "Powtrz nowe haso"); addFieldConfigurator(fieldConfiguratorCaptionImpl); addFieldBuilder(new FieldBuilder() { @Override/*from w w w . ja v a 2 s .c om*/ public Field<?> build(String propertyId) { return new PasswordField(); } }); setBean(passwordBean, fields); }
From source file:me.uni.emuseo.view.users.form.PasswordFieldBuilder.java
License:Open Source License
@Override public Field<?> build(String propertyId) { if ("password".equals(propertyId)) { return new PasswordField(); }/* w w w . ja va 2 s . c o m*/ return null; }
From source file:nz.co.senanque.vaadinsupport.HintsImpl.java
License:Apache License
public AbstractField getTextField(MaduraPropertyWrapper property) { AbstractTextField ret = null;/*w ww. jav a 2s.c om*/ if (property.isSecret()) { ret = new PasswordField(); } else { ret = new TextField(); // int maxLength = property.getMaxLength(); // if (maxLength > 100) { // ret = new TextArea(); // } else { // ret = new TextField(); // } } ret.setMaxLength(property.getMaxLength()); return ret; }