Java tutorial
/* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ package com.squadd.UI; import com.squadd.javaBeans.Group; import com.squadd.javaBeans.UserInfoBean; import com.squadd.managers.DBManager; import com.squadd.technical.Display; import com.squadd.technical.ImageGetter; import com.vaadin.ui.Alignment; import com.vaadin.ui.Button; import com.vaadin.ui.Button.ClickListener; import com.vaadin.ui.FormLayout; import com.vaadin.ui.HorizontalLayout; import com.vaadin.ui.Image; import com.vaadin.ui.Label; import com.vaadin.ui.TextField; import com.vaadin.ui.VerticalLayout; import java.util.List; /** * * @author SharkNado */ public class GroupMainInfoLayout extends HorizontalLayout { private Image groupPhoto; private Button uploadPhoto; private Label groupName; private Label placeName; private Label date; private Label description; private Button edit; public GroupMainInfoLayout(Group grp) { groupPhoto = new ImageGetter().get(grp); uploadPhoto = new Button("upload new photo"); edit = new Button("Edit"); configureTextFields(grp); buildLayout(); } private void configureTextFields(Group grp) { String first = ""; String second = ""; String third = ""; String four = ""; if (grp.getDescription() != null) { four = grp.getDescription(); } if (grp.getName() != null) { first = grp.getName(); } if (grp.getPlaceId().getCity() != null) { second = grp.getPlaceId().getCity(); } if (grp.getTime() != null) { third = grp.getTime().toString(); } groupName = new Label("Group Name: " + first); placeName = new Label("Place: " + second); date = new Label("Date: " + third); description = new Label("Description: " + four); } private void buildLayout() { HorizontalLayout knopki = new HorizontalLayout(edit); knopki.setSizeUndefined(); knopki.setSpacing(true); HorizontalLayout hor = new HorizontalLayout(knopki); hor.setWidth(0.4 * Display.width + "px"); hor.setComponentAlignment(knopki, Alignment.TOP_RIGHT); description.setWidth(0.2 * Display.width + "px"); FormLayout data = new FormLayout(groupName, placeName, date, description); HorizontalLayout first = new HorizontalLayout(); groupPhoto.setWidth(0.2 * Display.width + "px"); groupPhoto.setHeight(0.2 * Display.width + "px"); first.addComponent(groupPhoto); HorizontalLayout seventh = new HorizontalLayout(); seventh.setWidth(0.2 * Display.width + "px"); seventh.addComponents(uploadPhoto); uploadPhoto.setSizeUndefined(); seventh.setComponentAlignment(uploadPhoto, Alignment.TOP_CENTER); VerticalLayout lst = new VerticalLayout(); lst.setSpacing(true); lst.addComponents(hor, data); VerticalLayout photoAndUpload = new VerticalLayout(first, seventh); HorizontalLayout photoAndInfo = new HorizontalLayout(photoAndUpload, lst); VerticalLayout content = new VerticalLayout(photoAndInfo); addComponent(content); } public Image getGroupPhoto() { return groupPhoto; } public Button getUploadPhoto() { return uploadPhoto; } public Label getGroupName() { return groupName; } public Label getPlaceName() { return placeName; } public Label getDate() { return date; } public Label getDescriptionGroup() { return description; } public void setGroupPhoto(Image groupPhoto) { this.groupPhoto = groupPhoto; } public void setUploadPhoto(Button uploadPhoto) { this.uploadPhoto = uploadPhoto; } public void setGroupName(Label groupName) { this.groupName = groupName; } public void setPlaceName(Label placeName) { this.placeName = placeName; } public void setDate(Label date) { this.date = date; } public void setDescriptionGroup(Label description) { this.description = description; } public Label getDescr() { return description; } public Button getEdit() { return edit; } }