com.squadd.UI.EditVersionLayout.java Source code

Java tutorial

Introduction

Here is the source code for com.squadd.UI.EditVersionLayout.java

Source

/*
 * 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.technical.Display;
import com.squadd.technical.ImageGetter;
import com.vaadin.ui.Alignment;
import com.vaadin.ui.Button;
import com.vaadin.ui.DateField;
import com.vaadin.ui.FormLayout;
import com.vaadin.ui.HorizontalLayout;
import com.vaadin.ui.Image;
import com.vaadin.ui.Label;
import com.vaadin.ui.TextArea;
import com.vaadin.ui.TextField;
import com.vaadin.ui.VerticalLayout;

/**
 *
 * @author SharkNado
 */
public class EditVersionLayout extends HorizontalLayout {
    private Image groupPhoto;
    private Button uploadPhoto;
    private TextField groupName;
    private TextField placeName;
    private DateField date;
    private TextArea description;
    private Button save;
    private Button cancel;
    private Group group;

    public EditVersionLayout(Group group) {
        this.group = group;
        groupPhoto = new ImageGetter().get(group);
        uploadPhoto = new Button("upload new photo");
        groupName = new TextField("Group Name: ");
        groupName.setValue((group.getName() == null) ? "" : group.getName());
        placeName = new TextField("Place: ");
        placeName.setValue((group.getPlaceId().getCity() == null) ? "" : group.getPlaceId().getCity());
        date = new DateField("Date: ");
        date.setValue(group.getTime());
        description = new TextArea("Description: ");
        description.setWordwrap(true);
        description.setValue((group.getDescription() == null) ? "" : group.getDescription());
        save = new Button("save");
        cancel = new Button("cancel");
        buildLayout();
    }

    private void buildLayout() {
        HorizontalLayout knopki = new HorizontalLayout(save, cancel);
        knopki.setSizeUndefined();
        knopki.setSpacing(true);
        HorizontalLayout hor = new HorizontalLayout(knopki);
        hor.setWidth(0.4 * Display.width + "px");
        hor.setComponentAlignment(knopki, Alignment.TOP_RIGHT);
        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);
        VerticalLayout lst = new VerticalLayout();
        lst.setSpacing(true);
        lst.addComponents(hor, data);

        HorizontalLayout uploadAndUsers = new HorizontalLayout(uploadPhoto);
        uploadAndUsers.setWidth(0.2 * Display.width + "px");
        uploadPhoto.setSizeUndefined();
        uploadAndUsers.setComponentAlignment(uploadPhoto, Alignment.MIDDLE_CENTER);
        VerticalLayout vert = new VerticalLayout(groupPhoto, uploadAndUsers);
        HorizontalLayout second = new HorizontalLayout(vert);

        HorizontalLayout photoAndInfo = new HorizontalLayout(second, lst);

        addComponent(photoAndInfo);
    }

    public Image getGroupPhoto() {
        return groupPhoto;
    }

    public Button getUploadPhoto() {
        return uploadPhoto;
    }

    public TextField getGroupName() {
        return groupName;
    }

    public TextField getPlaceName() {
        return placeName;
    }

    public DateField getDate() {
        return date;
    }

    public Button getSave() {
        return save;
    }

    public Button getCancel() {
        return cancel;
    }

    public void setGroupPhoto(Image groupPhoto) {
        this.groupPhoto = groupPhoto;
    }

    public void setUploadPhoto(Button uploadPhoto) {
        this.uploadPhoto = uploadPhoto;
    }

    public void setGroupName(TextField groupName) {
        this.groupName = groupName;
    }

    public void setPlaceName(TextField placeName) {
        this.placeName = placeName;
    }

    public void setDate(DateField date) {
        this.date = date;
    }

    public void setSave(Button save) {
        this.save = save;
    }

    public void setCancel(Button cancel) {
        this.cancel = cancel;
    }

    public TextArea getDescr() {
        return description;
    }

}