List of usage examples for com.vaadin.ui Notification show
public static Notification show(String caption, Type type)
From source file:com.save.employee.maintenance.MRFormWindow.java
void requiredFields() { Notification.show("Required All Fields", Notification.Type.ERROR_MESSAGE); }
From source file:com.save.employee.maintenance.MRFormWindow.java
void clearFields() { plateNo.setValue(""); amount.setValue(""); description.setValue(""); Notification.show("Save " + formType.getItemCaption(formType.getValue()), Notification.Type.TRAY_NOTIFICATION); }
From source file:com.save.employee.RemoveAccountWindow.java
VerticalLayout getVLayout() { VerticalLayout vlayout = new VerticalLayout(); vlayout.setSpacing(true);/*from ww w. j a v a2 s.c o m*/ vlayout.setMargin(true); vlayout.setSizeFull(); final TextArea remarks = new TextArea("Remarks: "); remarks.setRows(2); remarks.setWidth("100%"); vlayout.addComponent(remarks); Button removeBtn = new Button("REMOVE ACCOUNT?"); removeBtn.setWidth("100%"); removeBtn.addClickListener((Button.ClickEvent event) -> { if (remarks.getValue() == null || remarks.getValue().trim().isEmpty()) { Notification.show("Add Remarks!", Notification.Type.ERROR_MESSAGE); return; } boolean result = employeeService.removeAccount(getEmployeeId(), remarks.getValue().trim().toLowerCase()); if (result) { close(); } }); vlayout.addComponent(removeBtn); return vlayout; }
From source file:com.save.employee.request.RequestFormWindow.java
Component buildRequestForm() { GridLayout glayout = new GridLayout(4, 7); glayout.setSizeFull();/*from w ww .jav a 2 s .co m*/ glayout.setSpacing(true); glayout.setMargin(true); controlNo = new TextField("Control No."); controlNo.setWidth("100%"); controlNo.addStyleName(ValoTheme.TEXTFIELD_SMALL); glayout.addComponent(controlNo, 0, 0); dateOfActivity = new DateField("Date of Activity: "); dateOfActivity.setWidth("100%"); dateOfActivity.addStyleName(ValoTheme.DATEFIELD_SMALL); glayout.addComponent(dateOfActivity, 1, 0); area = CommonComboBox.areas(); area.setWidth("100%"); glayout.addComponent(area, 2, 0); activity = new TextField("Activity: "); activity.setWidth("100%"); activity.addStyleName(ValoTheme.TEXTFIELD_SMALL); glayout.addComponent(activity, 0, 1, 1, 1); venue = new TextField("Venue: "); venue.setWidth("100%"); venue.addStyleName(ValoTheme.TEXTFIELD_SMALL); glayout.addComponent(venue, 0, 2, 1, 2); requirements = new TextArea("Requirements: "); requirements.setWidth("100%"); requirements.addStyleName(ValoTheme.TEXTAREA_SMALL); glayout.addComponent(requirements, 2, 1, 3, 2); Label lodging = new Label("Lodging: "); lodging.setWidthUndefined(); glayout.addComponent(lodging, 0, 3); glayout.setComponentAlignment(lodging, Alignment.MIDDLE_CENTER); lodgingPax = new TextField("Pax: "); lodgingPax.setWidth("100%"); lodgingPax.setValue("0"); lodgingPax.addStyleName(ValoTheme.TEXTFIELD_SMALL); lodgingPax.addStyleName("align-right"); glayout.addComponent(lodgingPax, 1, 3); lodgingAmount = new TextField("Amount: "); lodgingAmount.setWidth("100%"); lodgingAmount.setValue("0.00"); lodgingAmount.addStyleName(ValoTheme.TEXTFIELD_SMALL); lodgingAmount.addStyleName("align-right"); lodgingAmount.setEnabled(false); lodgingAmount.setImmediate(true); glayout.addComponent(lodgingAmount, 3, 3); lodgingBudget = new TextField("Budget: "); lodgingBudget.setWidth("100%"); lodgingBudget.setValue("0.00"); lodgingBudget.addStyleName(ValoTheme.TEXTFIELD_SMALL); lodgingBudget.addStyleName("align-right"); lodgingBudget.addValueChangeListener((ValueChangeEvent event) -> { if (!CommonUtilities.checkInputIfInteger(lodgingPax.getValue().trim())) { Notification.show("Enter a numeric value for Pax", Notification.Type.ERROR_MESSAGE); return; } if (!CommonUtilities.checkInputIfDouble(lodgingBudget.getValue().trim())) { Notification.show("Enter a numeric value for Budget", Notification.Type.ERROR_MESSAGE); return; } lodgingAmount.setValue(String.valueOf(CommonUtilities.convertStringToInt(lodgingPax.getValue().trim()) * CommonUtilities.convertStringToDouble(lodgingBudget.getValue().trim()))); }); lodgingBudget.setImmediate(true); glayout.addComponent(lodgingBudget, 2, 3); Label meals = new Label("Meals: "); meals.setWidthUndefined(); glayout.addComponent(meals, 0, 4); glayout.setComponentAlignment(meals, Alignment.MIDDLE_CENTER); mealsPax = new TextField("Pax: "); mealsPax.setWidth("100%"); mealsPax.setValue("0"); mealsPax.addStyleName(ValoTheme.TEXTFIELD_SMALL); mealsPax.addStyleName("align-right"); glayout.addComponent(mealsPax, 1, 4); mealsAmount = new TextField("Amount: "); mealsAmount.setWidth("100%"); mealsAmount.setValue("0.00"); mealsAmount.addStyleName(ValoTheme.TEXTFIELD_SMALL); mealsAmount.addStyleName("align-right"); mealsAmount.setEnabled(false); mealsAmount.setImmediate(liquidated); glayout.addComponent(mealsAmount, 3, 4); mealsBudget = new TextField("Budget: "); mealsBudget.setWidth("100%"); mealsBudget.setValue("0.00"); mealsBudget.addStyleName(ValoTheme.TEXTFIELD_SMALL); mealsBudget.addStyleName("align-right"); mealsBudget.addValueChangeListener((ValueChangeEvent event) -> { if (!CommonUtilities.checkInputIfInteger(mealsPax.getValue().trim())) { Notification.show("Enter a numeric value for Pax", Notification.Type.ERROR_MESSAGE); return; } if (!CommonUtilities.checkInputIfDouble(mealsBudget.getValue().trim())) { Notification.show("Enter a numeric value for Budget", Notification.Type.ERROR_MESSAGE); return; } mealsAmount.setValue(String.valueOf(CommonUtilities.convertStringToInt(mealsPax.getValue().trim()) * CommonUtilities.convertStringToDouble(mealsBudget.getValue().trim()))); }); mealsAmount.setImmediate(true); glayout.addComponent(mealsBudget, 2, 4); others = new TextArea("Others: "); others.setWidth("100%"); others.setRows(3); others.addStyleName(ValoTheme.TEXTAREA_SMALL); glayout.addComponent(others, 0, 5, 2, 6); othersAmount = new TextField("Amount: "); othersAmount.setWidth("100%"); othersAmount.setValue("0.00"); othersAmount.addStyleName(ValoTheme.TEXTFIELD_SMALL); othersAmount.addStyleName("align-right"); glayout.addComponent(othersAmount, 3, 5); glayout.setComponentAlignment(othersAmount, Alignment.TOP_CENTER); Button rlButton = new Button(); rlButton.setCaption("SAVE"); rlButton.setWidth("100%"); rlButton.addStyleName(ValoTheme.BUTTON_PRIMARY); rlButton.addStyleName(ValoTheme.BUTTON_SMALL); rlButton.addClickListener(buttonClickListener); glayout.addComponent(rlButton, 3, 6); glayout.setComponentAlignment(rlButton, Alignment.TOP_CENTER); if (getRequestId() != 0) { LiquidationForm lf = rls.getRLById(getRequestId()); controlNo.setValue(String.valueOf(lf.getControlNo())); dateOfActivity.setValue(lf.getDateOfActivity()); area.setValue(lf.getAreaId()); activity.setValue(lf.getActivity()); requirements.setValue(lf.getRequirements()); venue.setValue(lf.getVenue()); others.setValue(lf.getOthersRemarks()); othersAmount.setValue(String.valueOf(lf.getOthersAmount())); lodgingAmount.setValue(String.valueOf(lf.getLodgingAmount())); mealsAmount.setValue(String.valueOf(lf.getMealsAmount())); if (getLiquidated() == true) { setCaption("LIQUIDATE FROM"); rlButton.setCaption("LIQUIDATE"); controlNo.setReadOnly(liquidated); dateOfActivity.setReadOnly(liquidated); area.setReadOnly(liquidated); activity.setReadOnly(liquidated); requirements.setReadOnly(liquidated); venue.setReadOnly(liquidated); } else { rlButton.setCaption("EDIT"); lodgingPax.setValue(String.valueOf(lf.getLodgingPax())); lodgingBudget.setValue(String.valueOf(lf.getLodgingBudget())); mealsPax.setValue(String.valueOf(lf.getMealsPax())); mealsBudget.setValue(String.valueOf(lf.getMealsBudget())); rlButton.setEnabled(rls.getRLById(getRequestId()).getLiquidated() == 0); } // delete.setVisible(true); } return glayout; }
From source file:com.save.employee.request.RLDataGridProperties.java
@Override public void gridRenrderersAndGenerator() { //TODO/*from ww w . j ava 2 s . c o m*/ removeColumn("id"); getDefaultHeaderRow().join("edit", "liquidate", "view", "del").setText(""); setFrozenColumnCount(1); getColumn("del").setRenderer(new FontIconRenderer(e -> { Object itemId = e.getItemId(); Item item = getContainerDataSource().getItem(itemId); int result = rls .getRLById(CommonUtilities.convertStringToInt(item.getItemProperty("id").getValue().toString())) .getLiquidated(); if (result == 1) { // Notification.show(label.getCaption(), Notification.Type.WARNING_MESSAGE); ErrorLoggedNotification.showWarningLoggedOnWindow( "Your are not allowed to delete a reguest that has already been liquidated!", this.getClass().getName()); return; } Window sub = deletConfirmationWindow( CommonUtilities.convertStringToInt(item.getItemProperty("id").getValue().toString()), itemId); if (sub.getParent() == null) { UI.getCurrent().addWindow(sub); } })); getColumn("liquidate").setRenderer(new FontIconRenderer(e -> { Object itemId = e.getItemId(); Item item = getContainerDataSource().getItem(itemId); int result = rls .getRLById(CommonUtilities.convertStringToInt(item.getItemProperty("id").getValue().toString())) .getLiquidated(); if (result == 1) { Notification.show("Request has already been Liquidated. Click View instead!", Notification.Type.WARNING_MESSAGE); return; } Window sub = new RequestFormWindow(getEmployeeId(), CommonUtilities.convertStringToInt(item.getItemProperty("id").getValue().toString()), true, this); if (sub.getParent() == null) { UI.getCurrent().addWindow(sub); } })); getColumn("view").setRenderer(new FontIconRenderer(e -> { Object itemId = e.getItemId(); Item item = getContainerDataSource().getItem(itemId); Window sub = new ViewRLWindow(getEmployeeId(), CommonUtilities.convertStringToInt(item.getItemProperty("id").getValue().toString())); if (sub.getParent() == null) { UI.getCurrent().addWindow(sub); } })); getColumn("edit").setRenderer(new FontIconRenderer(e -> { Object itemId = e.getItemId(); Item item = getContainerDataSource().getItem(itemId); int result = rls .getRLById(CommonUtilities.convertStringToInt(item.getItemProperty("id").getValue().toString())) .getLiquidated(); if (result == 1) { Notification.show("Request has already been Liquidated. Click View instead!", Notification.Type.WARNING_MESSAGE); return; } Window sub = new RequestFormWindow(getEmployeeId(), CommonUtilities.convertStringToInt(item.getItemProperty("id").getValue().toString()), false, this); if (sub.getParent() == null) { UI.getCurrent().addWindow(sub); } })); recalculateColumnWidths(); }
From source file:com.save.reports.maintenance.MaintenanceReportUI.java
private Window filterReport() { Window sub = new Window("FILTER REPORT"); sub.setWidth("400px"); sub.setModal(true);/*from w w w .j a va2 s . c o m*/ sub.center(); FormLayout f = new FormLayout(); f.setWidth("100%"); f.setMargin(true); f.setSpacing(true); CheckBox areaCheckBox = new CheckBox("Filter by Area"); f.addComponent(areaCheckBox); CheckBox employeeCheckBox = new CheckBox("Filter by Employee"); f.addComponent(employeeCheckBox); CheckBox amountCheckBox = new CheckBox("Filter by Amount"); f.addComponent(amountCheckBox); CheckBox dateCheckBox = new CheckBox("Filter by Date"); f.addComponent(dateCheckBox); ComboBox areaComboBox = CommonComboBox.areas(); ComboBox employeeComboBox = CommonComboBox.getAllClients(); areaComboBox.setEnabled(false); f.addComponent(areaComboBox); areaCheckBox.addValueChangeListener((Property.ValueChangeEvent event) -> { areaComboBox.setEnabled((boolean) event.getProperty().getValue()); employeeComboBox.setEnabled(!(boolean) event.getProperty().getValue()); employeeCheckBox.setValue(!(boolean) event.getProperty().getValue()); isAreaSelect = (boolean) event.getProperty().getValue(); isEmployeeSelect = !(boolean) event.getProperty().getValue(); }); employeeComboBox.setEnabled(false); f.addComponent(employeeComboBox); employeeCheckBox.addValueChangeListener((Property.ValueChangeEvent e) -> { employeeComboBox.setEnabled((boolean) e.getProperty().getValue()); areaComboBox.setEnabled(!(boolean) e.getProperty().getValue()); areaCheckBox.setValue(!(boolean) e.getProperty().getValue()); isAreaSelect = !(boolean) e.getProperty().getValue(); isEmployeeSelect = (boolean) e.getProperty().getValue(); }); TextField amountField = new CommonTextField("Amount: "); amountField.addStyleName("align-right"); amountField.setEnabled(false); f.addComponent(amountField); amountCheckBox.addValueChangeListener((Property.ValueChangeEvent e) -> { amountField.setEnabled((boolean) e.getProperty().getValue()); isAmountSelect = (boolean) e.getProperty().getValue(); }); HorizontalLayout h = new HorizontalLayout(); h.setCaption("Date: "); h.setWidth("100%"); h.setSpacing(true); DateField from = new DateField(); from.setWidth("100%"); from.setEnabled(false); h.addComponent(from); DateField to = new DateField(); to.setWidth("100%"); to.setEnabled(false); h.addComponent(to); dateCheckBox.addValueChangeListener((Property.ValueChangeEvent e) -> { from.setEnabled((boolean) e.getProperty().getValue()); to.setEnabled((boolean) e.getProperty().getValue()); isDateSelect = (boolean) e.getProperty().getValue(); }); f.addComponent(h); Button generate = new CommonButton("Generate Report"); generate.addClickListener((Button.ClickEvent e) -> { if (!isEmployeeSelect && !isAmountSelect && !isDateSelect) { mrDataGrid.setContainerDataSource(new MaintenanceDataContainer()); mrDataGrid.setFrozenColumnCount(2); } if (isAreaSelect && !isAmountSelect && !isDateSelect) { if (areaComboBox.getValue() == null) { Notification.show("Select an Area!", Notification.Type.ERROR_MESSAGE); return; } mrDataGrid.setContainerDataSource( new MaintenanceDataContainer(areaComboBox.getItemCaption(areaComboBox.getValue()))); mrDataGrid.setFrozenColumnCount(2); } if (isEmployeeSelect && !isAmountSelect && !isDateSelect) { if (employeeComboBox.getValue() == null) { Notification.show("Select a Client!", Notification.Type.ERROR_MESSAGE); return; } mrDataGrid.setContainerDataSource(new MaintenanceDataContainer((int) employeeComboBox.getValue())); mrDataGrid.setFrozenColumnCount(2); } if (!isEmployeeSelect && isAmountSelect && !isDateSelect) { if (amountField.getValue() == null || amountField.getValue().trim().isEmpty()) { Notification.show("Enter Amount!", Notification.Type.ERROR_MESSAGE); return; } else { if (!CommonUtilities.checkInputIfDouble(amountField.getValue().trim())) { Notification.show("Enter numeric format for Amount!", Notification.Type.ERROR_MESSAGE); return; } } mrDataGrid.setContainerDataSource(new MaintenanceDataContainer( CommonUtilities.convertStringToDouble(amountField.getValue().trim()))); mrDataGrid.setFrozenColumnCount(2); } if (!isEmployeeSelect && !isAmountSelect && isDateSelect) { if (from.getValue() == null) { Notification.show("Select first Date!", Notification.Type.ERROR_MESSAGE); return; } if (to.getValue() == null) { Notification.show("Select 2nd Date!", Notification.Type.ERROR_MESSAGE); return; } mrDataGrid.setContainerDataSource(new MaintenanceDataContainer(from.getValue(), to.getValue())); mrDataGrid.setFrozenColumnCount(2); } if (isAreaSelect && isAmountSelect && !isDateSelect) { if (areaComboBox.getValue() == null) { Notification.show("Select an Area!", Notification.Type.ERROR_MESSAGE); return; } if (amountField.getValue() == null || amountField.getValue().trim().isEmpty()) { Notification.show("Enter Amount!", Notification.Type.ERROR_MESSAGE); return; } else { if (!CommonUtilities.checkInputIfDouble(amountField.getValue().trim())) { Notification.show("Enter numeric format for Amount!", Notification.Type.ERROR_MESSAGE); return; } } mrDataGrid.setContainerDataSource( new MaintenanceDataContainer(areaComboBox.getItemCaption(areaComboBox.getValue()), CommonUtilities.convertStringToDouble(amountField.getValue().trim()))); mrDataGrid.setFrozenColumnCount(2); } if (isEmployeeSelect && isAmountSelect && !isDateSelect) { if (employeeComboBox.getValue() == null) { Notification.show("Select a Client!", Notification.Type.ERROR_MESSAGE); return; } if (amountField.getValue() == null || amountField.getValue().trim().isEmpty()) { Notification.show("Enter Amount!", Notification.Type.ERROR_MESSAGE); return; } else { if (!CommonUtilities.checkInputIfDouble(amountField.getValue().trim())) { Notification.show("Enter numeric format for Amount!", Notification.Type.ERROR_MESSAGE); return; } } mrDataGrid.setContainerDataSource(new MaintenanceDataContainer((int) employeeComboBox.getValue(), CommonUtilities.convertStringToDouble(amountField.getValue().trim()))); mrDataGrid.setFrozenColumnCount(2); } if (isAreaSelect && !isAmountSelect && isDateSelect) { if (areaComboBox.getValue() == null) { Notification.show("Select an Area!", Notification.Type.ERROR_MESSAGE); return; } if (from.getValue() == null) { Notification.show("Select first Date!", Notification.Type.ERROR_MESSAGE); return; } if (to.getValue() == null) { Notification.show("Select 2nd Date!", Notification.Type.ERROR_MESSAGE); return; } mrDataGrid.setContainerDataSource(new MaintenanceDataContainer( areaComboBox.getItemCaption(areaComboBox.getValue()), from.getValue(), to.getValue())); mrDataGrid.setFrozenColumnCount(2); } if (isEmployeeSelect && !isAmountSelect && isDateSelect) { if (employeeComboBox.getValue() == null) { Notification.show("Select a Client!", Notification.Type.ERROR_MESSAGE); return; } if (from.getValue() == null) { Notification.show("Select first Date!", Notification.Type.ERROR_MESSAGE); return; } if (to.getValue() == null) { Notification.show("Select 2nd Date!", Notification.Type.ERROR_MESSAGE); return; } mrDataGrid.setContainerDataSource(new MaintenanceDataContainer((int) employeeComboBox.getValue(), from.getValue(), to.getValue())); mrDataGrid.setFrozenColumnCount(2); } if (!isEmployeeSelect && isAmountSelect && isDateSelect) { if (amountField.getValue() == null || amountField.getValue().trim().isEmpty()) { Notification.show("Enter Amount!", Notification.Type.ERROR_MESSAGE); return; } else { if (!CommonUtilities.checkInputIfDouble(amountField.getValue().trim())) { Notification.show("Enter numeric format for Amount!", Notification.Type.ERROR_MESSAGE); return; } } if (from.getValue() == null) { Notification.show("Select first Date!", Notification.Type.ERROR_MESSAGE); return; } if (to.getValue() == null) { Notification.show("Select 2nd Date!", Notification.Type.ERROR_MESSAGE); return; } mrDataGrid.setContainerDataSource(new MaintenanceDataContainer( CommonUtilities.convertStringToDouble(amountField.getValue().trim()), from.getValue(), to.getValue())); mrDataGrid.setFrozenColumnCount(2); } if (isAreaSelect && isAmountSelect && isDateSelect) { if (areaComboBox.getValue() == null) { Notification.show("Select an Area!", Notification.Type.ERROR_MESSAGE); return; } if (amountField.getValue() == null || amountField.getValue().trim().isEmpty()) { Notification.show("Enter Amount!", Notification.Type.ERROR_MESSAGE); return; } else { if (!CommonUtilities.checkInputIfDouble(amountField.getValue().trim())) { Notification.show("Enter numeric format for Amount!", Notification.Type.ERROR_MESSAGE); return; } } if (from.getValue() == null) { Notification.show("Select first Date!", Notification.Type.ERROR_MESSAGE); return; } if (to.getValue() == null) { Notification.show("Select 2nd Date!", Notification.Type.ERROR_MESSAGE); return; } mrDataGrid.setContainerDataSource( new MaintenanceDataContainer(employeeComboBox.getItemCaption(employeeComboBox.getValue()), CommonUtilities.convertStringToDouble(amountField.getValue().trim()), from.getValue(), to.getValue())); mrDataGrid.setFrozenColumnCount(2); } if (isEmployeeSelect && isAmountSelect && isDateSelect) { if (employeeComboBox.getValue() == null) { Notification.show("Select a Client!", Notification.Type.ERROR_MESSAGE); return; } if (amountField.getValue() == null || amountField.getValue().trim().isEmpty()) { Notification.show("Enter Amount!", Notification.Type.ERROR_MESSAGE); return; } else { if (!CommonUtilities.checkInputIfDouble(amountField.getValue().trim())) { Notification.show("Enter numeric format for Amount!", Notification.Type.ERROR_MESSAGE); return; } } if (from.getValue() == null) { Notification.show("Select first Date!", Notification.Type.ERROR_MESSAGE); return; } if (to.getValue() == null) { Notification.show("Select 2nd Date!", Notification.Type.ERROR_MESSAGE); return; } mrDataGrid.setContainerDataSource(new MaintenanceDataContainer((int) employeeComboBox.getValue(), CommonUtilities.convertStringToDouble(amountField.getValue().trim()), from.getValue(), to.getValue())); mrDataGrid.setFrozenColumnCount(2); } sub.close(); }); f.addComponent(generate); sub.setContent(f); sub.getContent().setHeightUndefined(); return sub; }
From source file:com.save.reports.promodeals.PromoDealReportUI.java
private Window filterReport() { Window sub = new Window("FILTER REPORT"); sub.setWidth("400px"); sub.setModal(true);/*from w ww.j av a2 s . co m*/ sub.center(); FormLayout f = new FormLayout(); f.setWidth("100%"); f.setMargin(true); f.setSpacing(true); CheckBox areaCheckBox = new CheckBox("Filter by Area"); f.addComponent(areaCheckBox); CheckBox clientCheckBox = new CheckBox("Filter by Client"); f.addComponent(clientCheckBox); CheckBox amountCheckBox = new CheckBox("Filter by Amount"); f.addComponent(amountCheckBox); CheckBox dateCheckBox = new CheckBox("Filter by Date"); f.addComponent(dateCheckBox); ComboBox areaComboBox = CommonComboBox.areas(); ComboBox clientComboBox = CommonComboBox.getAllClients(); areaComboBox.setEnabled(false); f.addComponent(areaComboBox); areaCheckBox.addValueChangeListener((Property.ValueChangeEvent event) -> { areaComboBox.setEnabled((boolean) event.getProperty().getValue()); clientComboBox.setEnabled(!(boolean) event.getProperty().getValue()); clientCheckBox.setValue(!(boolean) event.getProperty().getValue()); isAreaSelect = (boolean) event.getProperty().getValue(); isClientSelect = !(boolean) event.getProperty().getValue(); }); clientComboBox.setEnabled(false); f.addComponent(clientComboBox); clientCheckBox.addValueChangeListener((Property.ValueChangeEvent e) -> { clientComboBox.setEnabled((boolean) e.getProperty().getValue()); areaComboBox.setEnabled(!(boolean) e.getProperty().getValue()); areaCheckBox.setValue(!(boolean) e.getProperty().getValue()); isClientSelect = (boolean) e.getProperty().getValue(); isAreaSelect = !(boolean) e.getProperty().getValue(); }); TextField amountField = new CommonTextField("Amount: "); amountField.addStyleName("align-right"); amountField.setEnabled(false); f.addComponent(amountField); amountCheckBox.addValueChangeListener((Property.ValueChangeEvent e) -> { amountField.setEnabled((boolean) e.getProperty().getValue()); isAmountSelect = (boolean) e.getProperty().getValue(); }); HorizontalLayout h = new HorizontalLayout(); h.setCaption("Date: "); h.setWidth("100%"); h.setSpacing(true); DateField from = new DateField(); from.setWidth("100%"); from.setEnabled(false); h.addComponent(from); DateField to = new DateField(); to.setWidth("100%"); to.setEnabled(false); h.addComponent(to); dateCheckBox.addValueChangeListener((Property.ValueChangeEvent e) -> { from.setEnabled((boolean) e.getProperty().getValue()); to.setEnabled((boolean) e.getProperty().getValue()); isDateSelect = (boolean) e.getProperty().getValue(); }); f.addComponent(h); Button generate = new CommonButton("Generate Report"); generate.addClickListener((Button.ClickEvent e) -> { if (!isClientSelect && !isAmountSelect && !isDateSelect) { promoDealGrid.setContainerDataSource(new PromoDealDataContainer()); promoDealGrid.setFrozenColumnCount(2); } if (isAreaSelect && !isAmountSelect && !isDateSelect) { if (areaComboBox.getValue() == null) { Notification.show("Select a Client!", Notification.Type.ERROR_MESSAGE); return; } promoDealGrid.setContainerDataSource( new PromoDealDataContainer(areaComboBox.getItemCaption(areaComboBox.getValue()))); promoDealGrid.setFrozenColumnCount(2); } if (isClientSelect && !isAmountSelect && !isDateSelect) { if (clientComboBox.getValue() == null) { Notification.show("Select a Client!", Notification.Type.ERROR_MESSAGE); return; } promoDealGrid.setContainerDataSource(new PromoDealDataContainer((int) clientComboBox.getValue())); promoDealGrid.setFrozenColumnCount(2); } if (!isClientSelect && isAmountSelect && !isDateSelect) { if (amountField.getValue() == null || amountField.getValue().trim().isEmpty()) { Notification.show("Enter Amount!", Notification.Type.ERROR_MESSAGE); return; } else { if (!CommonUtilities.checkInputIfDouble(amountField.getValue().trim())) { Notification.show("Enter numeric format for Amount!", Notification.Type.ERROR_MESSAGE); return; } } promoDealGrid.setContainerDataSource(new PromoDealDataContainer( CommonUtilities.convertStringToDouble(amountField.getValue().trim()))); promoDealGrid.setFrozenColumnCount(2); } if (!isClientSelect && !isAmountSelect && isDateSelect) { if (from.getValue() == null) { Notification.show("Select first Date!", Notification.Type.ERROR_MESSAGE); return; } if (to.getValue() == null) { Notification.show("Select 2nd Date!", Notification.Type.ERROR_MESSAGE); return; } promoDealGrid.setContainerDataSource(new PromoDealDataContainer(from.getValue(), to.getValue())); promoDealGrid.setFrozenColumnCount(2); } if (isAreaSelect && isAmountSelect && !isDateSelect) { if (areaComboBox.getValue() == null) { Notification.show("Select an Area!", Notification.Type.ERROR_MESSAGE); return; } if (amountField.getValue() == null || amountField.getValue().trim().isEmpty()) { Notification.show("Enter Amount!", Notification.Type.ERROR_MESSAGE); return; } else { if (!CommonUtilities.checkInputIfDouble(amountField.getValue().trim())) { Notification.show("Enter numeric format for Amount!", Notification.Type.ERROR_MESSAGE); return; } } promoDealGrid.setContainerDataSource( new PromoDealDataContainer(areaComboBox.getItemCaption(areaComboBox.getValue()), CommonUtilities.convertStringToDouble(amountField.getValue().trim()))); promoDealGrid.setFrozenColumnCount(2); } if (isClientSelect && isAmountSelect && !isDateSelect) { if (clientComboBox.getValue() == null) { Notification.show("Select a Client!", Notification.Type.ERROR_MESSAGE); return; } if (amountField.getValue() == null || amountField.getValue().trim().isEmpty()) { Notification.show("Enter Amount!", Notification.Type.ERROR_MESSAGE); return; } else { if (!CommonUtilities.checkInputIfDouble(amountField.getValue().trim())) { Notification.show("Enter numeric format for Amount!", Notification.Type.ERROR_MESSAGE); return; } } promoDealGrid.setContainerDataSource(new PromoDealDataContainer((int) clientComboBox.getValue(), CommonUtilities.convertStringToDouble(amountField.getValue().trim()))); promoDealGrid.setFrozenColumnCount(2); } if (isAreaSelect && !isAmountSelect && isDateSelect) { if (areaComboBox.getValue() == null) { Notification.show("Select an Area!", Notification.Type.ERROR_MESSAGE); return; } if (from.getValue() == null) { Notification.show("Select first Date!", Notification.Type.ERROR_MESSAGE); return; } if (to.getValue() == null) { Notification.show("Select 2nd Date!", Notification.Type.ERROR_MESSAGE); return; } promoDealGrid.setContainerDataSource(new PromoDealDataContainer( areaComboBox.getItemCaption(areaComboBox.getValue()), from.getValue(), to.getValue())); promoDealGrid.setFrozenColumnCount(2); } if (isClientSelect && !isAmountSelect && isDateSelect) { if (clientComboBox.getValue() == null) { Notification.show("Select a Client!", Notification.Type.ERROR_MESSAGE); return; } if (from.getValue() == null) { Notification.show("Select first Date!", Notification.Type.ERROR_MESSAGE); return; } if (to.getValue() == null) { Notification.show("Select 2nd Date!", Notification.Type.ERROR_MESSAGE); return; } promoDealGrid.setContainerDataSource(new PromoDealDataContainer((int) clientComboBox.getValue(), from.getValue(), to.getValue())); promoDealGrid.setFrozenColumnCount(2); } if (!isClientSelect && isAmountSelect && isDateSelect) { if (amountField.getValue() == null || amountField.getValue().trim().isEmpty()) { Notification.show("Enter Amount!", Notification.Type.ERROR_MESSAGE); return; } else { if (!CommonUtilities.checkInputIfDouble(amountField.getValue().trim())) { Notification.show("Enter numeric format for Amount!", Notification.Type.ERROR_MESSAGE); return; } } if (from.getValue() == null) { Notification.show("Select first Date!", Notification.Type.ERROR_MESSAGE); return; } if (to.getValue() == null) { Notification.show("Select 2nd Date!", Notification.Type.ERROR_MESSAGE); return; } promoDealGrid.setContainerDataSource(new PromoDealDataContainer( CommonUtilities.convertStringToDouble(amountField.getValue().trim()), from.getValue(), to.getValue())); promoDealGrid.setFrozenColumnCount(2); } if (isAreaSelect && isAmountSelect && isDateSelect) { if (areaComboBox.getValue() == null) { Notification.show("Select an Area!", Notification.Type.ERROR_MESSAGE); return; } if (amountField.getValue() == null || amountField.getValue().trim().isEmpty()) { Notification.show("Enter Amount!", Notification.Type.ERROR_MESSAGE); return; } else { if (!CommonUtilities.checkInputIfDouble(amountField.getValue().trim())) { Notification.show("Enter numeric format for Amount!", Notification.Type.ERROR_MESSAGE); return; } } if (from.getValue() == null) { Notification.show("Select first Date!", Notification.Type.ERROR_MESSAGE); return; } if (to.getValue() == null) { Notification.show("Select 2nd Date!", Notification.Type.ERROR_MESSAGE); return; } promoDealGrid.setContainerDataSource( new PromoDealDataContainer(areaComboBox.getItemCaption(areaComboBox.getValue()), CommonUtilities.convertStringToDouble(amountField.getValue().trim()), from.getValue(), to.getValue())); promoDealGrid.setFrozenColumnCount(2); } if (isClientSelect && isAmountSelect && isDateSelect) { if (clientComboBox.getValue() == null) { Notification.show("Select a Client!", Notification.Type.ERROR_MESSAGE); return; } if (amountField.getValue() == null || amountField.getValue().trim().isEmpty()) { Notification.show("Enter Amount!", Notification.Type.ERROR_MESSAGE); return; } else { if (!CommonUtilities.checkInputIfDouble(amountField.getValue().trim())) { Notification.show("Enter numeric format for Amount!", Notification.Type.ERROR_MESSAGE); return; } } if (from.getValue() == null) { Notification.show("Select first Date!", Notification.Type.ERROR_MESSAGE); return; } if (to.getValue() == null) { Notification.show("Select 2nd Date!", Notification.Type.ERROR_MESSAGE); return; } promoDealGrid.setContainerDataSource(new PromoDealDataContainer((int) clientComboBox.getValue(), CommonUtilities.convertStringToDouble(amountField.getValue().trim()), from.getValue(), to.getValue())); promoDealGrid.setFrozenColumnCount(2); } sub.close(); }); f.addComponent(generate); sub.setContent(f); sub.getContent().setHeightUndefined(); return sub; }
From source file:com.save.reports.reimbursement.ReimbursementReportUI.java
private Window filterReport() { Window sub = new Window("FILTER REPORT"); sub.setWidth("400px"); sub.setModal(true);/*www . ja v a 2s . c o m*/ sub.center(); FormLayout f = new FormLayout(); f.setWidth("100%"); f.setMargin(true); f.setSpacing(true); CheckBox employeeCheckBox = new CheckBox("Filter by Employee"); f.addComponent(employeeCheckBox); CheckBox amountCheckBox = new CheckBox("Filter by Amount"); f.addComponent(amountCheckBox); CheckBox dateCheckBox = new CheckBox("Filter by Date"); f.addComponent(dateCheckBox); ComboBox employeeComboBox = CommonComboBox.getAllEmpployees(null); employeeComboBox.setEnabled(false); f.addComponent(employeeComboBox); employeeCheckBox.addValueChangeListener((Property.ValueChangeEvent e) -> { employeeComboBox.setEnabled((boolean) e.getProperty().getValue()); isEmployee = (boolean) e.getProperty().getValue(); }); TextField amountField = new CommonTextField("Amount: "); amountField.addStyleName("align-right"); amountField.setEnabled(false); f.addComponent(amountField); amountCheckBox.addValueChangeListener((Property.ValueChangeEvent e) -> { amountField.setEnabled((boolean) e.getProperty().getValue()); isAmount = (boolean) e.getProperty().getValue(); }); HorizontalLayout h = new HorizontalLayout(); h.setCaption("Date: "); h.setWidth("100%"); h.setSpacing(true); DateField from = new DateField(); from.setWidth("100%"); from.setEnabled(false); h.addComponent(from); DateField to = new DateField(); to.setWidth("100%"); to.setEnabled(false); h.addComponent(to); dateCheckBox.addValueChangeListener((Property.ValueChangeEvent e) -> { from.setEnabled((boolean) e.getProperty().getValue()); to.setEnabled((boolean) e.getProperty().getValue()); isDate = (boolean) e.getProperty().getValue(); }); f.addComponent(h); Button generate = new CommonButton("Generate Report"); generate.addClickListener((Button.ClickEvent e) -> { if (!isEmployee && !isAmount && !isDate) { mrDataGrid.setContainerDataSource(new ReimbursementDataContainer()); mrDataGrid.setFrozenColumnCount(2); } if (isEmployee && !isAmount && !isDate) { if (employeeComboBox.getValue() == null) { Notification.show("Select a Client!", Notification.Type.ERROR_MESSAGE); return; } mrDataGrid.setContainerDataSource( new ReimbursementDataContainer(employeeComboBox.getValue().toString())); mrDataGrid.setFrozenColumnCount(2); } if (!isEmployee && isAmount && !isDate) { if (amountField.getValue() == null || amountField.getValue().trim().isEmpty()) { Notification.show("Enter Amount!", Notification.Type.ERROR_MESSAGE); return; } else { if (!CommonUtilities.checkInputIfDouble(amountField.getValue().trim())) { Notification.show("Enter numeric format for Amount!", Notification.Type.ERROR_MESSAGE); return; } } mrDataGrid.setContainerDataSource(new ReimbursementDataContainer( CommonUtilities.convertStringToDouble(amountField.getValue().trim()))); mrDataGrid.setFrozenColumnCount(2); } if (!isEmployee && !isAmount && isDate) { if (from.getValue() == null) { Notification.show("Select first Date!", Notification.Type.ERROR_MESSAGE); return; } if (to.getValue() == null) { Notification.show("Select 2nd Date!", Notification.Type.ERROR_MESSAGE); return; } mrDataGrid.setContainerDataSource(new ReimbursementDataContainer(from.getValue(), to.getValue())); mrDataGrid.setFrozenColumnCount(2); } if (isEmployee && isAmount && !isDate) { if (employeeComboBox.getValue() == null) { Notification.show("Select a Client!", Notification.Type.ERROR_MESSAGE); return; } if (amountField.getValue() == null || amountField.getValue().trim().isEmpty()) { Notification.show("Enter Amount!", Notification.Type.ERROR_MESSAGE); return; } else { if (!CommonUtilities.checkInputIfDouble(amountField.getValue().trim())) { Notification.show("Enter numeric format for Amount!", Notification.Type.ERROR_MESSAGE); return; } } mrDataGrid.setContainerDataSource( new ReimbursementDataContainer(employeeComboBox.getValue().toString(), CommonUtilities.convertStringToDouble(amountField.getValue().trim()))); mrDataGrid.setFrozenColumnCount(2); } if (isEmployee && !isAmount && isDate) { if (employeeComboBox.getValue() == null) { Notification.show("Select a Client!", Notification.Type.ERROR_MESSAGE); return; } if (from.getValue() == null) { Notification.show("Select first Date!", Notification.Type.ERROR_MESSAGE); return; } if (to.getValue() == null) { Notification.show("Select 2nd Date!", Notification.Type.ERROR_MESSAGE); return; } mrDataGrid.setContainerDataSource(new ReimbursementDataContainer( employeeComboBox.getValue().toString(), from.getValue(), to.getValue())); mrDataGrid.setFrozenColumnCount(2); } if (!isEmployee && isAmount && isDate) { if (amountField.getValue() == null || amountField.getValue().trim().isEmpty()) { Notification.show("Enter Amount!", Notification.Type.ERROR_MESSAGE); return; } else { if (!CommonUtilities.checkInputIfDouble(amountField.getValue().trim())) { Notification.show("Enter numeric format for Amount!", Notification.Type.ERROR_MESSAGE); return; } } if (from.getValue() == null) { Notification.show("Select first Date!", Notification.Type.ERROR_MESSAGE); return; } if (to.getValue() == null) { Notification.show("Select 2nd Date!", Notification.Type.ERROR_MESSAGE); return; } mrDataGrid.setContainerDataSource(new ReimbursementDataContainer( CommonUtilities.convertStringToDouble(amountField.getValue().trim()), from.getValue(), to.getValue())); mrDataGrid.setFrozenColumnCount(2); } if (isEmployee && isAmount && isDate) { if (employeeComboBox.getValue() == null) { Notification.show("Select a Client!", Notification.Type.ERROR_MESSAGE); return; } if (amountField.getValue() == null || amountField.getValue().trim().isEmpty()) { Notification.show("Enter Amount!", Notification.Type.ERROR_MESSAGE); return; } else { if (!CommonUtilities.checkInputIfDouble(amountField.getValue().trim())) { Notification.show("Enter numeric format for Amount!", Notification.Type.ERROR_MESSAGE); return; } } if (from.getValue() == null) { Notification.show("Select first Date!", Notification.Type.ERROR_MESSAGE); return; } if (to.getValue() == null) { Notification.show("Select 2nd Date!", Notification.Type.ERROR_MESSAGE); return; } mrDataGrid.setContainerDataSource( new ReimbursementDataContainer(employeeComboBox.getValue().toString(), CommonUtilities.convertStringToDouble(amountField.getValue().trim()), from.getValue(), to.getValue())); mrDataGrid.setFrozenColumnCount(2); } sub.close(); }); f.addComponent(generate); sub.setContent(f); sub.getContent().setHeightUndefined(); return sub; }
From source file:com.save.serviceprovider.ClientServiceImpl.java
@Override public boolean insertNewClient(Client c) { Connection conn = DBConnection.connect(); PreparedStatement pstmt = null; boolean result = false; if (c.getAsDistributor() == 1) { c.setClientType("distributor"); }// w w w . j a v a 2s . co m try { pstmt = conn.prepareStatement( "INSERT INTO clients " + "SET ClientNAme = ?, " + "CityID = ?, " + "Street = ?, " + "Landline = ?, " + "Mobile = ?, " + "AsDistributor = ?, " + "ClientType = ? "); pstmt.setString(1, c.getClientName()); pstmt.setInt(2, c.getCityId()); pstmt.setString(3, c.getStreet()); pstmt.setString(4, c.getLandline()); pstmt.setString(5, c.getMobile()); pstmt.setInt(6, c.getAsDistributor()); pstmt.setString(7, c.getClientType()); pstmt.executeUpdate(); result = true; Notification.show("Added New Client", Notification.Type.TRAY_NOTIFICATION); } catch (SQLException ex) { ErrorLoggedNotification.showErrorLoggedOnWindow(ex.toString(), this.getClass().getName()); Logger.getLogger(this.getClass().getName()).log(Level.SEVERE, null, ex); } finally { try { if (conn != null || !conn.isClosed()) { pstmt.close(); conn.close(); } } catch (SQLException ex) { ErrorLoggedNotification.showErrorLoggedOnWindow(ex.toString(), this.getClass().getName()); Logger.getLogger(this.getClass().getName()).log(Level.SEVERE, null, ex); } } return result; }
From source file:com.save.serviceprovider.ClientServiceImpl.java
@Override public boolean editClient(Client c) { Connection conn = DBConnection.connect(); PreparedStatement pstmt = null; boolean result = false; if (c.getAsDistributor() == 1) { c.setClientType("distributor"); }/*w w w. jav a2 s .c o m*/ try { pstmt = conn.prepareStatement("UPDATE clients SET " + "ClientName = ?, " + "CityID = ?, " + "Street = ?, " + "Landline = ?, " + "Mobile = ?, " + "AsDistributor = ?, " + "ClientType = ? " + "WHERE ClientID = ? " + "AND Status = 0 "); pstmt.setString(1, c.getClientName()); pstmt.setInt(2, c.getCityId()); pstmt.setString(3, c.getStreet()); pstmt.setString(4, c.getLandline()); pstmt.setString(5, c.getMobile()); pstmt.setInt(6, c.getAsDistributor()); pstmt.setString(7, c.getClientType()); pstmt.setInt(8, c.getClientId()); pstmt.executeUpdate(); result = true; Notification.show("Update Client Info", Notification.Type.TRAY_NOTIFICATION); } catch (SQLException ex) { ErrorLoggedNotification.showErrorLoggedOnWindow(ex.toString(), this.getClass().getName()); Logger.getLogger(this.getClass().getName()).log(Level.SEVERE, null, ex); } finally { try { if (conn != null || !conn.isClosed()) { pstmt.close(); conn.close(); } } catch (SQLException ex) { ErrorLoggedNotification.showErrorLoggedOnWindow(ex.toString(), this.getClass().getName()); Logger.getLogger(this.getClass().getName()).log(Level.SEVERE, null, ex); } } return result; }