private Component buildPreferencesTab() { VerticalLayout root = new VerticalLayout(); root.setCaption("Preferences"); root.setIcon(FontAwesome.COGS); root.setSpacing(true); root.setMargin(true); root.setSizeFull(); Label message = new Label("Not implemented in this demo"); message.setSizeUndefined(); message.addStyleName(ValoTheme.LABEL_LIGHT); root.addComponent(message); root.setComponentAlignment(message, Alignment.MIDDLE_CENTER); return root; }
/** @param el */ public BookImage(Books el, String user) { super(); this.Book = el; this.setStyleName("cells"); this.setHeight("250px"); this.setWidth("200px"); rating.setAnimated(true); rating.setCaption(null); rating.setMaxValue(5); rating.setStyleName("rating"); rating.setReadOnly(true); rating_my.setAnimated(true); rating_my.setCaption(null); rating_my.setMaxValue(5); rating_my.setStyleName("rating_my"); IRaitingService iRaitingService = new IRaitingService(); try { double rate = iRaitingService.getRaiting(el.getId()); rating.setReadOnly(false); rating.setValue(rate); rating.setReadOnly(true); double myrate = iRaitingService.getRaiting(user, el.getId()); rating_my.setValue(myrate); } catch (SQLException e) { e.printStackTrace(); } rating_my.addValueChangeListener( e -> { try { Rating rat = iRaitingService.getUser( getUI().getSession().getAttribute("user").toString(), el.getId()); rat.setRaiting(rating_my.getValue()); iRaitingService.update(rat); double rate = iRaitingService.getRaiting(el.getId()); rating.setReadOnly(false); rating.setValue(rate); rating.setReadOnly(true); new Notification(String.valueOf(rate), Notification.Type.TRAY_NOTIFICATION) .show(Page.getCurrent()); } catch (SQLException e1) { e1.printStackTrace(); } }); rating_layout.addComponent(rating); rating_layout.addComponent(rating_my); rating_layout.setComponentAlignment(rating, Alignment.MIDDLE_LEFT); rating_layout.setComponentAlignment(rating_my, Alignment.MIDDLE_LEFT); rating_layout.setStyleName("ratinglayout"); imageEmbedded.setSource(new FileResource(new File(Book.getImage()))); title.setValue(Book.getTitle()); author.setValue(Book.getAuthor()); if (Book.getFile().isEmpty()) buttonDownload.setEnabled(false); buttonDownload.setWidth("80%"); imageEmbedded.setWidth("100%"); imageEmbedded.setHeight("100%"); title.setWidth(null); author.setWidth(null); VerticalLayout bodyLayout = new VerticalLayout(title, author, imageEmbedded); bodyLayout.setExpandRatio(title, 12); bodyLayout.setExpandRatio(author, 8); bodyLayout.setExpandRatio(imageEmbedded, 80); bodyLayout.setSizeFull(); bodyLayout.setComponentAlignment(title, Alignment.MIDDLE_CENTER); bodyLayout.setComponentAlignment(author, Alignment.MIDDLE_CENTER); bodyLayout.setComponentAlignment(imageEmbedded, Alignment.MIDDLE_CENTER); buttonDownload.setStyleName("super-button"); title.setStyleName("name-label"); author.setStyleName("author-label"); this.addComponent(rating_layout); this.addComponent(bodyLayout); this.addComponent(buttonDownload); this.setComponentAlignment(rating_layout, Alignment.TOP_CENTER); this.setComponentAlignment(bodyLayout, Alignment.TOP_CENTER); this.setComponentAlignment(buttonDownload, Alignment.BOTTOM_CENTER); this.setExpandRatio(rating_layout, 5); this.setExpandRatio(bodyLayout, 85); this.setExpandRatio(buttonDownload, 10); StreamResource sr = getStream(); FileDownloader fileDownloader = new FileDownloader(sr); fileDownloader.extend(buttonDownload); bodyLayout.addLayoutClickListener( e -> { BookWin win = new BookWin(this.Book); UI.getCurrent().addWindow(win); }); }
private Component buildProfileTab() { HorizontalLayout root = new HorizontalLayout(); root.setCaption("Profile"); root.setIcon(FontAwesome.USER); root.setWidth(100.0f, Unit.PERCENTAGE); root.setSpacing(true); root.setMargin(true); root.addStyleName("profile-form"); VerticalLayout pic = new VerticalLayout(); pic.setSizeUndefined(); pic.setSpacing(true); Image profilePic = new Image(null, new ThemeResource("img/profile-pic-300px.jpg")); profilePic.setWidth(100.0f, Unit.PIXELS); pic.addComponent(profilePic); Button upload = new Button( "Changeā¦", event -> { Notification.show("Not implemented in this demo"); }); upload.addStyleName(ValoTheme.BUTTON_TINY); pic.addComponent(upload); root.addComponent(pic); FormLayout details = new FormLayout(); details.addStyleName(ValoTheme.FORMLAYOUT_LIGHT); root.addComponent(details); root.setExpandRatio(details, 1); firstNameField = new TextField("First Name"); details.addComponent(firstNameField); lastNameField = new TextField("Last Name"); details.addComponent(lastNameField); titleField = new ComboBox("Title"); titleField.setInputPrompt("Please specify"); titleField.addItem("Mr."); titleField.addItem("Mrs."); titleField.addItem("Ms."); titleField.setNewItemsAllowed(true); details.addComponent(titleField); sexField = new OptionGroup("Sex"); sexField.addItem(Boolean.FALSE); sexField.setItemCaption(Boolean.FALSE, "Female"); sexField.addItem(Boolean.TRUE); sexField.setItemCaption(Boolean.TRUE, "Male"); sexField.addStyleName("horizontal"); details.addComponent(sexField); Label section = new Label("Contact Info"); section.addStyleName(ValoTheme.LABEL_H4); section.addStyleName(ValoTheme.LABEL_COLORED); details.addComponent(section); emailField = new TextField("Email"); emailField.setWidth("100%"); emailField.setRequired(true); emailField.setNullRepresentation(""); details.addComponent(emailField); locationField = new TextField("Location"); locationField.setWidth("100%"); locationField.setNullRepresentation(""); locationField.setComponentError(new UserError("This address doesn't exist")); details.addComponent(locationField); phoneField = new TextField("Phone"); phoneField.setWidth("100%"); phoneField.setNullRepresentation(""); details.addComponent(phoneField); newsletterField = new OptionalSelect<>(); newsletterField.addOption(0, "Daily"); newsletterField.addOption(1, "Weekly"); newsletterField.addOption(2, "Monthly"); details.addComponent(newsletterField); section = new Label("Additional Info"); section.addStyleName(ValoTheme.LABEL_H4); section.addStyleName(ValoTheme.LABEL_COLORED); details.addComponent(section); websiteField = new TextField("Website"); websiteField.setInputPrompt("http://"); websiteField.setWidth("100%"); websiteField.setNullRepresentation(""); details.addComponent(websiteField); bioField = new TextArea("Bio"); bioField.setWidth("100%"); bioField.setRows(4); bioField.setNullRepresentation(""); details.addComponent(bioField); return root; }