Example usage for com.vaadin.ui GridLayout setSpacing

List of usage examples for com.vaadin.ui GridLayout setSpacing

Introduction

In this page you can find the example usage for com.vaadin.ui GridLayout setSpacing.

Prototype

@Override
    public void setSpacing(boolean spacing) 

Source Link

Usage

From source file:com.openhris.employee.others.OtherInformation.java

Component component() {
    GridLayout glayout = new GridLayout(2, 13);
    glayout.setSpacing(true);
    glayout.setWidth("600px");
    glayout.setHeight("100%");

    tinField = new HRISTextField("TIN: ");
    glayout.addComponent(tinField, 0, 0);

    Button tinBtn = new Button("UPDATE TIN NO.");
    tinBtn.setWidth("100%");
    tinBtn.addListener(buttonClickListener);
    glayout.addComponent(tinBtn, 1, 0);/*from w w  w  .j  a v  a  2 s  . com*/
    glayout.setComponentAlignment(tinBtn, Alignment.BOTTOM_CENTER);
    if (GlobalVariables.getUserRole().equals("administrator") || GlobalVariables.getUserRole().equals("hr")) {
        tinBtn.setEnabled(true);
    } else {
        tinBtn.setEnabled(false);
    }

    glayout.addComponent(new Label("<HR>", Label.CONTENT_XHTML), 0, 1, 1, 1);

    employeeDependent = dropDown.populateTotalDependent("Employee's Dependent");
    employeeDependent.setWidth("100%");
    glayout.addComponent(employeeDependent, 0, 2);

    Button edBtn = new Button("UPDATE EMPLOYEE's DEPENDENT");
    edBtn.setWidth("100%");
    edBtn.addListener(buttonClickListener);
    glayout.addComponent(edBtn, 1, 2);
    glayout.setComponentAlignment(edBtn, Alignment.BOTTOM_CENTER);
    if (GlobalVariables.getUserRole().equals("administrator") || GlobalVariables.getUserRole().equals("hr")) {
        edBtn.setEnabled(true);
    } else {
        edBtn.setEnabled(false);
    }

    glayout.addComponent(new Label("<HR>", Label.CONTENT_XHTML), 0, 3, 1, 3);

    sssField = new HRISTextField("SSS: ");
    glayout.addComponent(sssField, 0, 4);

    Button sssbtn = new Button("UPDATE SSS NO.");
    sssbtn.setWidth("100%");
    sssbtn.addListener(buttonClickListener);
    glayout.addComponent(sssbtn, 1, 4);
    glayout.setComponentAlignment(sssbtn, Alignment.BOTTOM_CENTER);
    if (GlobalVariables.getUserRole().equals("administrator") || GlobalVariables.getUserRole().equals("hr")) {
        sssbtn.setEnabled(true);
    } else {
        sssbtn.setEnabled(false);
    }

    glayout.addComponent(new Label("<HR>", Label.CONTENT_XHTML), 0, 5, 1, 5);

    phicField = new HRISTextField("Philhealth");
    glayout.addComponent(phicField, 0, 6);

    Button phicBtn = new Button("UPDATE PHIC NO.");
    phicBtn.setWidth("100%");
    phicBtn.addListener(buttonClickListener);
    glayout.addComponent(phicBtn, 1, 6);
    glayout.setComponentAlignment(phicBtn, Alignment.BOTTOM_CENTER);
    if (GlobalVariables.getUserRole().equals("administrator") || GlobalVariables.getUserRole().equals("hr")) {
        phicBtn.setEnabled(true);
    } else {
        phicBtn.setEnabled(false);
    }

    glayout.addComponent(new Label("<HR>", Label.CONTENT_XHTML), 0, 7, 1, 7);

    hdmfField = new HRISTextField("HDMF: ");
    glayout.addComponent(hdmfField, 0, 8);

    Button hdmfBtn = new Button("UPDATE HDMF NO.");
    hdmfBtn.setWidth("100%");
    hdmfBtn.addListener(buttonClickListener);
    glayout.addComponent(hdmfBtn, 1, 8);
    glayout.setComponentAlignment(hdmfBtn, Alignment.BOTTOM_CENTER);
    if (GlobalVariables.getUserRole().equals("administrator") || GlobalVariables.getUserRole().equals("hr")) {
        hdmfBtn.setEnabled(true);
    } else {
        hdmfBtn.setEnabled(false);
    }

    glayout.addComponent(new Label("<HR>", Label.CONTENT_XHTML), 0, 9, 1, 9);

    bankAccountNo = new HRISTextField("Bank Account No: ");
    bankAccountNo.setImmediate(true);
    glayout.addComponent(bankAccountNo, 0, 10);

    Button bankAccountBtn = new Button("UPDATE BANK NO.");
    bankAccountBtn.setWidth("100%");
    bankAccountBtn.addListener(buttonClickListener);
    glayout.addComponent(bankAccountBtn, 1, 10);
    glayout.setComponentAlignment(bankAccountBtn, Alignment.BOTTOM_CENTER);
    if (GlobalVariables.getUserRole().equals("administrator") || GlobalVariables.getUserRole().equals("hr")) {
        bankAccountBtn.setEnabled(true);
    } else {
        bankAccountBtn.setEnabled(false);
    }

    if (getEmployeeId() != null) {
        EmploymentInformation ei = si.getEmployeeSalaryInformation(getEmployeeId());

        tinField.setValue(ei.getTinNo());
        sssField.setValue(ei.getSssNo());
        phicField.setValue(ei.getPhicNo());
        hdmfField.setValue(ei.gethdmfNo());
        bankAccountNo.setValue(ei.getBankAccountNo());
        employeeDependent
                .setValue(Constant.getKeyByValue(Constant.MAP_CONSTANT_DEPENDENT, ei.getTotalDependent()));
    }

    return glayout;
}

From source file:com.openhris.employee.PostEmploymentInfomation.java

