List of usage examples for com.vaadin.ui Alignment MIDDLE_RIGHT
Alignment MIDDLE_RIGHT
To view the source code for com.vaadin.ui Alignment MIDDLE_RIGHT.
Click Source Link
From source file:com.mycollab.vaadin.web.ui.SearchTextField.java
License:Open Source License
public SearchTextField() { this.setDefaultComponentAlignment(Alignment.MIDDLE_RIGHT); ELabel icon = ELabel.fontIcon(FontAwesome.SEARCH); innerField = new TextField(); innerField.setImmediate(true);/* w w w . j a v a2s. co m*/ innerField.setInputPrompt(UserUIContext.getMessage(GenericI18Enum.BUTTON_SEARCH)); innerField.setWidth("180px"); this.with(icon, innerField).withStyleName("searchfield"); ShortcutListener shortcutListener = new ShortcutListener("searchfield", ShortcutAction.KeyCode.ENTER, null) { @Override public void handleAction(Object sender, Object target) { String value = ((TextField) target).getValue(); if (isNotBlank(value)) { doSearch(value); } else { emptySearch(); } } }; ShortcutExtension.installShortcutAction(innerField, shortcutListener); }
From source file:com.mycollab.vaadin.web.ui.StyleCalendarExp.java
License:Open Source License
public StyleCalendarExp() { this.setWidth("230px"); this.setHeightUndefined(); this.setSpacing(false); this.setStyleName("stylecalendar-ext"); this.setMargin(new MarginInfo(true, false, false, false)); styleCalendar.setRenderHeader(false); styleCalendar.setRenderWeekNumbers(false); styleCalendar.setImmediate(true);/* w w w .j a v a2 s . c o m*/ styleCalendar.setWidth("100%"); setDateOptionsGenerator(); btnShowNextYear = new Button(); btnShowNextYear.setIcon( new ExternalResource(StorageFactory.generateAssetRelativeLink("icons/16/cal_year_next.png"))); btnShowNextYear.setStyleName(WebThemes.BUTTON_LINK); btnShowNextMonth = new Button(); btnShowNextMonth.setIcon( new ExternalResource(StorageFactory.generateAssetRelativeLink("icons/16/cal_month_next.png"))); btnShowNextMonth.setStyleName(WebThemes.BUTTON_LINK); btnShowPreviousMonth = new Button(); btnShowPreviousMonth.setIcon( new ExternalResource(StorageFactory.generateAssetRelativeLink("icons/16/cal_month_pre.png"))); btnShowPreviousMonth.setStyleName(WebThemes.BUTTON_LINK); btnShowPreviousYear = new Button(); btnShowPreviousYear.setIcon( new ExternalResource(StorageFactory.generateAssetRelativeLink("icons/16/cal_year_pre.png"))); btnShowPreviousYear.setStyleName(WebThemes.BUTTON_LINK); lbSelectedDate.setValue(UserUIContext.formatDate(new Date())); lbSelectedDate.addStyleName("calendarDateLabel"); lbSelectedDate.setWidth("80"); HorizontalLayout layoutControl = new HorizontalLayout(); layoutControl.setStyleName("calendarHeader"); layoutControl.setWidth("100%"); layoutControl.setHeight("35px"); HorizontalLayout layoutButtonPrevious = new HorizontalLayout(); layoutButtonPrevious.setSpacing(true); layoutButtonPrevious.addComponent(btnShowPreviousYear); layoutButtonPrevious.setComponentAlignment(btnShowPreviousYear, Alignment.MIDDLE_LEFT); layoutButtonPrevious.addComponent(btnShowPreviousMonth); layoutButtonPrevious.setComponentAlignment(btnShowPreviousMonth, Alignment.MIDDLE_LEFT); layoutControl.addComponent(layoutButtonPrevious); layoutControl.setComponentAlignment(layoutButtonPrevious, Alignment.MIDDLE_LEFT); layoutControl.addComponent(lbSelectedDate); layoutControl.setComponentAlignment(lbSelectedDate, Alignment.MIDDLE_CENTER); MHorizontalLayout layoutButtonNext = new MHorizontalLayout(); layoutButtonNext.addComponent(btnShowNextMonth); layoutButtonNext.setComponentAlignment(btnShowNextMonth, Alignment.MIDDLE_RIGHT); layoutButtonNext.addComponent(btnShowNextYear); layoutButtonNext.setComponentAlignment(btnShowNextYear, Alignment.MIDDLE_RIGHT); layoutControl.addComponent(layoutButtonNext); layoutControl.setComponentAlignment(layoutButtonNext, Alignment.MIDDLE_RIGHT); this.addComponent(layoutControl); this.setComponentAlignment(layoutControl, Alignment.TOP_CENTER); this.addComponent(styleCalendar); this.setExpandRatio(styleCalendar, 1.0f); }
From source file:com.mycollab.vaadin.web.ui.table.AbstractPagedBeanTable.java
License:Open Source License
private ComponentContainer createPagingControls() { controlBarWrapper = new HorizontalLayout(); controlBarWrapper.setWidth("100%"); controlBarWrapper.setStyleName("listControl"); pageManagement = new MHorizontalLayout(); // defined layout here --------------------------- if (currentPage > 1) { MButton firstLink = new MButton("1", clickEvent -> pageChange(1)).withStyleName("buttonPaging"); pageManagement.addComponent(firstLink); }// ww w .ja v a 2 s .co m if (currentPage >= 5) { Label ss1 = new Label("..."); ss1.addStyleName("buttonPaging"); pageManagement.addComponent(ss1); } if (currentPage > 3) { MButton previous2 = new MButton("" + (currentPage - 2), clickEvent -> pageChange(currentPage - 2)) .withStyleName("buttonPaging"); pageManagement.addComponent(previous2); } if (currentPage > 2) { MButton previous1 = new MButton("" + (currentPage - 1), clickEvent -> pageChange(currentPage - 1)) .withStyleName("buttonPaging"); pageManagement.addComponent(previous1); } // Here add current ButtonLinkLegacy MButton current = new MButton("" + currentPage, clickEvent -> pageChange(currentPage)) .withStyleName("buttonPaging", "current"); pageManagement.addComponent(current); final int range = totalPage - currentPage; if (range >= 1) { MButton next1 = new MButton("" + (currentPage + 1), clickEvent -> pageChange(currentPage + 1)) .withStyleName("buttonPaging"); pageManagement.addComponent(next1); } if (range >= 2) { MButton next2 = new MButton("" + (currentPage + 2), clickEvent -> pageChange(currentPage + 2)) .withStyleName("buttonPaging"); pageManagement.addComponent(next2); } if (range >= 4) { final Label ss2 = new Label("..."); ss2.addStyleName("buttonPaging"); pageManagement.addComponent(ss2); } if (range >= 3) { MButton last = new MButton("" + totalPage, clickEvent -> pageChange(totalPage)) .withStyleName("buttonPaging"); pageManagement.addComponent(last); } pageManagement.setWidth(null); controlBarWrapper.addComponent(pageManagement); controlBarWrapper.setComponentAlignment(pageManagement, Alignment.MIDDLE_RIGHT); return controlBarWrapper; }
From source file:com.oodrive.nuage.webui.component.VvrOperationComponent.java
License:Apache License
@Override public final AbstractComponent createComponent(final VvrModel model, final ModelCreator handler) { final HorizontalLayout operationLayout = new HorizontalLayout(); operationLayout.setMargin(true);//from w w w.jav a2 s .c om operationLayout.setSpacing(true); operationLayout.setWidth("100%"); // Start and description buttons // START/STOP final Button startStop = new Button(); startStop.setWidth(BUTTON_WIDTH); startStop.addStyleName(Runo.BUTTON_BIG); final Resource iconStartStop; final String description; if (!model.isVvrStarted()) { iconStartStop = WebUiResources.getStartIcon(); description = "Start"; } else { iconStartStop = WebUiResources.getStopIcon(); description = "Stop"; } startStop.setIcon(iconStartStop); startStop.setDescription(description); operationLayout.addComponent(startStop); operationLayout.setExpandRatio(startStop, 1f); operationLayout.setComponentAlignment(startStop, Alignment.MIDDLE_LEFT); final UUID vvrUuid = model.getItemUuid(); startStop.addClickListener(new Button.ClickListener() { @Override public void buttonClick(final ClickEvent event) { final boolean started = model.isVvrStarted(); // Start/Stop are done in background if (!started) { WaitingComponent.executeBackground(model, new Background() { @Override public void processing() { model.startVvr(); } @Override public void postProcessing() { startStop.setIcon(WebUiResources.getStopIcon()); startStop.setDescription("Stop"); Notification.show("VVR started ", vvrUuid.toString(), Notification.Type.TRAY_NOTIFICATION); } }); } else { WaitingComponent.executeBackground(model, new Background() { @Override public void processing() { model.stopVvr(); } @Override public void postProcessing() { startStop.setIcon(WebUiResources.getStartIcon()); startStop.setDescription("Start"); Notification.show("VVR stopped ", vvrUuid.toString(), Notification.Type.TRAY_NOTIFICATION); } }); } } }); // ATTRIBUTES final Button attributes = new Button(); attributes.addStyleName(Runo.BUTTON_BIG); attributes.setWidth(BUTTON_WIDTH); operationLayout.addComponent(attributes); operationLayout.setExpandRatio(attributes, 1f); operationLayout.setComponentAlignment(attributes, Alignment.MIDDLE_LEFT); attributes.setIcon(WebUiResources.getSettingsIcon()); attributes.setDescription("Settings"); attributes.addClickListener(new Button.ClickListener() { @Override public void buttonClick(final ClickEvent event) { try { final VvrAttributesWindow attributesWindow = new VvrAttributesWindow(vvrUuid); attributesWindow.add(model); } catch (final Exception e) { LOGGER.error("Can not get VVR attributes: ", e); final ErrorWindow err = new ErrorWindow("Can not display VVR Attributes: " + e.getMessage()); err.add(model); } } }); // DELETE final Button delete = new Button(); delete.addStyleName(Runo.BUTTON_BIG); delete.setWidth(BUTTON_WIDTH); delete.setIcon(WebUiResources.getTrashIcon()); delete.setDescription("Delete"); operationLayout.addComponent(delete); operationLayout.setExpandRatio(delete, 12f); operationLayout.setComponentAlignment(delete, Alignment.MIDDLE_RIGHT); delete.addClickListener(new Button.ClickListener() { @Override public void buttonClick(final ClickEvent event) { try { final VvrDeleteWindow deleteWindow = new VvrDeleteWindow(vvrUuid); deleteWindow.add(vvrManagerModel); } catch (final Exception e) { LOGGER.error("Can not delete VVR: ", e); final ErrorWindow err = new ErrorWindow("Can not delete VVR: " + e.getMessage()); err.add(model); } } }); return operationLayout; }
From source file:com.openhris.calendar.SchedulerMainUI.java
public SchedulerMainUI() { setMargin(true);//from w ww.ja va 2 s . c om cal = new Calendar(); calendarEvents(); cal.setWidth("100%"); cal.setHeight("100%"); cal.setImmediate(true); Date today = new Date(); calendar = new GregorianCalendar(); calendar.setTime(today); updateCaptionLabel(); initNavigationButtons(); if (!showWeeklyView) { int rollAmount = calendar.get(GregorianCalendar.DAY_OF_MONTH) - 1; calendar.add(GregorianCalendar.DAY_OF_MONTH, -rollAmount); currentMonthsFirstDate = calendar.getTime(); cal.setStartDate(currentMonthsFirstDate); calendar.add(GregorianCalendar.MONTH, 1); calendar.add(GregorianCalendar.DATE, -1); cal.setEndDate(calendar.getTime()); } cal.setHandler(new BasicDateClickHandler() { @Override public void dateClick(CalendarComponentEvents.DateClickEvent event) { Calendar cal = event.getComponent(); long currentCalDateRange = cal.getEndDate().getTime() - cal.getStartDate().getTime(); if (currentCalDateRange < VCalendar.DAYINMILLIS) { // Change the date range to the current week cal.setStartDate(cal.getFirstDateForWeek(event.getDate())); cal.setEndDate(cal.getLastDateForWeek(event.getDate())); } else { // Default behaviour, change date range to one day super.dateClick(event); } } }); addCalendarEventListeners(); GridLayout grid = new GridLayout(5, 1); grid.setSizeFull(); monthButton.setVisible(false); weekButton.setVisible(false); grid.addComponent(monthButton, 1, 0); grid.setComponentAlignment(monthButton, Alignment.MIDDLE_CENTER); monthLabel = new Label(); monthLabel.setValue(OpenHrisUtilities.convertDateFormatForCalendar(currentMonthsFirstDate.toString())); monthLabel.setContentMode(Label.CONTENT_XHTML); monthLabel.addStyleName("month"); grid.addComponent(monthLabel, 2, 0); grid.setComponentAlignment(monthLabel, Alignment.MIDDLE_CENTER); grid.addComponent(weekButton, 3, 0); grid.setComponentAlignment(weekButton, Alignment.MIDDLE_CENTER); grid.addComponent(nextButton, 4, 0); grid.setComponentAlignment(nextButton, Alignment.MIDDLE_RIGHT); grid.addComponent(prevButton, 0, 0); grid.setComponentAlignment(prevButton, Alignment.MIDDLE_LEFT); addComponent(grid); addComponent(cal); setExpandRatio(cal, 1); }
From source file:com.openhris.employee.PostEmploymentInfomation.java
public ComponentContainer layout2() { HorizontalLayout hlayout = new HorizontalLayout(); hlayout.setSpacing(true);/*from w w w .j a v a2 s . c o m*/ hlayout.setWidth("100%"); GridLayout glayout2 = new GridLayout(2, 2); glayout2.setSpacing(true); final PopupDateField endDate = new HRISPopupDateField("Exit Date: "); endDate.setWidth("250px"); endDate.setDateFormat("MM/dd/yyyy"); glayout2.addComponent(endDate, 0, 0); glayout2.setComponentAlignment(endDate, Alignment.BOTTOM_LEFT); Button endDateBtn = new Button("RESIGN"); endDateBtn.setWidth("150px"); endDateBtn.addListener(new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { if (endDate.getValue() == null || endDate.getValue().toString().trim().isEmpty()) { getWindow().showNotification("Enter End Date.", Window.Notification.TYPE_ERROR_MESSAGE); return; } Window window = new ConfirmResignWindow(getEmployeeId(), utilities.convertDateFormat(endDate.getValue().toString().trim().toLowerCase())); if (window.getParent() == null) { getWindow().addWindow(window); } } }); glayout2.addComponent(endDateBtn, 1, 0); glayout2.setComponentAlignment(endDateBtn, Alignment.BOTTOM_LEFT); if (GlobalVariables.getUserRole().equals("administrator") || GlobalVariables.getUserRole().equals("hr")) { endDateBtn.setEnabled(true); } else { endDateBtn.setEnabled(false); } hlayout.addComponent(glayout2); hlayout.setComponentAlignment(glayout2, Alignment.MIDDLE_RIGHT); final PopupDateField entryDateFromEmp = new HRISPopupDateField("Entry Date from Employment: "); entryDateFromEmp.setWidth("250px"); entryDateFromEmp.setDateFormat("MM/dd/yyyy"); entryDateFromEmp.setValue(utilities.parsingDate(employeeService.getEmploymentEntryDate(getEmployeeId()))); glayout2.addComponent(entryDateFromEmp, 0, 1); glayout2.setComponentAlignment(entryDateFromEmp, Alignment.BOTTOM_LEFT); Button entryDateFromEmpBtn = new Button("EDIT"); entryDateFromEmpBtn.setWidth("150px"); entryDateFromEmpBtn.addListener(new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { if (!GlobalVariables.getUserRole().equals("administrator")) { getWindow().showNotification( "You need to be an ADMINISTRATOR to EDIT date entry of employment.", Window.Notification.TYPE_ERROR_MESSAGE); return; } Window sub = new EditEmploymentDateEntryWindow(getEmployeeId(), utilities.convertDateFormat(entryDateFromEmp.getValue().toString())); if (sub.getParent() == null) { getWindow().addWindow(sub); } } }); glayout2.addComponent(entryDateFromEmpBtn, 1, 1); glayout2.setComponentAlignment(entryDateFromEmpBtn, Alignment.BOTTOM_LEFT); if (GlobalVariables.getUserRole().equals("administrator") || GlobalVariables.getUserRole().equals("hr")) { entryDateFromEmpBtn.setEnabled(true); } else { entryDateFromEmpBtn.setEnabled(false); } return hlayout; }
From source file:com.openhris.timekeeping.EditAttendanceTableContainerWindow.java
public EditAttendanceTableContainerWindow(String name, List dateList, String employeeId, String payrollPeriod, String payrollDate, String attendancePeriodFrom, String attendancePeriodTo, String employmentWageEntry, double employmentWage, int branchId, int payrollId) { this.name = name; this.dateList = dateList; this.employeeId = employeeId; this.payrollPeriod = payrollPeriod; this.payrollDate = payrollDate; this.attendancePeriodFrom = attendancePeriodFrom; this.attendancePeriodTo = attendancePeriodTo; this.employmentWageEntry = employmentWageEntry; this.employmentWage = employmentWage; this.branchId = branchId; this.payrollId = payrollId; setCaption("ATTENDANCE TABLE for " + getEmployeesName()); setSizeFull();//from ww w. java 2 s. c o m setModal(true); center(); VerticalLayout vlayout = new VerticalLayout(); vlayout.setSizeFull(); vlayout.setSpacing(true); GridLayout glayout = new GridLayout(2, 2); glayout.setSpacing(true); Label payrollPeriodLabel = new Label("Payroll Period: "); glayout.addComponent(payrollPeriodLabel, 0, 0); glayout.setComponentAlignment(payrollPeriodLabel, Alignment.MIDDLE_RIGHT); Label periodLabel = new Label(getPayrollPeriod()); glayout.addComponent(periodLabel, 1, 0); glayout.setComponentAlignment(periodLabel, Alignment.MIDDLE_LEFT); Label payrollDateLabel = new Label("Payroll Date: "); glayout.addComponent(payrollDateLabel, 0, 1); glayout.setComponentAlignment(payrollDateLabel, Alignment.MIDDLE_RIGHT); Label dateLabel = new Label(getPayrollDate()); glayout.addComponent(dateLabel, 1, 1); glayout.setComponentAlignment(dateLabel, Alignment.MIDDLE_LEFT); vlayout.addComponent(glayout); vlayout.addComponent(generateAttendanceTable()); addComponent(vlayout); }
From source file:com.openhris.timekeeping.EditAttendanceTableContainerWindow.java
VerticalLayout generateAttendanceTable() { VerticalLayout vlayout = new VerticalLayout(); vlayout.setSizeFull();//www.ja v a 2s. c o m vlayout.setSpacing(true); if (getEmploymentWageEntry().equals("monthly")) { employmentWage = utilities.roundOffToTwoDecimalPlaces((employmentWage * 12) / 314); } final Table table = new Table(); table.removeAllItems(); table.setEnabled(true); table.setWidth("100%"); table.setImmediate(true); table.setColumnCollapsingAllowed(true); table.addContainerProperty("edit", CheckBox.class, null); table.addContainerProperty("date", String.class, null); table.addContainerProperty("policy", String.class, null); table.addContainerProperty("holidays", String.class, null); table.addContainerProperty("premium", CheckBox.class, null); table.addContainerProperty("lates", TextField.class, null); table.addContainerProperty("undertime", TextField.class, null); table.addContainerProperty("overtime", TextField.class, null); table.addContainerProperty("night differential", TextField.class, null); table.addContainerProperty("l/min", Double.class, null); table.addContainerProperty("u/min", Double.class, null); table.addContainerProperty("o/min", Double.class, null); table.addContainerProperty("nd/min", Double.class, null); table.addContainerProperty("lholiday", Double.class, null); table.addContainerProperty("sholiday", Double.class, null); table.addContainerProperty("wdo", Double.class, null); table.addContainerProperty("psday", Double.class, null); //paid non-working holiday table.addContainerProperty("latesLH", Double.class, null); table.addContainerProperty("latesSH", Double.class, null); table.addContainerProperty("latesWO", Double.class, null); table.addContainerProperty("undertimeLH", Double.class, null); table.addContainerProperty("undertimeSH", Double.class, null); table.addContainerProperty("undertimeWO", Double.class, null); table.setColumnAlignment("edit", Table.ALIGN_CENTER); table.setColumnAlignment("date", Table.ALIGN_CENTER); table.setColumnAlignment("policy", Table.ALIGN_CENTER); table.setColumnAlignment("premium", Table.ALIGN_CENTER); table.setColumnAlignment("lates", Table.ALIGN_CENTER); table.setColumnAlignment("undertime", Table.ALIGN_CENTER); table.setColumnAlignment("overtime", Table.ALIGN_CENTER); table.setColumnAlignment("night differential", Table.ALIGN_CENTER); table.setColumnAlignment("l/min", Table.ALIGN_RIGHT); table.setColumnAlignment("u/min", Table.ALIGN_RIGHT); table.setColumnAlignment("o/min", Table.ALIGN_RIGHT); table.setColumnAlignment("nd/min", Table.ALIGN_RIGHT); table.setColumnAlignment("lholiday", Table.ALIGN_RIGHT); table.setColumnAlignment("sholiday", Table.ALIGN_RIGHT); table.setColumnAlignment("wdo", Table.ALIGN_RIGHT); table.setColumnAlignment("psday", Table.ALIGN_RIGHT); table.setColumnAlignment("latesLH", Table.ALIGN_RIGHT); table.setColumnAlignment("latesSH", Table.ALIGN_RIGHT); table.setColumnAlignment("latesWO", Table.ALIGN_RIGHT); table.setColumnAlignment("undertimeLH", Table.ALIGN_RIGHT); table.setColumnAlignment("undertimeSH", Table.ALIGN_RIGHT); table.setColumnAlignment("undertimeWO", Table.ALIGN_RIGHT); table.setColumnCollapsed("latesLH", true); table.setColumnCollapsed("latesSH", true); table.setColumnCollapsed("latesWO", true); table.setColumnCollapsed("undertimeLH", true); table.setColumnCollapsed("undertimeSH", true); table.setColumnCollapsed("undertimeWO", true); final String[] holidayList = { "legal-holiday", "special-holiday" }; for (int i = 0; i < getDateList().size(); i++) { Object itemId = new Integer(i); final CheckBox edit = new CheckBox(); edit.setData(i); edit.setEnabled(UserAccessControl.isEditAttendance()); edit.setImmediate(true); final CheckBox premium = new CheckBox(); premium.setData(itemId); premium.setEnabled(false); premium.setImmediate(true); final TextField lates = new TextField(); lates.setWidth("50px"); lates.setValue("0"); lates.setEnabled(true); lates.setData(itemId); lates.setEnabled(false); lates.setImmediate(true); final TextField undertime = new TextField(); undertime.setWidth("50px"); undertime.setValue("0"); undertime.setEnabled(true); undertime.setData(itemId); undertime.setEnabled(false); undertime.setImmediate(true); final TextField overtime = new TextField(); overtime.setWidth("50px"); overtime.setValue("0"); overtime.setEnabled(true); overtime.setData(itemId); overtime.setEnabled(false); overtime.setImmediate(true); final TextField nightDifferential = new TextField(); nightDifferential.setWidth("50px"); nightDifferential.setValue("0"); nightDifferential.setEnabled(true); nightDifferential.setData(itemId); nightDifferential.setEnabled(false); nightDifferential.setImmediate(true); edit.addListener(new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { premium.setEnabled(event.getButton().booleanValue()); lates.setEnabled(event.getButton().booleanValue()); undertime.setEnabled(event.getButton().booleanValue()); overtime.setEnabled(event.getButton().booleanValue()); nightDifferential.setEnabled(event.getButton().booleanValue()); } }); premium.addListener(new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { Object itemId = lates.getData(); Item item = table.getItem(itemId); lates.setValue("0"); undertime.setValue("0"); overtime.setValue("0"); nightDifferential.setValue("0"); item.getItemProperty("l/min").setValue(0.0); item.getItemProperty("u/min").setValue(0.0); item.getItemProperty("o/min").setValue(0.0); item.getItemProperty("nd/min").setValue(0.0); if (event.getButton().booleanValue() == true) { premiumRate = 0.1; } else { premiumRate = 0.0; } item.getItemProperty("wdo") .setValue(utilities.roundOffToTwoDecimalPlaces( Double.parseDouble(item.getItemProperty("wdo").getValue().toString()) + (Double.parseDouble(item.getItemProperty("wdo").getValue().toString()) * premiumRate))); item.getItemProperty("lholiday") .setValue(utilities.roundOffToTwoDecimalPlaces(Double .parseDouble(item.getItemProperty("lholiday").getValue().toString()) + (Double.parseDouble(item.getItemProperty("lholiday").getValue().toString()) * premiumRate))); item.getItemProperty("sholiday") .setValue(utilities.roundOffToTwoDecimalPlaces(Double .parseDouble(item.getItemProperty("sholiday").getValue().toString()) + (Double.parseDouble(item.getItemProperty("sholiday").getValue().toString()) * premiumRate))); } }); lates.addListener(new FieldEvents.TextChangeListener() { @Override public void textChange(FieldEvents.TextChangeEvent event) { Object itemId = lates.getData(); Item item = table.getItem(itemId); String policyStr = item.getItemProperty("policy").toString(); String holidayStr = item.getItemProperty("holidays").toString(); double lateDeduction; boolean checkIfInputIsInteger = utilities.checkInputIfInteger(event.getText().trim()); if (!checkIfInputIsInteger) { getWindow().showNotification("Enter numeric format for lates!", Window.Notification.TYPE_WARNING_MESSAGE); return; } if (!event.getText().isEmpty()) { if (utilities.convertStringToInteger(event.getText().trim()) > 5) { lateDeduction = computation.processEmployeesLates(policyStr, holidayStr, utilities.convertStringToInteger(event.getText().trim()), getEmploymentWage()); if (policyStr == null || policyStr.isEmpty()) { item.getItemProperty("l/min") .setValue(utilities.roundOffToTwoDecimalPlaces(lateDeduction)); } else if (policyStr.equals("working-holiday") && holidayStr.equals("legal-holiday")) { item.getItemProperty("latesLH") .setValue(utilities.roundOffToTwoDecimalPlaces(lateDeduction)); item.getItemProperty("latesSH").setValue(0.0); item.getItemProperty("latesWO").setValue(0.0); item.getItemProperty("l/min").setValue(0.0); } else if (policyStr.equals("working-holiday") && holidayStr.equals("special-holiday")) { item.getItemProperty("latesLH").setValue(0.0); item.getItemProperty("latesSH") .setValue(utilities.roundOffToTwoDecimalPlaces(lateDeduction)); item.getItemProperty("latesWO").setValue(0.0); item.getItemProperty("l/min").setValue(0.0); } else if (policyStr.equals("working-day-off")) { item.getItemProperty("latesLH").setValue(0.0); item.getItemProperty("latesSH").setValue(0.0); item.getItemProperty("latesWO") .setValue(utilities.roundOffToTwoDecimalPlaces(lateDeduction)); item.getItemProperty("l/min").setValue(0.0); } } else { item.getItemProperty("l/min").setValue(0.0); } } else { item.getItemProperty("l/min").setValue(0.0); } } }); undertime.addListener(new FieldEvents.TextChangeListener() { @Override public void textChange(FieldEvents.TextChangeEvent event) { Object itemId = lates.getData(); Item item = table.getItem(itemId); String policyStr = item.getItemProperty("policy").toString(); String holidayStr = item.getItemProperty("holidays").toString(); double undertimeDeduction; boolean checkIfInputIsInteger = utilities.checkInputIfInteger(event.getText().trim()); if (!checkIfInputIsInteger) { getWindow().showNotification("Enter numeric format for undertime!", Window.Notification.TYPE_WARNING_MESSAGE); return; } if (!event.getText().isEmpty()) { undertimeDeduction = computation.processEmployeesUndertime(policyStr, holidayStr, utilities.convertStringToInteger(event.getText().trim()), getEmploymentWage()); if (policyStr == null || policyStr.isEmpty()) { item.getItemProperty("u/min") .setValue(utilities.roundOffToTwoDecimalPlaces(undertimeDeduction)); } else if (policyStr.equals("working-holiday") && holidayStr.equals("legal-holiday")) { item.getItemProperty("undertimeLH") .setValue(utilities.roundOffToTwoDecimalPlaces(undertimeDeduction)); item.getItemProperty("undertimeSH").setValue(0.0); item.getItemProperty("undertimeWO").setValue(0.0); item.getItemProperty("u/min").setValue(0.0); } else if (policyStr.equals("working-holiday") && holidayStr.equals("special-holiday")) { item.getItemProperty("undertimeLH").setValue(0.0); item.getItemProperty("undertimeSH") .setValue(utilities.roundOffToTwoDecimalPlaces(undertimeDeduction)); item.getItemProperty("undertimeWO").setValue(0.0); item.getItemProperty("u/min").setValue(0.0); } else if (policyStr.equals("working-day-off")) { item.getItemProperty("undertimeLH").setValue(0.0); item.getItemProperty("undertimeSH").setValue(0.0); item.getItemProperty("undertimeWO") .setValue(utilities.roundOffToTwoDecimalPlaces(undertimeDeduction)); item.getItemProperty("u/min").setValue(0.0); } } else { item.getItemProperty("u/min").setValue(0.0); } } }); overtime.addListener(new FieldEvents.TextChangeListener() { @Override public void textChange(FieldEvents.TextChangeEvent event) { Object itemId = lates.getData(); Item item = table.getItem(itemId); String policyStr = item.getItemProperty("policy").toString(); String holidayStr = item.getItemProperty("holidays").toString(); double overtimeAddition; boolean checkIfInputIsInteger = utilities.checkInputIfInteger(event.getText().trim()); if (!checkIfInputIsInteger) { getWindow().showNotification("Enter numeric format for undertime!", Window.Notification.TYPE_WARNING_MESSAGE); return; } if (!event.getText().isEmpty()) { overtimeAddition = computation.processEmployeesOvertime(policyStr, holidayStr, Integer.parseInt(event.getText().trim()), getEmploymentWage()); item.getItemProperty("o/min").setValue(utilities .roundOffToTwoDecimalPlaces(overtimeAddition + (overtimeAddition * premiumRate))); } else { item.getItemProperty("o/min").setValue(0.0); } } }); nightDifferential.addListener(new FieldEvents.TextChangeListener() { @Override public void textChange(FieldEvents.TextChangeEvent event) { Object itemId = lates.getData(); Item item = table.getItem(itemId); String policyStr = item.getItemProperty("policy").toString(); String holidayStr = item.getItemProperty("holidays").toString(); double nightDifferentialAddition; boolean checkIfInputIsInteger = utilities.checkInputIfInteger(event.getText().trim()); if (!checkIfInputIsInteger) { getWindow().showNotification("Enter numeric format for undertime!", Window.Notification.TYPE_WARNING_MESSAGE); return; } if (!event.getText().isEmpty()) { nightDifferentialAddition = computation.processEmployeesNightDifferential(policyStr, holidayStr, Integer.parseInt(event.getText().trim()), getEmploymentWage()); item.getItemProperty("nd/min").setValue(utilities.roundOffToTwoDecimalPlaces( nightDifferentialAddition + (nightDifferentialAddition * premiumRate))); } else { item.getItemProperty("nd/min").setValue(0.0); } } }); List<Timekeeping> timekeepingListByRowData = timekeepingService.getTimekeepingRowData( utilities.convertDateFormat(getDateList().get(i).toString()), getPayrollId()); for (Timekeeping t : timekeepingListByRowData) { String policy; String holiday; if (!t.getPolicy().equals("null")) { policy = t.getPolicy(); } else { policy = ""; } if (!t.getHoliday().equals("null")) { holiday = t.getHoliday(); } else { holiday = ""; } premium.setValue(t.isPremium()); lates.setValue(t.getLates()); undertime.setValue(t.getUndertime()); overtime.setValue(t.getOvertime()); nightDifferential.setValue(t.getNightDifferential()); table.addItem( new Object[] { edit, utilities.convertDateFormat(getDateList().get(i).toString()), policy, holiday, premium, lates, undertime, overtime, nightDifferential, t.getLateDeduction(), t.getUndertimeDeduction(), t.getOvertimePaid(), t.getNightDifferentialPaid(), t.getLegalHolidayPaid(), t.getSpecialHolidayPaid(), t.getWorkingDayOffPaid(), t.getNonWorkingHolidayPaid(), t.getLatesLegalHolidayDeduction(), t.getLatesSpecialHolidayDeduction(), t.getLatesWorkingDayOffDeduction(), t.getUndertimeLegalHolidayDeduction(), t.getUndertimeSpecialHolidayDeduction(), t.getUndertimeWorkingDayOffDeduction() }, new Integer(i)); } } table.setPageLength(table.size()); for (Object listener : table.getListeners(ItemClickEvent.class)) { table.removeListener(ItemClickEvent.class, listener); } table.addListener(new ItemClickEvent.ItemClickListener() { @Override public void itemClick(ItemClickEvent event) { final Object itemId = event.getItemId(); final Item item = table.getItem(itemId); Boolean editRow = Boolean.valueOf(item.getItemProperty("edit").getValue().toString()); if (event.getPropertyId().equals("policy")) { if (editRow) { Window sub = new AttendancePolicyWindow(holidayList, item, getEmploymentWageEntry(), getEmploymentWage()); if (sub.getParent() == null) { getApplication().getMainWindow().addWindow(sub); } } else { getWindow().showNotification("Click Edit!", Window.Notification.TYPE_WARNING_MESSAGE); } } } }); vlayout.addComponent(table); final Button saveButton = new Button(); saveButton.setWidth("200px"); saveButton.setCaption("UPDATE ATTENDANCE DATA"); saveButton.setEnabled(UserAccessControl.isEditAttendance()); for (Object listener : saveButton.getListeners(Button.ClickListener.class)) { saveButton.removeListener(Button.ClickListener.class, listener); } GridLayout glayout = new GridLayout(2, 1); glayout.setSizeFull(); glayout.setSpacing(true); saveButton.addListener(new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { try { Collection attendanceTableCollection = table.getContainerDataSource().getItemIds(); List<Timekeeping> attendanceList = new ArrayList<>(); Iterator iterator = attendanceTableCollection.iterator(); while (iterator.hasNext()) { String str = table.getItem(iterator.next()).toString(); String[] attStr = str.split(" "); List<String> tkeepList = new ArrayList<>(Arrays.asList(attStr)); Timekeeping t = new Timekeeping(); t.setAttendanceDate(utilities.parsingDate(tkeepList.get(1))); t.setPolicy(tkeepList.get(2)); t.setHoliday(tkeepList.get(3)); t.setPremium(utilities.convertStringToBoolean(tkeepList.get(4))); t.setLates(utilities.convertStringToDouble(tkeepList.get(5))); t.setUndertime(utilities.convertStringToDouble(tkeepList.get(6))); t.setOvertime(utilities.convertStringToDouble(tkeepList.get(7))); t.setNightDifferential(utilities.convertStringToDouble(tkeepList.get(8))); t.setLateDeduction(utilities.convertStringToDouble(tkeepList.get(9))); t.setUndertimeDeduction(utilities.convertStringToDouble(tkeepList.get(10))); t.setOvertimePaid(utilities.convertStringToDouble(tkeepList.get(11))); t.setNightDifferentialPaid(utilities.convertStringToDouble(tkeepList.get(12))); t.setLegalHolidayPaid(utilities.convertStringToDouble(tkeepList.get(13))); t.setSpecialHolidayPaid(utilities.convertStringToDouble(tkeepList.get(14))); t.setWorkingDayOffPaid(utilities.convertStringToDouble(tkeepList.get(15))); t.setNonWorkingHolidayPaid(utilities.convertStringToDouble(tkeepList.get(16))); t.setLatesLegalHolidayDeduction(utilities.convertStringToDouble(tkeepList.get(17))); t.setLatesSpecialHolidayDeduction(utilities.convertStringToDouble(tkeepList.get(18))); t.setLatesWorkingDayOffDeduction(utilities.convertStringToDouble(tkeepList.get(19))); t.setUndertimeLegalHolidayDeduction(utilities.convertStringToDouble(tkeepList.get(20))); t.setUndertimeSpecialHolidayDeduction(utilities.convertStringToDouble(tkeepList.get(21))); t.setUndertimeWorkingDayOffDeduction(utilities.convertStringToDouble(tkeepList.get(22))); attendanceList.add(t); } ProcessPayrollComputation processPayroll = new ProcessPayrollComputation(getEmployeeId(), getBranchId()); processPayroll.initVariables(); processPayroll.initVariablesForComputation(attendanceList); boolean result = processPayroll.processPayrollComputation(payrollDate, payrollPeriod, attendancePeriodFrom, attendancePeriodTo, getPayrollId()); if (result) { close(); } else { getWindow().showNotification("SQL ERROR"); } } catch (Exception e) { e.getMessage(); } } }); glayout.addComponent(saveButton, 0, 0); glayout.setComponentAlignment(saveButton, Alignment.MIDDLE_LEFT); // vlayout.addComponent(saveButton); Button printButton = new Button("PRINT ATTENDANCE"); printButton.setWidth("200px"); printButton.addListener(new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { OpenHrisReports reports = new OpenHrisReports(0, null); String fileName = "IndividualAttendanceReport_"; reports.deleteFile(fileName); Window reportWindow = new IndividualAttendanceReport(getPayrollId(), getApplication()); } }); glayout.addComponent(printButton, 1, 0); glayout.setComponentAlignment(printButton, Alignment.MIDDLE_RIGHT); vlayout.addComponent(glayout); return vlayout; }
From source file:com.peergreen.webconsole.core.vaadin7.BaseUI.java
License:Open Source License
/** * Build login view//from ww w . j a v a 2 s.c om * * @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.core.vaadin7.BaseUI.java
License:Open Source License
/** * Build Welcome progress indicator view *//* w w w. j av a 2s . com*/ private void buildProgressIndicatorView() { final CssLayout progressPanel = new CssLayout(); progressPanel.addStyleName("login-panel"); HorizontalLayout labels = new HorizontalLayout(); labels.setWidth(MAX_WIDTH); labels.setMargin(true); progressPanel.addComponent(labels); Label welcome = new Label("Welcome " + ((securityManager == null) ? "" : securityManager.getUserName())); welcome.addStyleName("h4"); labels.addComponent(welcome); labels.setComponentAlignment(welcome, Alignment.MIDDLE_LEFT); Label title = new Label(consoleName); title.addStyleName("h2"); title.addStyleName("light"); labels.addComponent(title); labels.setComponentAlignment(title, Alignment.MIDDLE_RIGHT); Float scopesViewsBound = (float) scopes.size(); final Float stopValue = new Float(1.0); if (scopesFactories.isEmpty()) { progressIndicator.setValue(stopValue); } else { progressIndicator.setValue(scopesViewsBound / nbScopesToBind); } if (stopValue.equals(progressIndicator.getValue())) { showMainContent(); } else { // We are still waiting for scopes we have requested their creation, wait a while. TimeOutThread timeOutThread = new TimeOutThread(); timeOutThread.start(); progressIndicator.addValueChangeListener(new Property.ValueChangeListener() { @Override public void valueChange(Property.ValueChangeEvent event) { if (stopValue.equals(event.getProperty().getValue())) { showMainContent(); } } }); } HorizontalLayout progressBarPanel = new HorizontalLayout(); progressBarPanel.setWidth(MAX_WIDTH); progressBarPanel.setMargin(true); progressBarPanel.addComponent(progressIndicator); progressBarPanel.setComponentAlignment(progressIndicator, Alignment.MIDDLE_CENTER); progressPanel.addComponent(progressBarPanel); progressIndicatorLayout.addComponent(progressPanel); progressIndicatorLayout.setComponentAlignment(progressPanel, Alignment.MIDDLE_CENTER); }