List of usage examples for com.vaadin.ui Label Label
public Label(String text)
From source file:com.cerebro.provevaadin.Game.java
public Game() { Subject currentUser = SecurityUtils.getSubject(); this.addComponent(new Label("Area di gioco")); Button logout = new Button("Esci"); this.addComponent(logout); logout.addClickListener((Button.ClickEvent e) -> { logger.info("Esco dall'applicazione"); logger.info("Pulsante: " + e.toString()); SecurityUtils.getSubject().logout(); UI.getCurrent().getSession().close(); UI.getCurrent().getPage().setLocation(""); });//from www .jav a 2 s .c o m }
From source file:com.cerebro.provevaadin.Mappa.java
public Mappa(User user) { Label ultimoLuogo = new Label(user.getUltimoLuogoPG()); ComboBox elencoLuoghi = new ComboBox(); elencoLuoghi.addItems("Luogo A", "Luogo B"); elencoLuoghi.addValueChangeListener((Property.ValueChangeEvent event) -> { System.out.println("Cambio luogo, vai a: " + elencoLuoghi.getValue().toString()); user.setUltimoLuogo(elencoLuoghi.getValue().toString()); });// w ww . j a v a 2s . c om addComponents(ultimoLuogo, elencoLuoghi); }
From source file:com.cerebro.provevaadin.Secure.java
public Secure() { HorizontalLayout top = new HorizontalLayout(); this.addComponent(top); top.addComponent(new Label("Area sicura")); VerticalLayout content = new VerticalLayout(); this.addComponent(content); Navigator nav = new Navigator(UI.getCurrent(), content); nav.setErrorView(new ErrorView()); nav.addView("", new HomeView()); nav.navigateTo(""); Button logout = new Button("Logout"); logout.addClickListener((Button.ClickEvent event) -> { System.out.println("Esco dalla sessione"); SecurityUtils.getSubject().logout(); UI.getCurrent().getSession().close(); UI.getCurrent().getPage().setLocation(""); });/*from w ww. jav a2s.c o m*/ top.addComponent(logout); }
From source file:com.cerebro.provevaadin.SignIn.java
private VerticalLayout setFirstStep() { VerticalLayout firstStep = 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("1/*"); header.addComponents(title, istructions, step); HorizontalLayout body = new HorizontalLayout(); FormLayout datiIniziali = new FormLayout(); TextField nomePG = new TextField("Nome del Personaggio"); TextField cognomePG = new TextField("Cognome del Personaggio"); OptionGroup sessoPG = new OptionGroup("Sesso del Personaggio"); sessoPG.addItems("Maschio", "Femmina"); ComboBox razzaPG = new ComboBox("Razza"); datiIniziali.addComponents(nomePG, cognomePG, sessoPG, razzaPG); HorizontalLayout descrizioneRazza = new HorizontalLayout(); descrizioneRazza.setWidth(datiIniziali.getWidth(), datiIniziali.getWidthUnits()); // Dettagli di popolazione e comportamento ComboBox razzaPG.addItem("Essere umano"); body.addComponents(datiIniziali, descrizioneRazza); CssLayout footer = new CssLayout(); Button next = new Button("Avanti ->"); next.addClickListener((Button.ClickEvent event) -> { u.setNomePG(nomePG.getValue());//from w ww . j a v a 2 s . c o m u.setCognomePG(cognomePG.getValue()); u.setSessoPG(sessoPG.getValue().toString()); u.setRazzaPG(razzaPG.getValue().toString()); this.setContent(setSecondStep()); }); footer.addComponents(next, createCancelButton()); firstStep.addComponents(header, body, footer); return firstStep; }
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 w w . j a v a 2 s . c om*/ 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()); });// w w w . jav a2s.c om footer.addComponents(next, createCancelButton()); thirdStep.addComponents(header, body, footer); return thirdStep; }
From source file:com.cerebro.provevaadin.SignIn.java
private Component setFourthStep() { VerticalLayout fourthStep = 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); CssLayout body = new CssLayout(); Label resoconto = new Label("Stai per registrare il seguente personaggio: "); Label nomePG = new Label(u.getNomePG()); CssLayout footer = new CssLayout(); Button next = new Button("Fine"); next.addClickListener((Button.ClickEvent event) -> { // Salvare i dati nel database, inviare la mail, rimandare all'ultima pagina this.setContent(setFourthStep()); });//from ww w .j a v a 2 s. c om footer.addComponents(next, createCancelButton()); fourthStep.addComponents(header, body, footer); return fourthStep; }
From source file:com.cms.component.CollapseablePanel.java
void draw(String title, Component body) { CssLayout titleLayout = new CssLayout(); titleLayout.addStyleName("collapsablebox-title"); titleLayout.addComponent(new Label(title)); titleLayout.addListener(new LayoutClickListener() { private static final long serialVersionUID = -4750845792730551399L; @Override// w ww .j a v a 2s. c om public void layoutClick(LayoutClickEvent event) { toggleBodyVisible(); } }); bodyContainer = new CssLayout(); bodyContainer.addStyleName("collapsablebox-body"); bodyContainer.addComponent(body); root.addComponent(titleLayout); root.addComponent(bodyContainer); }
From source file:com.cms.component.CustomPageTable.java
public HorizontalLayout createControls(String pageSizeDefault) { this.pageSizeDefault = pageSizeDefault; separatorTotal.setImmediate(true);//from w w w. ja va 2s . 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.utils.ConfirmWindown.java
public ConfirmWindown(String caption, String question, String yes, String no) { setCaption(caption);//from w ww . j a va 2 s . c o m btnYes.setCaption(yes); btnYes.focus(); btnNo.setCaption(no); setModal(true); center(); buttonsLayout.addComponent(btnYes); buttonsLayout.setComponentAlignment(btnYes, Alignment.MIDDLE_CENTER); buttonsLayout.addComponent(btnNo); buttonsLayout.setComponentAlignment(btnNo, Alignment.MIDDLE_CENTER); layout.addComponent(new Label(question)); layout.addComponent(buttonsLayout); setContent(layout); layout.setMargin(true); buttonsLayout.setMargin(true); buttonsLayout.setWidth("100%"); setWidth("300px"); setHeight("160px"); setResizable(false); btnYes.addClickListener(new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { decision.yes(event); close(); } }); btnNo.addClickListener(new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { decision.no(event); close(); } }); addShortcutListener(new ShortcutListener("Close", ShortcutAction.KeyCode.ESCAPE, null) { @Override public void handleAction(Object sender, Object target) { close(); } }); UI.getCurrent().addWindow(this); }