public ComponentContainer layout2() {
    HorizontalLayout hlayout = new HorizontalLayout();
    hlayout.setSpacing(true);/*  w w w  .j ava 2 s .co m*/
    hlayout.setWidth("100%");

    GridLayout glayout2 = new GridLayout(2, 2);
    glayout2.setSpacing(true);

    final PopupDateField endDate = new HRISPopupDateField("Exit Date: ");
    endDate.setWidth("250px");
    endDate.setDateFormat("MM/dd/yyyy");
    glayout2.addComponent(endDate, 0, 0);
    glayout2.setComponentAlignment(endDate, Alignment.BOTTOM_LEFT);

    Button endDateBtn = new Button("RESIGN");
    endDateBtn.setWidth("150px");
    endDateBtn.addListener(new Button.ClickListener() {

        @Override
        public void buttonClick(Button.ClickEvent event) {
            if (endDate.getValue() == null || endDate.getValue().toString().trim().isEmpty()) {
                getWindow().showNotification("Enter End Date.", Window.Notification.TYPE_ERROR_MESSAGE);
                return;
            }

            Window window = new ConfirmResignWindow(getEmployeeId(),
                    utilities.convertDateFormat(endDate.getValue().toString().trim().toLowerCase()));
            if (window.getParent() == null) {
                getWindow().addWindow(window);
            }
        }
    });
    glayout2.addComponent(endDateBtn, 1, 0);
    glayout2.setComponentAlignment(endDateBtn, Alignment.BOTTOM_LEFT);
    if (GlobalVariables.getUserRole().equals("administrator") || GlobalVariables.getUserRole().equals("hr")) {
        endDateBtn.setEnabled(true);
    } else {
        endDateBtn.setEnabled(false);
    }

    hlayout.addComponent(glayout2);
    hlayout.setComponentAlignment(glayout2, Alignment.MIDDLE_RIGHT);

    final PopupDateField entryDateFromEmp = new HRISPopupDateField("Entry Date from Employment: ");
    entryDateFromEmp.setWidth("250px");
    entryDateFromEmp.setDateFormat("MM/dd/yyyy");
    entryDateFromEmp.setValue(utilities.parsingDate(employeeService.getEmploymentEntryDate(getEmployeeId())));
    glayout2.addComponent(entryDateFromEmp, 0, 1);
    glayout2.setComponentAlignment(entryDateFromEmp, Alignment.BOTTOM_LEFT);

    Button entryDateFromEmpBtn = new Button("EDIT");
    entryDateFromEmpBtn.setWidth("150px");
    entryDateFromEmpBtn.addListener(new Button.ClickListener() {

        @Override
        public void buttonClick(Button.ClickEvent event) {
            if (!GlobalVariables.getUserRole().equals("administrator")) {
                getWindow().showNotification(
                        "You need to be an ADMINISTRATOR to EDIT date entry of employment.",
                        Window.Notification.TYPE_ERROR_MESSAGE);
                return;
            }

            Window sub = new EditEmploymentDateEntryWindow(getEmployeeId(),
                    utilities.convertDateFormat(entryDateFromEmp.getValue().toString()));
            if (sub.getParent() == null) {
                getWindow().addWindow(sub);
            }
        }
    });
    glayout2.addComponent(entryDateFromEmpBtn, 1, 1);
    glayout2.setComponentAlignment(entryDateFromEmpBtn, Alignment.BOTTOM_LEFT);
    if (GlobalVariables.getUserRole().equals("administrator") || GlobalVariables.getUserRole().equals("hr")) {
        entryDateFromEmpBtn.setEnabled(true);
    } else {
        entryDateFromEmpBtn.setEnabled(false);
    }

    return hlayout;
}

From source file:com.openhris.employee.salary.EmployeeSalaryInformation.java

public ComponentContainer layout() {
    GridLayout glayout = new GridLayout(2, 8);
    glayout.setSpacing(true);
    glayout.setWidth("600px");
    glayout.setHeight("100%");

    employmentStatus = dropDown.populateEmploymentStatus("Employment Status: ");
    employmentStatus.setWidth("200px");
    glayout.addComponent(employmentStatus, 0, 0);

    Button esBtn = new Button("UPDATE EMPLOYMENT STATUS");
    esBtn.setWidth("100%");
    glayout.addComponent(esBtn, 1, 0);// w  w w.  j a va 2s.  c o  m
    esBtn.addListener(buttonClickListener);
    glayout.setColumnExpandRatio(1, 1);
    glayout.setComponentAlignment(esBtn, Alignment.BOTTOM_LEFT);
    if (GlobalVariables.getUserRole().equals("administrator") || GlobalVariables.getUserRole().equals("hr")) {
        esBtn.setEnabled(true);
    } else {
        esBtn.setEnabled(false);
    }

    glayout.addComponent(new Label("<HR>", Label.CONTENT_XHTML), 0, 2, 1, 2);

    employmentWageStatus = dropDown.populateEmploymentWageStatus("Employment Wage Status: ");
    employmentWageStatus.setWidth("200px");
    glayout.addComponent(employmentWageStatus, 0, 3);

    Button ewsBtn = new Button("UPDATE EMPLOYMENT WAGE STATUS");
    ewsBtn.setWidth("100%");
    ewsBtn.addListener(buttonClickListener);
    glayout.addComponent(ewsBtn, 1, 3);
    glayout.setComponentAlignment(ewsBtn, Alignment.BOTTOM_LEFT);
    if (GlobalVariables.getUserRole().equals("administrator") || GlobalVariables.getUserRole().equals("hr")) {
        ewsBtn.setEnabled(true);
    } else {
        ewsBtn.setEnabled(false);
    }

    glayout.addComponent(new Label("<HR>", Label.CONTENT_XHTML), 0, 4, 1, 4);

    employmentWageEntry = dropDown.populateEmploymentWageEntry("Employment Wage Entry: ");
    employmentWageEntry.setWidth("200px");
    glayout.addComponent(employmentWageEntry, 0, 5);

    Button eweBtn = new Button("UPDATE EMPLOYMENT WAGE ENTRY");
    eweBtn.setWidth("100%");
    glayout.addComponent(eweBtn, 1, 5);
    eweBtn.addListener(buttonClickListener);
    glayout.setComponentAlignment(eweBtn, Alignment.BOTTOM_LEFT);
    if (GlobalVariables.getUserRole().equals("administrator") || GlobalVariables.getUserRole().equals("hr")) {
        eweBtn.setEnabled(true);
    } else {
        eweBtn.setEnabled(false);
    }

    glayout.addComponent(new Label("<HR>", Label.CONTENT_XHTML), 0, 6, 1, 6);

    employmentWage = new TextField("Employment Wage");
    employmentWage.setWidth("200px");
    employmentWage.addStyleName("numerical");
    glayout.addComponent(employmentWage, 0, 7);

    Button ewBtn = new Button("UPDATE EMPLOYMENT WAGE");
    ewBtn.setWidth("100%");
    glayout.addComponent(ewBtn, 1, 7);
    ewBtn.addListener(buttonClickListener);
    glayout.setComponentAlignment(ewBtn, Alignment.BOTTOM_LEFT);
    if (GlobalVariables.getUserRole().equals("administrator") || GlobalVariables.getUserRole().equals("hr")) {
        ewBtn.setEnabled(true);
    } else {
        ewBtn.setEnabled(false);
    }

    if (getEmployeeId() != null) {
        EmploymentInformation ei = si.getEmployeeSalaryInformation(getEmployeeId());

        employmentStatus.setValue(
                Constant.getKeyByValue(Constant.MAP_CONSTANT_EMPLOYMENT_STATUS, ei.getEmploymentStatus()));
        employmentWageStatus.setValue(Constant.getKeyByValue(Constant.MAP_CONSTANT_EMPLOYMENT_WAGE_STATUS,
                ei.getEmploymentWageStatus()));
        employmentWageEntry.setValue(Constant.getKeyByValue(Constant.MAP_CONSTANT_EMPLOYMENT_WAGE_ENTRY,
                ei.getEmploymentWageEntry()));
        employmentWage.setValue(ei.getEmploymentWage());
    }

    return glayout;
}

