Example usage for com.vaadin.ui CheckBox CheckBox

List of usage examples for com.vaadin.ui CheckBox CheckBox

Introduction

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

Prototype

public CheckBox() 

Source Link

Document

Creates a new checkbox.

Usage

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

VerticalLayout generateAttendanceTable() {
    VerticalLayout vlayout = new VerticalLayout();
    vlayout.setSizeFull();//w w  w .j  a  v a 2s.  c  o  m
    vlayout.setSpacing(true);

    final Table table = new Table();
    table.removeAllItems();
    table.setEnabled(true);
    table.setSizeFull();
    table.setImmediate(true);
    table.setColumnCollapsingAllowed(true);

    table.addContainerProperty("date", String.class, null);
    table.addContainerProperty("policy", ComboBox.class, null);
    table.addContainerProperty("holidays", ComboBox.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("duty manager", 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("dm/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("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("duty manager", 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("dm/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.setColumnWidth("date", 70);
    table.setColumnWidth("policy", 125);
    table.setColumnWidth("holidays", 125);
    table.setColumnWidth("premium", 60);
    table.setColumnWidth("lates", 50);
    table.setColumnWidth("undertime", 60);
    table.setColumnWidth("overtime", 50);
    table.setColumnWidth("night differential", 110);
    table.setColumnWidth("duty manager", 80);
    table.setColumnWidth("l/min", 40);
    table.setColumnWidth("u/min", 40);
    table.setColumnWidth("o/min", 40);
    table.setColumnWidth("nd/min", 50);

    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" };
    if (getEmploymentWageEntry().equals("monthly")) {
        employmentWage = utilities.roundOffToTwoDecimalPlaces((employmentWage * 12) / 314);
    }

    for (int i = 0; i < dateList.size(); i++) {
        Object itemId = new Integer(i);
        final ComboBox holidays = dropDown.populateAttendanceHolidayDropDownList(new ComboBox());
        holidays.setEnabled(false);
        holidays.setWidth("120px");
        holidays.setNullSelectionAllowed(false);
        holidays.setData(itemId);

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

        final TextField lates = new TextField();
        lates.setWidth("100%");
        lates.setValue("0");
        lates.addStyleName("numerical");
        lates.setEnabled(true);
        lates.setData(itemId);
        lates.setImmediate(true);

        final TextField undertime = new TextField();
        undertime.setWidth("100%");
        undertime.setValue("0");
        undertime.addStyleName("numerical");
        undertime.setEnabled(true);
        undertime.setData(itemId);
        undertime.setImmediate(true);

        final TextField overtime = new TextField();
        overtime.setWidth("100%");
        overtime.setValue("0");
        overtime.addStyleName("numerical");
        overtime.setEnabled(true);
        overtime.setData(itemId);
        overtime.setImmediate(true);

        final TextField nightDifferential = new TextField();
        nightDifferential.setWidth("70%");
        nightDifferential.setValue("0");
        nightDifferential.addStyleName("numerical");
        nightDifferential.setEnabled(true);
        nightDifferential.setData(itemId);
        nightDifferential.setImmediate(true);

        final TextField dutyManager = new TextField();
        dutyManager.setWidth("80%");
        dutyManager.setValue("0");
        dutyManager.addStyleName("numerical");
        dutyManager.setEnabled(true);
        dutyManager.setData(itemId);
        dutyManager.setImmediate(true);

        final ComboBox policy = dropDown.populateAttendancePolicyDropDownList(new ComboBox());
        policy.setWidth("120px");
        policy.setNullSelectionAllowed(true);
        policy.setData(itemId);
        policy.addListener(new Property.ValueChangeListener() {

            @Override
            public void valueChange(Property.ValueChangeEvent event) {
                Object itemId = policy.getData();
                Item item = table.getItem(itemId);
                double additionalWorkingDayOffPay = 0;

                holidays.removeAllItems();
                for (String temp : holidayList) {
                    holidays.addItem(temp);
                }

                premium.setValue(false);
                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);
                item.getItemProperty("dm/min").setValue(0.0);
                item.getItemProperty("sholiday").setValue(0.0);
                item.getItemProperty("lholiday").setValue(0.0);
                item.getItemProperty("wdo").setValue(0.0);
                item.getItemProperty("psday").setValue(0.0);
                item.getItemProperty("psday").setValue(0.0);
                item.getItemProperty("latesLH").setValue(0.0);
                item.getItemProperty("latesSH").setValue(0.0);
                item.getItemProperty("latesWO").setValue(0.0);
                item.getItemProperty("undertimeLH").setValue(0.0);
                item.getItemProperty("undertimeSH").setValue(0.0);
                item.getItemProperty("undertimeWO").setValue(0.0);

                if (event.getProperty().getValue() == null) {
                    holidays.setEnabled(false);
                    lates.setEnabled(true);
                    undertime.setEnabled(true);
                    overtime.setEnabled(true);
                    nightDifferential.setEnabled(true);
                    dutyManager.setEnabled(true);
                } else if (event.getProperty().getValue().equals("holiday")) {
                    holidays.setEnabled(true);
                    lates.setEnabled(false);
                    undertime.setEnabled(false);
                    overtime.setEnabled(false);
                    nightDifferential.setEnabled(false);
                    dutyManager.setEnabled(false);
                } else if (event.getProperty().getValue().equals("working-holiday")) {
                    holidays.setEnabled(true);
                    lates.setEnabled(true);
                    undertime.setEnabled(true);
                    overtime.setEnabled(true);
                    nightDifferential.setEnabled(true);
                    dutyManager.setEnabled(true);
                } else if (event.getProperty().getValue().equals("working-day-off")) {
                    holidays.setEnabled(true);
                    lates.setEnabled(true);
                    undertime.setEnabled(true);
                    overtime.setEnabled(true);
                    nightDifferential.setEnabled(true);
                    dutyManager.setEnabled(true);

                    additionalWorkingDayOffPay = computation.processAdditionalWorkingDayOff(getEmploymentWage(),
                            getEmploymentWageEntry());
                    System.out.println("wdo: " + additionalWorkingDayOffPay);
                    if (getBranch().equals("on-call and trainees")) {
                        item.getItemProperty("wdo")
                                .setValue(utilities.roundOffToTwoDecimalPlaces(getEmploymentWage()));
                    } else {
                        item.getItemProperty("wdo")
                                .setValue(utilities.roundOffToTwoDecimalPlaces(additionalWorkingDayOffPay));
                    }
                } else {
                    holidays.setEnabled(false);
                    lates.setEnabled(false);
                    undertime.setEnabled(false);
                    overtime.setEnabled(false);
                    nightDifferential.setEnabled(false);
                    dutyManager.setEnabled(false);
                }
            }
        });
        policy.setImmediate(true);

        holidays.addListener(new ComboBox.ValueChangeListener() {

            @Override
            public void valueChange(Property.ValueChangeEvent event) {
                Object itemId = holidays.getData();
                Item item = table.getItem(itemId);

                String policyStr = item.getItemProperty("policy").toString();
                double additionalHolidayPay = 0;
                double multiplePremiumPay = 0;
                double additionalWorkingDayOffPay = 0;

                premium.setValue(false);
                lates.setValue("0");
                undertime.setValue("0");
                overtime.setValue("0");
                nightDifferential.setValue("0");
                item.getItemProperty("sholiday").setValue(0.0);
                item.getItemProperty("lholiday").setValue(0.0);
                item.getItemProperty("latesLH").setValue(0.0);
                item.getItemProperty("latesSH").setValue(0.0);
                item.getItemProperty("latesWO").setValue(0.0);
                item.getItemProperty("undertimeLH").setValue(0.0);
                item.getItemProperty("undertimeSH").setValue(0.0);
                item.getItemProperty("undertimeWO").setValue(0.0);

                if (policyStr == null) {
                } else {
                    if (policyStr.equals("working-holiday")) {
                        if (event.getProperty().getValue().equals("legal-holiday")) {
                            additionalHolidayPay = computation.processAdditionalHolidayPay(
                                    event.getProperty().getValue().toString(), getEmploymentWage());
                            item.getItemProperty("lholiday")
                                    .setValue(utilities.roundOffToTwoDecimalPlaces(additionalHolidayPay));
                            item.getItemProperty("sholiday").setValue(0.0);
                        } else {
                            additionalHolidayPay = computation.processAdditionalHolidayPay(
                                    event.getProperty().getValue().toString(), getEmploymentWage());
                            item.getItemProperty("sholiday")
                                    .setValue(utilities.roundOffToTwoDecimalPlaces(additionalHolidayPay));
                            item.getItemProperty("lholiday").setValue(0.0);
                        }
                    } else if (policyStr.equals("holiday")) {
                        if (event.getProperty().getValue().equals("legal-holiday")) {
                            if (getEmploymentWageEntry().equals("daily")) {
                                additionalHolidayPay = computation.processAdditionalHolidayPay(
                                        event.getProperty().getValue().toString(), getEmploymentWage());
                                item.getItemProperty("psday")
                                        .setValue(utilities.roundOffToTwoDecimalPlaces(additionalHolidayPay));
                            } else {
                                item.getItemProperty("psday").setValue(0.0);
                            }
                        } else {
                            item.getItemProperty("psday").setValue(0.0);
                        }
                    } else if (policyStr.equals("working-day-off")) {
                        if (event.getProperty().getValue() == null) {
                            item.getItemProperty("psday").setValue(0.0);
                        } else if (event.getProperty().getValue().equals("legal-holiday")) {
                            additionalWorkingDayOffPay = computation.processAdditionalWorkingDayOff(
                                    getEmploymentWage(), getEmploymentWageEntry());
                            item.getItemProperty("wdo")
                                    .setValue(utilities.roundOffToTwoDecimalPlaces(additionalWorkingDayOffPay));
                            multiplePremiumPay = computation.processMultiplePremiumPay(
                                    event.getProperty().getValue().toString(), getEmploymentWage());
                            item.getItemProperty("lholiday").setValue(multiplePremiumPay);
                            item.getItemProperty("sholiday").setValue(0.0);
                        } else {
                            additionalWorkingDayOffPay = computation.processAdditionalWorkingDayOff(
                                    getEmploymentWage(), getEmploymentWageEntry());
                            item.getItemProperty("wdo")
                                    .setValue(utilities.roundOffToTwoDecimalPlaces(additionalWorkingDayOffPay));
                            multiplePremiumPay = computation.processMultiplePremiumPay(
                                    event.getProperty().getValue().toString(), getEmploymentWage());
                            item.getItemProperty("sholiday").setValue(multiplePremiumPay);
                            item.getItemProperty("lholiday").setValue(0.0);
                        }
                    }
                }
            }
        });
        holidays.setImmediate(true);

        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");
                dutyManager.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);
                item.getItemProperty("dm/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 (getBranch().equals("on-call and trainees")) {
                        lateDeduction = computation.processEmployeesLatesForOnCall(policyStr, holidayStr,
                                utilities.convertStringToInteger(event.getText().trim()), getEmploymentWage());
                        item.getItemProperty("l/min")
                                .setValue(utilities.roundOffToTwoDecimalPlaces(lateDeduction));
                    } else {
                        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 * 0.3));
                                item.getItemProperty("latesWO").setValue(0.0);
                                if (getEmploymentWageEntry().equals("daily")) {
                                    item.getItemProperty("l/min").setValue(lateDeduction);
                                } else {
                                    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);

                                if (getEmploymentWageEntry().equals("daily")) {
                                    item.getItemProperty("latesWO")
                                            .setValue(utilities.roundOffToTwoDecimalPlaces(lateDeduction * .3));
                                    item.getItemProperty("l/min").setValue(lateDeduction);
                                } else {
                                    item.getItemProperty("latesWO")
                                            .setValue(utilities.roundOffToTwoDecimalPlaces(lateDeduction * .3));
                                    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()) {
                    if (getBranch().equals("on-call and trainees")) {
                        undertimeDeduction = computation.processEmployeesUndertimeForOnCall(policyStr,
                                holidayStr, utilities.convertStringToInteger(event.getText().trim()),
                                getEmploymentWage());
                        item.getItemProperty("u/min")
                                .setValue(utilities.roundOffToTwoDecimalPlaces(undertimeDeduction));
                    } else {
                        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 * 0.3));
                            item.getItemProperty("undertimeWO").setValue(0.0);
                            if (getEmploymentWageEntry().equals("daily")) {
                                item.getItemProperty("u/min").setValue(undertimeDeduction);
                            } else {
                                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);
                            if (getEmploymentWageEntry().equals("daily")) {
                                item.getItemProperty("undertimeWO").setValue(
                                        utilities.roundOffToTwoDecimalPlaces(undertimeDeduction * .3));
                                item.getItemProperty("u/min").setValue(undertimeDeduction);
                            } else {
                                item.getItemProperty("undertimeWO").setValue(
                                        utilities.roundOffToTwoDecimalPlaces(undertimeDeduction * .3));
                                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()) {
                    String branch = getBranch().replaceAll("\\(.*?\\)", "");
                    if (branch.trim().equals("on-call and trainees")) {
                        overtimeAddition = computation.processEmployeesOvertimeForOnCall(policyStr, holidayStr,
                                utilities.convertStringToInteger(event.getText().trim()), getEmploymentWage());
                        item.getItemProperty("o/min")
                                .setValue(utilities.roundOffToTwoDecimalPlaces(overtimeAddition));
                    } else {
                        overtimeAddition = computation.processEmployeesOvertime(policyStr, holidayStr,
                                utilities.convertStringToInteger(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()) {
                    if (getBranch().equals("on-call and trainees")) {
                        nightDifferentialAddition = computation.processEmployeesNightDifferentialForOnCall(
                                policyStr, holidayStr, utilities.convertStringToInteger(event.getText().trim()),
                                getEmploymentWage());
                        item.getItemProperty("nd/min").setValue(utilities.roundOffToTwoDecimalPlaces(
                                nightDifferentialAddition + (nightDifferentialAddition * premiumRate)));
                    } else {
                        nightDifferentialAddition = computation.processEmployeesNightDifferential(policyStr,
                                holidayStr, utilities.convertStringToInteger(event.getText().trim()),
                                getEmploymentWage());
                        item.getItemProperty("nd/min").setValue(utilities.roundOffToTwoDecimalPlaces(
                                nightDifferentialAddition + (nightDifferentialAddition * premiumRate)));
                    }

                } else {
                    item.getItemProperty("nd/min").setValue(0.0);
                }
            }
        });

        dutyManager.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 dutyManagerAddition;

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

                if (!event.getText().isEmpty()) {
                    if (getBranch().equals("on-call and trainees")) {
                        dutyManagerAddition = computation.processEmployeeDutyManagerForOnCall(policyStr,
                                holidayStr, utilities.convertStringToInteger(event.getText().trim()),
                                getEmploymentWage());
                        item.getItemProperty("dm/min")
                                .setValue(utilities.roundOffToTwoDecimalPlaces(dutyManagerAddition));
                    } else {
                        dutyManagerAddition = computation.processEmployeeDutyManager(policyStr, holidayStr,
                                utilities.convertStringToInteger(event.getText().trim()), getEmploymentWage());
                        item.getItemProperty("dm/min")
                                .setValue(utilities.roundOffToTwoDecimalPlaces(dutyManagerAddition));
                    }

                } else {
                    item.getItemProperty("dm/min").setValue(0.0);
                }
            }
        });

        table.addItem(new Object[] { utilities.convertDateFormat(dateList.get(i).toString()), policy, holidays,
                premium, lates, undertime, overtime, nightDifferential, dutyManager, 0.0, 0.0, 0.0, 0.0, 0.0,
                0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, //lates from legal & special holiday 
                0.0, 0.0, 0.0 //undertime from legal & special holiday
        }, i);
    }
    table.setPageLength(table.size());

    vlayout.addComponent(table);

    final Button button = new Button();
    button.setCaption("Save Attendance Data");
    vlayout.addComponent(button);

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

    button.addListener(new Button.ClickListener() {

        @Override
        public void buttonClick(Button.ClickEvent event) {
            try {
                Collection attendanceTableCollection = table.getContainerDataSource().getItemIds();
                List<Timekeeping> attendanceList = new ArrayList<Timekeeping>();
                for (int i = 0; i < attendanceTableCollection.size(); i++) {
                    String str = table.getItem(i).toString();
                    String[] attStr = str.split(" ");
                    List<String> tkeepList = new ArrayList<String>(Arrays.asList(attStr));

                    Timekeeping t = new Timekeeping();
                    t.setAttendanceDate(utilities.parsingDate(tkeepList.get(0)));
                    t.setPolicy(tkeepList.get(1));
                    t.setHoliday(tkeepList.get(2));
                    t.setPremium(utilities.convertStringToBoolean(tkeepList.get(3)));
                    t.setLates(utilities.convertStringToDouble(tkeepList.get(4)));
                    t.setUndertime(utilities.convertStringToDouble(tkeepList.get(5)));
                    t.setOvertime(utilities.convertStringToDouble(tkeepList.get(6)));
                    t.setNightDifferential(utilities.convertStringToDouble(tkeepList.get(7)));
                    t.setDutyManager(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.setDutyManagerPaid(utilities.convertStringToDouble(tkeepList.get(13)));
                    t.setLegalHolidayPaid(utilities.convertStringToDouble(tkeepList.get(14)));
                    t.setSpecialHolidayPaid(utilities.convertStringToDouble(tkeepList.get(15)));
                    t.setWorkingDayOffPaid(utilities.convertStringToDouble(tkeepList.get(16)));
                    t.setNonWorkingHolidayPaid(utilities.convertStringToDouble(tkeepList.get(17)));
                    t.setLatesLegalHolidayDeduction(utilities.convertStringToDouble(tkeepList.get(18)));
                    t.setLatesSpecialHolidayDeduction(utilities.convertStringToDouble(tkeepList.get(19)));
                    t.setLatesWorkingDayOffDeduction(utilities.convertStringToDouble(tkeepList.get(20)));
                    t.setUndertimeLegalHolidayDeduction(utilities.convertStringToDouble(tkeepList.get(21)));
                    t.setUndertimeSpecialHolidayDeduction(utilities.convertStringToDouble(tkeepList.get(22)));
                    t.setUndertimeWorkingDayOffDeduction(utilities.convertStringToDouble(tkeepList.get(23)));
                    attendanceList.add(t);
                }

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

    });

    return vlayout;
}

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

VerticalLayout generateAttendanceTable() {
    VerticalLayout vlayout = new VerticalLayout();
    vlayout.setSizeFull();/*from w  w  w  . ja va  2s. c  o 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.parship.roperty.ui.LoginUI.java

License:Apache License

@AutoGenerated
private HorizontalLayout buildButtonLayout() {
    // common part: create layout
    buttonLayout = new HorizontalLayout();
    buttonLayout.setImmediate(false);// w ww  .j  ava2  s  .c  om
    buttonLayout.setWidth("100.0%");
    buttonLayout.setHeight("-1px");
    buttonLayout.setMargin(false);

    // keeploggedinLabel
    keeploggedinLabel = new CheckBox();
    keeploggedinLabel.setCaption("Remember me!");
    keeploggedinLabel.setImmediate(false);
    keeploggedinLabel.setWidth("-1px");
    keeploggedinLabel.setHeight("-1px");
    keeploggedinLabel.setTabIndex(3);
    buttonLayout.addComponent(keeploggedinLabel);
    buttonLayout.setComponentAlignment(keeploggedinLabel, new Alignment(33));

    // loginButton
    loginButton = new Button();
    loginButton.setStyleName("v-button");
    loginButton.setCaption("Login");
    loginButton.setImmediate(true);
    loginButton.setWidth("100px");
    loginButton.setHeight("-1px");
    loginButton.setTabIndex(4);
    buttonLayout.addComponent(loginButton);
    buttonLayout.setComponentAlignment(loginButton, new Alignment(6));

    return buttonLayout;
}

From source file:com.siemens.ct.osgi.vaadin.pm.bundleview.BundleView.java

License:Open Source License

private void refreshTable() {
    table.removeAllItems();/*  w ww . j ava 2  s  .co m*/

    int i = 1;
    for (Bundle bundle : bundles) {
        final Bundle selectedBundle = bundle;
        CheckBox checkBox = new CheckBox();
        checkBox.setImmediate(true);
        checkBox.setValue(bundle.getState() == Bundle.ACTIVE);
        checkBox.addListener(new ValueChangeListener() {
            private static final long serialVersionUID = 1L;

            @Override
            public void valueChange(com.vaadin.data.Property.ValueChangeEvent event) {
                if (selectedBundle.getState() == Bundle.ACTIVE) {
                    try {
                        selectedBundle.stop();
                        refreshTable();
                    } catch (BundleException e1) {
                        e1.printStackTrace();
                    }
                } else if (selectedBundle.getState() == Bundle.RESOLVED) {
                    try {
                        selectedBundle.start();
                        refreshTable();
                    } catch (BundleException e1) {
                        e1.printStackTrace();
                    }
                }
            }
        });
        table.addItem(new Object[] { bundle.getSymbolicName(), bundle.getVersion(), getStateString(bundle),
                checkBox }, i++);
    }
    table.sort();
}

From source file:com.terralcode.gestion.frontend.view.widgets.appointment.AppointmentView.java

private void buildAppointmentStatus() {
    Label section = new Label("Estado");
    section.addStyleName(ValoTheme.LABEL_H4);
    section.addStyleName(ValoTheme.LABEL_COLORED);
    rootLayout.addComponent(section);// w  w w. j  ava  2 s. co m

    status = new ComboBox();
    status.setContainerDataSource(containerStatuses);
    status.setWidth("100%");
    status.setTextInputAllowed(false);
    status.setNullSelectionAllowed(false);

    notifyChanges = new CheckBox();
    notifyChanges.setIcon(FontAwesome.BELL);
    notifyChanges.setImmediate(true);

    HorizontalLayout statusWrapper = new HorizontalLayout();
    statusWrapper.setCaption("Estado");
    statusWrapper.addComponent(status);
    statusWrapper.addComponent(notifyChanges);
    statusWrapper.setWidth("100%");
    statusWrapper.setExpandRatio(status, 1);
    rootLayout.addComponent(statusWrapper);

    statusNotes = new TextArea("Notas de estado");
    statusNotes.setWidth("100%");
    statusNotes.setInputPrompt("Anotaciones del estado...");
    rootLayout.addComponent(statusNotes);
}

From source file:com.zklogtool.web.components.OpenTransactionLogFileDialog.java

License:Apache License

@AutoGenerated
private HorizontalLayout buildHorizontalLayout_1() {
    // common part: create layout
    horizontalLayout_1 = new HorizontalLayout();
    horizontalLayout_1.setImmediate(false);
    horizontalLayout_1.setWidth("-1px");
    horizontalLayout_1.setHeight("-1px");
    horizontalLayout_1.setMargin(false);
    horizontalLayout_1.setSpacing(true);

    // followCheckbox
    followCheckbox = new CheckBox();
    followCheckbox.setCaption("Follow");
    followCheckbox.setImmediate(false);/*from   w w w.  j av a2  s.c  o m*/
    followCheckbox.setWidth("-1px");
    followCheckbox.setHeight("-1px");
    horizontalLayout_1.addComponent(followCheckbox);

    // startFromLastCheckbox
    startFromLastCheckbox = new CheckBox();
    startFromLastCheckbox.setCaption("Start from last transaction");
    startFromLastCheckbox.setImmediate(false);
    startFromLastCheckbox.setWidth("-1px");
    startFromLastCheckbox.setHeight("-1px");
    horizontalLayout_1.addComponent(startFromLastCheckbox);

    return horizontalLayout_1;
}

From source file:cz.opendata.linked.lodcloud.loader.LoaderDialog.java

@Override
protected void buildDialogLayout() {
    // common part: create layout
    mainLayout = new VerticalLayout();
    mainLayout.setImmediate(false);/*from  ww w  . j av  a  2  s .co  m*/
    mainLayout.setSizeUndefined();
    mainLayout.setWidth("100%");
    //mainLayout.setHeight("-1px");
    mainLayout.setMargin(false);
    //mainLayout.setSpacing(true);

    // top-level component properties
    setWidth("100%");
    setHeight("100%");

    tfRestApiUrl = new TextField();
    tfRestApiUrl.setWidth("100%");
    tfRestApiUrl.setCaption("CKAN Rest API URL");
    tfRestApiUrl.setInputPrompt("http://datahub.io/api/rest/dataset");
    mainLayout.addComponent(tfRestApiUrl);

    tfApiKey = new PasswordField();
    tfApiKey.setWidth("100%");
    tfApiKey.setCaption("CKAN API Key");
    tfApiKey.setDescription("CKAN API Key");
    tfApiKey.setInputPrompt("00000000-0000-0000-0000-000000000000");
    mainLayout.addComponent(tfApiKey);

    tfDatasetID = new TextField();
    tfDatasetID.setImmediate(true);
    tfDatasetID.setWidth("100%");
    tfDatasetID.setTextChangeEventMode(TextChangeEventMode.EAGER);
    tfDatasetID.setCaption("Dataset ID");
    tfDatasetID.setDescription("CKAN Dataset Name used in CKAN Dataset URL");
    tfDatasetID.setInputPrompt("cz-test");
    tfDatasetID.addValueChangeListener(new ValueChangeListener() {
        private static final long serialVersionUID = -8684376114117545707L;

        @Override
        public void valueChange(ValueChangeEvent event) {
            String url = "http://datahub.io/api/rest/dataset/" + tfDatasetID.getValue();
            lblRestApiUrl.setValue("<a href=\"" + url + "\" target=\"_blank\">" + url + "</a>");
        }
    });
    mainLayout.addComponent(tfDatasetID);

    lblRestApiUrl = new Label();
    lblRestApiUrl.setContentMode(ContentMode.HTML);
    mainLayout.addComponent(lblRestApiUrl);

    tfOwnerOrg = new TextField();
    tfOwnerOrg.setWidth("100%");
    tfOwnerOrg.setCaption("Owner CKAN organization ID");
    tfOwnerOrg.setInputPrompt("00000000-0000-0000-0000-000000000000");
    mainLayout.addComponent(tfOwnerOrg);

    tfShortName = new TextField();
    tfShortName.setWidth("100%");
    tfShortName.setCaption("Dataset short name - for LOD cloud circle label");
    tfShortName.setInputPrompt("CZ IC");
    mainLayout.addComponent(tfShortName);

    cbTopic = new ComboBox();
    cbTopic.setWidth("100%");
    cbTopic.setCaption("Topic");
    cbTopic.setDescription("Topic is used for coloring of the LOD cloud");
    for (LoaderConfig.Topics topic : LoaderConfig.Topics.values()) {
        cbTopic.addItem(topic);
    }
    cbTopic.setInvalidAllowed(false);
    cbTopic.setNullSelectionAllowed(false);
    cbTopic.setTextInputAllowed(false);
    mainLayout.addComponent(cbTopic);

    tfMaintainerName = new TextField();
    tfMaintainerName.setWidth("100%");
    tfMaintainerName.setCaption("Maintainer name");
    tfMaintainerName.setInputPrompt("Jakub Klmek");
    mainLayout.addComponent(tfMaintainerName);

    tfMaintainerEmail = new TextField();
    tfMaintainerEmail.setWidth("100%");
    tfMaintainerEmail.setCaption("Maintainer email");
    tfMaintainerEmail.setInputPrompt("klimek@opendata.cz");
    mainLayout.addComponent(tfMaintainerEmail);

    tfAuthorName = new TextField();
    tfAuthorName.setWidth("100%");
    tfAuthorName.setCaption("Author name");
    tfAuthorName.setInputPrompt("Jakub Klmek");
    mainLayout.addComponent(tfAuthorName);

    tfAuthorEmail = new TextField();
    tfAuthorEmail.setWidth("100%");
    tfAuthorEmail.setCaption("Author email");
    tfAuthorEmail.setInputPrompt("klimek@opendata.cz");
    mainLayout.addComponent(tfAuthorEmail);

    tfVersion = new TextField();
    tfVersion.setWidth("100%");
    tfVersion.setCaption("Version");
    tfVersion.setInputPrompt("2014-03-01");
    mainLayout.addComponent(tfVersion);

    chkGenerateVersion = new CheckBox();
    chkGenerateVersion.setCaption("Generate Version as current date");
    chkGenerateVersion.setImmediate(true);
    chkGenerateVersion.addValueChangeListener(new ValueChangeListener() {
        private static final long serialVersionUID = 7348068985822592639L;

        @Override
        public void valueChange(ValueChangeEvent event) {
            tfVersion.setEnabled(!chkGenerateVersion.getValue());
        }
    });
    mainLayout.addComponent(chkGenerateVersion);

    cbLicense = new ComboBox();
    cbLicense.setWidth("100%");
    cbLicense.setCaption("License");
    cbLicense.setDescription("License displayed in CKAN");
    for (LoaderConfig.Licenses license : LoaderConfig.Licenses.values()) {
        cbLicense.addItem(license);
    }
    cbLicense.setImmediate(true);
    cbLicense.setInvalidAllowed(false);
    cbLicense.setTextInputAllowed(false);
    cbLicense.setNullSelectionAllowed(false);
    cbLicense.addValueChangeListener(new ValueChangeListener() {
        private static final long serialVersionUID = -5553056221069512526L;

        @Override
        public void valueChange(ValueChangeEvent event) {
            LoaderConfig.Licenses l = (Licenses) cbLicense.getValue();
            boolean enabled = false;
            enabled = enabled || l == LoaderConfig.Licenses.otherat;
            enabled = enabled || l == LoaderConfig.Licenses.otherclosed;
            enabled = enabled || l == LoaderConfig.Licenses.othernc;
            enabled = enabled || l == LoaderConfig.Licenses.otheropen;
            enabled = enabled || l == LoaderConfig.Licenses.otherpd;
        }
    });

    mainLayout.addComponent(cbLicense);

    tfSPARQLName = new TextField();
    tfSPARQLName.setWidth("100%");
    tfSPARQLName.setCaption("SPARQL Endpoint name");
    tfSPARQLName.setInputPrompt("Opendata.cz SPARQL Endpoint");
    mainLayout.addComponent(tfSPARQLName);

    tfSPARQLDescription = new TextField();
    tfSPARQLDescription.setWidth("100%");
    tfSPARQLDescription.setCaption("SPARQL Endpoint description");
    tfSPARQLDescription.setInputPrompt("Running Virtuoso 7");
    mainLayout.addComponent(tfSPARQLDescription);

    tfNamespace = new TextField();
    tfNamespace.setWidth("100%");
    tfNamespace.setCaption("RDF namespace");
    tfNamespace.setInputPrompt("http://linked.opendata.cz/resource/");
    mainLayout.addComponent(tfNamespace);

    lsLicenseMetadataTag = new ListSelect();
    lsLicenseMetadataTag.setWidth("100%");
    lsLicenseMetadataTag.setCaption("License metadata");
    lsLicenseMetadataTag.setDescription("Switches between license-metadata and no-license-metadata tags");
    for (LoaderConfig.LicenseMetadataTags lmdTag : LoaderConfig.LicenseMetadataTags.values()) {
        lsLicenseMetadataTag.addItem(lmdTag);
    }
    lsLicenseMetadataTag.setNewItemsAllowed(false);
    lsLicenseMetadataTag.setMultiSelect(false);
    lsLicenseMetadataTag.setNullSelectionAllowed(false);
    lsLicenseMetadataTag.setRows(LoaderConfig.LicenseMetadataTags.values().length);
    mainLayout.addComponent(lsLicenseMetadataTag);

    lsProvenanceMetadataTag = new ListSelect();
    lsProvenanceMetadataTag.setWidth("100%");
    lsProvenanceMetadataTag.setCaption("Provenance metadata");
    lsProvenanceMetadataTag
            .setDescription("Switches between provenance-metadata and no-provenance-metadata tags");
    for (LoaderConfig.ProvenanceMetadataTags pmdTag : LoaderConfig.ProvenanceMetadataTags.values()) {
        lsProvenanceMetadataTag.addItem(pmdTag);
    }
    lsProvenanceMetadataTag.setNewItemsAllowed(false);
    lsProvenanceMetadataTag.setMultiSelect(false);
    lsProvenanceMetadataTag.setNullSelectionAllowed(false);
    lsProvenanceMetadataTag.setRows(LoaderConfig.ProvenanceMetadataTags.values().length);
    mainLayout.addComponent(lsProvenanceMetadataTag);

    lsPublishedTag = new ListSelect();
    lsPublishedTag.setWidth("100%");
    lsPublishedTag.setCaption("Publised by");
    lsPublishedTag.setDescription("Switches between published-by-producer and published-by-third-party tags");
    for (LoaderConfig.PublishedTags pTag : LoaderConfig.PublishedTags.values()) {
        lsPublishedTag.addItem(pTag);
    }
    lsPublishedTag.setNewItemsAllowed(false);
    lsPublishedTag.setMultiSelect(false);
    lsPublishedTag.setNullSelectionAllowed(false);
    lsPublishedTag.setRows(LoaderConfig.PublishedTags.values().length);
    mainLayout.addComponent(lsPublishedTag);

    lsVocabTag = new ListSelect();
    lsVocabTag.setWidth("100%");
    lsVocabTag.setCaption("Proprietary vocabulary");
    lsVocabTag.setDescription("Switches among no-proprietary-vocab deref-vocab and no-deref-vocab tags");
    for (LoaderConfig.VocabTags vTag : LoaderConfig.VocabTags.values()) {
        lsVocabTag.addItem(vTag);
    }
    lsVocabTag.setNewItemsAllowed(false);
    lsVocabTag.setImmediate(true);
    lsVocabTag.setMultiSelect(false);
    lsVocabTag.setNullSelectionAllowed(false);
    lsVocabTag.setRows(LoaderConfig.VocabTags.values().length);

    mainLayout.addComponent(lsVocabTag);

    lsVocabMappingsTag = new ListSelect();
    lsVocabMappingsTag.setWidth("100%");
    lsVocabMappingsTag.setCaption("Vocabulary mapping");
    lsVocabMappingsTag.setDescription(
            "Only valid when using proprietary vocabulary. Switches between vocab-mappings and no-vocab-mappings tags");
    for (LoaderConfig.VocabMappingsTags vmTag : LoaderConfig.VocabMappingsTags.values()) {
        lsVocabMappingsTag.addItem(vmTag);
    }
    lsVocabMappingsTag.setNewItemsAllowed(false);
    lsVocabMappingsTag.setMultiSelect(false);
    lsVocabMappingsTag.setNullSelectionAllowed(false);
    lsVocabMappingsTag.setRows(LoaderConfig.VocabMappingsTags.values().length);
    mainLayout.addComponent(lsVocabMappingsTag);

    lsAdditionalTags = new ListSelect();
    lsAdditionalTags.setRows(4);
    lsAdditionalTags.setWidth("100%");
    lsAdditionalTags.setCaption("Additional CKAN tags");
    lsAdditionalTags.setDescription("Custom CKAN tags in addition to the ones required for the LODCloud");
    lsAdditionalTags.setNewItemsAllowed(true);
    lsAdditionalTags.setNullSelectionAllowed(false);
    lsAdditionalTags.setMultiSelect(true);
    mainLayout.addComponent(lsAdditionalTags);

    chkLodcloudNolinks = new CheckBox();
    chkLodcloudNolinks.setCaption("Data set has no external RDF links to other datasets.");
    mainLayout.addComponent(chkLodcloudNolinks);

    chkLodcloudUnconnected = new CheckBox();
    chkLodcloudUnconnected.setCaption("Data set has no external RDF links to or from other datasets.");
    mainLayout.addComponent(chkLodcloudUnconnected);

    chkLodcloudNeedsFixing = new CheckBox();
    chkLodcloudNeedsFixing.setCaption("The dataset is currently broken.");
    mainLayout.addComponent(chkLodcloudNeedsFixing);

    chkLodcloudNeedsInfo = new CheckBox();
    chkLodcloudNeedsInfo
            .setCaption("The data provider or data set homepage do not provide mininum information.");
    mainLayout.addComponent(chkLodcloudNeedsInfo);

    chkLimitedSparql = new CheckBox();
    chkLimitedSparql.setCaption("Indicates whether the SPARQL endpoint is not serving the whole data set.");
    mainLayout.addComponent(chkLimitedSparql);

    lsVocabularies = new ListSelect();
    lsVocabularies.setRows(4);
    lsVocabularies.setWidth("100%");
    lsVocabularies.setCaption("Standard prefixes of vocabularies used");
    lsVocabularies.setDescription("Tags the dataset with used vocabulary prefixes. Lookup: http://prefix.cc");
    lsVocabularies.setNewItemsAllowed(true);
    lsVocabularies.setNullSelectionAllowed(false);
    lsVocabularies.setMultiSelect(true);
    mainLayout.addComponent(lsVocabularies);

    gtLinkCounts = new ComponentTable<LoaderConfig.LinkCount>(LoaderConfig.LinkCount.class,
            new ComponentTable.ColumnInfo("targetDataset", "Target CKAN dataset name", null, 0.4f),
            new ComponentTable.ColumnInfo("linkCount", "Link count", null, 0.1f));

    gtLinkCounts.setPolicy(new ComponentTable.Policy<LoaderConfig.LinkCount>() {

        @Override
        public boolean isSet(LoaderConfig.LinkCount value) {
            return !value.getTargetDataset().isEmpty();
        }

    });
    mainLayout.addComponent(gtLinkCounts);

    gtMappingFiles = new ComponentTable<LoaderConfig.MappingFile>(LoaderConfig.MappingFile.class,
            new ComponentTable.ColumnInfo("mappingFormat", "Mapping format", null, 0.1f),
            new ComponentTable.ColumnInfo("mappingFile", "Link to mapping file", null, 0.4f));

    gtMappingFiles.setPolicy(new ComponentTable.Policy<LoaderConfig.MappingFile>() {

        @Override
        public boolean isSet(LoaderConfig.MappingFile value) {
            return !value.getMappingFile().isEmpty();
        }

    });
    mainLayout.addComponent(gtMappingFiles);

    Panel panel = new Panel();
    panel.setSizeFull();
    panel.setContent(mainLayout);
    setCompositionRoot(panel);
}

From source file:cz.opendata.linked.metadata.form.ExtractorDialog.java

private VerticalLayout buildMainLayout() {
    // common part: create layout
    mainLayout = new VerticalLayout();
    mainLayout.setImmediate(true);//from w  w w  .jav  a 2  s .  c om
    mainLayout.setWidth("100%");
    mainLayout.setHeight(null);
    mainLayout.setMargin(false);
    //mainLayout.setSpacing(true);

    // top-level component properties
    setWidth("100%");
    setHeight("100%");

    tfDatasetUri = new TextField();
    tfDatasetUri.setCaption("Dataset URI:");
    tfDatasetUri.setWidth("100%");
    mainLayout.addComponent(tfDatasetUri);

    tfDistributionUri = new TextField();
    tfDistributionUri.setCaption("Distribution URI:");
    tfDistributionUri.setWidth("100%");
    mainLayout.addComponent(tfDistributionUri);

    tfDataDumpUrl = new TextField();
    tfDataDumpUrl.setCaption("Data dump URL:");
    tfDataDumpUrl.setWidth("100%");
    mainLayout.addComponent(tfDataDumpUrl);

    cbMime = new ComboBox();
    cbMime.setCaption("Media Type:");
    cbMime.setNewItemsAllowed(false);
    cbMime.setNullSelectionAllowed(false);
    cbMime.setWidth("100%");
    for (String u : mimes)
        cbMime.addItem(u);
    mainLayout.addComponent(cbMime);

    tfSparqlEndpointUrl = new TextField();
    tfSparqlEndpointUrl.setCaption("Sparql Endpoint URI:");
    tfSparqlEndpointUrl.setWidth("100%");
    mainLayout.addComponent(tfSparqlEndpointUrl);

    tfContactPoint = new TextField();
    tfContactPoint.setCaption("Contact Point URL:");
    tfContactPoint.setWidth("100%");
    mainLayout.addComponent(tfContactPoint);

    tfTitleCs = new TextField();
    tfTitleCs.setCaption("Title (cs):");
    tfTitleCs.setWidth("100%");
    mainLayout.addComponent(tfTitleCs);

    tfTitleEn = new TextField();
    tfTitleEn.setCaption("Title (en):");
    tfTitleEn.setWidth("100%");
    mainLayout.addComponent(tfTitleEn);

    tfDescCs = new TextField();
    tfDescCs.setCaption("Description (cs):");
    tfDescCs.setWidth("100%");
    mainLayout.addComponent(tfDescCs);

    tfDescEn = new TextField();
    tfDescEn.setCaption("Description (en):");
    tfDescEn.setWidth("100%");
    mainLayout.addComponent(tfDescEn);

    chkQb = new CheckBox();
    chkQb.setCaption("Dataset is RDF Data Cube");
    chkQb.setWidth("100%");
    mainLayout.addComponent(chkQb);

    dfModified = new DateField();
    dfModified.setCaption("Modified:");
    dfModified.setWidth("100%");
    dfModified.setResolution(Resolution.DAY);
    mainLayout.addComponent(dfModified);

    chkNow = new CheckBox();
    chkNow.setCaption("Always use current date instead");
    chkNow.setWidth("100%");
    mainLayout.addComponent(chkNow);

    cbPeriodicity = new ComboBox();
    cbPeriodicity.setCaption("Periodicity:");
    cbPeriodicity.setNewItemsAllowed(false);
    cbPeriodicity.setNullSelectionAllowed(false);
    cbPeriodicity.setItemCaptionMode(ItemCaptionMode.EXPLICIT);
    cbPeriodicity.setWidth("100%");
    for (URLandCaption u : periodicities) {
        cbPeriodicity.addItem(u.url.toString());
        cbPeriodicity.setItemCaption(u.url.toString(), u.caption);
    }
    mainLayout.addComponent(cbPeriodicity);

    tcsLicenses = new TwinColSelect();
    tcsLicenses.setWidth("97%");
    tcsLicenses.setNewItemsAllowed(true);
    tcsLicenses.setLeftColumnCaption("Available licenses");
    tcsLicenses.setRightColumnCaption("Selected licenses");
    mainLayout.addComponent(tcsLicenses);

    tcsExamples = new TwinColSelect();
    tcsExamples.setWidth("97%");
    tcsExamples.setNewItemsAllowed(true);
    tcsExamples.setLeftColumnCaption("Available example resources");
    tcsExamples.setRightColumnCaption("Selected example resources");
    mainLayout.addComponent(tcsExamples);

    tcsSources = new TwinColSelect();
    tcsSources.setWidth("97%");
    tcsSources.setNewItemsAllowed(true);
    tcsSources.setLeftColumnCaption("Available sources");
    tcsSources.setRightColumnCaption("Selected sources");
    mainLayout.addComponent(tcsSources);

    tcsKeywords = new TwinColSelect();
    tcsKeywords.setWidth("97%");
    tcsKeywords.setNewItemsAllowed(true);
    tcsKeywords.setLeftColumnCaption("Available keywords");
    tcsKeywords.setRightColumnCaption("Selected keywords");
    mainLayout.addComponent(tcsKeywords);

    tcsThemes = new TwinColSelect();
    tcsThemes.setWidth("97%");
    tcsThemes.setNewItemsAllowed(true);
    tcsThemes.setLeftColumnCaption("Available themes");
    tcsThemes.setRightColumnCaption("Selected themes");
    mainLayout.addComponent(tcsThemes);

    tcsLanguages = new TwinColSelect();
    tcsLanguages.setWidth("97%");
    tcsLanguages.setLeftColumnCaption("Available languages");
    tcsLanguages.setRightColumnCaption("Selected languages");
    mainLayout.addComponent(tcsLanguages);

    tcsAuthors = new TwinColSelect();
    tcsAuthors.setWidth("97%");
    tcsAuthors.setNewItemsAllowed(true);
    tcsAuthors.setLeftColumnCaption("Available authors");
    tcsAuthors.setRightColumnCaption("Selected authors");
    mainLayout.addComponent(tcsAuthors);

    tcsPublishers = new TwinColSelect();
    tcsPublishers.setWidth("97%");
    tcsPublishers.setNewItemsAllowed(true);
    tcsPublishers.setLeftColumnCaption("Available publishers");
    tcsPublishers.setRightColumnCaption("Selected publishers");
    mainLayout.addComponent(tcsPublishers);

    return mainLayout;
}

From source file:cz.opendata.unifiedviews.dpus.datasetMetadata.DatasetMetadataVaadinDialog.java

License:Creative Commons License

@Override
protected void buildDialogLayout() {
    // common part: create layout
    mainLayout = new VerticalLayout();
    mainLayout.setImmediate(true);/*  ww  w . j a va  2s . c o  m*/
    mainLayout.setWidth("100%");
    mainLayout.setHeight(null);
    mainLayout.setMargin(false);
    //mainLayout.setSpacing(true);

    // top-level component properties
    setWidth("100%");
    setHeight("100%");

    tfDatasetUri = new TextField();
    tfDatasetUri.setCaption("Dataset URI:");
    tfDatasetUri.setInputPrompt("http://data.mydomain.com/resource/dataset/mydataset");
    tfDatasetUri.setWidth("100%");
    mainLayout.addComponent(tfDatasetUri);

    tfLanguage = new TextField();
    tfLanguage.setCaption("Original language (RDF language tag, e.g. cs):");
    tfLanguage.setInputPrompt("cs|en|sk|it");
    tfLanguage.setWidth("100%");
    mainLayout.addComponent(tfLanguage);

    tfTitle = new TextField();
    tfTitle.setCaption("Dataset title original language:");
    tfTitle.setInputPrompt("My dataset");
    tfTitle.setWidth("100%");
    mainLayout.addComponent(tfTitle);

    tfTitleEn = new TextField();
    tfTitleEn.setCaption("Dataset title in English:");
    tfTitleEn.setInputPrompt("My dataset");
    tfTitleEn.setWidth("100%");
    mainLayout.addComponent(tfTitleEn);

    tfDesc = new TextField();
    tfDesc.setCaption("Description in original language:");
    tfDesc.setInputPrompt("Longer description in original language");
    tfDesc.setWidth("100%");
    mainLayout.addComponent(tfDesc);

    tfDescEn = new TextField();
    tfDescEn.setCaption("Description in English:");
    tfDescEn.setInputPrompt("Longer description in English");
    tfDescEn.setWidth("100%");
    mainLayout.addComponent(tfDescEn);

    dfIssued = new DateField();
    dfIssued.setCaption("Issued:");
    dfIssued.setWidth("100%");
    dfIssued.setResolution(Resolution.DAY);
    mainLayout.addComponent(dfIssued);

    dfModified = new DateField();
    dfModified.setCaption("Modified:");
    dfModified.setWidth("100%");
    dfModified.setResolution(Resolution.DAY);
    mainLayout.addComponent(dfModified);

    chkNow = new CheckBox();
    chkNow.setCaption("Use current date as modified");
    chkNow.setWidth("100%");
    chkNow.setImmediate(true);
    chkNow.addValueChangeListener(new ValueChangeListener() {
        private static final long serialVersionUID = -6135328311357043784L;

        @Override
        public void valueChange(ValueChangeEvent event) {
            dfModified.setEnabled(!chkNow.getValue());
        }
    });
    mainLayout.addComponent(chkNow);

    tfIdentifier = new TextField();
    tfIdentifier.setCaption("Identifier:");
    tfIdentifier.setInputPrompt("CTIA_1");
    tfIdentifier.setWidth("100%");
    mainLayout.addComponent(tfIdentifier);

    lsKeywords_orig = new ListSelect();
    lsKeywords_orig.setWidth("100%");
    lsKeywords_orig.setNewItemsAllowed(true);
    lsKeywords_orig.setCaption("Keywords in original language");
    lsKeywords_orig.setMultiSelect(true);
    lsKeywords_orig.setRows(3);
    mainLayout.addComponent(lsKeywords_orig);

    lsKeywords_en = new ListSelect();
    lsKeywords_en.setWidth("100%");
    lsKeywords_en.setNewItemsAllowed(true);
    lsKeywords_en.setCaption("Keywords in English");
    lsKeywords_en.setMultiSelect(true);
    lsKeywords_en.setRows(3);
    mainLayout.addComponent(lsKeywords_en);

    lsLanguages = new ListSelect();
    lsLanguages.setWidth("100%");
    lsLanguages.setNewItemsAllowed(true);
    lsLanguages.setCaption("Languages");
    lsLanguages.setMultiSelect(true);
    lsLanguages.addItems(languages);
    lsLanguages.setRows(3);
    mainLayout.addComponent(lsLanguages);

    tfContactPoint = new TextField();
    tfContactPoint.setCaption("Contact point email:");
    tfContactPoint.setInputPrompt("contact@myorganization.com");
    tfContactPoint.setWidth("100%");
    mainLayout.addComponent(tfContactPoint);

    dfTemporalStart = new DateField();
    dfTemporalStart.setCaption("Temporal coverage start:");
    dfTemporalStart.setWidth("100%");
    dfTemporalStart.setResolution(Resolution.DAY);
    mainLayout.addComponent(dfTemporalStart);

    dfTemporalEnd = new DateField();
    dfTemporalEnd.setCaption("Temporal coverage end:");
    dfTemporalEnd.setWidth("100%");
    dfTemporalEnd.setResolution(Resolution.DAY);
    mainLayout.addComponent(dfTemporalEnd);

    tfSpatial = new TextField();
    tfSpatial.setCaption("Spatial coverage URI:");
    tfSpatial.setInputPrompt("http://ruian.linked.opendata.cz/resource/adresni-mista/25958810");
    tfSpatial.setWidth("100%");
    mainLayout.addComponent(tfSpatial);

    tfPeriodicity = new TextField();
    tfPeriodicity.setCaption("Periodicity:");
    tfPeriodicity.setInputPrompt("R-P1Y");
    tfPeriodicity.setWidth("100%");
    mainLayout.addComponent(tfPeriodicity);

    tfSchema = new TextField();
    tfSchema.setCaption("Schema URL:");
    tfSchema.setInputPrompt("http://data.example.org/dataset/myschema");
    tfSchema.setWidth("100%");
    mainLayout.addComponent(tfSchema);

    tfLandingPage = new TextField();
    tfLandingPage.setCaption("Landing page URL:");
    tfLandingPage.setInputPrompt("http://data.example.org/dataset/mydataset");
    tfLandingPage.setWidth("100%");
    mainLayout.addComponent(tfLandingPage);

    lsLicenses = new ListSelect();
    lsLicenses.setWidth("100%");
    lsLicenses.setNewItemsAllowed(true);
    lsLicenses.setCaption("Licenses");
    lsLicenses.setMultiSelect(false);
    lsLicenses.setNullSelectionAllowed(false);
    lsLicenses.setRows(3);
    lsLicenses.addItems(licenses);
    mainLayout.addComponent(lsLicenses);

    lsSources = new ListSelect();
    lsSources.setWidth("100%");
    lsSources.setNewItemsAllowed(true);
    lsSources.setCaption("Sources");
    lsSources.setMultiSelect(true);
    lsSources.setRows(2);
    mainLayout.addComponent(lsSources);

    lsThemes = new ListSelect();
    lsThemes.setWidth("100%");
    lsThemes.setNewItemsAllowed(true);
    lsThemes.setCaption("Themes");
    lsThemes.setMultiSelect(true);
    lsThemes.setRows(3);
    mainLayout.addComponent(lsThemes);

    lsAuthors = new ListSelect();
    lsAuthors.setWidth("100%");
    lsAuthors.setNewItemsAllowed(true);
    lsAuthors.setCaption("Selected authors");
    lsAuthors.setMultiSelect(true);
    lsAuthors.setRows(2);
    mainLayout.addComponent(lsAuthors);

    lsPublishers = new ListSelect();
    lsPublishers.setWidth("100%");
    lsPublishers.setNewItemsAllowed(true);
    lsPublishers.setCaption("Publishers");
    lsPublishers.setMultiSelect(true);
    lsPublishers.addItems(publishers);
    lsPublishers.setRows(2);
    mainLayout.addComponent(lsPublishers);

    Panel p = new Panel();
    p.setSizeFull();
    p.setContent(mainLayout);

    setCompositionRoot(p);
}

From source file:cz.opendata.unifiedviews.dpus.distributionMetadata.DistributionMetadataVaadinDialog.java

License:Creative Commons License

@Override
protected void buildDialogLayout() {
    // common part: create layout
    mainLayout = new VerticalLayout();
    mainLayout.setImmediate(true);/* ww w  .  jav a  2s  . c om*/
    mainLayout.setWidth("100%");
    mainLayout.setHeight(null);
    mainLayout.setMargin(false);
    //mainLayout.setSpacing(true);

    // top-level component properties
    setWidth("100%");
    setHeight("100%");

    tfDownloadURL = new TextField();
    tfDownloadURL.setCaption("Download URL:");
    tfDownloadURL.setInputPrompt("http://data.mydomain.com/dumps/dataset.ttl");
    tfDownloadURL.setWidth("100%");
    mainLayout.addComponent(tfDownloadURL);

    tfMediaType = new TextField();
    tfMediaType.setCaption("Media (MIME) type:");
    tfMediaType.setInputPrompt("text/turtle|text/csv");
    tfMediaType.setWidth("100%");
    mainLayout.addComponent(tfMediaType);

    tfAccessURL = new TextField();
    tfAccessURL.setCaption("Access URL:");
    tfAccessURL.setInputPrompt("http://data.mydomain.com/dataset/dataset");
    tfAccessURL.setWidth("100%");
    mainLayout.addComponent(tfAccessURL);

    lsExampleResources = new ListSelect();
    lsExampleResources.setWidth("100%");
    lsExampleResources.setNewItemsAllowed(true);
    lsExampleResources.setCaption("Example resources");
    lsExampleResources.setMultiSelect(true);
    lsExampleResources.setRows(3);
    mainLayout.addComponent(lsExampleResources);

    tfSPARQLEndpointURL = new TextField();
    tfSPARQLEndpointURL.setCaption("SPARQL Endpoint URL:");
    tfSPARQLEndpointURL.setInputPrompt("http://linked.opendata.cz/sparql");
    tfSPARQLEndpointURL.setWidth("100%");
    mainLayout.addComponent(tfSPARQLEndpointURL);

    tfSchemaType = new TextField();
    tfSchemaType.setCaption("Schema MIME type:");
    tfSchemaType.setInputPrompt("text/csv");
    tfSchemaType.setWidth("100%");
    mainLayout.addComponent(tfSchemaType);

    chkSchemaFromInput = new CheckBox();
    chkSchemaFromInput.setCaption("Use schema from dataset");
    chkSchemaFromInput.setWidth("100%");
    chkSchemaFromInput.setImmediate(true);
    chkSchemaFromInput.addValueChangeListener(new ValueChangeListener() {
        private static final long serialVersionUID = -6135328311357043784L;

        @Override
        public void valueChange(ValueChangeEvent event) {
            tfSchema.setEnabled(!chkSchemaFromInput.getValue());
        }
    });
    mainLayout.addComponent(chkSchemaFromInput);

    tfSchema = new TextField();
    tfSchema.setCaption("Schema URL:");
    tfSchema.setInputPrompt("http://data.example.org/dataset/myschema");
    tfSchema.setWidth("100%");
    mainLayout.addComponent(tfSchema);

    chkDatasetURIFromInput = new CheckBox();
    chkDatasetURIFromInput.setCaption("Get dataset URI from dataset");
    chkDatasetURIFromInput.setWidth("100%");
    chkDatasetURIFromInput.setImmediate(true);
    chkDatasetURIFromInput.addValueChangeListener(new ValueChangeListener() {
        private static final long serialVersionUID = -6135328311357043784L;

        @Override
        public void valueChange(ValueChangeEvent event) {
            tfDatasetURI.setEnabled(!chkDatasetURIFromInput.getValue());
        }
    });
    mainLayout.addComponent(chkDatasetURIFromInput);

    tfDatasetURI = new TextField();
    tfDatasetURI.setCaption("Dataset URI:");
    tfDatasetURI.setInputPrompt("http://data.mydomain.com/resource/dataset/mydataset");
    tfDatasetURI.setWidth("100%");
    mainLayout.addComponent(tfDatasetURI);

    chkGenerateDistroURIFromDataset = new CheckBox();
    chkGenerateDistroURIFromDataset.setCaption("Generate distribution URI from dataset (+\"/distribution\")");
    chkGenerateDistroURIFromDataset.setWidth("100%");
    chkGenerateDistroURIFromDataset.setImmediate(true);
    chkGenerateDistroURIFromDataset.addValueChangeListener(new ValueChangeListener() {
        private static final long serialVersionUID = -6135328311357043784L;

        @Override
        public void valueChange(ValueChangeEvent event) {
            tfDistributionURI.setEnabled(!chkGenerateDistroURIFromDataset.getValue());
        }
    });
    mainLayout.addComponent(chkGenerateDistroURIFromDataset);

    tfDistributionURI = new TextField();
    tfDistributionURI.setCaption("Distribution URI:");
    tfDistributionURI.setInputPrompt("http://data.mydomain.com/resource/dataset/mydataset/distribution/rdf");
    tfDistributionURI.setWidth("100%");
    mainLayout.addComponent(tfDistributionURI);

    chkLanguageFromInput = new CheckBox();
    chkLanguageFromInput.setCaption("Get original language from dataset");
    chkLanguageFromInput.setWidth("100%");
    chkLanguageFromInput.setImmediate(true);
    chkLanguageFromInput.addValueChangeListener(new ValueChangeListener() {
        private static final long serialVersionUID = -6135328311357043784L;

        @Override
        public void valueChange(ValueChangeEvent event) {
            tfLanguage.setEnabled(!chkLanguageFromInput.getValue());
        }
    });
    mainLayout.addComponent(chkLanguageFromInput);

    tfLanguage = new TextField();
    tfLanguage.setCaption("Original language (RDF language tag, e.g. cs):");
    tfLanguage.setInputPrompt("cs|en|sk|it");
    tfLanguage.setWidth("100%");
    mainLayout.addComponent(tfLanguage);

    chkTitleFromInput = new CheckBox();
    chkTitleFromInput.setCaption("Get title from dataset");
    chkTitleFromInput.setWidth("100%");
    chkTitleFromInput.setImmediate(true);
    chkTitleFromInput.addValueChangeListener(new ValueChangeListener() {
        private static final long serialVersionUID = -6135328311357043784L;

        @Override
        public void valueChange(ValueChangeEvent event) {
            tfTitle.setEnabled(!chkTitleFromInput.getValue());
            tfTitleEn.setEnabled(!chkTitleFromInput.getValue());
        }
    });
    mainLayout.addComponent(chkTitleFromInput);

    tfTitle = new TextField();
    tfTitle.setCaption("Dataset title in original language:");
    tfTitle.setInputPrompt("My dataset");
    tfTitle.setWidth("100%");
    mainLayout.addComponent(tfTitle);

    tfTitleEn = new TextField();
    tfTitleEn.setCaption("Dataset title in English:");
    tfTitleEn.setInputPrompt("My dataset");
    tfTitleEn.setWidth("100%");
    mainLayout.addComponent(tfTitleEn);

    chkDescriptionFromInput = new CheckBox();
    chkDescriptionFromInput.setCaption("Get description from dataset");
    chkDescriptionFromInput.setWidth("100%");
    chkDescriptionFromInput.setImmediate(true);
    chkDescriptionFromInput.addValueChangeListener(new ValueChangeListener() {
        private static final long serialVersionUID = -6135328311357043784L;

        @Override
        public void valueChange(ValueChangeEvent event) {
            tfDesc.setEnabled(!chkDescriptionFromInput.getValue());
            tfDescEn.setEnabled(!chkDescriptionFromInput.getValue());
        }
    });
    mainLayout.addComponent(chkDescriptionFromInput);

    tfDesc = new TextField();
    tfDesc.setCaption("Description in original language:");
    tfDesc.setInputPrompt("Longer description in original language");
    tfDesc.setWidth("100%");
    mainLayout.addComponent(tfDesc);

    tfDescEn = new TextField();
    tfDescEn.setCaption("Description in English:");
    tfDescEn.setInputPrompt("Longer description in English");
    tfDescEn.setWidth("100%");
    mainLayout.addComponent(tfDescEn);

    chkIssuedFromInput = new CheckBox();
    chkIssuedFromInput.setCaption("Use issued date from dataset");
    chkIssuedFromInput.setWidth("100%");
    chkIssuedFromInput.setImmediate(true);
    chkIssuedFromInput.addValueChangeListener(new ValueChangeListener() {
        private static final long serialVersionUID = -6135328311357043784L;

        @Override
        public void valueChange(ValueChangeEvent event) {
            dfIssued.setEnabled(!chkIssuedFromInput.getValue());
        }
    });
    mainLayout.addComponent(chkIssuedFromInput);

    dfIssued = new DateField();
    dfIssued.setCaption("Issued:");
    dfIssued.setWidth("100%");
    dfIssued.setResolution(Resolution.DAY);
    mainLayout.addComponent(dfIssued);

    chkNow = new CheckBox();
    chkNow.setCaption("Use current date as modified");
    chkNow.setWidth("100%");
    chkNow.setImmediate(true);
    chkNow.addValueChangeListener(new ValueChangeListener() {
        private static final long serialVersionUID = -6135328311357043784L;

        @Override
        public void valueChange(ValueChangeEvent event) {
            dfModified.setEnabled(!chkNow.getValue());
        }
    });
    mainLayout.addComponent(chkNow);

    dfModified = new DateField();
    dfModified.setCaption("Modified:");
    dfModified.setWidth("100%");
    dfModified.setResolution(Resolution.DAY);
    mainLayout.addComponent(dfModified);

    chkTemporalFromInput = new CheckBox();
    chkTemporalFromInput.setCaption("Use temporal coverage from dataset");
    chkTemporalFromInput.setWidth("100%");
    chkTemporalFromInput.setImmediate(true);
    chkTemporalFromInput.addValueChangeListener(new ValueChangeListener() {
        private static final long serialVersionUID = -6135328311357043784L;

        @Override
        public void valueChange(ValueChangeEvent event) {
            dfTemporalStart.setEnabled(!chkTemporalFromInput.getValue());
            dfTemporalEnd.setEnabled(!chkTemporalFromInput.getValue());
        }
    });
    mainLayout.addComponent(chkTemporalFromInput);

    dfTemporalStart = new DateField();
    dfTemporalStart.setCaption("Temporal coverage start:");
    dfTemporalStart.setWidth("100%");
    dfTemporalStart.setResolution(Resolution.DAY);
    mainLayout.addComponent(dfTemporalStart);

    dfTemporalEnd = new DateField();
    dfTemporalEnd.setCaption("Temporal coverage end:");
    dfTemporalEnd.setWidth("100%");
    dfTemporalEnd.setResolution(Resolution.DAY);
    mainLayout.addComponent(dfTemporalEnd);

    chkSpatialFromInput = new CheckBox();
    chkSpatialFromInput.setCaption("Use spatial coverage from dataset");
    chkSpatialFromInput.setWidth("100%");
    chkSpatialFromInput.setImmediate(true);
    chkSpatialFromInput.addValueChangeListener(new ValueChangeListener() {
        private static final long serialVersionUID = -6135328311357043784L;

        @Override
        public void valueChange(ValueChangeEvent event) {
            tfSpatial.setEnabled(!chkSpatialFromInput.getValue());
        }
    });
    mainLayout.addComponent(chkSpatialFromInput);

    tfSpatial = new TextField();
    tfSpatial.setCaption("Spatial coverage URI:");
    tfSpatial.setInputPrompt("http://ruian.linked.opendata.cz/resource/adresni-mista/25958810");
    tfSpatial.setWidth("100%");
    mainLayout.addComponent(tfSpatial);

    chkLicensesFromInput = new CheckBox();
    chkLicensesFromInput.setCaption("Use license from dataset");
    chkLicensesFromInput.setWidth("100%");
    chkLicensesFromInput.setImmediate(true);
    chkLicensesFromInput.addValueChangeListener(new ValueChangeListener() {
        private static final long serialVersionUID = -6135328311357043784L;

        @Override
        public void valueChange(ValueChangeEvent event) {
            lsLicenses.setEnabled(!chkLicensesFromInput.getValue());
        }
    });
    mainLayout.addComponent(chkLicensesFromInput);

    lsLicenses = new ListSelect();
    lsLicenses.setWidth("100%");
    lsLicenses.setNewItemsAllowed(true);
    lsLicenses.setCaption("License");
    lsLicenses.setMultiSelect(false);
    lsLicenses.setNullSelectionAllowed(false);
    lsLicenses.setRows(3);
    lsLicenses.addItems(licenses);
    mainLayout.addComponent(lsLicenses);

    Panel p = new Panel();
    p.setSizeFull();
    p.setContent(mainLayout);

    setCompositionRoot(p);
}