List of usage examples for com.vaadin.ui.themes ValoTheme BUTTON_PRIMARY
String BUTTON_PRIMARY
To view the source code for com.vaadin.ui.themes ValoTheme BUTTON_PRIMARY.
Click Source Link
From source file:org.vaadin.spring.samples.security.ui.login.views.LoginView.java
License:Apache License
private Component buildFields() { HorizontalLayout fields = new HorizontalLayout(); fields.setSpacing(true);/*w w w .j av a 2 s. c om*/ fields.addStyleName("fields"); username = new TextField("Username"); username.setIcon(FontAwesome.USER); username.addStyleName(ValoTheme.TEXTFIELD_INLINE_ICON); password = new PasswordField("Password"); password.setIcon(FontAwesome.LOCK); password.addStyleName(ValoTheme.TEXTFIELD_INLINE_ICON); final Button signin = new Button("Sign In"); signin.addStyleName(ValoTheme.BUTTON_PRIMARY); signin.setClickShortcut(KeyCode.ENTER); signin.focus(); fields.addComponents(username, password, signin); fields.setComponentAlignment(signin, Alignment.BOTTOM_LEFT); signin.addClickListener(new ClickListener() { private static final long serialVersionUID = 1L; @Override public void buttonClick(final ClickEvent event) { try { security.login(username.getValue(), password.getValue()); } catch (AuthenticationException e) { e.printStackTrace(); } catch (Exception e) { e.printStackTrace(); } // TODO Register Remember me Token /* * Redirect is handled by the VaadinRedirectStrategy * User is redirected to either always the default * or the URL the user request before authentication * * Strategy is configured within SecurityConfiguration * Defaults to User request URL. */ } }); return fields; }
From source file:tad.grupo7.ccamistadeslargas.AmigosLayout.java
/** * Muestra el formulario para aadir una nueva amistad. *//*w w w . j a va 2s. com*/ private void mostrarFormularioAddAmistad() { TextField nombre = new TextField("Nombre"); nombre.setRequired(true); final Button add = new Button("Crear Participante"); add.addStyleName(ValoTheme.BUTTON_PRIMARY); FormLayout form = new FormLayout(nombre, add); add.addClickListener(clickEvent -> { try { nombre.validate(); if (ParticipanteDAO.read(nombre.getValue(), usuario.getId()) == null) { ParticipanteDAO.create(nombre.getValue(), usuario.getId()); UsuarioDAO.addAmigo(nombre.getValue(), usuario.getId()); mostrarAmistades(); } else { Notification n = new Notification("Ya existe un amigo con el mismo nombre", Notification.Type.WARNING_MESSAGE); n.setPosition(Position.TOP_CENTER); n.show(Page.getCurrent()); } } catch (Validator.InvalidValueException ex) { Notification n = new Notification("Error con los campos", Notification.Type.WARNING_MESSAGE); n.setPosition(Position.TOP_CENTER); n.show(Page.getCurrent()); } }); form.setMargin(true); setSecondComponent(form); }
From source file:tad.grupo7.ccamistadeslargas.EventosLayout.java
/** * Se muestra el formulario de aadir un nuevo evento. *//*from w ww .j a va 2s . co m*/ private void mostrarFormularioAddEvento() { //T?TULO CssLayout labels = new CssLayout(); labels.addStyleName("labels"); Label l = new Label("Aadir Evento"); l.setSizeUndefined(); l.addStyleName(ValoTheme.LABEL_H2); l.addStyleName(ValoTheme.LABEL_COLORED); //FORMULARIO TextField nombre = new TextField("Nombre"); nombre.setRequired(true); ComboBox divisa = new ComboBox("Divisa"); divisa.setRequired(true); divisa.addItem(""); divisa.addItem("$"); final Button add = new Button("Crear evento"); add.addStyleName(ValoTheme.BUTTON_PRIMARY); add.setClickShortcut(ShortcutAction.KeyCode.ENTER); FormLayout form = new FormLayout(nombre, divisa, add); //BOTN PARA AADIR EVENTO add.addClickListener(clickEvent -> { try { nombre.validate(); divisa.validate(); if (EventoDAO.readDBObject(nombre.getValue(), usuario.getId()) == null) { EventoDAO.create(nombre.getValue(), divisa.getValue().toString(), usuario); mostrarEventos(); } else { Notification n = new Notification("Ya existe un evento con ese nombre", Notification.Type.WARNING_MESSAGE); n.setPosition(Position.TOP_CENTER); n.show(Page.getCurrent()); } } catch (Validator.InvalidValueException ex) { Notification n = new Notification("Error con los campos", Notification.Type.WARNING_MESSAGE); n.setPosition(Position.TOP_CENTER); n.show(Page.getCurrent()); } }); //AADIMOS COMPONENTES form.setMargin(true); setSecondComponent(form); }
From source file:tad.grupo7.ccamistadeslargas.EventosLayout.java
/** * Se muestra el formulario para aadir un participante al evento. * * @param e Recoge el evento./* w w w . jav a2 s . c o m*/ */ private void mostrarFormularioAddParticipante(Evento e) { //T?TULO CssLayout labels = new CssLayout(); labels.addStyleName("labels"); Label l = new Label("Aadir Participante"); l.setSizeUndefined(); l.addStyleName(ValoTheme.LABEL_H2); l.addStyleName(ValoTheme.LABEL_COLORED); //FORMULARIO List<Participante> participantes = ParticipanteDAO.readAllFromUsuario(usuario.getId()); ComboBox nuevoParticipante = new ComboBox("Participante Nuevo"); nuevoParticipante.setRequired(true); for (Participante p : participantes) { nuevoParticipante.addItem(p.getNombre()); } final Button add = new Button("Aadir participante"); add.addStyleName(ValoTheme.BUTTON_PRIMARY); add.setClickShortcut(ShortcutAction.KeyCode.ENTER); add.addClickListener(clickEvent -> { try { nuevoParticipante.validate(); Participante p = ParticipanteDAO.read(nuevoParticipante.getValue().toString(), usuario.getId()); if (!EventoDAO.esParticipante(e, p)) { EventoDAO.addParticipante(e.getId(), p.getId()); Notification n = new Notification("Participante aadido", Notification.Type.ASSISTIVE_NOTIFICATION); n.setPosition(Position.TOP_CENTER); n.show(Page.getCurrent()); setSecondComponent(null); mostrarEvento(e); } else { Notification n = new Notification("El participante ya se encuentra en el evento", Notification.Type.WARNING_MESSAGE); n.setPosition(Position.TOP_CENTER); n.show(Page.getCurrent()); } } catch (Validator.InvalidValueException ex) { Notification n = new Notification("Error con los campos", Notification.Type.WARNING_MESSAGE); n.setPosition(Position.TOP_CENTER); n.show(Page.getCurrent()); } }); FormLayout form = new FormLayout(l, nuevoParticipante, add); form.setMargin(true); setSecondComponent(form); }
From source file:tad.grupo7.ccamistadeslargas.EventosLayout.java
/** * Muestra el formulario para aadir un gasto al evento. * * @param e Evento al que aadir el gasto. *//*ww w.j av a 2 s . c o m*/ private void mostrarFormularioAddGasto(Evento e) { //T?TULO CssLayout labels = new CssLayout(); labels.addStyleName("labels"); Label l = new Label("Aadir Gasto"); l.setSizeUndefined(); l.addStyleName(ValoTheme.LABEL_H2); l.addStyleName(ValoTheme.LABEL_COLORED); //FORMULARIO TextField titulo = new TextField("Ttulo"); titulo.setRequired(true); TextField precio = new TextField("Precio"); precio.setRequired(true); List<Participante> participantes = ParticipanteDAO.readAllFromEvento(e.getId()); ComboBox pagador = new ComboBox("Pagador"); List<Participante> deudores = new ArrayList<>(); Label d = new Label("Deudores"); FormLayout form = new FormLayout(l, titulo, precio, pagador, d); for (Participante p : participantes) { pagador.addItem(p.getNombre()); CheckBox c = new CheckBox(p.getNombre()); c.addValueChangeListener(evento -> { deudores.add(p); }); form.addComponent(c); } final Button add = new Button("Aadir Gasto"); add.addStyleName(ValoTheme.BUTTON_PRIMARY); add.setClickShortcut(ShortcutAction.KeyCode.ENTER); //SI SE CLICA EN AADIR PAGO SE CREA EL PAGO A LA VEZ QUE SE CIERRA LA VENTANA add.addClickListener(new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { try { titulo.validate(); precio.validate(); pagador.validate(); GastoDAO.create(titulo.getValue(), Double.valueOf(precio.getValue()), e.getId(), ParticipanteDAO.read(pagador.getValue().toString(), usuario.getId()).getId(), deudores); mostrarEvento(e); } catch (Validator.InvalidValueException ex) { Notification n = new Notification("Rellena todos los campos", Notification.Type.WARNING_MESSAGE); n.setPosition(Position.TOP_CENTER); n.show(Page.getCurrent()); } } }); //AADIMOS LOS COMPONENTES form.addComponent(add); setSecondComponent(form); }
From source file:tad.grupo7.ccamistadeslargas.LoginView.java
/** * Crea los campos del formulario./*from w w w. j a va 2s . c o m*/ * * @return Component Devuelve el layout que contiene todos los campos del * formulario. */ private Component buildFields() { //LAYOUT CON LOS CAMPOS DEL FORMULARIO HorizontalLayout fields = new HorizontalLayout(); fields.setSpacing(true); fields.addStyleName("fields"); final TextField email = new TextField("Email"); email.setRequired(true); email.setIcon(FontAwesome.USER); email.addStyleName(ValoTheme.TEXTFIELD_INLINE_ICON); email.focus(); final PasswordField password = new PasswordField("Password"); password.setRequired(true); password.setIcon(FontAwesome.LOCK); password.addStyleName(ValoTheme.TEXTFIELD_INLINE_ICON); final Button signin = new Button("Sign In"); signin.addStyleName(ValoTheme.BUTTON_PRIMARY); signin.setClickShortcut(KeyCode.ENTER); final Button registrar = new Button("Sign Up"); signin.addStyleName(ValoTheme.BUTTON_PRIMARY); fields.addComponents(email, password, signin, registrar); fields.setComponentAlignment(signin, Alignment.BOTTOM_LEFT); fields.setComponentAlignment(registrar, Alignment.BOTTOM_LEFT); //LOGARSE signin.addClickListener(new ClickListener() { @Override public void buttonClick(final ClickEvent event) { try { email.validate(); password.validate(); Usuario u = UsuarioDAO.read(email.getValue(), password.getValue()); if (u != null) { if (u.getEmail().equals("admin") && u.getPassword().equals("admin")) { Session.setAttribute("usuario", u); UI.getCurrent().getNavigator().navigateTo("AdminIndex"); } else { Session.setAttribute("usuario", u); UI.getCurrent().getNavigator().navigateTo("index"); } } else { Notification n = new Notification("Usuario incorrecto", Notification.Type.WARNING_MESSAGE); n.setPosition(Position.TOP_CENTER); n.show(Page.getCurrent()); } } catch (Validator.InvalidValueException ex) { Notification n = new Notification("Rellena todos los campos", Notification.Type.WARNING_MESSAGE); n.setPosition(Position.TOP_CENTER); n.show(Page.getCurrent()); } } }); //IR AL FORMULARIO DE REGISTRARSE registrar.addClickListener(new ClickListener() { @Override public void buttonClick(final ClickEvent event) { UI.getCurrent().getNavigator().navigateTo("registrar"); } }); return fields; }
From source file:tad.grupo7.ccamistadeslargas.RegistrarView.java
public RegistrarView() { setMargin(true);// w w w . j a va 2 s . com setSpacing(true); //T?TULO CssLayout labels = new CssLayout(); labels.addStyleName("labels"); Label l = new Label("Registro"); l.setSizeUndefined(); l.addStyleName(ValoTheme.LABEL_H2); l.addStyleName(ValoTheme.LABEL_COLORED); //FORMULARIO TextField nombre = new TextField("Nombre"); nombre.setRequired(true); PasswordField password = new PasswordField("Contrasea"); password.setRequired(true); TextField email = new TextField("Email"); email.setRequired(true); final Button registrar = new Button("Sign Up"); registrar.setClickShortcut(ShortcutAction.KeyCode.ENTER); registrar.addStyleName(ValoTheme.BUTTON_PRIMARY); FormLayout form = new FormLayout(nombre, password, email, registrar); //BOTN PARA REGISTRARSE registrar.addClickListener(new Button.ClickListener() { @Override public void buttonClick(final Button.ClickEvent event) { try { nombre.validate(); password.validate(); email.validate(); UsuarioDAO.create(nombre.getValue(), password.getValue(), email.getValue()); Usuario u = UsuarioDAO.read(email.getValue(), password.getValue()); Session.setAttribute("usuario", u); UI.getCurrent().getNavigator().navigateTo("index"); } catch (Validator.InvalidValueException ex) { } } }); //AADIR COMPONENTES addComponents(l, form); setComponentAlignment(form, Alignment.MIDDLE_CENTER); }
From source file:trader.LoginUI.java
License:Apache License
@Override protected void init(VaadinRequest request) { setLocale(Locale.ENGLISH);//from w w w . j av a 2s.c o m FormLayout loginForm = new FormLayout(); loginForm.setSizeUndefined(); loginForm.addComponent(userName = new TextField("Username")); loginForm.addComponent(passwordField = new PasswordField("Password")); loginForm.addComponent(rememberMe = new CheckBox("Remember me")); loginForm.addComponent(login = new Button("Login")); login.addStyleName(ValoTheme.BUTTON_PRIMARY); login.setDisableOnClick(true); login.setClickShortcut(ShortcutAction.KeyCode.ENTER); login.addClickListener(new Button.ClickListener() { /** * */ private static final long serialVersionUID = 7813011112417170727L; @Override public void buttonClick(Button.ClickEvent event) { login(); } }); VerticalLayout loginLayout = new VerticalLayout(); loginLayout.setSpacing(true); loginLayout.setSizeUndefined(); if (request.getParameter("logout") != null) { loggedOutLabel = new Label("You have been logged out!"); loggedOutLabel.addStyleName(ValoTheme.LABEL_SUCCESS); loggedOutLabel.setSizeUndefined(); loginLayout.addComponent(loggedOutLabel); loginLayout.setComponentAlignment(loggedOutLabel, Alignment.BOTTOM_CENTER); } loginLayout.addComponent(loginFailedLabel = new Label()); loginLayout.setComponentAlignment(loginFailedLabel, Alignment.BOTTOM_CENTER); loginFailedLabel.setSizeUndefined(); loginFailedLabel.addStyleName(ValoTheme.LABEL_FAILURE); loginFailedLabel.setVisible(false); loginLayout.addComponent(loginForm); loginLayout.setComponentAlignment(loginForm, Alignment.TOP_CENTER); VerticalLayout rootLayout = new VerticalLayout(loginLayout); rootLayout.setSizeFull(); rootLayout.setComponentAlignment(loginLayout, Alignment.MIDDLE_CENTER); setContent(rootLayout); setSizeFull(); }
From source file:uk.co.intec.keyDatesApp.pages.KeyDateView.java
License:Apache License
/** * Loads the main content for the page. Only called on first entry to the * page, because calling method sets <i>isLoaded</i> to true after * successfully completing./*from ww w .j av a 2 s . co m*/ */ public void loadContent() { getEditForm().setSizeUndefined(); getEditForm().setWidth("100%"); getBeanFields().setBuffered(false); getBeanFields().setItemDataSource(getCurrDocBean()); getBeanFields().setFieldFactory(DefaultFieldGroupFieldFactory.get()); getBeanFields().setReadOnly(getCurrDoc().isReadOnly()); final TextField t1 = (TextField) getBeanFields().buildAndBind("Title: ", "title"); t1.setNullRepresentation(""); t1.setSizeFull(); t1.setRequired(true); t1.setRequiredError("Please enter title"); final DateField d1 = getBeanFields().buildAndBind("Date: ", "date", DateField.class); d1.setRequired(true); d1.setRequiredError("Please enter date"); d1.setRangeStart(getStartDate()); d1.setRangeEnd(getEndDate()); final TextArea ta1 = getBeanFields().buildAndBind("Description: ", "description", TextArea.class); ta1.setSizeFull(); setCustomerCombo(new ComboBox("Customer:", KeyDateDatabaseUtils.getCustContainer())); getCustomerCombo().setInputPrompt("No Customer Selected"); getCustomerCombo().setFilteringMode(FilteringMode.STARTSWITH); getCustomerCombo().setImmediate(true); getCustomerCombo().setNewItemsAllowed(true); getCustomerCombo().setInvalidAllowed(false); getCustomerCombo().setNullSelectionAllowed(true); getCustomerCombo().setPageLength(5); getCustomerCombo().setWidth("100%"); getCustomerCombo().setResponsive(true); getBeanFields().bind(getCustomerCombo(), "customer"); getCustomerCombo().addValueChangeListener(new Property.ValueChangeListener() { private static final long serialVersionUID = 1L; /* * (non-Javadoc) * * @see * com.vaadin.data.Property.ValueChangeListener#valueChange(com. * vaadin.data.Property.ValueChangeEvent) */ @Override public void valueChange(com.vaadin.data.Property.ValueChangeEvent event) { getContactCombo().setContainerDataSource( KeyDateDatabaseUtils.getContactContainer((String) event.getProperty().getValue())); getContactCombo().setValue(""); } }); setContactCombo(new ComboBox("Contact:")); getContactCombo().setInputPrompt("No Contact Selected"); getContactCombo().setFilteringMode(FilteringMode.STARTSWITH); getContactCombo().setImmediate(true); getContactCombo().setNewItemsAllowed(true); getContactCombo().setInvalidAllowed(false); getContactCombo().setNullSelectionAllowed(true); getContactCombo().setPageLength(5); getContactCombo().setWidth("100%"); getContactCombo().setResponsive(true); getBeanFields().bind(getContactCombo(), "contact"); final HorizontalLayout buttonRow = new HorizontalLayout(); setSaveButton(new Button("Save")); getSaveButton().addStyleName(ValoTheme.BUTTON_PRIMARY); getSaveButton().setIcon(FontAwesome.SAVE); getSaveButton().setVisible(getCurrDoc().isEditable()); getSaveButton().addClickListener(new Button.ClickListener() { private static final long serialVersionUID = 1L; /* * (non-Javadoc) * * @see * com.vaadin.ui.Button.ClickListener#buttonClick(com.vaadin.ui. * Button.ClickEvent) */ @Override public void buttonClick(ClickEvent event) { getCurrDocBean().saveDocumentWrapper(getCurrDoc()); getCurrDoc().setEditMode(false); getCurrDoc().setReadOnly(true); getBeanFields().setReadOnly(true); getSaveButton().setVisible(false); getEditButton().setVisible(true); } }); setEditButton(new Button("Edit")); getEditButton().addStyleName(ValoTheme.BUTTON_PRIMARY); getEditButton().setIcon(FontAwesome.EDIT); getEditButton().setVisible(!getCurrDoc().isEditable()); getEditButton().addClickListener(new Button.ClickListener() { private static final long serialVersionUID = 1L; /* * (non-Javadoc) * * @see * com.vaadin.ui.Button.ClickListener#buttonClick(com.vaadin.ui. * Button.ClickEvent) */ @Override public void buttonClick(ClickEvent event) { getCurrDoc().setEditMode(true); getCurrDoc().setReadOnly(false); getBeanFields().setReadOnly(false); getEditButton().setVisible(false); getSaveButton().setVisible(true); } }); final Button cancelButton = new Button("Cancel"); cancelButton.addStyleName(ValoTheme.BUTTON_QUIET); cancelButton.setIcon(FontAwesome.UNDO); cancelButton.addClickListener(new Button.ClickListener() { private static final long serialVersionUID = 1L; /* * (non-Javadoc) * * @see * com.vaadin.ui.Button.ClickListener#buttonClick(com.vaadin.ui. * Button.ClickEvent) */ @Override public void buttonClick(ClickEvent event) { MainUI.get().getNavigator().navigateTo(MainView.VIEW_NAME); } }); buttonRow.addComponents(getEditButton(), getSaveButton(), cancelButton); getEditForm().addComponents(t1, d1, ta1, getCustomerCombo(), getContactCombo(), buttonRow); addComponent(editForm); }
From source file:xyz.iipster.ui.ChangePasswordComponent.java
License:Apache License
@Override public void attach() { super.attach(); setModal(true);/*from w ww .j a v a 2s .com*/ setClosable(false); setResizable(false); setCaption(i18N.get("iipster.changePassword.title")); oldPasswordField.setCaption(i18N.get("iipster.changePassword.oldPassword.label")); newPasswordField1.setCaption(i18N.get("iipster.changePassword.newPassword1.label")); newPasswordField2.setCaption(i18N.get("iipster.changePassword.newPassword2.label")); VerticalLayout vl = new VerticalLayout(); vl.setSizeUndefined(); vl.setMargin(true); if (currentPassword != null) { // currentPassowrd is not null, that means we are on login screen and the password is expired Label expiredLabel = new Label(i18N.get("iipster.changePassword.expired.text")); vl.addComponent(expiredLabel); } FormLayout fl = new FormLayout(); fl.setSizeUndefined(); fl.addComponents(oldPasswordField, newPasswordField1, newPasswordField2); vl.addComponent(fl); vl.setExpandRatio(fl, 1F); okButton.setCaption(i18N.get("iipster.ok")); okButton.addStyleName(ValoTheme.BUTTON_PRIMARY); okButton.setClickShortcut(ShortcutAction.KeyCode.ENTER); okButton.addClickListener(e -> { try { ibmiService.changePassword( securityUtils.getAuthentication() == null ? userName : securityUtils.getAuthentication().getPrincipal().toString(), oldPasswordField.getValue(), newPasswordField1.getValue()); close(); eventBus.post(new PasswordChangedEvent(newPasswordField1.getValue())); } catch (BadCredentialsException e1) { Notification.show(i18N.get("iipster.changePassword.oldPassword.error"), Notification.Type.WARNING_MESSAGE); oldPasswordField.focus(); } catch (IOException e1) { Notification.show("Error while changing password", Notification.Type.ERROR_MESSAGE); } catch (NewPasswordInvalidException e1) { Notification.show(i18N.get(e1.getMessageId()), Notification.Type.WARNING_MESSAGE); newPasswordField1.focus(); } }); cancelButton.setCaption(i18N.get("iipster.cancel")); cancelButton.setClickShortcut(ShortcutAction.KeyCode.F12); cancelButton.addClickListener(e -> { close(); }); HorizontalLayout hl = new HorizontalLayout(); hl.setSizeUndefined(); hl.setSpacing(true); hl.addComponents(okButton, cancelButton); vl.addComponent(hl); vl.setComponentAlignment(hl, Alignment.MIDDLE_CENTER); setContent(vl); if (currentPassword == null) { // currentPassword is null so we are not forced to change password during login oldPasswordField.setValue(""); oldPasswordField.setEnabled(true); oldPasswordField.focus(); } else { oldPasswordField.setValue(currentPassword); oldPasswordField.setEnabled(false); newPasswordField1.focus(); } newPasswordField1.setValue(""); newPasswordField2.setValue(""); }