From source file:com.openhris.employee.salary.EmployeeSalaryInformation.java

public ComponentContainer layout2() {
    GridLayout glayout = new GridLayout(2, 1);
    glayout.setSpacing(true);
    glayout.setWidth("600px");

    TextField employmentStatusField = new HRISTextField("Employment Status: ");
    employmentStatusField.setWidth("200px");
    glayout.addComponent(employmentStatusField, 0, 0);

    Button setContributionBtn = new Button("SET EMPLOYEE'S CONTRIBUTIONS MAIN BRANCH");
    setContributionBtn.setWidth("100%");
    setContributionBtn.addListener(new Button.ClickListener() {

        @Override//from  w  w  w  . ja  v  a  2  s .co  m
        public void buttonClick(Button.ClickEvent event) {
            Window subWindow = setContributionMainBranch();
            if (subWindow.getParent() == null) {
                getWindow().addWindow(subWindow);
            }
            subWindow.setModal(true);
            subWindow.center();
        }
    });
    glayout.addComponent(setContributionBtn, 1, 0);
    glayout.setColumnExpandRatio(1, 1);
    glayout.setComponentAlignment(setContributionBtn, Alignment.BOTTOM_CENTER);
    if (GlobalVariables.getUserRole().equals("administrator") || GlobalVariables.getUserRole().equals("hr")) {
        setContributionBtn.setEnabled(true);
    } else {
        setContributionBtn.setEnabled(false);
    }

    if (getEmployeeId() != null) {
        EmploymentInformation employmentInformation = si.getEmployeeSalaryInformation(getEmployeeId());
        employmentStatusField.setValue(employmentInformation.getCurrentStatus().toUpperCase());
    }
    employmentStatusField.setReadOnly(true);

    return glayout;
}

From source file:com.openhris.payroll.PayrollAdvancesLedgerUI.java

public PayrollAdvancesLedgerUI(int branchId) {
    this.branchId = branchId;

    setSpacing(false);/* ww w.  j a  va2s . c  o  m*/
    setMargin(false);
    setWidth("100%");
    setHeight("100%");
    setImmediate(true);

    final VerticalSplitPanel vsplit = new VerticalSplitPanel();

    vsplit.setImmediate(true);
    vsplit.setMargin(false);
    vsplit.setSizeFull();
    vsplit.setLocked(true);

    vsplit.setSplitPosition(90, Sizeable.UNITS_PIXELS);

    GridLayout glayout = new GridLayout(2, 1);
    glayout.setWidth("60%");
    glayout.setMargin(true);
    glayout.setSpacing(true);

    employeeComboBox(getBranchId());
    glayout.addComponent(employee, 0, 0);

    Button button = new Button();
    button.setWidth("100%");
    button.setCaption("Generate Ledger");
    button.setEnabled(UserAccessControl.isPayroll());
    button.addListener(new Button.ClickListener() {

        @Override
        public void buttonClick(Button.ClickEvent event) {
            System.out.println("employeeId: " + employee.getValue());
        }
    });

    glayout.addComponent(button, 1, 0);
    glayout.setComponentAlignment(button, Alignment.BOTTOM_LEFT);

    vsplit.setFirstComponent(glayout);
    addComponent(vsplit);

    setExpandRatio(vsplit, 1.0f);
}

From source file:com.openhris.timekeeping.EditAttendanceTableContainerWindow.java

public EditAttendanceTableContainerWindow(String name, List dateList, String employeeId, String payrollPeriod,
        String payrollDate, String attendancePeriodFrom, String attendancePeriodTo, String employmentWageEntry,
        double employmentWage, int branchId, int payrollId) {

    this.name = name;
    this.dateList = dateList;
    this.employeeId = employeeId;
    this.payrollPeriod = payrollPeriod;
    this.payrollDate = payrollDate;
    this.attendancePeriodFrom = attendancePeriodFrom;
    this.attendancePeriodTo = attendancePeriodTo;
    this.employmentWageEntry = employmentWageEntry;
    this.employmentWage = employmentWage;
    this.branchId = branchId;
    this.payrollId = payrollId;

    setCaption("ATTENDANCE TABLE for " + getEmployeesName());
    setSizeFull();//from ww  w.  ja v  a  2s. c o m
    setModal(true);
    center();

    VerticalLayout vlayout = new VerticalLayout();
    vlayout.setSizeFull();
    vlayout.setSpacing(true);

    GridLayout glayout = new GridLayout(2, 2);
    glayout.setSpacing(true);

    Label payrollPeriodLabel = new Label("Payroll Period: ");
    glayout.addComponent(payrollPeriodLabel, 0, 0);
    glayout.setComponentAlignment(payrollPeriodLabel, Alignment.MIDDLE_RIGHT);

    Label periodLabel = new Label(getPayrollPeriod());
    glayout.addComponent(periodLabel, 1, 0);
    glayout.setComponentAlignment(periodLabel, Alignment.MIDDLE_LEFT);

    Label payrollDateLabel = new Label("Payroll Date: ");
    glayout.addComponent(payrollDateLabel, 0, 1);
    glayout.setComponentAlignment(payrollDateLabel, Alignment.MIDDLE_RIGHT);

    Label dateLabel = new Label(getPayrollDate());
    glayout.addComponent(dateLabel, 1, 1);
    glayout.setComponentAlignment(dateLabel, Alignment.MIDDLE_LEFT);

    vlayout.addComponent(glayout);
    vlayout.addComponent(generateAttendanceTable());
    addComponent(vlayout);
}

