List of usage examples for com.vaadin.ui VerticalLayout setSizeFull
@Override public void setSizeFull()
From source file:com.openhris.payroll.reports.PayrollRegisterReport.java
public PayrollRegisterReport(int branchId, String payrollDate, Application payrollApplication) { this.branchId = branchId; this.payrollDate = payrollDate; this.payrollApplication = payrollApplication; setCaption("Payroll Register Report"); setSizeFull();//from w w w .j a v a2 s . c o m center(); Connection conn = getConnection.connection(); // URL url = this.getClass().getResource("/com/openhris/reports/payrollRegisterReport.jasper"); File reportFile = new File("C:/reportsJasper/payrollRegisterReport.jasper"); // File reportFile = new File(jasperUrl.getPath()); final HashMap hm = new HashMap(); hm.put("BRANCH_ID", getBranchId()); hm.put("PAYROLL_DATE", getPayrollDate()); try { JasperPrint jpReport = JasperFillManager.fillReport(reportFile.getPath(), hm, conn); SimpleDateFormat df = new SimpleDateFormat("yyyyMMddHHmmssSSS"); String timestamp = df.format(new Date()); // file = File.createTempFile("payrollRegisterReport_"+timestamp, ".pdf"); file = "C:/reportsPdf/payrollRegisterReport_" + timestamp + ".pdf"; JasperExportManager.exportReportToPdfFile(jpReport, file); } catch (JRException ex) { Logger.getLogger(PayrollRegisterReport.class.getName()).log(Level.SEVERE, null, ex); } finally { try { if (conn != null || !conn.isClosed()) { conn.close(); } } catch (SQLException ex) { Logger.getLogger(PayrollRegisterReport.class.getName()).log(Level.SEVERE, null, ex); } } StreamResource.StreamSource source = new StreamResource.StreamSource() { @Override public InputStream getStream() { try { File f = new File(file); FileInputStream fis = new FileInputStream(f); return fis; } catch (Exception e) { e.getMessage(); return null; } } }; StreamResource resource = new StreamResource(source, file, getPayrollApplication()); resource.setMIMEType("application/pdf"); VerticalLayout vlayout = new VerticalLayout(); vlayout.setSizeFull(); Embedded e = new Embedded("", new FileResource(new File(resource.getFilename()), getPayrollApplication())); // e.setMimeType("application/pdf"); // e.setType(Embedded.TYPE_OBJECT); e.setSizeFull(); e.setType(Embedded.TYPE_BROWSER); // e.setSource(resource); // e.setParameter("Content-Disposition", "attachment; filename=" + resource.getFilename()); vlayout.addComponent(e); addComponent(vlayout); // getPayrollApplication().getMainWindow().addWindow(this); getPayrollApplication().getMainWindow().open(resource, "_blank"); }
From source file:com.openhris.timekeeping.AttendanceTableContainerWindow.java
VerticalLayout generateAttendanceTable() { VerticalLayout vlayout = new VerticalLayout(); vlayout.setSizeFull(); vlayout.setSpacing(true);//ww w .ja v a2 s . c om 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
public EditAttendanceTableContainerWindow(String name, List dateList, String employeeId, String payrollPeriod, String payrollDate, String attendancePeriodFrom, String attendancePeriodTo, String employmentWageEntry, double employmentWage, int branchId, int payrollId) { this.name = name; this.dateList = dateList; this.employeeId = employeeId; this.payrollPeriod = payrollPeriod; this.payrollDate = payrollDate; this.attendancePeriodFrom = attendancePeriodFrom; this.attendancePeriodTo = attendancePeriodTo; this.employmentWageEntry = employmentWageEntry; this.employmentWage = employmentWage; this.branchId = branchId; this.payrollId = payrollId; setCaption("ATTENDANCE TABLE for " + getEmployeesName()); setSizeFull();//w ww . jav a2 s. c om setModal(true); center(); VerticalLayout vlayout = new VerticalLayout(); vlayout.setSizeFull(); vlayout.setSpacing(true); GridLayout glayout = new GridLayout(2, 2); glayout.setSpacing(true); Label payrollPeriodLabel = new Label("Payroll Period: "); glayout.addComponent(payrollPeriodLabel, 0, 0); glayout.setComponentAlignment(payrollPeriodLabel, Alignment.MIDDLE_RIGHT); Label periodLabel = new Label(getPayrollPeriod()); glayout.addComponent(periodLabel, 1, 0); glayout.setComponentAlignment(periodLabel, Alignment.MIDDLE_LEFT); Label payrollDateLabel = new Label("Payroll Date: "); glayout.addComponent(payrollDateLabel, 0, 1); glayout.setComponentAlignment(payrollDateLabel, Alignment.MIDDLE_RIGHT); Label dateLabel = new Label(getPayrollDate()); glayout.addComponent(dateLabel, 1, 1); glayout.setComponentAlignment(dateLabel, Alignment.MIDDLE_LEFT); vlayout.addComponent(glayout); vlayout.addComponent(generateAttendanceTable()); addComponent(vlayout); }
From source file:com.openhris.timekeeping.EditAttendanceTableContainerWindow.java
VerticalLayout generateAttendanceTable() { VerticalLayout vlayout = new VerticalLayout(); vlayout.setSizeFull(); vlayout.setSpacing(true);/*w w w. j a va2 s . c om*/ if (getEmploymentWageEntry().equals("monthly")) { employmentWage = utilities.roundOffToTwoDecimalPlaces((employmentWage * 12) / 314); } final Table table = new Table(); table.removeAllItems(); table.setEnabled(true); table.setWidth("100%"); table.setImmediate(true); table.setColumnCollapsingAllowed(true); table.addContainerProperty("edit", CheckBox.class, null); table.addContainerProperty("date", String.class, null); table.addContainerProperty("policy", String.class, null); table.addContainerProperty("holidays", String.class, null); table.addContainerProperty("premium", CheckBox.class, null); table.addContainerProperty("lates", TextField.class, null); table.addContainerProperty("undertime", TextField.class, null); table.addContainerProperty("overtime", TextField.class, null); table.addContainerProperty("night differential", TextField.class, null); table.addContainerProperty("l/min", Double.class, null); table.addContainerProperty("u/min", Double.class, null); table.addContainerProperty("o/min", Double.class, null); table.addContainerProperty("nd/min", Double.class, null); table.addContainerProperty("lholiday", Double.class, null); table.addContainerProperty("sholiday", Double.class, null); table.addContainerProperty("wdo", Double.class, null); table.addContainerProperty("psday", Double.class, null); //paid non-working holiday table.addContainerProperty("latesLH", Double.class, null); table.addContainerProperty("latesSH", Double.class, null); table.addContainerProperty("latesWO", Double.class, null); table.addContainerProperty("undertimeLH", Double.class, null); table.addContainerProperty("undertimeSH", Double.class, null); table.addContainerProperty("undertimeWO", Double.class, null); table.setColumnAlignment("edit", Table.ALIGN_CENTER); table.setColumnAlignment("date", Table.ALIGN_CENTER); table.setColumnAlignment("policy", Table.ALIGN_CENTER); table.setColumnAlignment("premium", Table.ALIGN_CENTER); table.setColumnAlignment("lates", Table.ALIGN_CENTER); table.setColumnAlignment("undertime", Table.ALIGN_CENTER); table.setColumnAlignment("overtime", Table.ALIGN_CENTER); table.setColumnAlignment("night differential", Table.ALIGN_CENTER); table.setColumnAlignment("l/min", Table.ALIGN_RIGHT); table.setColumnAlignment("u/min", Table.ALIGN_RIGHT); table.setColumnAlignment("o/min", Table.ALIGN_RIGHT); table.setColumnAlignment("nd/min", Table.ALIGN_RIGHT); table.setColumnAlignment("lholiday", Table.ALIGN_RIGHT); table.setColumnAlignment("sholiday", Table.ALIGN_RIGHT); table.setColumnAlignment("wdo", Table.ALIGN_RIGHT); table.setColumnAlignment("psday", Table.ALIGN_RIGHT); table.setColumnAlignment("latesLH", Table.ALIGN_RIGHT); table.setColumnAlignment("latesSH", Table.ALIGN_RIGHT); table.setColumnAlignment("latesWO", Table.ALIGN_RIGHT); table.setColumnAlignment("undertimeLH", Table.ALIGN_RIGHT); table.setColumnAlignment("undertimeSH", Table.ALIGN_RIGHT); table.setColumnAlignment("undertimeWO", Table.ALIGN_RIGHT); table.setColumnCollapsed("latesLH", true); table.setColumnCollapsed("latesSH", true); table.setColumnCollapsed("latesWO", true); table.setColumnCollapsed("undertimeLH", true); table.setColumnCollapsed("undertimeSH", true); table.setColumnCollapsed("undertimeWO", true); final String[] holidayList = { "legal-holiday", "special-holiday" }; for (int i = 0; i < getDateList().size(); i++) { Object itemId = new Integer(i); final CheckBox edit = new CheckBox(); edit.setData(i); edit.setEnabled(UserAccessControl.isEditAttendance()); edit.setImmediate(true); final CheckBox premium = new CheckBox(); premium.setData(itemId); premium.setEnabled(false); premium.setImmediate(true); final TextField lates = new TextField(); lates.setWidth("50px"); lates.setValue("0"); lates.setEnabled(true); lates.setData(itemId); lates.setEnabled(false); lates.setImmediate(true); final TextField undertime = new TextField(); undertime.setWidth("50px"); undertime.setValue("0"); undertime.setEnabled(true); undertime.setData(itemId); undertime.setEnabled(false); undertime.setImmediate(true); final TextField overtime = new TextField(); overtime.setWidth("50px"); overtime.setValue("0"); overtime.setEnabled(true); overtime.setData(itemId); overtime.setEnabled(false); overtime.setImmediate(true); final TextField nightDifferential = new TextField(); nightDifferential.setWidth("50px"); nightDifferential.setValue("0"); nightDifferential.setEnabled(true); nightDifferential.setData(itemId); nightDifferential.setEnabled(false); nightDifferential.setImmediate(true); edit.addListener(new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { premium.setEnabled(event.getButton().booleanValue()); lates.setEnabled(event.getButton().booleanValue()); undertime.setEnabled(event.getButton().booleanValue()); overtime.setEnabled(event.getButton().booleanValue()); nightDifferential.setEnabled(event.getButton().booleanValue()); } }); premium.addListener(new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { Object itemId = lates.getData(); Item item = table.getItem(itemId); lates.setValue("0"); undertime.setValue("0"); overtime.setValue("0"); nightDifferential.setValue("0"); item.getItemProperty("l/min").setValue(0.0); item.getItemProperty("u/min").setValue(0.0); item.getItemProperty("o/min").setValue(0.0); item.getItemProperty("nd/min").setValue(0.0); if (event.getButton().booleanValue() == true) { premiumRate = 0.1; } else { premiumRate = 0.0; } item.getItemProperty("wdo") .setValue(utilities.roundOffToTwoDecimalPlaces( Double.parseDouble(item.getItemProperty("wdo").getValue().toString()) + (Double.parseDouble(item.getItemProperty("wdo").getValue().toString()) * premiumRate))); item.getItemProperty("lholiday") .setValue(utilities.roundOffToTwoDecimalPlaces(Double .parseDouble(item.getItemProperty("lholiday").getValue().toString()) + (Double.parseDouble(item.getItemProperty("lholiday").getValue().toString()) * premiumRate))); item.getItemProperty("sholiday") .setValue(utilities.roundOffToTwoDecimalPlaces(Double .parseDouble(item.getItemProperty("sholiday").getValue().toString()) + (Double.parseDouble(item.getItemProperty("sholiday").getValue().toString()) * premiumRate))); } }); lates.addListener(new FieldEvents.TextChangeListener() { @Override public void textChange(FieldEvents.TextChangeEvent event) { Object itemId = lates.getData(); Item item = table.getItem(itemId); String policyStr = item.getItemProperty("policy").toString(); String holidayStr = item.getItemProperty("holidays").toString(); double lateDeduction; boolean checkIfInputIsInteger = utilities.checkInputIfInteger(event.getText().trim()); if (!checkIfInputIsInteger) { getWindow().showNotification("Enter numeric format for lates!", Window.Notification.TYPE_WARNING_MESSAGE); return; } if (!event.getText().isEmpty()) { if (utilities.convertStringToInteger(event.getText().trim()) > 5) { lateDeduction = computation.processEmployeesLates(policyStr, holidayStr, utilities.convertStringToInteger(event.getText().trim()), getEmploymentWage()); if (policyStr == null || policyStr.isEmpty()) { item.getItemProperty("l/min") .setValue(utilities.roundOffToTwoDecimalPlaces(lateDeduction)); } else if (policyStr.equals("working-holiday") && holidayStr.equals("legal-holiday")) { item.getItemProperty("latesLH") .setValue(utilities.roundOffToTwoDecimalPlaces(lateDeduction)); item.getItemProperty("latesSH").setValue(0.0); item.getItemProperty("latesWO").setValue(0.0); item.getItemProperty("l/min").setValue(0.0); } else if (policyStr.equals("working-holiday") && holidayStr.equals("special-holiday")) { item.getItemProperty("latesLH").setValue(0.0); item.getItemProperty("latesSH") .setValue(utilities.roundOffToTwoDecimalPlaces(lateDeduction)); item.getItemProperty("latesWO").setValue(0.0); item.getItemProperty("l/min").setValue(0.0); } else if (policyStr.equals("working-day-off")) { item.getItemProperty("latesLH").setValue(0.0); item.getItemProperty("latesSH").setValue(0.0); item.getItemProperty("latesWO") .setValue(utilities.roundOffToTwoDecimalPlaces(lateDeduction)); item.getItemProperty("l/min").setValue(0.0); } } else { item.getItemProperty("l/min").setValue(0.0); } } else { item.getItemProperty("l/min").setValue(0.0); } } }); undertime.addListener(new FieldEvents.TextChangeListener() { @Override public void textChange(FieldEvents.TextChangeEvent event) { Object itemId = lates.getData(); Item item = table.getItem(itemId); String policyStr = item.getItemProperty("policy").toString(); String holidayStr = item.getItemProperty("holidays").toString(); double undertimeDeduction; boolean checkIfInputIsInteger = utilities.checkInputIfInteger(event.getText().trim()); if (!checkIfInputIsInteger) { getWindow().showNotification("Enter numeric format for undertime!", Window.Notification.TYPE_WARNING_MESSAGE); return; } if (!event.getText().isEmpty()) { undertimeDeduction = computation.processEmployeesUndertime(policyStr, holidayStr, utilities.convertStringToInteger(event.getText().trim()), getEmploymentWage()); if (policyStr == null || policyStr.isEmpty()) { item.getItemProperty("u/min") .setValue(utilities.roundOffToTwoDecimalPlaces(undertimeDeduction)); } else if (policyStr.equals("working-holiday") && holidayStr.equals("legal-holiday")) { item.getItemProperty("undertimeLH") .setValue(utilities.roundOffToTwoDecimalPlaces(undertimeDeduction)); item.getItemProperty("undertimeSH").setValue(0.0); item.getItemProperty("undertimeWO").setValue(0.0); item.getItemProperty("u/min").setValue(0.0); } else if (policyStr.equals("working-holiday") && holidayStr.equals("special-holiday")) { item.getItemProperty("undertimeLH").setValue(0.0); item.getItemProperty("undertimeSH") .setValue(utilities.roundOffToTwoDecimalPlaces(undertimeDeduction)); item.getItemProperty("undertimeWO").setValue(0.0); item.getItemProperty("u/min").setValue(0.0); } else if (policyStr.equals("working-day-off")) { item.getItemProperty("undertimeLH").setValue(0.0); item.getItemProperty("undertimeSH").setValue(0.0); item.getItemProperty("undertimeWO") .setValue(utilities.roundOffToTwoDecimalPlaces(undertimeDeduction)); item.getItemProperty("u/min").setValue(0.0); } } else { item.getItemProperty("u/min").setValue(0.0); } } }); overtime.addListener(new FieldEvents.TextChangeListener() { @Override public void textChange(FieldEvents.TextChangeEvent event) { Object itemId = lates.getData(); Item item = table.getItem(itemId); String policyStr = item.getItemProperty("policy").toString(); String holidayStr = item.getItemProperty("holidays").toString(); double overtimeAddition; boolean checkIfInputIsInteger = utilities.checkInputIfInteger(event.getText().trim()); if (!checkIfInputIsInteger) { getWindow().showNotification("Enter numeric format for undertime!", Window.Notification.TYPE_WARNING_MESSAGE); return; } if (!event.getText().isEmpty()) { overtimeAddition = computation.processEmployeesOvertime(policyStr, holidayStr, Integer.parseInt(event.getText().trim()), getEmploymentWage()); item.getItemProperty("o/min").setValue(utilities .roundOffToTwoDecimalPlaces(overtimeAddition + (overtimeAddition * premiumRate))); } else { item.getItemProperty("o/min").setValue(0.0); } } }); nightDifferential.addListener(new FieldEvents.TextChangeListener() { @Override public void textChange(FieldEvents.TextChangeEvent event) { Object itemId = lates.getData(); Item item = table.getItem(itemId); String policyStr = item.getItemProperty("policy").toString(); String holidayStr = item.getItemProperty("holidays").toString(); double nightDifferentialAddition; boolean checkIfInputIsInteger = utilities.checkInputIfInteger(event.getText().trim()); if (!checkIfInputIsInteger) { getWindow().showNotification("Enter numeric format for undertime!", Window.Notification.TYPE_WARNING_MESSAGE); return; } if (!event.getText().isEmpty()) { nightDifferentialAddition = computation.processEmployeesNightDifferential(policyStr, holidayStr, Integer.parseInt(event.getText().trim()), getEmploymentWage()); item.getItemProperty("nd/min").setValue(utilities.roundOffToTwoDecimalPlaces( nightDifferentialAddition + (nightDifferentialAddition * premiumRate))); } else { item.getItemProperty("nd/min").setValue(0.0); } } }); List<Timekeeping> timekeepingListByRowData = timekeepingService.getTimekeepingRowData( utilities.convertDateFormat(getDateList().get(i).toString()), getPayrollId()); for (Timekeeping t : timekeepingListByRowData) { String policy; String holiday; if (!t.getPolicy().equals("null")) { policy = t.getPolicy(); } else { policy = ""; } if (!t.getHoliday().equals("null")) { holiday = t.getHoliday(); } else { holiday = ""; } premium.setValue(t.isPremium()); lates.setValue(t.getLates()); undertime.setValue(t.getUndertime()); overtime.setValue(t.getOvertime()); nightDifferential.setValue(t.getNightDifferential()); table.addItem( new Object[] { edit, utilities.convertDateFormat(getDateList().get(i).toString()), policy, holiday, premium, lates, undertime, overtime, nightDifferential, t.getLateDeduction(), t.getUndertimeDeduction(), t.getOvertimePaid(), t.getNightDifferentialPaid(), t.getLegalHolidayPaid(), t.getSpecialHolidayPaid(), t.getWorkingDayOffPaid(), t.getNonWorkingHolidayPaid(), t.getLatesLegalHolidayDeduction(), t.getLatesSpecialHolidayDeduction(), t.getLatesWorkingDayOffDeduction(), t.getUndertimeLegalHolidayDeduction(), t.getUndertimeSpecialHolidayDeduction(), t.getUndertimeWorkingDayOffDeduction() }, new Integer(i)); } } table.setPageLength(table.size()); for (Object listener : table.getListeners(ItemClickEvent.class)) { table.removeListener(ItemClickEvent.class, listener); } table.addListener(new ItemClickEvent.ItemClickListener() { @Override public void itemClick(ItemClickEvent event) { final Object itemId = event.getItemId(); final Item item = table.getItem(itemId); Boolean editRow = Boolean.valueOf(item.getItemProperty("edit").getValue().toString()); if (event.getPropertyId().equals("policy")) { if (editRow) { Window sub = new AttendancePolicyWindow(holidayList, item, getEmploymentWageEntry(), getEmploymentWage()); if (sub.getParent() == null) { getApplication().getMainWindow().addWindow(sub); } } else { getWindow().showNotification("Click Edit!", Window.Notification.TYPE_WARNING_MESSAGE); } } } }); vlayout.addComponent(table); final Button saveButton = new Button(); saveButton.setWidth("200px"); saveButton.setCaption("UPDATE ATTENDANCE DATA"); saveButton.setEnabled(UserAccessControl.isEditAttendance()); for (Object listener : saveButton.getListeners(Button.ClickListener.class)) { saveButton.removeListener(Button.ClickListener.class, listener); } GridLayout glayout = new GridLayout(2, 1); glayout.setSizeFull(); glayout.setSpacing(true); saveButton.addListener(new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { try { Collection attendanceTableCollection = table.getContainerDataSource().getItemIds(); List<Timekeeping> attendanceList = new ArrayList<>(); Iterator iterator = attendanceTableCollection.iterator(); while (iterator.hasNext()) { String str = table.getItem(iterator.next()).toString(); String[] attStr = str.split(" "); List<String> tkeepList = new ArrayList<>(Arrays.asList(attStr)); Timekeeping t = new Timekeeping(); t.setAttendanceDate(utilities.parsingDate(tkeepList.get(1))); t.setPolicy(tkeepList.get(2)); t.setHoliday(tkeepList.get(3)); t.setPremium(utilities.convertStringToBoolean(tkeepList.get(4))); t.setLates(utilities.convertStringToDouble(tkeepList.get(5))); t.setUndertime(utilities.convertStringToDouble(tkeepList.get(6))); t.setOvertime(utilities.convertStringToDouble(tkeepList.get(7))); t.setNightDifferential(utilities.convertStringToDouble(tkeepList.get(8))); t.setLateDeduction(utilities.convertStringToDouble(tkeepList.get(9))); t.setUndertimeDeduction(utilities.convertStringToDouble(tkeepList.get(10))); t.setOvertimePaid(utilities.convertStringToDouble(tkeepList.get(11))); t.setNightDifferentialPaid(utilities.convertStringToDouble(tkeepList.get(12))); t.setLegalHolidayPaid(utilities.convertStringToDouble(tkeepList.get(13))); t.setSpecialHolidayPaid(utilities.convertStringToDouble(tkeepList.get(14))); t.setWorkingDayOffPaid(utilities.convertStringToDouble(tkeepList.get(15))); t.setNonWorkingHolidayPaid(utilities.convertStringToDouble(tkeepList.get(16))); t.setLatesLegalHolidayDeduction(utilities.convertStringToDouble(tkeepList.get(17))); t.setLatesSpecialHolidayDeduction(utilities.convertStringToDouble(tkeepList.get(18))); t.setLatesWorkingDayOffDeduction(utilities.convertStringToDouble(tkeepList.get(19))); t.setUndertimeLegalHolidayDeduction(utilities.convertStringToDouble(tkeepList.get(20))); t.setUndertimeSpecialHolidayDeduction(utilities.convertStringToDouble(tkeepList.get(21))); t.setUndertimeWorkingDayOffDeduction(utilities.convertStringToDouble(tkeepList.get(22))); attendanceList.add(t); } ProcessPayrollComputation processPayroll = new ProcessPayrollComputation(getEmployeeId(), getBranchId()); processPayroll.initVariables(); processPayroll.initVariablesForComputation(attendanceList); boolean result = processPayroll.processPayrollComputation(payrollDate, payrollPeriod, attendancePeriodFrom, attendancePeriodTo, getPayrollId()); if (result) { close(); } else { getWindow().showNotification("SQL ERROR"); } } catch (Exception e) { e.getMessage(); } } }); glayout.addComponent(saveButton, 0, 0); glayout.setComponentAlignment(saveButton, Alignment.MIDDLE_LEFT); // vlayout.addComponent(saveButton); Button printButton = new Button("PRINT ATTENDANCE"); printButton.setWidth("200px"); printButton.addListener(new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { OpenHrisReports reports = new OpenHrisReports(0, null); String fileName = "IndividualAttendanceReport_"; reports.deleteFile(fileName); Window reportWindow = new IndividualAttendanceReport(getPayrollId(), getApplication()); } }); glayout.addComponent(printButton, 1, 0); glayout.setComponentAlignment(printButton, Alignment.MIDDLE_RIGHT); vlayout.addComponent(glayout); return vlayout; }
From source file:com.peergreen.webconsole.core.vaadin7.BaseUI.java
License:Open Source License
/** * Build login view/*from w w w .j a v a2 s . c o m*/ * * @param exit */ private void buildLoginView(final boolean exit) { if (exit) { root.removeAllComponents(); } notifierService.closeAll(); addStyleName("login"); VerticalLayout loginLayout = new VerticalLayout(); loginLayout.setId("webconsole_loginlayout_id"); loginLayout.setSizeFull(); loginLayout.addStyleName("login-layout"); root.addComponent(loginLayout); final CssLayout loginPanel = new CssLayout(); loginPanel.addStyleName("login-panel"); HorizontalLayout labels = new HorizontalLayout(); labels.setWidth(MAX_WIDTH); labels.setMargin(true); loginPanel.addComponent(labels); Label welcome = new Label("Welcome"); welcome.addStyleName("h4"); labels.addComponent(welcome); labels.setComponentAlignment(welcome, Alignment.MIDDLE_LEFT); Label title = new Label(consoleName); //title.setSizeUndefined(); title.addStyleName("h2"); title.addStyleName("light"); labels.addComponent(title); labels.setComponentAlignment(title, Alignment.MIDDLE_RIGHT); HorizontalLayout fields = new HorizontalLayout(); fields.setSpacing(true); fields.setMargin(true); fields.addStyleName("fields"); final TextField username = new TextField("Username"); username.focus(); username.setId("webconsole_login_username"); fields.addComponent(username); final PasswordField password = new PasswordField("Password"); password.setId("webconsole_login_password"); fields.addComponent(password); final Button signin = new Button("Sign In"); signin.setId("webconsole_login_signin"); signin.addStyleName("default"); fields.addComponent(signin); fields.setComponentAlignment(signin, Alignment.BOTTOM_LEFT); final ShortcutListener enter = new ShortcutListener("Sign In", ShortcutAction.KeyCode.ENTER, null) { @Override public void handleAction(Object sender, Object target) { signin.click(); } }; signin.addShortcutListener(enter); loginPanel.addComponent(fields); HorizontalLayout bottomRow = new HorizontalLayout(); bottomRow.setWidth(MAX_WIDTH); bottomRow.setMargin(new MarginInfo(false, true, false, true)); final CheckBox keepLoggedIn = new CheckBox("Keep me logged in"); bottomRow.addComponent(keepLoggedIn); bottomRow.setComponentAlignment(keepLoggedIn, Alignment.MIDDLE_LEFT); // Add new error message final Label error = new Label("Wrong username or password.", ContentMode.HTML); error.setId("webconsole_login_error"); error.addStyleName("error"); error.setSizeUndefined(); error.addStyleName("light"); // Add animation error.addStyleName("v-animate-reveal"); error.setVisible(false); bottomRow.addComponent(error); bottomRow.setComponentAlignment(error, Alignment.MIDDLE_RIGHT); loginPanel.addComponent(bottomRow); signin.addClickListener(new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { if (authenticate(username.getValue(), password.getValue())) { // if (keepLoggedIn.getValue()) { // //Cookie userCookie = getCookieByName(PEERGREEN_USER_COOKIE_NAME); // if (getCookieByName(PEERGREEN_USER_COOKIE_NAME) == null) { // // Get a token for this user and create a cooki // Page.getCurrent().getJavaScript().execute( String.format("document.cookie = '%s=%s; path=%s'", // PEERGREEN_USER_COOKIE_NAME, token, VaadinService.getCurrentRequest().getContextPath())); // } else { // // update token // userCookie.setValue(token); // userCookie.setPath(VaadinService.getCurrentRequest().getContextPath()); // } // } buildMainView(); } else { error.setVisible(true); } } }); loginLayout.addComponent(loginPanel); loginLayout.setComponentAlignment(loginPanel, Alignment.MIDDLE_CENTER); }
From source file:com.peergreen.webconsole.scope.deployment.internal.deployable.DeployablePanel.java
License:Open Source License
@PostConstruct public void init() { setSizeFull();//www . jav a 2 s. c o m VerticalLayout mainContent = new VerticalLayout(); mainContent.setSpacing(true); mainContent.setMargin(true); mainContent.setStyleName("deployable-style"); mainContent.setSizeFull(); HorizontalLayout header = new HorizontalLayout(); header.setWidth("100%"); Button openManager = new Button("Edit repositories"); openManager.addStyleName("link"); openManager.addClickListener(new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { if (tabSheet.getTab(manager) == null) { tabSheet.addTab(manager, "Manager", new ClassResource(getClass(), "/images/22x22/configuration.png"), containers.size()) .setClosable(true); } tabSheet.setSelectedTab(manager); } }); header.addComponent(openManager); header.setComponentAlignment(openManager, Alignment.MIDDLE_RIGHT); mainContent.addComponent(header); tabSheet.setSizeFull(); mainContent.addComponent(tabSheet); mainContent.setExpandRatio(tabSheet, 1.5f); DragAndDropWrapper mainContentWrapper = new DragAndDropWrapper(mainContent); mainContentWrapper.setDropHandler(new DeploymentDropHandler(deploymentViewManager, this, notifierService)); mainContentWrapper.setSizeFull(); setContent(mainContentWrapper); }
From source file:com.peergreen.webconsole.scope.deployment.internal.deployed.DeployedPanel.java
License:Open Source License
@PostConstruct public void init() { setSizeFull();/*from w w w. j a va2s . c o m*/ Table table = new Table(); VerticalLayout mainContent = new VerticalLayout(); mainContent.setSpacing(true); mainContent.setMargin(true); mainContent.setStyleName("deployable-style"); mainContent.setSizeFull(); setContent(mainContent); HorizontalLayout toolBar = new HorizontalLayout(); toolBar.setMargin(true); toolBar.setSpacing(true); toolBar.setWidth("100%"); // Select all deployed artifacts CheckBox selectAll = new CheckBox("All"); selectAll.addValueChangeListener(new SelectAll(table)); toolBar.addComponent(selectAll); toolBar.setExpandRatio(selectAll, 1); // Filter TextField filter = new TextField(); filter.setInputPrompt("Filter deployed artifacts"); filter.setWidth("100%"); filter.addTextChangeListener(new FilterFiles(TREE_ITEM_ID, container)); toolBar.addComponent(filter); toolBar.setComponentAlignment(filter, Alignment.TOP_LEFT); toolBar.setExpandRatio(filter, 3); HorizontalLayout actionArea = new HorizontalLayout(); final NativeSelect actionSelection = new NativeSelect(); actionSelection.addItem(DeploymentActions.UNDEPLOY); actionSelection.addItem(DeploymentActions.DELETE); actionSelection.addItem(DeploymentActions.DEPLOYMENT_PLAN); actionSelection.setWidth("100px"); actionSelection.setNullSelectionAllowed(false); Button doButton = new Button("Do"); doButton.addStyleName("default"); doButton.addClickListener( new DoClickListener(artifactBuilder, table, actionSelection, deploymentViewManager)); actionArea.addComponent(actionSelection); actionArea.addComponent(doButton); toolBar.addComponent(actionArea); toolBar.setComponentAlignment(actionArea, Alignment.TOP_RIGHT); mainContent.addComponent(toolBar); VerticalLayout deployedContainer = new VerticalLayout(); DragAndDropWrapper deployedContainerWrapper = new DragAndDropWrapper(deployedContainer); deployedContainerWrapper .setDropHandler(new DeploymentDropHandler(deploymentViewManager, this, notifierService)); deployedContainerWrapper.setSizeFull(); mainContent.addComponent(deployedContainerWrapper); mainContent.setExpandRatio(deployedContainerWrapper, 1.5f); container.addContainerProperty(TREE_ITEM_ID, String.class, null); table.setSizeFull(); table.setImmediate(true); table.setMultiSelect(true); table.setSelectable(true); table.setColumnHeaderMode(Table.ColumnHeaderMode.HIDDEN); table.setContainerDataSource(container); table.setDragMode(Table.TableDragMode.MULTIROW); table.setItemCaptionPropertyId(TREE_ITEM_ID); table.setCellStyleGenerator(new ItemStyle(DeployableContainerType.DEPLOYED, deploymentManager)); table.addShortcutListener(new DeleteFileShortcutListener(deploymentViewManager, table, "Delete", ShortcutAction.KeyCode.DELETE, null)); table.setItemDescriptionGenerator(new ItemDescription()); table.addItemClickListener(new ItemClickEvent.ItemClickListener() { @Override public void itemClick(ItemClickEvent event) { if (event.isDoubleClick()) { DeployableEntry deployableEntry = (DeployableEntry) event.getItemId(); try { ArtifactStatusReport report = deploymentManager .getReport(deployableEntry.getUri().toString()); event.getComponent().getUI() .addWindow(new DeployableWindow(deployableEntry, report).getWindow()); } catch (ArtifactStatusReportException e) { LOGGER.warn("Cannot get artifact status report for ''{0}''", deployableEntry.getUri(), e); event.getComponent().getUI().addWindow(new DeployableWindow(deployableEntry).getWindow()); } } } }); deployedContainer.addComponent(table); deployedContainer.setExpandRatio(table, 1.5f); refresh(); }
From source file:com.peergreen.webconsole.scope.deployment.internal.deploymentplan.DeploymentPlanPanel.java
License:Open Source License
@PostConstruct public void init() { setSizeFull();//from www .j av a 2s . c o m TreeTable table = new TreeTable(); VerticalLayout mainContent = new VerticalLayout(); mainContent.setSpacing(true); mainContent.setMargin(true); mainContent.setStyleName("deployable-style"); mainContent.setSizeFull(); setContent(mainContent); HorizontalLayout toolBar = new HorizontalLayout(); toolBar.setMargin(true); toolBar.setSpacing(true); toolBar.setWidth("100%"); // Deployment Plan name Label deploymentPlanNameLabel = new Label("Plan"); toolBar.addComponent(deploymentPlanNameLabel); toolBar.setExpandRatio(deploymentPlanNameLabel, 1); deploymentPlanName = new TextField(); deploymentPlanName.setInputPrompt(getDefaultName()); deploymentPlanName.setWidth("100%"); toolBar.addComponent(deploymentPlanName); toolBar.setComponentAlignment(deploymentPlanName, Alignment.TOP_LEFT); toolBar.setExpandRatio(deploymentPlanName, 3); error = new Label("", ContentMode.HTML); error.addStyleName("error"); error.setSizeUndefined(); error.addStyleName("light"); error.addStyleName("v-animate-reveal"); error.setVisible(false); toolBar.addComponent(error); toolBar.setComponentAlignment(error, Alignment.TOP_RIGHT); toolBar.setExpandRatio(error, 1); mainContent.addComponent(toolBar); mainContent.setComponentAlignment(toolBar, Alignment.TOP_LEFT); mainContent.setExpandRatio(toolBar, 1); VerticalLayout deploymentPlanContainer = new VerticalLayout(); DragAndDropWrapper deploymentPlanContainerWrapper = new DragAndDropWrapper(deploymentPlanContainer); DropHandler deploymentPlanDropHandler = new DeploymentDropHandler(deploymentViewManager, this, notifierService); deploymentPlanContainerWrapper.setDropHandler(deploymentPlanDropHandler); deploymentPlanContainerWrapper.setSizeFull(); mainContent.addComponent(deploymentPlanContainerWrapper); mainContent.setExpandRatio(deploymentPlanContainerWrapper, 10); container.addContainerProperty(TREE_ITEM_ID, String.class, null); table.setSizeFull(); table.setImmediate(true); table.setMultiSelect(true); table.setSelectable(true); table.setContainerDataSource(container); table.setDragMode(Table.TableDragMode.MULTIROW); table.setItemCaptionPropertyId(TREE_ITEM_ID); table.setCellStyleGenerator(new ItemStyle(DeployableContainerType.DEPLOYED)); table.setColumnHeaderMode(Table.ColumnHeaderMode.HIDDEN); table.setDropHandler(new OrderedContainerDropHandler(table, deploymentPlanDropHandler)); table.addShortcutListener(new ShortcutListener("Delete", ShortcutAction.KeyCode.DELETE, null) { @Override public void handleAction(Object sender, Object target) { Table table = (Table) target; Collection<DeployableEntry> deployableEntries = (Collection<DeployableEntry>) table.getValue(); for (DeployableEntry deployableEntry : deployableEntries) { removeDeployable(deployableEntry); } } }); deploymentPlanContainer.addComponent(table); HorizontalLayout footer = new HorizontalLayout(); footer.setSizeFull(); footer.setSpacing(true); footer.setMargin(true); footer.addStyleName("footer"); footer.setWidth("100%"); deployIt = new CheckBox("Deploy this deployment plan"); footer.addComponent(deployIt); footer.setComponentAlignment(deployIt, Alignment.TOP_LEFT); HorizontalLayout buttons = new HorizontalLayout(); buttons.setSpacing(true); buttons.setMargin(true); Button cancel = new Button("Cancel"); cancel.addClickListener(new CancelButtonListener()); Button create = new Button("Create"); create.addClickListener(new CreateButtonListener()); create.addStyleName("wide"); create.addStyleName("default"); buttons.addComponent(cancel); buttons.addComponent(create); footer.addComponent(buttons); footer.setComponentAlignment(buttons, Alignment.TOP_RIGHT); mainContent.addComponent(footer); mainContent.setComponentAlignment(footer, Alignment.BOTTOM_RIGHT); mainContent.setExpandRatio(footer, 1); }
From source file:com.peergreen.webconsole.scope.deployment.internal.DeploymentScope.java
License:Open Source License
@PostConstruct public void init() { deploymentViewManager = createDeploymentViewManager(); OptionGroup option = new OptionGroup(); HorizontalLayout toolBar = new HorizontalLayout(); toolBar.setWidth("100%"); toolBar.setSpacing(true);/*from w w w .ja va 2 s. com*/ toolBar.setMargin(true); VerticalLayout uploadLayout = new VerticalLayout(); Upload uploader = new Upload("Upload a file here", null); uploader.setButtonCaption("Upload"); final FileUploader fileUploader = new FileUploader(deploymentViewManager, notifierService, artifactBuilder, option); uploader.setReceiver(fileUploader); uploader.addSucceededListener(fileUploader); uploader.addStartedListener(fileUploader); uploadLayout.addComponent(uploader); HorizontalLayout target = new HorizontalLayout(); option.addContainerProperty("id", String.class, null); option.setItemCaptionPropertyId("id"); option.addItem(DeployableContainerType.DEPLOYABLE.attribute()).getItemProperty("id") .setValue("Add to deployables"); option.addItem(DeployableContainerType.DEPLOYED.attribute()).getItemProperty("id").setValue("Deploy"); option.addItem(DeployableContainerType.DEPLOYMENT_PLAN.attribute()).getItemProperty("id") .setValue("Create a deployment plan"); option.addStyleName("horizontal"); option.select(DeployableContainerType.DEPLOYABLE.attribute()); target.addComponent(option); uploadLayout.addComponent(target); toolBar.addComponent(uploadLayout); Label infoLabel = new Label("Drop files here to create a deployment plan"); infoLabel.setSizeUndefined(); final VerticalLayout deploymentPlanMaker = new VerticalLayout(infoLabel); deploymentPlanMaker.setComponentAlignment(infoLabel, Alignment.MIDDLE_CENTER); Button draft = new Button("A draft is under construction"); draft.addStyleName("link"); draft.addClickListener(new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { deploymentViewManager.showDeploymentPlanView(); } }); draft.setVisible(false); deploymentViewManager.setDeploymentPlanDraftViewer(draft); deploymentPlanMaker.addComponent(draft); deploymentPlanMaker.setComponentAlignment(draft, Alignment.TOP_CENTER); deploymentPlanMaker.setSizeFull(); deploymentPlanMaker.addStyleName("drop-area"); deploymentPlanMakerWrapper = new DragAndDropWrapper(deploymentPlanMaker); deploymentPlanMakerWrapper.setSizeFull(); toolBar.addComponent(deploymentPlanMakerWrapper); addComponent(toolBar); addComponent(framesContainer); setExpandRatio(framesContainer, 1.5f); helpWindow = notifierService.createHelpOverlay("Deployment module", "<p>To deploy, or undeploy, artifacts, you can drag and drop elements from deployables panel " + "to deployed panel and vice versa.</p>" + "<p>You can also drag files from desktop and drop them where you want to add them."); }
From source file:com.pms.component.ganttchart.DemoUI.java
License:Apache License
public Component init() { ganttListener = null;// w w w. j av a 2s .com createGantt(); MenuBar menu = controlsMenuBar(); Panel controls = createControls(); TabSheet tabsheet = new TabSheet(); tabsheet.setSizeFull(); Component wrapper = UriFragmentWrapperFactory.wrapByUriFragment(UI.getCurrent().getPage().getUriFragment(), gantt); if (wrapper instanceof GanttListener) { ganttListener = (GanttListener) wrapper; } final VerticalLayout layout = new VerticalLayout(); layout.setStyleName("demoContentLayout"); layout.setSizeFull(); layout.addComponent(menu); layout.addComponent(controls); layout.addComponent(wrapper); layout.setExpandRatio(wrapper, 1); return layout; }