com.save.employee.request.ViewRLWindow.java Source code

Java tutorial

Introduction

Here is the source code for com.save.employee.request.ViewRLWindow.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.save.employee.request;

import com.save.common.CommonComboBox;
import com.save.model.LiquidationForm;
import com.save.service.RLService;
import com.save.employee.serviceprovider.RLServiceImpl;
import com.vaadin.ui.Alignment;
import com.vaadin.ui.ComboBox;
import com.vaadin.ui.DateField;
import com.vaadin.ui.FormLayout;
import com.vaadin.ui.HorizontalLayout;
import com.vaadin.ui.TextArea;
import com.vaadin.ui.TextField;
import com.vaadin.ui.Window;
import com.vaadin.ui.themes.ValoTheme;

/**
 *
 * @author jetdario
 */
public class ViewRLWindow extends Window {

    RLService rls = new RLServiceImpl();
    private int employeeId;
    private int requestId;

    TextField controlNo;
    DateField dateOfActivity;
    ComboBox area;
    TextField activity;
    TextField venue;
    TextArea requirements;
    TextField requestLodgingPax;
    TextField requestLodgingBudget;
    TextField requestLodgingAmount;
    TextField requestMealsPax;
    TextField requestMealsBudget;
    TextField requestMealsAmount;
    TextField liquidateLodgingPax;
    TextField liquidateLodgingBudget;
    TextField liquidateLodgingAmount;
    TextField liquidateMealsPax;
    TextField liquidateMealsBudget;
    TextField liquidateMealsAmount;
    TextField reimbursement;
    TextArea others;
    TextField othersAmount;

    public ViewRLWindow(int employeeId, int requestId) {
        this.employeeId = employeeId;
        this.requestId = requestId;

        setCaption("R/L VIEW FORM");
        setWidth("600px");
        setModal(true);
        setResizable(false);
        center();

        setContent(buildFormLayout());
        getContent().setHeightUndefined();
    }