From source file:com.openhris.timekeeping.EditAttendanceTableContainerWindow.java

VerticalLayout generateAttendanceTable() {
    VerticalLayout vlayout = new VerticalLayout();
    vlayout.setSizeFull();//  w  w w  .java2s .  co m
    vlayout.setSpacing(true);

    if (getEmploymentWageEntry().equals("monthly")) {
        employmentWage = utilities.roundOffToTwoDecimalPlaces((employmentWage * 12) / 314);
    }

    final Table table = new Table();
    table.removeAllItems();
    table.setEnabled(true);
    table.setWidth("100%");
    table.setImmediate(true);
    table.setColumnCollapsingAllowed(true);

    table.addContainerProperty("edit", CheckBox.class, null);
    table.addContainerProperty("date", String.class, null);
    table.addContainerProperty("policy", String.class, null);
    table.addContainerProperty("holidays", String.class, null);
    table.addContainerProperty("premium", CheckBox.class, null);
    table.addContainerProperty("lates", TextField.class, null);
    table.addContainerProperty("undertime", TextField.class, null);
    table.addContainerProperty("overtime", TextField.class, null);
    table.addContainerProperty("night differential", TextField.class, null);
    table.addContainerProperty("l/min", Double.class, null);
    table.addContainerProperty("u/min", Double.class, null);
    table.addContainerProperty("o/min", Double.class, null);
    table.addContainerProperty("nd/min", Double.class, null);
    table.addContainerProperty("lholiday", Double.class, null);
    table.addContainerProperty("sholiday", Double.class, null);
    table.addContainerProperty("wdo", Double.class, null);
    table.addContainerProperty("psday", Double.class, null); //paid non-working holiday
    table.addContainerProperty("latesLH", Double.class, null);
    table.addContainerProperty("latesSH", Double.class, null);
    table.addContainerProperty("latesWO", Double.class, null);
    table.addContainerProperty("undertimeLH", Double.class, null);
    table.addContainerProperty("undertimeSH", Double.class, null);
    table.addContainerProperty("undertimeWO", Double.class, null);

    table.setColumnAlignment("edit", Table.ALIGN_CENTER);
    table.setColumnAlignment("date", Table.ALIGN_CENTER);
    table.setColumnAlignment("policy", Table.ALIGN_CENTER);
    table.setColumnAlignment("premium", Table.ALIGN_CENTER);
    table.setColumnAlignment("lates", Table.ALIGN_CENTER);
    table.setColumnAlignment("undertime", Table.ALIGN_CENTER);
    table.setColumnAlignment("overtime", Table.ALIGN_CENTER);
    table.setColumnAlignment("night differential", Table.ALIGN_CENTER);
    table.setColumnAlignment("l/min", Table.ALIGN_RIGHT);
    table.setColumnAlignment("u/min", Table.ALIGN_RIGHT);
    table.setColumnAlignment("o/min", Table.ALIGN_RIGHT);
    table.setColumnAlignment("nd/min", Table.ALIGN_RIGHT);
    table.setColumnAlignment("lholiday", Table.ALIGN_RIGHT);
    table.setColumnAlignment("sholiday", Table.ALIGN_RIGHT);
    table.setColumnAlignment("wdo", Table.ALIGN_RIGHT);
    table.setColumnAlignment("psday", Table.ALIGN_RIGHT);
    table.setColumnAlignment("latesLH", Table.ALIGN_RIGHT);
    table.setColumnAlignment("latesSH", Table.ALIGN_RIGHT);
    table.setColumnAlignment("latesWO", Table.ALIGN_RIGHT);
    table.setColumnAlignment("undertimeLH", Table.ALIGN_RIGHT);
    table.setColumnAlignment("undertimeSH", Table.ALIGN_RIGHT);
    table.setColumnAlignment("undertimeWO", Table.ALIGN_RIGHT);

    table.setColumnCollapsed("latesLH", true);
    table.setColumnCollapsed("latesSH", true);
    table.setColumnCollapsed("latesWO", true);
    table.setColumnCollapsed("undertimeLH", true);
    table.setColumnCollapsed("undertimeSH", true);
    table.setColumnCollapsed("undertimeWO", true);

    final String[] holidayList = { "legal-holiday", "special-holiday" };
    for (int i = 0; i < getDateList().size(); i++) {
        Object itemId = new Integer(i);

        final CheckBox edit = new CheckBox();
        edit.setData(i);
        edit.setEnabled(UserAccessControl.isEditAttendance());
        edit.setImmediate(true);

        final CheckBox premium = new CheckBox();
        premium.setData(itemId);
        premium.setEnabled(false);
        premium.setImmediate(true);

        final TextField lates = new TextField();
        lates.setWidth("50px");
        lates.setValue("0");
        lates.setEnabled(true);
        lates.setData(itemId);
        lates.setEnabled(false);
        lates.setImmediate(true);

        final TextField undertime = new TextField();
        undertime.setWidth("50px");
        undertime.setValue("0");
        undertime.setEnabled(true);
        undertime.setData(itemId);
        undertime.setEnabled(false);
        undertime.setImmediate(true);

        final TextField overtime = new TextField();
        overtime.setWidth("50px");
        overtime.setValue("0");
        overtime.setEnabled(true);
        overtime.setData(itemId);
        overtime.setEnabled(false);
        overtime.setImmediate(true);

        final TextField nightDifferential = new TextField();
        nightDifferential.setWidth("50px");
        nightDifferential.setValue("0");
        nightDifferential.setEnabled(true);
        nightDifferential.setData(itemId);
        nightDifferential.setEnabled(false);
        nightDifferential.setImmediate(true);

        edit.addListener(new Button.ClickListener() {

            @Override
            public void buttonClick(Button.ClickEvent event) {
                premium.setEnabled(event.getButton().booleanValue());
                lates.setEnabled(event.getButton().booleanValue());
                undertime.setEnabled(event.getButton().booleanValue());
                overtime.setEnabled(event.getButton().booleanValue());
                nightDifferential.setEnabled(event.getButton().booleanValue());
            }
        });

        premium.addListener(new Button.ClickListener() {

            @Override
            public void buttonClick(Button.ClickEvent event) {
                Object itemId = lates.getData();
                Item item = table.getItem(itemId);

                lates.setValue("0");
                undertime.setValue("0");
                overtime.setValue("0");
                nightDifferential.setValue("0");

                item.getItemProperty("l/min").setValue(0.0);
                item.getItemProperty("u/min").setValue(0.0);
                item.getItemProperty("o/min").setValue(0.0);
                item.getItemProperty("nd/min").setValue(0.0);

                if (event.getButton().booleanValue() == true) {
                    premiumRate = 0.1;
                } else {
                    premiumRate = 0.0;
                }

                item.getItemProperty("wdo")
                        .setValue(utilities.roundOffToTwoDecimalPlaces(
                                Double.parseDouble(item.getItemProperty("wdo").getValue().toString())
                                        + (Double.parseDouble(item.getItemProperty("wdo").getValue().toString())
                                                * premiumRate)));

                item.getItemProperty("lholiday")
                        .setValue(utilities.roundOffToTwoDecimalPlaces(Double
                                .parseDouble(item.getItemProperty("lholiday").getValue().toString())
                                + (Double.parseDouble(item.getItemProperty("lholiday").getValue().toString())
                                        * premiumRate)));

                item.getItemProperty("sholiday")
                        .setValue(utilities.roundOffToTwoDecimalPlaces(Double
                                .parseDouble(item.getItemProperty("sholiday").getValue().toString())
                                + (Double.parseDouble(item.getItemProperty("sholiday").getValue().toString())
                                        * premiumRate)));
            }
        });

        lates.addListener(new FieldEvents.TextChangeListener() {

            @Override
            public void textChange(FieldEvents.TextChangeEvent event) {
                Object itemId = lates.getData();
                Item item = table.getItem(itemId);
                String policyStr = item.getItemProperty("policy").toString();
                String holidayStr = item.getItemProperty("holidays").toString();
                double lateDeduction;

                boolean checkIfInputIsInteger = utilities.checkInputIfInteger(event.getText().trim());
                if (!checkIfInputIsInteger) {
                    getWindow().showNotification("Enter numeric format for lates!",
                            Window.Notification.TYPE_WARNING_MESSAGE);
                    return;
                }

                if (!event.getText().isEmpty()) {
                    if (utilities.convertStringToInteger(event.getText().trim()) > 5) {
                        lateDeduction = computation.processEmployeesLates(policyStr, holidayStr,
                                utilities.convertStringToInteger(event.getText().trim()), getEmploymentWage());
                        if (policyStr == null || policyStr.isEmpty()) {
                            item.getItemProperty("l/min")
                                    .setValue(utilities.roundOffToTwoDecimalPlaces(lateDeduction));
                        } else if (policyStr.equals("working-holiday") && holidayStr.equals("legal-holiday")) {
                            item.getItemProperty("latesLH")
                                    .setValue(utilities.roundOffToTwoDecimalPlaces(lateDeduction));
                            item.getItemProperty("latesSH").setValue(0.0);
                            item.getItemProperty("latesWO").setValue(0.0);
                            item.getItemProperty("l/min").setValue(0.0);
                        } else if (policyStr.equals("working-holiday")
                                && holidayStr.equals("special-holiday")) {
                            item.getItemProperty("latesLH").setValue(0.0);
                            item.getItemProperty("latesSH")
                                    .setValue(utilities.roundOffToTwoDecimalPlaces(lateDeduction));
                            item.getItemProperty("latesWO").setValue(0.0);
                            item.getItemProperty("l/min").setValue(0.0);
                        } else if (policyStr.equals("working-day-off")) {
                            item.getItemProperty("latesLH").setValue(0.0);
                            item.getItemProperty("latesSH").setValue(0.0);
                            item.getItemProperty("latesWO")
                                    .setValue(utilities.roundOffToTwoDecimalPlaces(lateDeduction));
                            item.getItemProperty("l/min").setValue(0.0);
                        }
                    } else {
                        item.getItemProperty("l/min").setValue(0.0);
                    }
                } else {
                    item.getItemProperty("l/min").setValue(0.0);
                }

            }
        });

        undertime.addListener(new FieldEvents.TextChangeListener() {

            @Override
            public void textChange(FieldEvents.TextChangeEvent event) {
                Object itemId = lates.getData();
                Item item = table.getItem(itemId);
                String policyStr = item.getItemProperty("policy").toString();
                String holidayStr = item.getItemProperty("holidays").toString();
                double undertimeDeduction;

                boolean checkIfInputIsInteger = utilities.checkInputIfInteger(event.getText().trim());
                if (!checkIfInputIsInteger) {
                    getWindow().showNotification("Enter numeric format for undertime!",
                            Window.Notification.TYPE_WARNING_MESSAGE);
                    return;
                }

                if (!event.getText().isEmpty()) {
                    undertimeDeduction = computation.processEmployeesUndertime(policyStr, holidayStr,
                            utilities.convertStringToInteger(event.getText().trim()), getEmploymentWage());
                    if (policyStr == null || policyStr.isEmpty()) {
                        item.getItemProperty("u/min")
                                .setValue(utilities.roundOffToTwoDecimalPlaces(undertimeDeduction));
                    } else if (policyStr.equals("working-holiday") && holidayStr.equals("legal-holiday")) {
                        item.getItemProperty("undertimeLH")
                                .setValue(utilities.roundOffToTwoDecimalPlaces(undertimeDeduction));
                        item.getItemProperty("undertimeSH").setValue(0.0);
                        item.getItemProperty("undertimeWO").setValue(0.0);
                        item.getItemProperty("u/min").setValue(0.0);
                    } else if (policyStr.equals("working-holiday") && holidayStr.equals("special-holiday")) {
                        item.getItemProperty("undertimeLH").setValue(0.0);
                        item.getItemProperty("undertimeSH")
                                .setValue(utilities.roundOffToTwoDecimalPlaces(undertimeDeduction));
                        item.getItemProperty("undertimeWO").setValue(0.0);
                        item.getItemProperty("u/min").setValue(0.0);
                    } else if (policyStr.equals("working-day-off")) {
                        item.getItemProperty("undertimeLH").setValue(0.0);
                        item.getItemProperty("undertimeSH").setValue(0.0);
                        item.getItemProperty("undertimeWO")
                                .setValue(utilities.roundOffToTwoDecimalPlaces(undertimeDeduction));
                        item.getItemProperty("u/min").setValue(0.0);
                    }
                } else {
                    item.getItemProperty("u/min").setValue(0.0);
                }
            }
        });

        overtime.addListener(new FieldEvents.TextChangeListener() {

            @Override
            public void textChange(FieldEvents.TextChangeEvent event) {
                Object itemId = lates.getData();
                Item item = table.getItem(itemId);
                String policyStr = item.getItemProperty("policy").toString();
                String holidayStr = item.getItemProperty("holidays").toString();
                double overtimeAddition;

                boolean checkIfInputIsInteger = utilities.checkInputIfInteger(event.getText().trim());
                if (!checkIfInputIsInteger) {
                    getWindow().showNotification("Enter numeric format for undertime!",
                            Window.Notification.TYPE_WARNING_MESSAGE);
                    return;
                }

                if (!event.getText().isEmpty()) {
                    overtimeAddition = computation.processEmployeesOvertime(policyStr, holidayStr,
                            Integer.parseInt(event.getText().trim()), getEmploymentWage());
                    item.getItemProperty("o/min").setValue(utilities
                            .roundOffToTwoDecimalPlaces(overtimeAddition + (overtimeAddition * premiumRate)));
                } else {
                    item.getItemProperty("o/min").setValue(0.0);
                }
            }
        });

        nightDifferential.addListener(new FieldEvents.TextChangeListener() {

            @Override
            public void textChange(FieldEvents.TextChangeEvent event) {
                Object itemId = lates.getData();
                Item item = table.getItem(itemId);
                String policyStr = item.getItemProperty("policy").toString();
                String holidayStr = item.getItemProperty("holidays").toString();
                double nightDifferentialAddition;

                boolean checkIfInputIsInteger = utilities.checkInputIfInteger(event.getText().trim());
                if (!checkIfInputIsInteger) {
                    getWindow().showNotification("Enter numeric format for undertime!",
                            Window.Notification.TYPE_WARNING_MESSAGE);
                    return;
                }

                if (!event.getText().isEmpty()) {
                    nightDifferentialAddition = computation.processEmployeesNightDifferential(policyStr,
                            holidayStr, Integer.parseInt(event.getText().trim()), getEmploymentWage());
                    item.getItemProperty("nd/min").setValue(utilities.roundOffToTwoDecimalPlaces(
                            nightDifferentialAddition + (nightDifferentialAddition * premiumRate)));
                } else {
                    item.getItemProperty("nd/min").setValue(0.0);
                }
            }
        });

        List<Timekeeping> timekeepingListByRowData = timekeepingService.getTimekeepingRowData(
                utilities.convertDateFormat(getDateList().get(i).toString()), getPayrollId());

        for (Timekeeping t : timekeepingListByRowData) {
            String policy;
            String holiday;
            if (!t.getPolicy().equals("null")) {
                policy = t.getPolicy();
            } else {
                policy = "";
            }

            if (!t.getHoliday().equals("null")) {
                holiday = t.getHoliday();
            } else {
                holiday = "";
            }

            premium.setValue(t.isPremium());

            lates.setValue(t.getLates());
            undertime.setValue(t.getUndertime());
            overtime.setValue(t.getOvertime());
            nightDifferential.setValue(t.getNightDifferential());
            table.addItem(
                    new Object[] { edit, utilities.convertDateFormat(getDateList().get(i).toString()), policy,
                            holiday, premium, lates, undertime, overtime, nightDifferential,
                            t.getLateDeduction(), t.getUndertimeDeduction(), t.getOvertimePaid(),
                            t.getNightDifferentialPaid(), t.getLegalHolidayPaid(), t.getSpecialHolidayPaid(),
                            t.getWorkingDayOffPaid(), t.getNonWorkingHolidayPaid(),
                            t.getLatesLegalHolidayDeduction(), t.getLatesSpecialHolidayDeduction(),
                            t.getLatesWorkingDayOffDeduction(), t.getUndertimeLegalHolidayDeduction(),
                            t.getUndertimeSpecialHolidayDeduction(), t.getUndertimeWorkingDayOffDeduction() },
                    new Integer(i));
        }
    }
    table.setPageLength(table.size());

    for (Object listener : table.getListeners(ItemClickEvent.class)) {
        table.removeListener(ItemClickEvent.class, listener);
    }

    table.addListener(new ItemClickEvent.ItemClickListener() {

        @Override
        public void itemClick(ItemClickEvent event) {
            final Object itemId = event.getItemId();
            final Item item = table.getItem(itemId);

            Boolean editRow = Boolean.valueOf(item.getItemProperty("edit").getValue().toString());

            if (event.getPropertyId().equals("policy")) {
                if (editRow) {
                    Window sub = new AttendancePolicyWindow(holidayList, item, getEmploymentWageEntry(),
                            getEmploymentWage());
                    if (sub.getParent() == null) {
                        getApplication().getMainWindow().addWindow(sub);
                    }
                } else {
                    getWindow().showNotification("Click Edit!", Window.Notification.TYPE_WARNING_MESSAGE);
                }
            }
        }
    });

    vlayout.addComponent(table);

    final Button saveButton = new Button();
    saveButton.setWidth("200px");
    saveButton.setCaption("UPDATE ATTENDANCE DATA");
    saveButton.setEnabled(UserAccessControl.isEditAttendance());

    for (Object listener : saveButton.getListeners(Button.ClickListener.class)) {
        saveButton.removeListener(Button.ClickListener.class, listener);
    }

    GridLayout glayout = new GridLayout(2, 1);
    glayout.setSizeFull();
    glayout.setSpacing(true);

    saveButton.addListener(new Button.ClickListener() {

        @Override
        public void buttonClick(Button.ClickEvent event) {
            try {
                Collection attendanceTableCollection = table.getContainerDataSource().getItemIds();
                List<Timekeeping> attendanceList = new ArrayList<>();
                Iterator iterator = attendanceTableCollection.iterator();
                while (iterator.hasNext()) {
                    String str = table.getItem(iterator.next()).toString();
                    String[] attStr = str.split(" ");
                    List<String> tkeepList = new ArrayList<>(Arrays.asList(attStr));

                    Timekeeping t = new Timekeeping();
                    t.setAttendanceDate(utilities.parsingDate(tkeepList.get(1)));
                    t.setPolicy(tkeepList.get(2));
                    t.setHoliday(tkeepList.get(3));
                    t.setPremium(utilities.convertStringToBoolean(tkeepList.get(4)));
                    t.setLates(utilities.convertStringToDouble(tkeepList.get(5)));
                    t.setUndertime(utilities.convertStringToDouble(tkeepList.get(6)));
                    t.setOvertime(utilities.convertStringToDouble(tkeepList.get(7)));
                    t.setNightDifferential(utilities.convertStringToDouble(tkeepList.get(8)));
                    t.setLateDeduction(utilities.convertStringToDouble(tkeepList.get(9)));
                    t.setUndertimeDeduction(utilities.convertStringToDouble(tkeepList.get(10)));
                    t.setOvertimePaid(utilities.convertStringToDouble(tkeepList.get(11)));
                    t.setNightDifferentialPaid(utilities.convertStringToDouble(tkeepList.get(12)));
                    t.setLegalHolidayPaid(utilities.convertStringToDouble(tkeepList.get(13)));
                    t.setSpecialHolidayPaid(utilities.convertStringToDouble(tkeepList.get(14)));
                    t.setWorkingDayOffPaid(utilities.convertStringToDouble(tkeepList.get(15)));
                    t.setNonWorkingHolidayPaid(utilities.convertStringToDouble(tkeepList.get(16)));
                    t.setLatesLegalHolidayDeduction(utilities.convertStringToDouble(tkeepList.get(17)));
                    t.setLatesSpecialHolidayDeduction(utilities.convertStringToDouble(tkeepList.get(18)));
                    t.setLatesWorkingDayOffDeduction(utilities.convertStringToDouble(tkeepList.get(19)));
                    t.setUndertimeLegalHolidayDeduction(utilities.convertStringToDouble(tkeepList.get(20)));
                    t.setUndertimeSpecialHolidayDeduction(utilities.convertStringToDouble(tkeepList.get(21)));
                    t.setUndertimeWorkingDayOffDeduction(utilities.convertStringToDouble(tkeepList.get(22)));
                    attendanceList.add(t);
                }

                ProcessPayrollComputation processPayroll = new ProcessPayrollComputation(getEmployeeId(),
                        getBranchId());
                processPayroll.initVariables();
                processPayroll.initVariablesForComputation(attendanceList);
                boolean result = processPayroll.processPayrollComputation(payrollDate, payrollPeriod,
                        attendancePeriodFrom, attendancePeriodTo, getPayrollId());
                if (result) {
                    close();
                } else {
                    getWindow().showNotification("SQL ERROR");
                }
            } catch (Exception e) {
                e.getMessage();
            }
        }

    });
    glayout.addComponent(saveButton, 0, 0);
    glayout.setComponentAlignment(saveButton, Alignment.MIDDLE_LEFT);
    //        vlayout.addComponent(saveButton);

    Button printButton = new Button("PRINT ATTENDANCE");
    printButton.setWidth("200px");
    printButton.addListener(new Button.ClickListener() {

        @Override
        public void buttonClick(Button.ClickEvent event) {
            OpenHrisReports reports = new OpenHrisReports(0, null);
            String fileName = "IndividualAttendanceReport_";
            reports.deleteFile(fileName);
            Window reportWindow = new IndividualAttendanceReport(getPayrollId(), getApplication());
        }
    });
    glayout.addComponent(printButton, 1, 0);
    glayout.setComponentAlignment(printButton, Alignment.MIDDLE_RIGHT);

    vlayout.addComponent(glayout);

    return vlayout;
}

