List of usage examples for com.vaadin.ui Panel Panel
public Panel(String caption)
From source file:org.airline.CelestiaLogin.java
@Override protected void init(VaadinRequest request) { //Vista final para la UI final VerticalLayout layout = new VerticalLayout(); Panel loginPanel = new Panel("Login"); CustomLayout login = new CustomLayout("LoginLayout"); //Seccin de Vista del Login //VerticalLayout login=new VerticalLayout(); Label label = new Label("Iniciar Sesin / Registrarse"); TextField user = new TextField("", "Usuario"); TextField passwd = new TextField("", "Contrasea"); Button init_session = new Button("Iniciar Sesin"); init_session.setStyleName(ValoTheme.BUTTON_PRIMARY); init_session.addClickListener(cliqueo -> { Notification.show("Bienvenido " + user.getValue()); });//from w w w. j a va2 s . co m login.addComponent(label); login.addComponent(user); login.addComponent(passwd); login.addComponent(init_session); login.setWidth("500px"); //login.setMargin(true); login.setResponsive(true); layout.addComponent(login); layout.setComponentAlignment(login, Alignment.MIDDLE_CENTER); setContent(login); }
From source file:org.bitpimp.VaadinCurrencyConverter.MyVaadinApplication.java
License:Apache License
@Override protected void init(VaadinRequest request) { // Set the window or tab title getPage().setTitle("Yahoo Currency Converter"); // Create the content root layout for the UI final FormLayout content = new FormLayout(); content.setMargin(true);/* w w w .jav a 2s. c o m*/ final Panel panel = new Panel(content); panel.setWidth("500"); panel.setHeight("400"); final VerticalLayout root = new VerticalLayout(); root.addComponent(panel); root.setComponentAlignment(panel, Alignment.MIDDLE_CENTER); root.setSizeFull(); root.setMargin(true); setContent(root); content.addComponent(new Embedded("", new ExternalResource("https://vaadin.com/vaadin-theme/images/vaadin/vaadin-logo-color.png"))); content.addComponent(new Embedded("", new ExternalResource("http://images.wikia.com/logopedia/images/e/e4/YahooFinanceLogo.png"))); // Display the greeting final Label heading = new Label("<b>Simple Currency Converter " + "Using YQL/Yahoo Finance Service</b>", ContentMode.HTML); heading.setWidth(null); content.addComponent(heading); // Build the set of fields for the converter form final TextField fromField = new TextField("From Currency", "AUD"); fromField.setRequired(true); fromField.addValidator(new StringLengthValidator(CURRENCY_CODE_REQUIRED, 3, 3, false)); content.addComponent(fromField); final TextField toField = new TextField("To Currency", "USD"); toField.setRequired(true); toField.addValidator(new StringLengthValidator(CURRENCY_CODE_REQUIRED, 3, 3, false)); content.addComponent(toField); final TextField resultField = new TextField("Result"); resultField.setEnabled(false); content.addComponent(resultField); final TextField timeField = new TextField("Time"); timeField.setEnabled(false); content.addComponent(timeField); final Button submitButton = new Button("Submit", new ClickListener() { @Override public void buttonClick(ClickEvent event) { // Do the conversion final String result = converter.convert(fromField.getValue().toUpperCase(), toField.getValue().toUpperCase()); if (result != null) { resultField.setValue(result); timeField.setValue(new Date().toString()); } } }); content.addComponent(submitButton); // Configure the error handler for the UI UI.getCurrent().setErrorHandler(new DefaultErrorHandler() { @Override public void error(com.vaadin.server.ErrorEvent event) { // Find the final cause String cause = "<b>The operation failed :</b><br/>"; Throwable th = Throwables.getRootCause(event.getThrowable()); if (th != null) cause += th.getClass().getName() + "<br/>"; // Display the error message in a custom fashion content.addComponent(new Label(cause, ContentMode.HTML)); // Do the default error handling (optional) doDefault(event); } }); }
From source file:org.bubblecloud.ilves.comment.CommentAddComponent.java
License:Open Source License
/** * The default constructor which instantiates Vaadin * component hierarchy.// ww w. j a v a 2 s.c om */ public CommentAddComponent() { final User user = DefaultSiteUI.getSecurityProvider().getUserFromSession(); final String contextPath = VaadinService.getCurrentRequest().getContextPath(); final Site site = Site.getCurrent(); final Company company = site.getSiteContext().getObject(Company.class); final EntityManager entityManager = site.getSiteContext().getObject(EntityManager.class); final Panel panel = new Panel(site.localize("panel-add-comment")); setCompositionRoot(panel); final VerticalLayout mainLayout = new VerticalLayout(); panel.setContent(mainLayout); mainLayout.setMargin(true); mainLayout.setSpacing(true); final TextArea commentMessageField = new TextArea(site.localize("field-comment-message")); mainLayout.addComponent(commentMessageField); commentMessageField.setWidth(100, Unit.PERCENTAGE); commentMessageField.setRows(3); commentMessageField.setMaxLength(255); final Button addCommentButton = new Button(site.localize("button-add-comment")); mainLayout.addComponent(addCommentButton); if (user == null) { commentMessageField.setEnabled(false); commentMessageField.setInputPrompt(site.localize("message-please-login-to-comment")); addCommentButton.setEnabled(false); } addCommentButton.addClickListener(new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { final String commentMessage = commentMessageField.getValue(); if (StringUtils.isEmpty(commentMessage)) { return; } final Comment comment = new Comment(company, user, contextPath, commentMessage); entityManager.getTransaction().begin(); try { entityManager.persist(comment); entityManager.getTransaction().commit(); commentMessageField.setValue(""); if (commentListComponent != null) { commentListComponent.refresh(); } } finally { if (entityManager.getTransaction().isActive()) { entityManager.getTransaction().rollback(); } } } }); }
From source file:org.bubblecloud.ilves.comment.CommentListComponent.java
License:Open Source License
public void refresh() { final String contextPath = VaadinService.getCurrentRequest().getContextPath(); final Site site = Site.getCurrent(); final Company company = site.getSiteContext().getObject(Company.class); final EntityManager entityManager = site.getSiteContext().getObject(EntityManager.class); final CriteriaBuilder builder = entityManager.getCriteriaBuilder(); final CriteriaQuery<Comment> commentCriteriaQuery = builder.createQuery(Comment.class); final Root<Comment> commentRoot = commentCriteriaQuery.from(Comment.class); commentCriteriaQuery.where(builder.and(builder.equal(commentRoot.get("owner"), company), builder.equal(commentRoot.get("dataId"), contextPath))); commentCriteriaQuery.orderBy(builder.asc(commentRoot.get("created"))); final TypedQuery<Comment> commentTypedQuery = entityManager.createQuery(commentCriteriaQuery); final List<Comment> commentList = commentTypedQuery.getResultList(); final Panel panel = new Panel(site.localize("panel-comments")); setCompositionRoot(panel);//from w w w . jav a2 s. co m final GridLayout gridLayout = new GridLayout(3, commentList.size() + 1); panel.setContent(gridLayout); gridLayout.setSpacing(true); gridLayout.setMargin(true); gridLayout.setColumnExpandRatio(0, 0.0f); gridLayout.setColumnExpandRatio(1, 0.1f); gridLayout.setColumnExpandRatio(2, 0.9f); final Label authorHeaderLabel = new Label(); authorHeaderLabel.setStyleName(ValoTheme.LABEL_BOLD); authorHeaderLabel.setValue(site.localize("column-header-author")); gridLayout.addComponent(authorHeaderLabel, 0, 0, 1, 0); final Label commentHeaderLabel = new Label(); commentHeaderLabel.setStyleName(ValoTheme.LABEL_BOLD); commentHeaderLabel.setValue(site.localize("column-header-comment")); gridLayout.addComponent(commentHeaderLabel, 2, 0); for (int i = 0; i < commentList.size(); i++) { final Comment comment = commentList.get(i); final Link authorImageLink = GravatarUtil.getGravatarImageLink(comment.getAuthor().getEmailAddress()); gridLayout.addComponent(authorImageLink, 0, i + 1); final Label authorLabel = new Label(); final String authorName = comment.getAuthor().getFirstName(); authorLabel.setValue(authorName); gridLayout.addComponent(authorLabel, 1, i + 1); final Label messageLabel = new Label(); messageLabel.setValue(comment.getMessage()); gridLayout.addComponent(messageLabel, 2, i + 1); } }
From source file:org.casbah.ui.MainCAView.java
License:Open Source License
public void init() throws CAProviderException { final X509Certificate caCert = provider.getCACertificate(); Panel panel = new Panel("CA Details"); VerticalLayout mainLayout = new VerticalLayout(); panel.setContent(mainLayout);// w w w . j a v a 2 s. com mainLayout.setSizeFull(); VerticalLayout caInfo = new VerticalLayout(); TextField name = new TextField("Distinguished Name"); String nameValue = caCert.getSubjectX500Principal().getName(); name.setValue(nameValue); name.setColumns(50); name.setReadOnly(true); TextField issuer = new TextField("Issuer"); issuer.setColumns(50); issuer.setValue(caCert.getIssuerX500Principal().getName()); issuer.setReadOnly(true); DateField expDate = new DateField("Expiration Date"); expDate.setResolution(DateField.RESOLUTION_SEC); expDate.setValue(caCert.getNotAfter()); expDate.setReadOnly(true); TextField serial = new TextField("Serial"); serial.setValue(caCert.getSerialNumber().toString(16)); serial.setReadOnly(true); caInfo.addComponent(name); caInfo.addComponent(issuer); caInfo.addComponent(expDate); caInfo.addComponent(serial); caInfo.setSizeFull(); HorizontalLayout caButtons = new HorizontalLayout(); caButtons.addComponent(new Button("View Certificate", new Button.ClickListener() { private static final long serialVersionUID = 1L; public void buttonClick(ClickEvent event) { try { showEncodedCertificate(caCert, caCert.getSerialNumber().toString(16)); } catch (CAProviderException e) { e.printStackTrace(); } } })); caButtons.addComponent(new Button("Download Certificate", new Button.ClickListener() { private static final long serialVersionUID = 1L; public void buttonClick(ClickEvent event) { try { downloadEncodedCertificate(caCert, caCert.getSerialNumber().toString(16)); } catch (CAProviderException e) { e.printStackTrace(); } } })); caButtons.addComponent(new Button("Sign a CSR", new Button.ClickListener() { private static final long serialVersionUID = 1L; public void buttonClick(ClickEvent event) { try { uploadAndSignCsr(); } catch (CAProviderException pe) { pe.printStackTrace(); } } })); caButtons.addComponent(new Button("Get CRL", new Button.ClickListener() { private static final long serialVersionUID = 1L; @Override public void buttonClick(ClickEvent event) { try { downloadCrlList(provider.getLatestCrl(false)); } catch (CAProviderException pe) { logger.log(Level.SEVERE, "Could not retrieve CRL", pe); getWindow().showNotification("An error occurred while retrieving the CRL", Notification.TYPE_ERROR_MESSAGE); } } })); panel.addComponent(caInfo); panel.addComponent(caButtons); panel.setSizeFull(); setSizeFull(); setCompositionRoot(panel); }
From source file:org.characterbuilder.pages.LoginPage.java
private void addPost(String header, String content, Timestamp timestamp) { VerticalLayout vl = new VerticalLayout(); vl.addComponent(new Label("<h3>" + header + "</h3>", Label.CONTENT_XHTML)); vl.addComponent(new Label("<p><b>Posted:</b> " + timestamp.toString().substring(0, 16) + "</p>", Label.CONTENT_XHTML)); vl.addComponent(new Label(content, Label.CONTENT_PREFORMATTED)); Panel p = new Panel(vl); p.setSizeUndefined();//w ww . j a va2 s .c om newslayLayout.addComponent(p); }