List of usage examples for com.vaadin.ui HorizontalLayout HorizontalLayout
public HorizontalLayout()
From source file:com.cerebro.provevaadin.SignIn.java
private VerticalLayout setSecondStep() { VerticalLayout secondStep = new VerticalLayout(); CssLayout header = new CssLayout(); Label title = new Label("Benvenuto " + u.getNomeUtente() + "!"); Label istructions = new Label("Crea il tuo personaggio"); Label step = new Label("2/*"); header.addComponents(title, istructions, step); VerticalLayout body = new VerticalLayout(); Label ageIstruction = new Label("Indica l'et del tuo personaggio in anni"); // Cambiare i parametri in base alla razza Slider age = new Slider(1, 150); age.setImmediate(true);//from w ww .j a v a 2 s.co m age.setSizeFull(); HorizontalLayout ageDescription = new HorizontalLayout(); ageDescription.setHeight("250px"); Label ageText = new Label("Valore dell'et: "); Label ageValue = new Label(age.getValue().toString()); Label periodoVita = new Label(""); ageDescription.addComponents(ageText, ageValue, periodoVita); age.addValueChangeListener((Property.ValueChangeEvent event) -> { System.out.println("Valore: " + age.getValue().toString()); ageValue.setValue(age.getValue().toString()); Double value = (100 * (age.getValue()) / (age.getMax())); if (value < 14) { periodoVita.setValue("Bambino"); } else if (value > 14 && value < 24) { periodoVita.setValue("Adolescenza"); } else if (value > 24 && value < 73) { periodoVita.setValue("Et adulta"); } else if (value > 73) { periodoVita.setValue("Et anziana"); } }); body.addComponents(ageIstruction, age, ageDescription); CssLayout footer = new CssLayout(); Button next = new Button("Avanti ->"); next.addClickListener((Button.ClickEvent event) -> { u.setEtaPG(age.getValue().toString()); this.setContent(setThirdStep()); }); footer.addComponents(next, createCancelButton()); secondStep.addComponents(header, body, footer); return secondStep; }
From source file:com.cerebro.provevaadin.SignIn.java
private Component setThirdStep() { VerticalLayout thirdStep = new VerticalLayout(); CssLayout header = new CssLayout(); Label title = new Label("Benvenuto " + u.getNomeUtente() + "!"); Label istructions = new Label("Crea il tuo personaggio"); Label step = new Label("3/*"); header.addComponents(title, istructions, step); HorizontalLayout body = new HorizontalLayout(); VerticalLayout carrieraPanel = new VerticalLayout(); ComboBox carriera = new ComboBox("Scegli la tua carriera:"); carriera.addItem("Guerriero"); HorizontalLayout descrizioneCarriera = new HorizontalLayout(); // Comportamento ComboBox carrieraPanel.addComponents(carriera, descrizioneCarriera); VerticalLayout orientamentoPanel = new VerticalLayout(); ComboBox orientamento = new ComboBox("Scegli il tuo orientamento"); orientamento.addItem("Buono Ordine"); HorizontalLayout descrizioneOrientamento = new HorizontalLayout(); // Comportamento ComboBox orientamentoPanel.addComponents(orientamento, descrizioneOrientamento); body.addComponents(carrieraPanel, orientamentoPanel); CssLayout footer = new CssLayout(); Button next = new Button("Avanti ->"); next.addClickListener((Button.ClickEvent event) -> { u.setCarrieraPG(carriera.getValue().toString()); u.setOrientamentoPG(orientamento.getValue().toString()); this.setContent(setFourthStep()); });//from w ww. j av a2 s.com footer.addComponents(next, createCancelButton()); thirdStep.addComponents(header, body, footer); return thirdStep; }
From source file:com.cerebro.provevaadin.Start.java
public Start() { InputStream iniFile = VaadinServlet.getCurrent().getServletContext() .getResourceAsStream("/WEB-INF/shiro.ini"); if (iniFile == null) { logger.error("Il file Shiro.ini non esiste"); return;//from w ww.ja v a 2 s . c om } else { logger.info("File presente"); } Ini ini = new Ini(); ini.load(iniFile); Factory<SecurityManager> factory = new IniSecurityManagerFactory(ini); SecurityManager securityManager = factory.getInstance(); SecurityUtils.setSecurityManager(securityManager); HorizontalLayout root = new HorizontalLayout(); root.setWidth("800px"); root.setHeight("600px"); this.addComponent(root); this.setComponentAlignment(root, Alignment.MIDDLE_CENTER); FormLayout loginDiv = new FormLayout(); root.addComponent(loginDiv); username.focus(); errorMessage.setVisible(false); loginDiv.addComponents(username, password, rememberMe, login, errorMessage); login.addClickListener((Button.ClickEvent e) -> { logger.info("Pulsante: " + e.toString()); Subject currentUser = SecurityUtils.getSubject(); UsernamePasswordToken token = new UsernamePasswordToken(username.getValue(), password.getValue()); token.setRememberMe(rememberMe.getValue()); try { currentUser.login(token); if (currentUser.hasRole("firsttime")) { logger.info("Configurazione parametri del primo avvio"); getUI().setContent(new FirstTime()); } else { logger.info("Classe di gioco principale"); getUI().setContent(new Game()); VaadinService.reinitializeSession(VaadinService.getCurrentRequest()); } } catch (Exception ex) { logger.error("Errore nel login: " + ex.getMessage()); username.setValue(""); password.setValue(""); errorMessage.setVisible(true); } }); FormLayout signInForm = new FormLayout(); root.addComponent(signInForm); usernameSignIn.focus(); sesso.addItems("Maschio", "Femmina"); signInForm.addComponents(usernameSignIn, passwordSignIn, passwordConf, nome, cognome, sesso, eta, signIn); signIn.addClickListener((Button.ClickEvent event) -> { logger.info("Iscrizione al sito"); User utente = new User(); utente.setEmail(usernameSignIn.getValue()); utente.setPassword(passwordSignIn.getValue()); utente.setNomeUtente(nome.getValue()); utente.setCognomeUtente(cognome.getValue()); utente.setSessoUtente(sesso.getValue().toString()); utente.setDataNascitaUtente(eta.getValue()); SignIn signInWindow = new SignIn(utente); signInWindow.center(); UI.getCurrent().addWindow(signInWindow); }); }
From source file:com.cms.component.CustomPageTable.java
public HorizontalLayout createControls(String pageSizeDefault) { this.pageSizeDefault = pageSizeDefault; separatorTotal.setImmediate(true);/*w ww. ja v a 2 s . c o m*/ Label itemsPerPageLabel = new Label(BundleUtils.getString("common.table.numberRecord")); for (String numberSize : Constants.PAGE_SIZE_LIST) { itemsPerPageSelect.addItem(numberSize); } itemsPerPageSelect.setImmediate(true); itemsPerPageSelect.setNullSelectionAllowed(false); itemsPerPageSelect.setWidth("50px"); itemsPerPageSelect.addValueChangeListener(new Property.ValueChangeListener() { private static final long serialVersionUID = -2255853716069800092L; @Override public void valueChange(com.vaadin.data.Property.ValueChangeEvent event) { setPageLength(Integer.valueOf(String.valueOf(event.getProperty().getValue()))); firePagedChangedEvent(); } }); itemsPerPageSelect.select(pageSizeDefault); Label pageLabel = new Label(BundleUtils.getString("common.table.page"), ContentMode.HTML); final TextField currentPageTextField = new TextField(); currentPageTextField.setValue(String.valueOf(getCurrentPage())); currentPageTextField.setConverter(Integer.class); currentPageTextField .addValidator(new IntegerRangeValidator("Wrong page number", 1, getTotalAmountOfPages())); Label separatorLabel = new Label(" / ", ContentMode.HTML); final Label totalPagesLabel = new Label(String.valueOf(getTotalAmountOfPages()), ContentMode.HTML); currentPageTextField.setStyleName(Reindeer.TEXTFIELD_SMALL); currentPageTextField.setImmediate(true); currentPageTextField.addValueChangeListener(new Property.ValueChangeListener() { private static final long serialVersionUID = -2255853716069800092L; @Override public void valueChange(com.vaadin.data.Property.ValueChangeEvent event) { currentPageTextField.removeAllValidators(); currentPageTextField .addValidator(new IntegerRangeValidator("Wrong page number", 1, getTotalAmountOfPages())); if (Integer.valueOf(String.valueOf(currentPageTextField.getValue())) <= getTotalAmountOfPages()) { int page = Integer.valueOf(String.valueOf(currentPageTextField.getValue())); setCurrentPage(page); } } }); pageLabel.setWidth(null); currentPageTextField.setWidth("30px"); separatorLabel.setWidth(null); totalPagesLabel.setWidth(null); HorizontalLayout controlBar = new HorizontalLayout(); HorizontalLayout pageSize = new HorizontalLayout(); HorizontalLayout pageManagement = new HorizontalLayout(); final Button first = new Button("<<", new Button.ClickListener() { private static final long serialVersionUID = -355520120491283992L; @Override public void buttonClick(Button.ClickEvent event) { setCurrentPage(0); } }); previous = new Button("<", new Button.ClickListener() { private static final long serialVersionUID = -355520120491283992L; @Override public void buttonClick(Button.ClickEvent event) { previousPage(); } }); final Button next = new Button(">", new Button.ClickListener() { private static final long serialVersionUID = -1927138212640638452L; @Override public void buttonClick(Button.ClickEvent event) { nextPage(); } }); final Button last = new Button(">>", new Button.ClickListener() { private static final long serialVersionUID = -355520120491283992L; @Override public void buttonClick(Button.ClickEvent event) { setCurrentPage(getTotalAmountOfPages()); } }); first.setStyleName(Reindeer.BUTTON_LINK); previous.setStyleName(Reindeer.BUTTON_LINK); next.setStyleName(Reindeer.BUTTON_LINK); last.setStyleName(Reindeer.BUTTON_LINK); itemsPerPageLabel.addStyleName("pagedtable-itemsperpagecaption"); itemsPerPageSelect.addStyleName("pagedtable-itemsperpagecombobox"); pageLabel.addStyleName("pagedtable-pagecaption"); currentPageTextField.addStyleName("pagedtable-pagefield"); separatorLabel.addStyleName("pagedtable-separator"); separatorTotal.addStyleName("pagedtable-separator"); totalPagesLabel.addStyleName("pagedtable-total"); first.addStyleName("pagedtable-first"); previous.addStyleName("pagedtable-previous"); next.addStyleName("pagedtable-next"); last.addStyleName("pagedtable-last"); itemsPerPageLabel.addStyleName("pagedtable-label"); itemsPerPageSelect.addStyleName("pagedtable-combobox"); pageLabel.addStyleName("pagedtable-label"); currentPageTextField.addStyleName("pagedtable-label"); separatorLabel.addStyleName("pagedtable-label"); separatorTotal.addStyleName("pagedtable-label"); totalPagesLabel.addStyleName("pagedtable-label"); first.addStyleName("pagedtable-button"); previous.addStyleName("pagedtable-button"); next.addStyleName("pagedtable-button"); last.addStyleName("pagedtable-button"); pageSize.addComponent(itemsPerPageLabel); pageSize.addComponent(itemsPerPageSelect); Label separator = new Label(" / ", ContentMode.HTML); pageSize.addComponent(separator); pageSize.addComponent(separatorTotal); pageSize.setComponentAlignment(itemsPerPageLabel, Alignment.MIDDLE_LEFT); pageSize.setComponentAlignment(itemsPerPageSelect, Alignment.MIDDLE_LEFT); pageSize.setComponentAlignment(separator, Alignment.MIDDLE_LEFT); pageSize.setComponentAlignment(separatorTotal, Alignment.MIDDLE_LEFT); pageSize.setSpacing(true); pageManagement.addComponent(first); pageManagement.addComponent(previous); pageManagement.addComponent(pageLabel); pageManagement.addComponent(currentPageTextField); pageManagement.addComponent(separatorLabel); pageManagement.addComponent(totalPagesLabel); pageManagement.addComponent(next); pageManagement.addComponent(last); pageManagement.setComponentAlignment(first, Alignment.MIDDLE_LEFT); pageManagement.setComponentAlignment(previous, Alignment.MIDDLE_LEFT); pageManagement.setComponentAlignment(pageLabel, Alignment.MIDDLE_LEFT); pageManagement.setComponentAlignment(currentPageTextField, Alignment.MIDDLE_LEFT); pageManagement.setComponentAlignment(separatorLabel, Alignment.MIDDLE_LEFT); pageManagement.setComponentAlignment(totalPagesLabel, Alignment.MIDDLE_LEFT); pageManagement.setComponentAlignment(next, Alignment.MIDDLE_LEFT); pageManagement.setComponentAlignment(last, Alignment.MIDDLE_LEFT); pageManagement.setWidth(null); pageManagement.setSpacing(true); controlBar.addComponent(pageSize); controlBar.addComponent(pageManagement); controlBar.setComponentAlignment(pageManagement, Alignment.MIDDLE_CENTER); controlBar.setWidth("100%"); controlBar.setExpandRatio(pageSize, 1); addListener(new PageChangeListener() { @Override public void pageChanged(PagedTableChangeEvent event) { int abc = event.getCurrentPage(); first.setEnabled(container.getStartIndex() > 0); previous.setEnabled(container.getStartIndex() > 0); next.setEnabled(container.getStartIndex() < container.getRealSize() - getPageLength()); last.setEnabled(container.getStartIndex() < container.getRealSize() - getPageLength()); currentPageTextField.setValue(String.valueOf(getCurrentPage())); totalPagesLabel.setValue(String.valueOf(getTotalAmountOfPages())); if (resizePage) { int lenght = getPageLength(); int a = lenght % 5; int b = lenght / 5; if (a != 0) { int pageLenght = 5 * (b + 1); itemsPerPageSelect.setValue(pageLenght); } } separatorTotal.setValue(String.valueOf(container.getRealSize())); } }); return controlBar; }
From source file:com.cms.component.WindowProgress.java
public WindowProgress(String caption) { setClosable(false);//w w w . j a va 2 s . co m setReadOnly(true); setResizable(false); setWidth("-1px"); setHeight("-1px"); setModal(true); // setStyleName("loading-window"); HorizontalLayout horizontalLayout = new HorizontalLayout(); horizontalLayout.setWidth("-1px"); horizontalLayout.setHeight("-1px"); horizontalLayout.setSpacing(true); horizontalLayout.setMargin(true); pb = new ProgressBar(); pb.setIndeterminate(true); lb = new Label(); lb.setValue(BundleUtils.getString("Running")); horizontalLayout.addComponent(pb); horizontalLayout.addComponent(lb); setContent(horizontalLayout); }
From source file:com.cms.component.WindowProgress.java
public WindowProgress() { setClosable(false);/* ww w . ja v a 2s . c o m*/ setReadOnly(true); setResizable(false); setWidth("-1px"); setHeight("-1px"); setModal(true); // setStyleName("loading-window"); HorizontalLayout horizontalLayout = new HorizontalLayout(); horizontalLayout.setWidth("-1px"); horizontalLayout.setHeight("-1px"); horizontalLayout.setSpacing(true); horizontalLayout.setMargin(true); pb = new ProgressBar(); pb.setIndeterminate(true); lb = new Label(); lb.setValue(BundleUtils.getString("Running")); horizontalLayout.addComponent(pb); horizontalLayout.addComponent(lb); setContent(horizontalLayout); }
From source file:com.cms.utils.ComboComponent.java
public ComboComponent(String all, String vaDefault, List<AppParamsDTO> appPatamDTO, String parType) { if (DataUtil.isListNullOrEmpty(appPatamDTO)) { appPatamDTO = Lists.newArrayList(); }/*ww w .j av a 2s . c om*/ Layout layout = new HorizontalLayout(); final BeanItemContainer<AppParamsDTO> container = new BeanItemContainer<AppParamsDTO>(AppParamsDTO.class); parType = parType.replace('_', '.').toLowerCase() + "."; if (appPatamDTO != null && appPatamDTO.size() > 0) { for (int i = 0; i < appPatamDTO.size(); i++) { if (appPatamDTO.get(i).getParCode().equalsIgnoreCase(vaDefault) && !DataUtil.isStringNullOrEmpty(vaDefault)) { appPatamDTO.get(i) .setDisplayName(BundleUtils.getString(parType + appPatamDTO.get(i).getParName())); objDefault = appPatamDTO.get(i); } } } // select all if (!DataUtil.isStringNullOrEmpty(all)) { objall.setDisplayName(BundleUtils.getString(parType + all)); appPatamDTO.add(0, objall); } container.addAll(appPatamDTO); combo = new ComboBox("", container); layout.addComponent(combo); combo.setItemCaptionPropertyId("valueLangView"); combo.setNullSelectionAllowed(false); // default if (!DataUtil.isStringNullOrEmpty(all)) { combo.setValue(objall); } else if (objDefault != null && !DataUtil.isStringNullOrEmpty(vaDefault)) { combo.setValue(objDefault); } setCompositionRoot(layout); setSizeFull(); }
From source file:com.cms.utils.ComboComponent.java
public void fillDataCombo(ComboBox combo, String addAll, String valueDefault, List<AppParamsDTO> appPatamDTO, String parType) {//from ww w . jav a2s . c o m if (DataUtil.isListNullOrEmpty(appPatamDTO)) { appPatamDTO = Lists.newArrayList(); } List<AppParamsDTO> appPatamDTOs = Lists.newArrayList(); appPatamDTOs.addAll(appPatamDTO); Layout layout = new HorizontalLayout(); final BeanItemContainer<AppParamsDTO> container = new BeanItemContainer<AppParamsDTO>(AppParamsDTO.class); parType = parType.replace('_', '.').toLowerCase() + "."; //Set gia tri if (appPatamDTOs.size() > 0) { String displayName; for (int i = 0; i < appPatamDTOs.size(); i++) { displayName = BundleUtils.getString(parType + appPatamDTOs.get(i).getParCode()); displayName = displayName.contains(parType) ? appPatamDTO.get(i).getParName() : displayName; appPatamDTOs.get(i).setDisplayName(displayName); if (!DataUtil.isStringNullOrEmpty(valueDefault) && appPatamDTOs.get(i).getParCode().equalsIgnoreCase(valueDefault)) { objDefault = appPatamDTOs.get(i); } } } // Them gia tri if (!DataUtil.isStringNullOrEmpty(addAll)) { objall.setDisplayName(BundleUtils.getString(addAll)); appPatamDTOs.add(0, objall); } container.addAll(appPatamDTOs); combo.setFilteringMode(FilteringMode.CONTAINS); combo.setContainerDataSource(container); combo.setItemCaptionPropertyId("displayName"); combo.setNullSelectionAllowed(false); // default if (!DataUtil.isStringNullOrEmpty(valueDefault)) { combo.setValue(objDefault); } else if (!DataUtil.isStringNullOrEmpty(addAll)) { combo.setValue(objall); } }
From source file:com.coatl.pruebas.datastore.DataStoreUI.java
@Override protected void init(VaadinRequest vaadinRequest) { this.principal = new VerticalLayout(); {/*from w w w. j a va 2 s . c o m*/ principal.addComponent(new Label("Pruebas de DataStore")); HorizontalLayout superior = new HorizontalLayout(); principal.addComponent(superior); this.forma = new FormLayout(); superior.addComponent(forma); { this.tabla = new TextField("Tabla"); tabla.setValue("iq3_usuarios"); forma.addComponents(tabla); this.nombre = new TextField("Nombre"); forma.addComponents(nombre); this.ap1 = new TextField("Apellido Paterno"); forma.addComponents(ap1); this.ap2 = new TextField("Apellido Materno"); forma.addComponents(ap2); this.renglones = new Label("Renglones"); forma.addComponents(renglones); } FormLayout botones = new FormLayout(); /* botones.addComponent(new Label(" ")); botones.addComponent(new Label("Acciones:")); */ superior.addComponent(botones); Button recargar = new Button("Recargar"); botones.addComponent(recargar); recargar.addClickListener(new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { listarObjetos(); } }); Button guardar = new Button("Guardar"); botones.addComponent(guardar); guardar.addClickListener(new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { Map m = new HashMap(); m.put("nombre", nombre.getValue()); m.put("ap1", ap1.getValue()); m.put("ap2", ap2.getValue()); m.put("id", nombre.getValue()); IU7.ds.guardar(tabla.getValue(), m); System.out.println("Objeto guardado"); listarObjetos(); } }); Button borrar = new Button("Borrar"); botones.addComponent(borrar); borrar.addClickListener(new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { borrar(); } }); Button mil = new Button("Hacer 1,000"); botones.addComponent(mil); mil.addClickListener(new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { for (int i = 0; i < 1000; i++) { Map m = new HashMap(); String id = "ID_" + i + "_" + Math.random(); m.put("id", id); m.put("nombre", "Nombre_" + id + "_" + Math.random()); m.put("ap1", "Ap1_" + id + "_" + Math.random()); m.put("ap2", "Ap2_" + id + "_" + Math.random()); IU7.ds.guardar(tabla.getValue(), m); System.out.println(" >" + id); } } }); } VerticalSplitPanel vsl = new VerticalSplitPanel(); setContent(vsl); vsl.setFirstComponent(principal); grid.setSizeFull(); grid.setComponenteSuperior(new Label("primer panel")); //grid.setComponenteMedio(new Label("segundo panel")); //grid.setComponenteInferior(new Label("tercer panel")); grid.setNombreTabla(tabla.getValue()); grid.setColumnas("id,nombre,ap1,ap2"); grid.setColumnasVisibles("nombre,ap1,ap2"); vsl.setSecondComponent(grid); //grid.setComponenteMedio(grid); this.listarObjetos(); }
From source file:com.coatl.vaadin.abc.ixABCDialogos.java
ixDefinicionDeForma getForma(String forma, String tipo) { Stack<AbstractComponent> pila = new Stack(); Map<String, AbstractComponent> componentes = new HashMap(); AbstractComponent ultimo = null;/* w w w . j av a 2 s .c o m*/ String[] cmds = forma.split(" "); for (String cmd : cmds) { cmd = cmd.trim(); if (!cmd.equals("")) { //System.out.println("CMD> [" + cmd + "]"); if (cmd.equals("bConfBorrar")) { agregar(pila, getbConfBorrar()); } else if (cmd.equals("bBorrar")) { agregar(pila, getbBorrar()); } else if (cmd.equals("bGuardar")) { agregar(pila, getbGuardar()); } else if (cmd.equals("bCrear")) { agregar(pila, getbCrear()); } else if (cmd.startsWith("H")) { HorizontalLayout hl = new HorizontalLayout(); if (cmd.contains("m")) { hl.setMargin(true); } agregar(pila, hl); } else if (cmd.startsWith("V")) { VerticalLayout vl = new VerticalLayout(); if (cmd.contains("m")) { vl.setMargin(true); } agregar(pila, vl); } else if (cmd.startsWith("F")) { FormLayout fl = new FormLayout(); if (cmd.contains("m")) { fl.setMargin(true); } agregar(pila, fl); } else if (cmd.equals(".")) { ultimo = pila.pop(); //System.out.println("Sacando de pila a " + ultimo); } else if (cmd.startsWith("'")) { String txt = cmd.substring(1); while (txt.contains("~")) { txt = txt.replace("~", " "); } Label l = new Label(txt); agregar(pila, l); } else { //System.out.println("Buscando columna [" + cmd + "]"); ixDefinicionDeColumna columna = columnas.get(cmd); String claseControl = columna.getClaseControl(); if (claseControl == null) { claseControl = "com.vaadin.ui.TextField"; } AbstractComponent con = null; try { con = (AbstractComponent) this.getClass().getClassLoader().loadClass(claseControl) .newInstance(); } catch (Exception ex) { System.out.println("ERROR INSTANCIANDO> [" + claseControl + "], " + ex); } con.setCaption(this.getTituloColumna(cmd)); if (con != null) { agregar(pila, con); componentes.put(cmd, con); } if (tipo != null) { if (tipo.toLowerCase().equals("c")) { if (columna.isSoloLecturaCrear() || columna.isSoloLectura()) { con.setReadOnly(true); } } if (tipo.toLowerCase().equals("e") || tipo.toLowerCase().equals("g")) { if (columna.isSoloLecturaGuardar() || columna.isSoloLectura()) { con.setReadOnly(true); } } if (tipo.toLowerCase().equals("b")) { con.setReadOnly(true); } } } } } while (pila.size() > 0) { ultimo = pila.pop(); } ixDefinicionDeForma res = new ixDefinicionDeForma(); res.setComponente(ultimo); res.setComponentes(componentes); return res; }