From source file:com.peergreen.webconsole.scope.system.internal.bundle.BundleTab.java

License:Open Source License

private void init() {

    setMargin(true);/*  w  ww  . j a  v  a 2  s  .  c  o  m*/
    setSpacing(true);

    // ----------------------------------------------------
    // Title
    // ----------------------------------------------------

    HorizontalLayout header = new HorizontalLayout();
    header.setSpacing(true);
    header.setMargin(true);

    Label title = new Label(format("Bundle %d: %s (%s)", bundle.getBundleId(),
            getHeader(bundle, Constants.BUNDLE_NAME), bundle.getVersion()));
    title.addStyleName("h1");
    header.addComponent(title);
    header.setComponentAlignment(title, Alignment.MIDDLE_LEFT);

    addComponent(header);

    // ----------------------------------------------------
    // Action(s) Bar
    // ----------------------------------------------------

    HorizontalLayout actions = new HorizontalLayout();
    if (BundleHelper.isState(bundle, Bundle.INSTALLED) || BundleHelper.isState(bundle, Bundle.RESOLVED)) {
        Button changeState = new Button();
        changeState.addClickListener(new StartBundleClickListener(bundle, notifierService));
        //changeState.addStyleName("no-padding");
        changeState.setCaption("Start");
        changeState.setIcon(new ClassResource(getClass(), "/images/32x32/go-next.png"));
        actions.addComponent(changeState);
    }
    if (BundleHelper.isState(bundle, Bundle.ACTIVE)) {
        Button changeState = new Button();
        changeState.addClickListener(new StopBundleClickListener(bundle, notifierService));
        //changeState.addStyleName("no-padding");
        changeState.setCaption("Stop");
        changeState.setIcon(new ClassResource(getClass(), "/images/32x32/media-record.png"));
        actions.addComponent(changeState);
    }

    // Update
    Button update = new Button();
    update.addClickListener(new UpdateBundleClickListener(bundle, notifierService));
    //update.addStyleName("no-padding");
    update.setCaption("Update");
    update.setIcon(new ClassResource(getClass(), "/images/32x32/view-refresh.png"));
    actions.addComponent(update);

    // Trash
    Button trash = new Button();
    trash.addClickListener(new UninstallBundleClickListener(bundle, notifierService));
    //trash.addStyleName("no-padding");
    trash.setCaption("Remove");
    trash.setIcon(new ClassResource(getClass(), "/images/32x32/user-trash-full.png"));
    actions.addComponent(trash);
    addComponent(actions);
    setComponentAlignment(actions, Alignment.MIDDLE_RIGHT);

    // ----------------------------------------------------
    // Standard Section
    // ----------------------------------------------------

    Table table = new Table();
    table.setColumnHeaderMode(Table.ColumnHeaderMode.HIDDEN);
    table.setWidth("100%");

    Section mainSection = new Section("Standard", table);
    addComponent(mainSection);

    table.addContainerProperty("label", Label.class, null);
    table.addContainerProperty("value", Label.class, null);

    table.addItem(new Object[] { label("Bundle ID"), label(String.valueOf(bundle.getBundleId())) },
            "bundle.id");
    for (Map.Entry<String, String> entry : HEADERS.entrySet()) {
        String value = getHeader(bundle, entry.getKey());
        if (value != null) {
            table.addItem(new Object[] { label(entry.getValue()), label(value) }, entry.getKey());
        }
    }
    table.addItem(new Object[] { label("Location"), label(bundle.getLocation()) }, "bundle.location");
    Date date = new Date(bundle.getLastModified());
    table.addItem(new Object[] { label("Last Modified"), label(date.toString()) }, "last.modified");

    // ----------------------------------------------------
    // Packages Section
    // ----------------------------------------------------

    FilteredPackageTable exported = new FilteredPackageTable("Exported");

    FilteredPackageTable imported = new FilteredPackageTable("Imported");

    GridLayout packages = new GridLayout(2, 1);
    packages.addComponent(exported);
    packages.addComponent(imported);
    packages.setSpacing(true);
    packages.setWidth("100%");

    Section packagesSection = new Section("Packages", packages);
    addComponent(packagesSection);

    BundleWiring wiring = bundle.adapt(BundleWiring.class);
    if (wiring != null) {
        for (BundleCapability capability : wiring.getCapabilities(PackageNamespace.PACKAGE_NAMESPACE)) {
            String name = (String) capability.getAttributes().get(PackageNamespace.PACKAGE_NAMESPACE);
            Version version = (Version) capability.getAttributes()
                    .get(PackageNamespace.CAPABILITY_VERSION_ATTRIBUTE);
            exported.addPackage(format("%s (%s)", name, version));
        }
        for (BundleRequirement requirement : wiring.getRequirements(PackageNamespace.PACKAGE_NAMESPACE)) {
            String filter = requirement.getDirectives().get(PackageNamespace.REQUIREMENT_FILTER_DIRECTIVE);
            imported.addPackage(filter);
        }
    }

    // ----------------------------------------------------
    // Services Section
    // ----------------------------------------------------

    FilteredServiceTable registered = new FilteredServiceTable("Registered");

    FilteredServiceTable used = new FilteredServiceTable("Used Services");

    VerticalLayout services = new VerticalLayout(registered, used);
    services.setSpacing(true);
    services.setWidth("100%");

    ServiceReference<?>[] registeredServices = bundle.getRegisteredServices();
    if (registeredServices != null) {
        for (ServiceReference<?> reference : registeredServices) {
            registered.addService(reference);
        }
    }

    ServiceReference<?>[] inUseServices = bundle.getServicesInUse();
    if (inUseServices != null) {
        for (ServiceReference<?> reference : inUseServices) {
            used.addService(reference);
        }
    }

    if (!registered.isEmpty() || !used.isEmpty()) {
        Section servicesSection = new Section("Services", services);
        addComponent(servicesSection);
    }

    // ----------------------------------------------------
    // Raw Manifest Section
    // ----------------------------------------------------

    Page.Styles styles = Page.getCurrent().getStyles();
    styles.add(".monospaced-font {font-family: monospace !important; }");

    Table manifest = new Table();
    manifest.setColumnHeaderMode(Table.ColumnHeaderMode.HIDDEN);
    manifest.setWidth("100%");
    manifest.addStyleName("monospaced-font");
    manifest.setPageLength(15);
    manifest.addContainerProperty("name", String.class, null);
    manifest.addContainerProperty("value", String.class, null);

    Dictionary<String, String> headers = bundle.getHeaders();
    for (String key : Collections.list(headers.keys())) {
        manifest.addItem(new Object[] { key, headers.get(key) }, null);
    }

    Section manifestSection = new Section("Manifest", manifest);
    addComponent(manifestSection);

}

