Example usage for com.vaadin.ui.themes ValoTheme LABEL_H2

List of usage examples for com.vaadin.ui.themes ValoTheme LABEL_H2

Introduction

In this page you can find the example usage for com.vaadin.ui.themes ValoTheme LABEL_H2.

Prototype

String LABEL_H2

To view the source code for com.vaadin.ui.themes ValoTheme LABEL_H2.

Click Source Link

Document

Header style for different sections in the application.

Usage

From source file:tad.grupo7.ccamistadeslargas.EventosLayout.java

/**
 * Se muestra el formulario de aadir un nuevo evento.
 *///  www .  j  av  a  2 s . c  o 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.//  ww w .  j a  va2s  .  c  om
 */
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.
 *///from  ww w.j  ava2 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.ListadoLayout.java

/**
 * Muestra una tabla con todos los usuarios.
 *///from w  w w.  jav  a2s  .  c  o  m
private void mostrarListado() {
    removeAllComponents();
    //T?TULO
    CssLayout labels = new CssLayout();
    labels.addStyleName("labels");
    Label l = new Label("Selecciona un usuario para eliminarlo");
    l.setSizeUndefined();
    l.addStyleName(ValoTheme.LABEL_H2);
    l.addStyleName(ValoTheme.LABEL_COLORED);
    //TABLA DE USUARIOS
    Table table = getTablaListado();
    //AADIMOS COMPONENTES
    addComponents(l, table);
    setMargin(true);

}

From source file:tad.grupo7.ccamistadeslargas.PerfilLayout.java

private void mostrarPerfil() {
    //T?TULO/* w w w .ja v a 2  s  .co  m*/
    CssLayout labels = new CssLayout();
    labels.addStyleName("labels");
    Label l = new Label("Perfil");
    l.setSizeUndefined();
    l.addStyleName(ValoTheme.LABEL_H2);
    l.addStyleName(ValoTheme.LABEL_COLORED);
    //FORMULARIO
    TextField nombre = new TextField("Nombre");
    nombre.setValue(usuario.getNombre());
    nombre.setRequired(true);
    TextField password = new TextField("Password");
    password.setValue(usuario.getPassword());
    password.setRequired(true);
    TextField email = new TextField("Email");
    email.setValue(usuario.getEmail());
    email.setEnabled(false);
    Button actualizar = new Button("Actualizar");
    //BOTN ACTUALIZAR
    actualizar.addClickListener(clickEvent -> {
        UsuarioDAO.update(usuario.getId(), nombre.getValue(), password.getValue(), usuario.getEmail());
        Notification n = new Notification("Usuario actualizado", Notification.Type.ASSISTIVE_NOTIFICATION);
        n.setPosition(Position.TOP_CENTER);
        n.show(Page.getCurrent());
        usuario.setNombre(nombre.getValue());
        usuario.setPassword(password.getValue());
    });
    //AADIR COMPONENTES
    FormLayout form = new FormLayout(l, nombre, password, email, actualizar);
    form.setMargin(true);
    addComponents(form);
}

From source file:tad.grupo7.ccamistadeslargas.RegistrarView.java

public RegistrarView() {
    setMargin(true);/* w  w w .  j a  va2 s  . c o  m*/
    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:uk.co.intec.keyDatesApp.pages.HomeView.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  w  ww.j  a v  a2s.  c  o m*/
 */
public void loadContent() {
    if ("Anonymous".equals(GenericDatabaseUtils.getUserName())) {
        final Label warning = new Label();
        warning.setStyleName(ValoTheme.LABEL_H2);
        warning.setStyleName(ValoTheme.LABEL_FAILURE);
        warning.setValue("Anonymous access is not allowed on this application!");
        addComponent(warning);
    } else {
        if (GenericDatabaseUtils.doesDbExist()) {
            final Label intro = new Label();
            intro.setStyleName(ValoTheme.LABEL_H2);
            intro.setValue("Welcome to Key Dates OSGi Application");
            addComponent(intro);
        } else {
            final Label warning = new Label();
            warning.setStyleName(ValoTheme.LABEL_H2);
            warning.setStyleName(ValoTheme.LABEL_FAILURE);
            warning.setContentMode(ContentMode.HTML);
            warning.setValue(
                    "We cannot open the data database. Most likely reasons are:<ul><li>You don't have access to the database, in which case you should contact IT.</li>"
                            + "<li>The Key Dates database has not been set up at the filepath "
                            + AppUtils.getDataDbFilepath()
                            + ". Create the data database at that location or amend the 'dataDbFilePath' context parameter in WebContent > WEB-INF > web.xml of the application and issue 'restart task http' to the Domino server</li></ul>");
            addComponent(warning);
        }
    }
}