List of usage examples for com.vaadin.ui FormLayout setMargin
@Override public void setMargin(boolean enabled)
From source file:com.save.employee.request.ViewRLWindow.java
FormLayout buildFormLayout() { FormLayout f = new FormLayout(); f.setWidth("100%"); f.setMargin(true); LiquidationForm lf = rls.getRLById(getRequestId()); controlNo = new TextField("Control No."); controlNo.setWidth("100%"); controlNo.addStyleName(ValoTheme.TEXTFIELD_SMALL); controlNo.setValue(String.valueOf(lf.getControlNo())); controlNo.setEnabled(false);// ww w . j a va2s . co m f.addComponent(controlNo); dateOfActivity = new DateField("Date of Activity: "); dateOfActivity.setWidth("100%"); dateOfActivity.addStyleName(ValoTheme.DATEFIELD_SMALL); dateOfActivity.setValue(lf.getDateOfActivity()); dateOfActivity.setEnabled(false); f.addComponent(dateOfActivity); area = CommonComboBox.areas(); area.setWidth("100%"); area.setValue(lf.getAreaId()); area.setEnabled(false); f.addComponent(area); activity = new TextField("Activity: "); activity.setWidth("100%"); activity.addStyleName(ValoTheme.TEXTFIELD_SMALL); activity.setValue(lf.getActivity()); activity.setEnabled(false); f.addComponent(activity); venue = new TextField("Venue: "); venue.setWidth("100%"); venue.addStyleName(ValoTheme.TEXTFIELD_SMALL); venue.setValue(lf.getVenue()); venue.setEnabled(false); f.addComponent(venue); requirements = new TextArea("Requirements: "); requirements.setWidth("100%"); requirements.addStyleName(ValoTheme.TEXTAREA_SMALL); requirements.setValue(lf.getRequirements()); requirements.setEnabled(false); f.addComponent(requirements); HorizontalLayout h1 = new HorizontalLayout(); h1.setWidth("100%"); h1.setCaption("Request Lodging"); h1.addStyleName("light"); // h1.setReadOnly(true); requestLodgingPax = new TextField(); requestLodgingPax.setWidth("100%"); requestLodgingPax.addStyleName(ValoTheme.TEXTFIELD_SMALL); requestLodgingPax.addStyleName("align-right"); requestLodgingPax.setValue("Pax: " + String.valueOf(lf.getLodgingPax())); requestLodgingPax.setEnabled(false); h1.addComponent(requestLodgingPax); requestLodgingBudget = new TextField(); requestLodgingBudget.setWidth("100%"); requestLodgingBudget.addStyleName(ValoTheme.TEXTFIELD_SMALL); requestLodgingBudget.addStyleName("align-right"); requestLodgingBudget.setValue("Budget: " + String.valueOf(lf.getLodgingBudget())); requestLodgingBudget.setEnabled(false); h1.addComponent(requestLodgingBudget); requestLodgingAmount = new TextField(); requestLodgingAmount.setWidth("100%"); requestLodgingAmount.addStyleName(ValoTheme.TEXTFIELD_SMALL); requestLodgingAmount.addStyleName("align-right"); requestLodgingAmount.setValue("Amount: " + String.valueOf(lf.getLodgingAmount())); requestLodgingAmount.setEnabled(false); h1.addComponent(requestLodgingAmount); f.addComponent(h1); f.setComponentAlignment(h1, Alignment.MIDDLE_LEFT); HorizontalLayout h2 = new HorizontalLayout(); h2.setWidth("100%"); h2.setCaption("Request Meals"); // h2.setReadOnly(true); requestMealsPax = new TextField(); requestMealsPax.setWidth("100%"); requestMealsPax.addStyleName(ValoTheme.TEXTFIELD_SMALL); requestMealsPax.addStyleName("align-right"); requestMealsPax.setValue("Pax: " + String.valueOf(lf.getMealsPax())); requestMealsPax.setEnabled(false); h2.addComponent(requestMealsPax); requestMealsBudget = new TextField(); requestMealsBudget.setWidth("100%"); requestMealsBudget.addStyleName(ValoTheme.TEXTFIELD_SMALL); requestMealsBudget.addStyleName("align-right"); requestMealsBudget.setValue("Budget: " + String.valueOf(lf.getMealsBudget())); requestMealsBudget.setEnabled(false); h2.addComponent(requestMealsBudget); requestMealsAmount = new TextField(); requestMealsAmount.setWidth("100%"); requestMealsAmount.addStyleName(ValoTheme.TEXTFIELD_SMALL); requestMealsAmount.addStyleName("align-right"); requestMealsAmount.setValue("Amount: " + String.valueOf(lf.getMealsAmount())); requestMealsAmount.setEnabled(false); h2.addComponent(requestMealsAmount); f.addComponent(h2); f.setComponentAlignment(h2, Alignment.MIDDLE_LEFT); HorizontalLayout h3 = new HorizontalLayout(); h3.setWidth("100%"); h3.setCaption("Liquidated Lodging"); // h3.setReadOnly(true); liquidateLodgingPax = new TextField(); liquidateLodgingPax.setWidth("100%"); liquidateLodgingPax.addStyleName(ValoTheme.TEXTFIELD_SMALL); liquidateLodgingPax.addStyleName("align-right"); liquidateLodgingPax.setValue("Pax: " + String.valueOf(lf.getLiquidationLodgingPax())); liquidateLodgingPax.setEnabled(false); h3.addComponent(liquidateLodgingPax); liquidateLodgingBudget = new TextField(); liquidateLodgingBudget.setWidth("100%"); liquidateLodgingBudget.addStyleName(ValoTheme.TEXTFIELD_SMALL); liquidateLodgingBudget.addStyleName("align-right"); liquidateLodgingBudget.setValue("Budget: " + String.valueOf(lf.getLiquidationLodgingBudget())); liquidateLodgingBudget.setEnabled(false); h3.addComponent(liquidateLodgingBudget); liquidateLodgingAmount = new TextField(); liquidateLodgingAmount.setWidth("100%"); liquidateLodgingAmount.addStyleName(ValoTheme.TEXTFIELD_SMALL); liquidateLodgingAmount.addStyleName("align-right"); liquidateLodgingAmount.setValue("Amount: " + String.valueOf(lf.getLiquidationLodgingAmount())); liquidateLodgingAmount.setEnabled(false); h3.addComponent(liquidateLodgingAmount); f.addComponent(h3); f.setComponentAlignment(h3, Alignment.MIDDLE_LEFT); HorizontalLayout h4 = new HorizontalLayout(); h4.setWidth("100%"); h4.setCaption("Liquidated Meals"); h4.setReadOnly(true); liquidateMealsPax = new TextField(); liquidateMealsPax.setWidth("100%"); liquidateMealsPax.addStyleName(ValoTheme.TEXTFIELD_SMALL); liquidateMealsPax.addStyleName("align-right"); liquidateMealsPax.setValue("Pax: " + String.valueOf(lf.getLiquidationMealsPax())); liquidateMealsPax.setEnabled(false); h4.addComponent(liquidateMealsPax); liquidateMealsBudget = new TextField(); liquidateMealsBudget.setWidth("100%"); liquidateMealsBudget.addStyleName(ValoTheme.TEXTFIELD_SMALL); liquidateMealsBudget.addStyleName("align-right"); liquidateMealsBudget.setValue("Budget: " + String.valueOf(lf.getLiquidationMealsBudget())); liquidateMealsBudget.setEnabled(false); h4.addComponent(liquidateMealsBudget); liquidateMealsAmount = new TextField(); liquidateMealsAmount.setWidth("100%"); liquidateMealsAmount.addStyleName(ValoTheme.TEXTFIELD_SMALL); liquidateMealsAmount.addStyleName("align-right"); liquidateMealsAmount.setValue("Amount: " + String.valueOf(lf.getLiquidationMealsAmount())); liquidateMealsAmount.setEnabled(false); h4.addComponent(liquidateMealsAmount); f.addComponent(h4); f.setComponentAlignment(h4, Alignment.MIDDLE_LEFT); reimbursement = new TextField("Reimbursement: "); reimbursement.setWidth("50%"); reimbursement.addStyleName(ValoTheme.TEXTFIELD_SMALL); reimbursement.setValue(String.valueOf(lf.getReimbursedAmount())); reimbursement.setEnabled(false); f.addComponent(reimbursement); f.addStyleName("light"); f.setReadOnly(true); return f; }
From source file:com.save.reports.maintenance.MaintenanceReportUI.java
private Window filterReport() { Window sub = new Window("FILTER REPORT"); sub.setWidth("400px"); sub.setModal(true);/* ww w . ja va2s .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 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 w w. ja v a2 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 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);//from ww w . jav a 2 s . c om 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.skysql.manager.ui.components.ChartControls.java
License:Open Source License
/** * Instantiates a new chart controls.//w w w .j ava 2 s . c o m */ public ChartControls() { setSpacing(true); final FormLayout form1 = new FormLayout(); form1.setSpacing(false); form1.setMargin(false); addComponent(form1); selectInterval = new NativeSelect("Charts Time Span"); selectInterval.setImmediate(true); selectInterval.setNullSelectionAllowed(false); selectInterval.addItem(INTERVAL_5_MIN); selectInterval.addItem(INTERVAL_10_MIN); selectInterval.addItem(INTERVAL_30_MIN); selectInterval.addItem(INTERVAL_1_HOUR); selectInterval.addItem(INTERVAL_6_HOURS); selectInterval.addItem(INTERVAL_12_HOURS); selectInterval.addItem(INTERVAL_1_DAY); selectInterval.addItem(INTERVAL_1_WEEK); selectInterval.addItem(INTERVAL_1_MONTH); selectInterval.setItemCaption(INTERVAL_5_MIN, "5 Minutes"); selectInterval.setItemCaption(INTERVAL_10_MIN, "10 Minutes"); selectInterval.setItemCaption(INTERVAL_30_MIN, "30 Minutes"); selectInterval.setItemCaption(INTERVAL_1_HOUR, "1 Hour"); selectInterval.setItemCaption(INTERVAL_6_HOURS, "6 Hours"); selectInterval.setItemCaption(INTERVAL_12_HOURS, "12 Hours"); selectInterval.setItemCaption(INTERVAL_1_DAY, "1 Day"); selectInterval.setItemCaption(INTERVAL_1_WEEK, "1 Week"); selectInterval.setItemCaption(INTERVAL_1_MONTH, "1 Month"); form1.addComponent(selectInterval); final FormLayout form2 = new FormLayout(); form2.setSpacing(false); form2.setMargin(false); addComponent(form2); selectTheme = new NativeSelect("Theme"); selectTheme.setImmediate(true); selectTheme.setNullSelectionAllowed(false); for (Themes theme : Themes.values()) { selectTheme.addItem(theme.name()); } form2.addComponent(selectTheme); }
From source file:com.skysql.manager.ui.components.ParametersLayout.java
License:Open Source License
/** * Instantiates a new parameters layout. * * @param runningTask the running task/* www. j a v a2s .c om*/ * @param nodeInfo the node info * @param commandEnum the command enum */ public ParametersLayout(final RunningTask runningTask, final NodeInfo nodeInfo, Commands.Command commandEnum) { this.runningTask = runningTask; addStyleName("parametersLayout"); setSizeFull(); setSpacing(true); setMargin(true); params = new HashMap<String, String>(); runningTask.selectParameter(params); switch (commandEnum) { case backup: backupLevel = new OptionGroup("Backup Level"); backupLevel.setImmediate(true); backupLevel.addItem(BackupRecord.BACKUP_TYPE_FULL); backupLevel.setItemCaption(BackupRecord.BACKUP_TYPE_FULL, "Full"); backupLevel.addItem(BackupRecord.BACKUP_TYPE_INCREMENTAL); backupLevel.setItemCaption(BackupRecord.BACKUP_TYPE_INCREMENTAL, "Incremental"); addComponent(backupLevel); setComponentAlignment(backupLevel, Alignment.MIDDLE_LEFT); backupLevel.addValueChangeListener(new ValueChangeListener() { private static final long serialVersionUID = 0x4C656F6E6172646FL; public void valueChange(ValueChangeEvent event) { String level = (String) event.getProperty().getValue(); params.put(PARAM_BACKUP_TYPE, level); if (level.equals(BackupRecord.BACKUP_TYPE_INCREMENTAL)) { addComponent(prevBackupsLayout); selectPrevBackup.select(firstItem); } else { params.remove(PARAM_BACKUP_PARENT); if (getComponentIndex(prevBackupsLayout) != -1) { removeComponent(prevBackupsLayout); } } } }); backupLevel.setValue(BackupRecord.BACKUP_TYPE_FULL); isParameterReady = true; case restore: VerticalLayout restoreLayout = new VerticalLayout(); restoreLayout.setSpacing(true); if (commandEnum == Command.restore) { addComponent(restoreLayout); FormLayout formLayout = new FormLayout(); //formLayout.setMargin(new MarginInfo(false, false, true, false)); formLayout.setMargin(false); restoreLayout.addComponent(formLayout); final NativeSelect selectSystem; selectSystem = new NativeSelect("Backups from"); selectSystem.setImmediate(true); selectSystem.setNullSelectionAllowed(false); SystemInfo systemInfo = VaadinSession.getCurrent().getAttribute(SystemInfo.class); for (SystemRecord systemRecord : systemInfo.getSystemsMap().values()) { if (!systemRecord.getID().equals(SystemInfo.SYSTEM_ROOT)) { selectSystem.addItem(systemRecord.getID()); selectSystem.setItemCaption(systemRecord.getID(), systemRecord.getName()); } } selectSystem.select(systemInfo.getCurrentID()); formLayout.addComponent(selectSystem); selectSystem.addValueChangeListener(new ValueChangeListener() { private static final long serialVersionUID = 0x4C656F6E6172646FL; public void valueChange(ValueChangeEvent event) { String systemID = (String) event.getProperty().getValue(); Backups backups = new Backups(systemID, null); backupsList = backups.getBackupsList(); selectPrevBackup.removeAllItems(); firstItem = null; if (backupsList != null && backupsList.size() > 0) { Collection<BackupRecord> set = backupsList.values(); Iterator<BackupRecord> iter = set.iterator(); while (iter.hasNext()) { BackupRecord backupRecord = iter.next(); String backupID = backupRecord.getID(); selectPrevBackup.addItem(backupID); selectPrevBackup.setItemCaption(backupID, "ID: " + backupID + ", " + backupRecord.getStarted()); if (firstItem == null) { firstItem = backupID; selectPrevBackup.select(firstItem); } } runningTask.getControlsLayout().enableControls(true, Controls.Run); } else { if (backupInfoLayout != null) { displayBackupInfo(backupInfoLayout, new BackupRecord()); } runningTask.getControlsLayout().enableControls(false, Controls.Run); } } }); } prevBackupsLayout = new HorizontalLayout(); restoreLayout.addComponent(prevBackupsLayout); selectPrevBackup = (commandEnum == Command.backup) ? new ListSelect("Backups") : new ListSelect(); selectPrevBackup.setImmediate(true); selectPrevBackup.setNullSelectionAllowed(false); selectPrevBackup.setRows(8); // Show a few items and a scrollbar if there are more selectPrevBackup.setWidth("20em"); prevBackupsLayout.addComponent(selectPrevBackup); final Backups backups = new Backups(nodeInfo.getParentID(), null); //*** this is for when we only want backups from a specific node // backupsList = backups.getBackupsForNode(nodeInfo.getID()); backupsList = backups.getBackupsList(); if (backupsList != null && backupsList.size() > 0) { Collection<BackupRecord> set = backupsList.values(); Iterator<BackupRecord> iter = set.iterator(); while (iter.hasNext()) { BackupRecord backupRecord = iter.next(); selectPrevBackup.addItem(backupRecord.getID()); selectPrevBackup.setItemCaption(backupRecord.getID(), "ID: " + backupRecord.getID() + ", " + backupRecord.getStarted()); if (firstItem == null) { firstItem = backupRecord.getID(); } } backupInfoLayout = new VerticalLayout(); backupInfoLayout.setSpacing(false); backupInfoLayout.setMargin(new MarginInfo(false, true, false, true)); prevBackupsLayout.addComponent(backupInfoLayout); prevBackupsLayout.setComponentAlignment(backupInfoLayout, Alignment.MIDDLE_CENTER); selectPrevBackup.addValueChangeListener(new ValueChangeListener() { private static final long serialVersionUID = 0x4C656F6E6172646FL; public void valueChange(ValueChangeEvent event) { String backupID = (String) event.getProperty().getValue(); if (backupID == null) { isParameterReady = false; runningTask.getControlsLayout().enableControls(isParameterReady, Controls.Run); return; } BackupRecord backupRecord = backupsList.get(backupID); displayBackupInfo(backupInfoLayout, backupRecord); if (backupLevel != null) { // we're doing a backup params.put(PARAM_BACKUP_PARENT, backupRecord.getID()); } else { // we're doing a restore params.put(PARAM_BACKUP_ID, backupRecord.getID()); } isParameterReady = true; ScriptingControlsLayout controlsLayout = runningTask.getControlsLayout(); if (controlsLayout != null) { controlsLayout.enableControls(isParameterReady, Controls.Run); } } }); // final DisplayBackupRecord displayRecord = new // DisplayBackupRecord(parameterLayout); if (commandEnum == Command.restore) { restoreLayout.addComponent(prevBackupsLayout); selectPrevBackup.select(firstItem); } } else { // no previous backups if (commandEnum == Command.backup) { backupLevel.setEnabled(false); isParameterReady = true; } else if (commandEnum == Command.restore) { //runningTask.getControlsLayout().enableControls(false, Controls.run); } } break; case connect: VerticalLayout connectLayout = new VerticalLayout(); addComponent(connectLayout); final Validator validator = new Password2Validator(connectPassword); passwordOption.addItem(true); passwordOption.setItemCaption(true, "Authenticate with root user"); passwordOption.addItem(false); passwordOption.setItemCaption(false, "Authenticate with SSH Key"); passwordOption.setImmediate(true); passwordOption.addValueChangeListener(new Property.ValueChangeListener() { private static final long serialVersionUID = 0x4C656F6E6172646FL; @Override public void valueChange(ValueChangeEvent event) { usePassword = (Boolean) event.getProperty().getValue(); if (usePassword) { connectPassword2.addValidator(validator); } else { connectPassword2.removeValidator(validator); } connectPassword.setVisible(usePassword); connectPassword.setRequired(usePassword); connectPassword2.setVisible(usePassword); connectPassword2.setRequired(usePassword); connectKey.setVisible(!usePassword); connectKey.setRequired(!usePassword); boolean isValid; if (runningTask.getControlsLayout() != null) { if (usePassword) { isValid = connectPassword.isValid(); } else { isValid = connectKey.isValid(); } if (isValid) { connectParamsListener.valueChange(null); } else { form.setComponentError(null); form.setValidationVisible(false); runningTask.getControlsLayout().enableControls(false, Controls.Run); } } } }); connectLayout.addComponent(passwordOption); passwordOption.select(false); connectLayout.addComponent(form); form.setImmediate(true); form.setFooter(null); Layout layout = form.getLayout(); form.addField("connectPassword", connectPassword); connectPassword.setImmediate(true); connectPassword.setRequiredError("Root Password is a required field"); connectPassword.addValueChangeListener(connectParamsListener); form.addField("connectPassword2", connectPassword2); connectPassword2.setImmediate(true); connectPassword2.setRequiredError("Confirm Password is a required field"); connectPassword2.addValueChangeListener(connectParamsListener); form.addField("connectKey", connectKey); connectKey.setStyleName("sshkey"); connectKey.setColumns(41); connectKey.setImmediate(true); connectKey.setRequiredError("SSH Key is a required field"); connectKey.addValueChangeListener(connectParamsListener); break; default: isParameterReady = true; break; } }
From source file:com.snowy.NewUserSubWindow.java
public void build() { //setClosable(false); setModal(true);//from www.j av a 2 s . c om setResizable(false); setResponsive(true); setDraggable(false); FormLayout fl = new FormLayout(); fl.setMargin(true); //fl.setSizeFull(); fl.setSizeUndefined(); fl.setSpacing(true); TextField uname = new TextField("Username"); uname.setRequired(true); //uname.addValidator(null); fl.addComponent(uname); TextField email = new TextField("Email"); email.setRequired(true); email.addValidator(new EmailValidator("A Valid Email is Required")); fl.addComponent(email); PasswordField pf1 = new PasswordField("Password"); pf1.setRequired(true); pf1.addValidator(new StringLengthValidator("Password must be between 8 and 60 characters", 8, 60, false)); fl.addComponent(pf1); PasswordField pf2 = new PasswordField("Confirm Password"); pf2.setRequired(true); pf2.addValidator((Object value) -> { if (!pf2.getValue().equals(pf1.getValue())) { throw new InvalidValueException("Passwords Must Match"); } }); //pf2.setImmediate(true); fl.addComponent(pf2); Button b = new Button("Submit"); b.addClickListener((Button.ClickEvent e) -> { if (uname.isValid() && email.isValid() && pf1.isValid() && pf2.isValid()) { String result = d.createUser(uname.getValue(), pf2.getValue(), email.getValue()); if (result.equals("Creation Sucess")) { fl.removeAllComponents(); fl.addComponent(new Label("User Created Sucessfully")); fl.addComponent(new Button("Close", (ee) -> { this.close(); })); } else { Notification.show(result); } } else { b.setComponentError(new UserError("Issues with required fields")); } //d.close(); }); fl.addComponent(b); setContent(fl); }
From source file:com.terralcode.gestion.frontend.view.widgets.example.crudtestform.CrudExampleForm.java
private void openProductWindow(Item beanItem, String caption) { Window window = new Window(caption); window.setModal(true);//from w w w . j a va2 s .c o m FormLayout layout = new FormLayout(); layout.setMargin(true); window.setContent(layout); fieldGroup = new BeanFieldGroup<TestProduct>(TestProduct.class); fieldGroup.setItemDataSource(beanItem); for (Object propertyId : fieldGroup.getUnboundPropertyIds()) { layout.addComponent(fieldGroup.buildAndBind(propertyId)); } layout.addComponent(createOkButton(window)); getUI().addWindow(window); }
From source file:de.escidoc.admintool.view.resource.FormLayoutFactory.java
License:Open Source License
public static FormLayout create() { final FormLayout formLayout = new FormLayout(); formLayout.setMargin(true); formLayout.setWidth("800px"); formLayout.setHeight("100%"); return formLayout; }
From source file:de.fatalix.app.view.login.LoginView.java
private Component buildLoginForm() { FormLayout loginForm = new FormLayout(); loginForm.addStyleName("login-form"); loginForm.setSizeUndefined();/* w w w .j a v a 2s .c om*/ loginForm.setMargin(false); loginForm.addComponent(username = new TextField("Username", "admin")); username.setWidth(15, Unit.EM); loginForm.addComponent(password = new PasswordField("Password")); password.setWidth(15, Unit.EM); password.setDescription("Write anything"); CssLayout buttons = new CssLayout(); buttons.setStyleName("buttons"); loginForm.addComponent(buttons); buttons.addComponent(login = new Button("Login")); login.setDisableOnClick(true); login.addClickListener(new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { try { presenter.doLogin(username.getValue(), password.getValue()); } catch (AuthenticationException ex) { LoginView.this.showNotification( new Notification("Wrong login", Notification.Type.ERROR_MESSAGE), ValoTheme.NOTIFICATION_FAILURE); } finally { login.setEnabled(true); } } }); login.setClickShortcut(ShortcutAction.KeyCode.ENTER); login.addStyleName(ValoTheme.BUTTON_FRIENDLY); buttons.addComponent(forgotPassword = new Button("Forgot password?")); forgotPassword.addClickListener(new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { showNotification(new Notification("Hint: Try anything", Notification.Type.HUMANIZED_MESSAGE), ValoTheme.NOTIFICATION_SUCCESS); } }); forgotPassword.addStyleName(ValoTheme.BUTTON_LINK); return loginForm; }