From source file:com.purebred.core.view.field.FormFields.java

License:Open Source License

public GridLayout createGridLayout(String tabName) {
    GridLayout gridLayout;
    if (form instanceof EntityForm) {
        gridLayout = new LeftLabelGridLayout(getColumns(tabName), getRows(tabName));
    } else {/* w w  w  . j ava  2 s  .c o m*/
        gridLayout = new TopLabelGridLayout(getColumns(tabName), getRows(tabName));
    }
    gridLayout.setMargin(true, true, true, true);
    gridLayout.setSpacing(true);
    gridLayout.setSizeUndefined();

    return gridLayout;
}

From source file:com.save.clients.AcknowledgementPromoForm.java

VerticalLayout acknowledgementFormContent() {
    VerticalLayout content = new VerticalLayout();
    content.setSizeFull();//from w  w  w . ja  va2  s . c o m
    content.setMargin(true);
    content.setSpacing(true);

    GridLayout glayout = new GridLayout(4, 5);
    glayout.setWidth("100%");
    glayout.setSpacing(true);

    entryDate = new DateField("Date: ");
    entryDate.setWidth("100%");
    glayout.addComponent(entryDate, 0, 0);

    promoItem = new TextField("Promo Items: ");
    promoItem.setWidth("100%");
    glayout.addComponent(promoItem, 1, 0, 3, 0);

    promoAmount = new TextField("Amount: ");
    promoAmount.setWidth("100%");
    promoAmount.setStyleName("align-right");
    glayout.addComponent(promoAmount, 0, 1);

    quantity = new TextField("Quantity: ");
    quantity.setWidth("100%");
    quantity.setStyleName("align-right");
    glayout.addComponent(quantity, 1, 1);

    productItems = CommonComboBox.productItems();
    productItems.setWidth("100%");
    glayout.addComponent(productItems, 2, 1, 3, 1);

    startDate = new DateField("From: ");
    startDate.setWidth("100%");
    glayout.addComponent(startDate, 0, 2);

    endDate = new DateField("To: ");
    endDate.setWidth("100%");
    glayout.addComponent(endDate, 1, 2);

    salesRep.setWidth("100%");
    glayout.addComponent(salesRep, 2, 2, 3, 2);

    areaSales.setWidth("100%");
    glayout.addComponent(areaSales, 2, 3, 3, 3);

    remarks = new TextArea("Remarks: ");
    remarks.setWidth("100%");
    remarks.setRows(4);
    glayout.addComponent(remarks, 0, 3, 1, 4);

    Button submitBtn = new Button();
    submitBtn.setCaption("SAVE");
    submitBtn.setWidth("100%");
    submitBtn.addClickListener(this);
    glayout.addComponent(submitBtn, 2, 4, 3, 4);
    glayout.setComponentAlignment(submitBtn, Alignment.BOTTOM_CENTER);

    if (getPromoId() != 0) {
        PromoDeals pd = pds.getPromoDealById(getPromoId());
        submitBtn.setCaption("UPDATE");
        entryDate.setValue(pd.getEntryDate());
        startDate.setValue(pd.getStartDate());
        endDate.setValue(pd.getEndDate());
        promoItem.setValue(pd.getPromoItem());
        promoAmount.setValue(String.valueOf(pd.getPromoAmount()));
        quantity.setValue(String.valueOf(pd.getQuantity()));
        productItems.setValue(pd.getProductId());
        areaSales.setValue(pd.getAreaSalesId());
        salesRep.setValue(pd.getSalesRepId());
        remarks.setValue(pd.getRemarks());
    }

    content.addComponent(glayout);
    return content;
}