    FormLayout buildFormLayout() {
        FormLayout f = new FormLayout();
        f.setWidth("100%");
        f.setMargin(true);

        LiquidationForm lf = rls.getRLById(getRequestId());

        controlNo = new TextField("Control No.");
        controlNo.setWidth("100%");
        controlNo.addStyleName(ValoTheme.TEXTFIELD_SMALL);
        controlNo.setValue(String.valueOf(lf.getControlNo()));
        controlNo.setEnabled(false);
        f.addComponent(controlNo);

        dateOfActivity = new DateField("Date of Activity: ");
        dateOfActivity.setWidth("100%");
        dateOfActivity.addStyleName(ValoTheme.DATEFIELD_SMALL);
        dateOfActivity.setValue(lf.getDateOfActivity());
        dateOfActivity.setEnabled(false);
        f.addComponent(dateOfActivity);

        area = CommonComboBox.areas();
        area.setWidth("100%");
        area.setValue(lf.getAreaId());
        area.setEnabled(false);
        f.addComponent(area);

        activity = new TextField("Activity: ");
        activity.setWidth("100%");
        activity.addStyleName(ValoTheme.TEXTFIELD_SMALL);
        activity.setValue(lf.getActivity());
        activity.setEnabled(false);
        f.addComponent(activity);

        venue = new TextField("Venue: ");
        venue.setWidth("100%");
        venue.addStyleName(ValoTheme.TEXTFIELD_SMALL);
        venue.setValue(lf.getVenue());
        venue.setEnabled(false);
        f.addComponent(venue);

        requirements = new TextArea("Requirements: ");
        requirements.setWidth("100%");
        requirements.addStyleName(ValoTheme.TEXTAREA_SMALL);
        requirements.setValue(lf.getRequirements());
        requirements.setEnabled(false);
        f.addComponent(requirements);

        HorizontalLayout h1 = new HorizontalLayout();
        h1.setWidth("100%");
        h1.setCaption("Request Lodging");
        h1.addStyleName("light");
        //        h1.setReadOnly(true);

        requestLodgingPax = new TextField();
        requestLodgingPax.setWidth("100%");
        requestLodgingPax.addStyleName(ValoTheme.TEXTFIELD_SMALL);
        requestLodgingPax.addStyleName("align-right");
        requestLodgingPax.setValue("Pax: " + String.valueOf(lf.getLodgingPax()));
        requestLodgingPax.setEnabled(false);
        h1.addComponent(requestLodgingPax);

        requestLodgingBudget = new TextField();
        requestLodgingBudget.setWidth("100%");
        requestLodgingBudget.addStyleName(ValoTheme.TEXTFIELD_SMALL);
        requestLodgingBudget.addStyleName("align-right");
        requestLodgingBudget.setValue("Budget: " + String.valueOf(lf.getLodgingBudget()));
        requestLodgingBudget.setEnabled(false);
        h1.addComponent(requestLodgingBudget);

        requestLodgingAmount = new TextField();
        requestLodgingAmount.setWidth("100%");
        requestLodgingAmount.addStyleName(ValoTheme.TEXTFIELD_SMALL);
        requestLodgingAmount.addStyleName("align-right");
        requestLodgingAmount.setValue("Amount: " + String.valueOf(lf.getLodgingAmount()));
        requestLodgingAmount.setEnabled(false);
        h1.addComponent(requestLodgingAmount);

        f.addComponent(h1);
        f.setComponentAlignment(h1, Alignment.MIDDLE_LEFT);

        HorizontalLayout h2 = new HorizontalLayout();
        h2.setWidth("100%");
        h2.setCaption("Request Meals");
        //        h2.setReadOnly(true);

        requestMealsPax = new TextField();
        requestMealsPax.setWidth("100%");
        requestMealsPax.addStyleName(ValoTheme.TEXTFIELD_SMALL);
        requestMealsPax.addStyleName("align-right");
        requestMealsPax.setValue("Pax: " + String.valueOf(lf.getMealsPax()));
        requestMealsPax.setEnabled(false);
        h2.addComponent(requestMealsPax);

        requestMealsBudget = new TextField();
        requestMealsBudget.setWidth("100%");
        requestMealsBudget.addStyleName(ValoTheme.TEXTFIELD_SMALL);
        requestMealsBudget.addStyleName("align-right");
        requestMealsBudget.setValue("Budget: " + String.valueOf(lf.getMealsBudget()));
        requestMealsBudget.setEnabled(false);
        h2.addComponent(requestMealsBudget);

        requestMealsAmount = new TextField();
        requestMealsAmount.setWidth("100%");
        requestMealsAmount.addStyleName(ValoTheme.TEXTFIELD_SMALL);
        requestMealsAmount.addStyleName("align-right");
        requestMealsAmount.setValue("Amount: " + String.valueOf(lf.getMealsAmount()));
        requestMealsAmount.setEnabled(false);
        h2.addComponent(requestMealsAmount);

        f.addComponent(h2);
        f.setComponentAlignment(h2, Alignment.MIDDLE_LEFT);

        HorizontalLayout h3 = new HorizontalLayout();
        h3.setWidth("100%");
        h3.setCaption("Liquidated Lodging");
        //        h3.setReadOnly(true);

        liquidateLodgingPax = new TextField();
        liquidateLodgingPax.setWidth("100%");
        liquidateLodgingPax.addStyleName(ValoTheme.TEXTFIELD_SMALL);
        liquidateLodgingPax.addStyleName("align-right");
        liquidateLodgingPax.setValue("Pax: " + String.valueOf(lf.getLiquidationLodgingPax()));
        liquidateLodgingPax.setEnabled(false);
        h3.addComponent(liquidateLodgingPax);

        liquidateLodgingBudget = new TextField();
        liquidateLodgingBudget.setWidth("100%");
        liquidateLodgingBudget.addStyleName(ValoTheme.TEXTFIELD_SMALL);
        liquidateLodgingBudget.addStyleName("align-right");
        liquidateLodgingBudget.setValue("Budget: " + String.valueOf(lf.getLiquidationLodgingBudget()));
        liquidateLodgingBudget.setEnabled(false);
        h3.addComponent(liquidateLodgingBudget);

        liquidateLodgingAmount = new TextField();
        liquidateLodgingAmount.setWidth("100%");
        liquidateLodgingAmount.addStyleName(ValoTheme.TEXTFIELD_SMALL);
        liquidateLodgingAmount.addStyleName("align-right");
        liquidateLodgingAmount.setValue("Amount: " + String.valueOf(lf.getLiquidationLodgingAmount()));
        liquidateLodgingAmount.setEnabled(false);
        h3.addComponent(liquidateLodgingAmount);

        f.addComponent(h3);
        f.setComponentAlignment(h3, Alignment.MIDDLE_LEFT);

        HorizontalLayout h4 = new HorizontalLayout();
        h4.setWidth("100%");
        h4.setCaption("Liquidated Meals");
        h4.setReadOnly(true);

        liquidateMealsPax = new TextField();
        liquidateMealsPax.setWidth("100%");
        liquidateMealsPax.addStyleName(ValoTheme.TEXTFIELD_SMALL);
        liquidateMealsPax.addStyleName("align-right");
        liquidateMealsPax.setValue("Pax: " + String.valueOf(lf.getLiquidationMealsPax()));
        liquidateMealsPax.setEnabled(false);
        h4.addComponent(liquidateMealsPax);

        liquidateMealsBudget = new TextField();
        liquidateMealsBudget.setWidth("100%");
        liquidateMealsBudget.addStyleName(ValoTheme.TEXTFIELD_SMALL);
        liquidateMealsBudget.addStyleName("align-right");
        liquidateMealsBudget.setValue("Budget: " + String.valueOf(lf.getLiquidationMealsBudget()));
        liquidateMealsBudget.setEnabled(false);
        h4.addComponent(liquidateMealsBudget);

        liquidateMealsAmount = new TextField();
        liquidateMealsAmount.setWidth("100%");
        liquidateMealsAmount.addStyleName(ValoTheme.TEXTFIELD_SMALL);
        liquidateMealsAmount.addStyleName("align-right");
        liquidateMealsAmount.setValue("Amount: " + String.valueOf(lf.getLiquidationMealsAmount()));
        liquidateMealsAmount.setEnabled(false);
        h4.addComponent(liquidateMealsAmount);

        f.addComponent(h4);
        f.setComponentAlignment(h4, Alignment.MIDDLE_LEFT);

        reimbursement = new TextField("Reimbursement: ");
        reimbursement.setWidth("50%");
        reimbursement.addStyleName(ValoTheme.TEXTFIELD_SMALL);
        reimbursement.setValue(String.valueOf(lf.getReimbursedAmount()));
        reimbursement.setEnabled(false);
        f.addComponent(reimbursement);

        f.addStyleName("light");
        f.setReadOnly(true);

        return f;
    }

    int getEmployeeId() {
        return employeeId;
    }

    int getRequestId() {
        return requestId;
    }
}