Example usage for com.vaadin.ui Button setWidth

List of usage examples for com.vaadin.ui Button setWidth

Introduction

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

Prototype

@Override
    public void setWidth(String width) 

Source Link

Usage

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

VerticalLayout getVlayout() {
    VerticalLayout vlayout = new VerticalLayout();
    vlayout.setSpacing(true);/*from w  w w. j  a va  2 s  .  c om*/

    final ComboBox policy = dropDown.populateAttendancePolicyDropDownList(new ComboBox());
    policy.setWidth("100%");
    policy.setNullSelectionAllowed(true);
    policy.setImmediate(true);
    vlayout.addComponent(policy);

    final ComboBox holidayType = new ComboBox("Type: ");
    holidayType.setWidth("100%");
    holidayType.setNullSelectionAllowed(false);
    holidayType.setVisible(false);
    holidayType.setImmediate(true);
    for (String temp : holidayList) {
        holidayType.addItem(temp);
    }
    policy.addListener(new Property.ValueChangeListener() {

        @Override
        public void valueChange(Property.ValueChangeEvent event) {
            if (event.getProperty().getValue() == null) {
                item.getItemProperty("wdo").setValue(0.0);
                item.getItemProperty("sholiday").setValue(0.0);
                item.getItemProperty("lholiday").setValue(0.0);
                item.getItemProperty("psday").setValue(0.0);
                holidayType.setVisible(false);
                holidayType.removeAllItems();
                for (String temp : holidayList) {
                    holidayType.addItem(temp);
                }
            } else if (event.getProperty().getValue().toString().equals("holiday")
                    || event.getProperty().getValue().toString().equals("working-holiday")) {
                item.getItemProperty("wdo").setValue(0.0);
                item.getItemProperty("sholiday").setValue(0.0);
                item.getItemProperty("lholiday").setValue(0.0);
                item.getItemProperty("psday").setValue(0.0);
                holidayType.setVisible(true);
            } else if (event.getProperty().getValue().toString().equals("working-day-off")) {
                item.getItemProperty("wdo").setValue(0.0);
                item.getItemProperty("sholiday").setValue(0.0);
                item.getItemProperty("lholiday").setValue(0.0);
                item.getItemProperty("psday").setValue(0.0);
                holidayType.setVisible(true);

                double additionalWorkingDayOffPay = computation
                        .processAdditionalWorkingDayOff(getEmploymentWage(), getEmploymentWageEntry());
                item.getItemProperty("wdo").setValue(df.format(additionalWorkingDayOffPay));
            } else {
                item.getItemProperty("wdo").setValue(0.0);
                item.getItemProperty("sholiday").setValue(0.0);
                item.getItemProperty("lholiday").setValue(0.0);
                item.getItemProperty("psday").setValue(0.0);
                holidayType.removeAllItems();
                for (String temp : holidayList) {
                    holidayType.addItem(temp);
                }
                holidayType.setVisible(false);
            }
        }

    });
    holidayType.addListener(new Property.ValueChangeListener() {

        @Override
        public void valueChange(Property.ValueChangeEvent event) {
            double additionalHolidayPay;
            double additionalWorkingDayOffPay;
            double multiplePremiumPay;
            if (policy.getValue() == null) {
            } else if (policy.getValue().equals("working-holiday")) {
                item.getItemProperty("psday").setValue(0.0);
                if (event.getProperty().getValue().toString().equals("legal-holiday")) {
                    additionalHolidayPay = computation.processAdditionalHolidayPay(
                            event.getProperty().getValue().toString(), getEmploymentWage());
                    item.getItemProperty("lholiday").setValue(new Double(df.format(additionalHolidayPay)));
                    item.getItemProperty("sholiday").setValue(0.0);
                } else {
                    additionalHolidayPay = computation.processAdditionalHolidayPay(
                            event.getProperty().getValue().toString(), getEmploymentWage());
                    item.getItemProperty("sholiday").setValue(new Double(df.format(additionalHolidayPay)));
                    item.getItemProperty("lholiday").setValue(0.0);
                }
            } else if (policy.getValue().equals("holiday")) {
                item.getItemProperty("lholiday").setValue(0.0);
                item.getItemProperty("sholiday").setValue(0.0);
                if (event.getProperty().getValue().toString().equals("legal-holiday")) {
                    if (getEmploymentWageEntry().equals("daily")) {
                        additionalHolidayPay = computation.processAdditionalHolidayPay(
                                event.getProperty().getValue().toString(), getEmploymentWage());
                        item.getItemProperty("psday").setValue(new Double(df.format(additionalHolidayPay)));
                    } else {
                        item.getItemProperty("psday").setValue(0.0);
                    }
                } else {
                    item.getItemProperty("psday").setValue(0.0);
                }
            } else if (policy.getValue().equals("working-day-off")) {
                if (event.getProperty().getValue() == null) {
                    item.getItemProperty("sholiday").setValue(0.0);
                    item.getItemProperty("lholiday").setValue(0.0);
                    item.getItemProperty("psday").setValue(0.0);
                } else if (event.getProperty().getValue().equals("legal-holiday")) {
                    additionalWorkingDayOffPay = computation.processAdditionalWorkingDayOff(getEmploymentWage(),
                            getEmploymentWageEntry());
                    item.getItemProperty("wdo").setValue(df.format(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(df.format(additionalWorkingDayOffPay));
                    multiplePremiumPay = computation.processMultiplePremiumPay(
                            event.getProperty().getValue().toString(), getEmploymentWage());
                    item.getItemProperty("sholiday").setValue(multiplePremiumPay);
                    item.getItemProperty("lholiday").setValue(0.0);
                }
            }
        }

    });
    vlayout.addComponent(holidayType);

    Button button = new Button("UPDATE POLICY");
    button.setWidth("100%");
    button.addListener(new Button.ClickListener() {

        @Override
        public void buttonClick(Button.ClickEvent event) {
            String policyStr;
            if (policy.getValue() == null || policy.getValue().toString().isEmpty()) {
                policyStr = "";
            } else {
                policyStr = policy.getValue().toString();
            }
            if (policyStr.equals("holiday") || policyStr.equals("working-holiday")) {
                if (holidayType.getValue() == null) {
                    getWindow().showNotification("Select a Holiday type!",
                            Window.Notification.TYPE_ERROR_MESSAGE);
                    return;
                }
            }
            item.getItemProperty("policy").setValue(policyStr);
            item.getItemProperty("holidays").setValue(holidayType.getValue());

            close();
        }

    });
    vlayout.addComponent(button);

    return vlayout;
}

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

VerticalLayout generateAttendanceTable() {
    VerticalLayout vlayout = new VerticalLayout();
    vlayout.setSizeFull();/* ww  w  .j  a  va  2s. c om*/
    vlayout.setSpacing(true);

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

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

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

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

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

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

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

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

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

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

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

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

        edit.addListener(new Button.ClickListener() {

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

        premium.addListener(new Button.ClickListener() {

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

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

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

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

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

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

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

        lates.addListener(new FieldEvents.TextChangeListener() {

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

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

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

            }
        });

        undertime.addListener(new FieldEvents.TextChangeListener() {

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

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

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

        overtime.addListener(new FieldEvents.TextChangeListener() {

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

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

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

        nightDifferential.addListener(new FieldEvents.TextChangeListener() {

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

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

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

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

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

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

            premium.setValue(t.isPremium());

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

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

    table.addListener(new ItemClickEvent.ItemClickListener() {

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

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

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

    vlayout.addComponent(table);

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

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

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

    saveButton.addListener(new Button.ClickListener() {

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

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

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

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

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

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

    vlayout.addComponent(glayout);

    return vlayout;
}

From source file:com.peergreen.example.webconsole.extensions.CssContributionExtension.java

License:Open Source License

@PostConstruct
public void init() {
    String css = ".custom_button_style {\n" + "   color : red !important;\n"
            + "   border : 1px green dashed !important;\n" + "}";
    final TextArea textArea = new TextArea("Css : ", css);
    textArea.setWidth("500px");
    addComponent(textArea);//from   w w w. j a  v  a2  s  .  c  o  m
    Button button = new Button("Change my style !");
    button.setWidth("500px");
    button.addStyleName("custom_button_style");
    button.addClickListener(new Button.ClickListener() {
        @Override
        public void buttonClick(Button.ClickEvent clickEvent) {
            String newCss = textArea.getValue();
            cssInjectorService.inject(newCss);
        }
    });
    addComponent(button);
    setExpandRatio(button, 1.5f);
}

From source file:com.peergreen.example.webconsole.extensions.DefaultWindowExtension.java

License:Open Source License

public DefaultWindowExtension() {
    setSizeFull();/*from  w w  w  .j  ava 2  s.co  m*/
    setSpacing(true);
    setMargin(true);

    Link showCodeSource = new Link("Show code source",
            new ExternalResource(GitHubClassURL.getURL(DefaultWindowExtension.class)));
    showCodeSource.setTargetName("_blank");
    addComponent(showCodeSource);
    setComponentAlignment(showCodeSource, Alignment.TOP_RIGHT);

    Button simpleButton = new Button("Click to open a Window");
    simpleButton.setWidth("400px");
    simpleButton.addClickListener(new Button.ClickListener() {
        @Override
        public void buttonClick(Button.ClickEvent clickEvent) {
            final UI ui = clickEvent.getConnector().getUI();
            String caption = "Default window";
            Label content = new Label("This is a simple window");
            Button close = new Button("Close");
            close.addStyleName("wide");
            close.addStyleName("default");
            final DefaultWindow window = new DefaultWindow(caption, content, close);
            window.center();
            ui.addWindow(window);
            close.addClickListener(new Button.ClickListener() {
                @Override
                public void buttonClick(Button.ClickEvent clickEvent) {
                    window.close();
                }
            });
        }
    });
    addComponent(simpleButton);

    setExpandRatio(simpleButton, 1.5f);
}

From source file:com.peergreen.example.webconsole.extensions.NotifierExtension.java

License:Open Source License

@PostConstruct
public void init() {
    HorizontalLayout row = new HorizontalLayout();
    row.setWidth("100%");
    Button simpleButton = new Button("Click to create a notification !");
    final Random random = new Random();
    simpleButton.addClickListener(new Button.ClickListener() {
        @Override/*  w  ww. ja  v  a 2 s.  c o  m*/
        public void buttonClick(Button.ClickEvent clickEvent) {
            notifierService.addNotification(MESSAGES[random.nextInt(MESSAGES.length)]);
        }
    });
    simpleButton.setWidth("400px");
    row.addComponent(simpleButton);
    row.setComponentAlignment(simpleButton, Alignment.BOTTOM_LEFT);

    final TextField customNotification = new TextField();
    customNotification.setCaption("Write something and type enter");
    final ShortcutListener addNotification = new ShortcutListener("Execute", ShortcutAction.KeyCode.ENTER,
            null) {
        @Override
        public void handleAction(Object o, Object o2) {
            notifierService.addNotification(customNotification.getValue());
            customNotification.setValue("");
        }
    };
    customNotification.addFocusListener(new FieldEvents.FocusListener() {
        @Override
        public void focus(FieldEvents.FocusEvent focusEvent) {
            customNotification.addShortcutListener(addNotification);
        }
    });
    customNotification.addBlurListener(new FieldEvents.BlurListener() {
        @Override
        public void blur(FieldEvents.BlurEvent blurEvent) {
            customNotification.removeShortcutListener(addNotification);
        }
    });
    customNotification.setWidth("400px");
    row.addComponent(customNotification);
    addComponent(row);
    setExpandRatio(row, 1.5f);
}

From source file:com.salsaw.msalsa.HomePageView.java

License:Apache License

/**
 * The constructor should first build the main layout, set the
 * composition root and then do any custom initialization.
 *
 * The constructor will not be automatically regenerated by the
 * visual editor./*from  www . j a  v a2  s  . c  om*/
 * @param navigator 
 */
public HomePageView(SalsaParameters salsaParameters) {
    if (salsaParameters == null) {
        throw new IllegalArgumentException("salsaParameters");
    }

    buildMainLayout();

    // Create form with salsa parameters
    BeanItem<SalsaParameters> salsaParametersBeanItem = new BeanItem<SalsaParameters>(salsaParameters);
    SalsaParametersForm salsaParametersForm = new SalsaParametersForm(salsaParametersBeanItem);

    Button toogleSalsaParametersButton = new Button("Show/Hide M-SALSA Parameters");
    toogleSalsaParametersButton.addClickListener(new Button.ClickListener() {
        /**
        * 
        */
        private static final long serialVersionUID = 1L;

        public void buttonClick(ClickEvent event) {
            salsaParametersForm.setVisible(!salsaParametersForm.isVisible());
        }
    });

    toogleSalsaParametersButton.setWidth("-1px");
    toogleSalsaParametersButton.setHeight("-1px");
    mainLayout.addComponent(toogleSalsaParametersButton);
    mainLayout.setComponentAlignment(toogleSalsaParametersButton, new Alignment(48));

    salsaParametersForm.setWidth("-1px");
    salsaParametersForm.setHeight("-1px");
    mainLayout.addComponent(salsaParametersForm);
    mainLayout.setComponentAlignment(salsaParametersForm, new Alignment(48));

    setCompositionRoot(mainLayout);

    // TODO add user code here      

    // Implement both receiver that saves upload in a file and
    // listener for successful upload
    class AligmentUploader implements Receiver, SucceededListener {
        /**
        * 
        */
        private static final long serialVersionUID = 1L;

        public File file;

        public OutputStream receiveUpload(String filename, String mimeType) {
            // Create upload stream
            FileOutputStream fos = null; // Stream to write to
            try {
                // Load server configuration
                String tmpFolder = ConfigurationManager.getInstance().getServerConfiguration()
                        .getTemporaryFilePath();

                // Open the file for writing.
                file = Paths.get(tmpFolder, filename).toFile();
                fos = new FileOutputStream(file);
            } catch (final java.io.FileNotFoundException e) {
                new Notification("Could not open file<br/>", e.getMessage(), Notification.Type.ERROR_MESSAGE)
                        .show(Page.getCurrent());
                return null;
            }
            return fos; // Return the output stream to write to
        }

        public void uploadSucceeded(SucceededEvent event) {
            try {
                for (IHomePageListener listener : listeners) {
                    listener.buttonClick(file);
                }

            } catch (SALSAException | IOException | InterruptedException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();

                new Notification("ERROR: ", e.getMessage(), Notification.Type.ERROR_MESSAGE)
                        .show(Page.getCurrent());
            }
        }
    }
    ;

    AligmentUploader receiver = new AligmentUploader();

    uploadInput.setReceiver(receiver);
    uploadInput.addSucceededListener(receiver);

}

From source file:com.save.area.AddLocationToAreaWindow.java

VerticalLayout getVlayout() {
    VerticalLayout vlayout = new VerticalLayout();
    vlayout.setSizeFull();//ww  w. j  av  a2  s  . c  o  m
    vlayout.setMargin(true);
    vlayout.setSpacing(true);

    area.setInputPrompt("Select Area..");
    area.setNullSelectionAllowed(false);
    vlayout.addComponent(area);

    province.setInputPrompt("Select Province..");
    province.addValueChangeListener(new ProvincePropertyChangeListener(city));
    vlayout.addComponent(province);

    city.setInputPrompt("Select City..");
    city.setWidth("100%");
    vlayout.addComponent(city);

    Button addBtn = new Button("ADD LOCATION TO AREA");
    addBtn.setWidth("100%");
    addBtn.addClickListener(addBtnListener);
    vlayout.addComponent(addBtn);

    return vlayout;
}

From source file:com.save.area.AddNewCityWindow.java

VerticalLayout getVlayout() {
    VerticalLayout vlayout = new VerticalLayout();
    vlayout.setSizeFull();//  www  . j  a  va 2 s .  c o m
    vlayout.setMargin(true);
    vlayout.setSpacing(true);

    province.setInputPrompt("Select Province..");
    province.setWidth("100%");
    vlayout.addComponent(province);

    cityField.setWidth("100%");
    vlayout.addComponent(cityField);

    Button addCityBtn = new Button("ADD CITY");
    addCityBtn.setWidth("100%");
    addCityBtn.addClickListener(addCityBtnListener);
    vlayout.addComponent(addCityBtn);

    return vlayout;
}

From source file:com.save.area.AddNewProvinceWindow.java

VerticalLayout getVlayout() {
    VerticalLayout vlayout = new VerticalLayout();
    vlayout.setSizeFull();/*  w w w  .  java 2  s .  c  o m*/
    vlayout.setMargin(true);
    vlayout.setSpacing(true);

    provinceField.setWidth("100%");
    vlayout.addComponent(provinceField);

    Button provinceBtn = new Button("ADD PROVINCE");
    provinceBtn.setWidth("100%");
    provinceBtn.addClickListener(addProvinceBtnListener);
    vlayout.addComponent(provinceBtn);

    return vlayout;
}

From source file:com.save.area.CreateNewAreaWindow.java

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

    final TextField areaField = new TextField("Create Area: ");
    areaField.setWidth("100%");
    areaField.setRequired(true);
    areaField.setRequiredError("*Required Field");
    vlayout.addComponent(areaField);

    Button createBtn = new Button("CREATE NEW AREA");
    createBtn.setWidth("100%");
    createBtn.addClickListener(new Button.ClickListener() {

        @Override
        public void buttonClick(Button.ClickEvent event) {
            if (as.isAreaExist(areaField.getValue().trim().toLowerCase())) {
                Notification.show("Area already Exist!", Notification.Type.WARNING_MESSAGE);
                return;
            }

            if (areaField.getValue() == null || areaField.getValue().trim().isEmpty()) {
                Notification.show("Area Field cannot be empty!", Notification.Type.ERROR_MESSAGE);
                return;
            }

            boolean result = as.createNewArea(areaField.getValue().trim().toLowerCase());
            if (result) {
                Notification.show("Done!");
                close();
            }
        }
    });
    createBtn.setImmediate(true);

    vlayout.addComponent(createBtn);

    return vlayout;
}