List of usage examples for com.vaadin.ui Button addClickListener
public Registration addClickListener(ClickListener listener)
From source file:com.save.area.AddLocationToAreaWindow.java
VerticalLayout getVlayout() { VerticalLayout vlayout = new VerticalLayout(); vlayout.setSizeFull();//www .j a v a 2s . co m vlayout.setMargin(true); vlayout.setSpacing(true); area.setInputPrompt("Select Area.."); area.setNullSelectionAllowed(false); vlayout.addComponent(area); province.setInputPrompt("Select Province.."); province.addValueChangeListener(new ProvincePropertyChangeListener(city)); vlayout.addComponent(province); city.setInputPrompt("Select City.."); city.setWidth("100%"); vlayout.addComponent(city); Button addBtn = new Button("ADD LOCATION TO AREA"); addBtn.setWidth("100%"); addBtn.addClickListener(addBtnListener); vlayout.addComponent(addBtn); return vlayout; }
From source file:com.save.area.AddNewCityWindow.java
VerticalLayout getVlayout() { VerticalLayout vlayout = new VerticalLayout(); vlayout.setSizeFull();//from w w w. j a v a 2 s . co m vlayout.setMargin(true); vlayout.setSpacing(true); province.setInputPrompt("Select Province.."); province.setWidth("100%"); vlayout.addComponent(province); cityField.setWidth("100%"); vlayout.addComponent(cityField); Button addCityBtn = new Button("ADD CITY"); addCityBtn.setWidth("100%"); addCityBtn.addClickListener(addCityBtnListener); vlayout.addComponent(addCityBtn); return vlayout; }
From source file:com.save.area.AddNewProvinceWindow.java
VerticalLayout getVlayout() { VerticalLayout vlayout = new VerticalLayout(); vlayout.setSizeFull();//from ww w.ja v a2 s . c o m vlayout.setMargin(true); vlayout.setSpacing(true); provinceField.setWidth("100%"); vlayout.addComponent(provinceField); Button provinceBtn = new Button("ADD PROVINCE"); provinceBtn.setWidth("100%"); provinceBtn.addClickListener(addProvinceBtnListener); vlayout.addComponent(provinceBtn); return vlayout; }
From source file:com.save.area.AreaUI.java
ComponentContainer getHlayoutWithBtn() { VerticalLayout buttonsLayout = new VerticalLayout(); buttonsLayout.setMargin(new MarginInfo(true, false, false, false)); Button addBtn = new AreaButton("ADD LOCATION TO AREA"); buttonsLayout.addComponent(addBtn);//from ww w.j a v a 2s . co m addBtn.addClickListener(actionBtnListener); buttonsLayout.setComponentAlignment(addBtn, Alignment.MIDDLE_LEFT); Button createBtn = new AreaButton("CREATE NEW AREA"); buttonsLayout.addComponent(createBtn); createBtn.addClickListener(actionBtnListener); buttonsLayout.setComponentAlignment(createBtn, Alignment.MIDDLE_LEFT); Button editBtn = new AreaButton("EDIT AREA"); buttonsLayout.addComponent(editBtn); editBtn.addClickListener(actionBtnListener); buttonsLayout.setComponentAlignment(editBtn, Alignment.MIDDLE_LEFT); Button deleteBtn = new AreaButton("DELETE AREA"); buttonsLayout.addComponent(deleteBtn); deleteBtn.addClickListener(actionBtnListener); buttonsLayout.setComponentAlignment(deleteBtn, Alignment.MIDDLE_LEFT); Button addProvinceBtn = new AreaButton("ADD PROVINCE"); buttonsLayout.addComponent(addProvinceBtn); addProvinceBtn.addClickListener(actionBtnListener); buttonsLayout.setComponentAlignment(addProvinceBtn, Alignment.MIDDLE_LEFT); Button addCityBtn = new AreaButton("ADD CITY"); buttonsLayout.addComponent(addCityBtn); addCityBtn.addClickListener(actionBtnListener); buttonsLayout.setComponentAlignment(addCityBtn, Alignment.MIDDLE_LEFT); return buttonsLayout; }
From source file:com.save.area.CreateNewAreaWindow.java
VerticalLayout getVlayout() { VerticalLayout vlayout = new VerticalLayout(); vlayout.setSizeFull();//from ww w . ja va2s.c om vlayout.setMargin(true); vlayout.setSpacing(true); final TextField areaField = new TextField("Create Area: "); areaField.setWidth("100%"); areaField.setRequired(true); areaField.setRequiredError("*Required Field"); vlayout.addComponent(areaField); Button createBtn = new Button("CREATE NEW AREA"); createBtn.setWidth("100%"); createBtn.addClickListener(new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { if (as.isAreaExist(areaField.getValue().trim().toLowerCase())) { Notification.show("Area already Exist!", Notification.Type.WARNING_MESSAGE); return; } if (areaField.getValue() == null || areaField.getValue().trim().isEmpty()) { Notification.show("Area Field cannot be empty!", Notification.Type.ERROR_MESSAGE); return; } boolean result = as.createNewArea(areaField.getValue().trim().toLowerCase()); if (result) { Notification.show("Done!"); close(); } } }); createBtn.setImmediate(true); vlayout.addComponent(createBtn); return vlayout; }
From source file:com.save.client.promodeals.PromoUI.java
public PromoUI(int clientId) { this.clientId = clientId; setWidth("90%"); setHeight("100%"); setMargin(new MarginInfo(true, true, false, false)); PDDataGridProperties dataGrid = new PDDataGridProperties(getClientId()); Button button = new Button("Acknowledgement Form"); button.setWidthUndefined();//from w w w . jav a2s . co m button.setIcon(FontAwesome.OPENID); button.addStyleName(ValoTheme.BUTTON_LINK); button.addStyleName(ValoTheme.BUTTON_SMALL); button.addClickListener((Button.ClickEvent event) -> { Window sub = new com.save.clients.AcknowledgementPromoForm(getClientId()); if (sub.getParent() == null) { UI.getCurrent().addWindow(sub); } sub.addCloseListener((Window.CloseEvent e) -> { dataGrid.getContainerDataSource().removeAllItems(); dataGrid.setContainerDataSource(new PDDataContainer(getClientId())); }); }); addComponent(button); setComponentAlignment(button, Alignment.TOP_RIGHT); addComponent(dataGrid); setExpandRatio(dataGrid, 2); }
From source file:com.save.client.RemoveAccountWindow.java
VerticalLayout getVLayout() { VerticalLayout vlayout = new VerticalLayout(); vlayout.setSpacing(true);/*from w ww .ja v a2 s .co 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 = clientService.removeAccount(getClientId(), remarks.getValue().trim().toLowerCase()); if (result) { close(); } }); vlayout.addComponent(removeBtn); return vlayout; }
From source file:com.save.client.RemoveAccountWindow.java
void getConfirmationWindow(final String str) { final Window sub = new Window("Conifrm?"); sub.setWidth("180px"); sub.setHeight("150px"); sub.center();/*from w w w .j a v a 2 s. c om*/ sub.setResizable(false); UI.getCurrent().addWindow(sub); VerticalLayout vlayout = new VerticalLayout(); vlayout.setMargin(true); vlayout.setSpacing(true); vlayout.addComponent(new Label("Client is a Distributor!")); Button removeBtn = new Button("REMOVE"); removeBtn.setWidth("100%"); removeBtn.addClickListener((Button.ClickEvent event) -> { boolean result = clientService.removeAccount(getClientId(), str); if (result) { sub.close(); close(); } }); vlayout.addComponent(removeBtn); sub.setContent(vlayout); sub.addCloseListener((CloseEvent e) -> { close(); }); }
From source file:com.save.clients.AcknowledgementPromoForm.java
VerticalLayout acknowledgementFormContent() { VerticalLayout content = new VerticalLayout(); content.setSizeFull();/* ww w.j a v a 2s . com*/ content.setMargin(true); content.setSpacing(true); GridLayout glayout = new GridLayout(4, 5); glayout.setWidth("100%"); glayout.setSpacing(true); entryDate = new DateField("Date: "); entryDate.setWidth("100%"); glayout.addComponent(entryDate, 0, 0); promoItem = new TextField("Promo Items: "); promoItem.setWidth("100%"); glayout.addComponent(promoItem, 1, 0, 3, 0); promoAmount = new TextField("Amount: "); promoAmount.setWidth("100%"); promoAmount.setStyleName("align-right"); glayout.addComponent(promoAmount, 0, 1); quantity = new TextField("Quantity: "); quantity.setWidth("100%"); quantity.setStyleName("align-right"); glayout.addComponent(quantity, 1, 1); productItems = CommonComboBox.productItems(); productItems.setWidth("100%"); glayout.addComponent(productItems, 2, 1, 3, 1); startDate = new DateField("From: "); startDate.setWidth("100%"); glayout.addComponent(startDate, 0, 2); endDate = new DateField("To: "); endDate.setWidth("100%"); glayout.addComponent(endDate, 1, 2); salesRep.setWidth("100%"); glayout.addComponent(salesRep, 2, 2, 3, 2); areaSales.setWidth("100%"); glayout.addComponent(areaSales, 2, 3, 3, 3); remarks = new TextArea("Remarks: "); remarks.setWidth("100%"); remarks.setRows(4); glayout.addComponent(remarks, 0, 3, 1, 4); Button submitBtn = new Button(); submitBtn.setCaption("SAVE"); submitBtn.setWidth("100%"); submitBtn.addClickListener(this); glayout.addComponent(submitBtn, 2, 4, 3, 4); glayout.setComponentAlignment(submitBtn, Alignment.BOTTOM_CENTER); if (getPromoId() != 0) { PromoDeals pd = pds.getPromoDealById(getPromoId()); submitBtn.setCaption("UPDATE"); entryDate.setValue(pd.getEntryDate()); startDate.setValue(pd.getStartDate()); endDate.setValue(pd.getEndDate()); promoItem.setValue(pd.getPromoItem()); promoAmount.setValue(String.valueOf(pd.getPromoAmount())); quantity.setValue(String.valueOf(pd.getQuantity())); productItems.setValue(pd.getProductId()); areaSales.setValue(pd.getAreaSalesId()); salesRep.setValue(pd.getSalesRepId()); remarks.setValue(pd.getRemarks()); } content.addComponent(glayout); return content; }
From source file:com.save.employee.CreateNewAccountWindow.java
FormLayout getLayout() { FormLayout f = new FormLayout(); f.setReadOnly(false);/* w w w. j a v a 2s . co m*/ f.setSpacing(true); f.setMargin(true); final TextField employeeNo = new TextField("Employee No: "); employeeNo.setWidth("100%"); employeeNo.setRequired(true); employeeNo.setNullSettingAllowed(false); f.addComponent(employeeNo); final TextField firstname = new TextField("Firstname: "); firstname.setWidth("100%"); firstname.setRequired(true); firstname.setNullSettingAllowed(false); f.addComponent(firstname); final TextField middlename = new TextField("Middlename: "); middlename.setWidth("100%"); middlename.setRequired(true); middlename.setNullSettingAllowed(false); f.addComponent(middlename); final TextField lastname = new TextField("Lastname: "); lastname.setWidth("100%"); lastname.setRequired(true); lastname.setNullSettingAllowed(false); f.addComponent(lastname); final OptionGroup gender = new OptionGroup("Gender: "); gender.addItem("Female"); gender.addItem("Male"); gender.addStyleName("horizontal"); gender.setValue("Female"); f.addComponent(gender); final ComboBox status = new ComboBox("Status: "); status.setWidth("100%"); status.setNullSelectionAllowed(false); status.addItem("Single"); status.addItem("Married"); status.addItem("Widow"); status.addItem("Separated"); f.addComponent(status); Button saveBtn = new Button("SAVE"); saveBtn.setWidth("100%"); saveBtn.addClickListener((Button.ClickEvent event) -> { //TODO if (employeeNo.getValue().isEmpty() || employeeNo.getValue() == null) { Notification.show("Requried Emloyee ID", Notification.Type.WARNING_MESSAGE); return; } if (firstname.getValue().isEmpty() || firstname.getValue() == null) { Notification.show("Requried Firstname", Notification.Type.WARNING_MESSAGE); return; } if (middlename.getValue().isEmpty() || middlename.getValue() == null) { Notification.show("Requried Middlename", Notification.Type.WARNING_MESSAGE); return; } if (lastname.getValue().isEmpty() || lastname.getValue() == null) { Notification.show("Requried Lastname", Notification.Type.WARNING_MESSAGE); return; } if (status.getValue() == null) { Notification.show("Requried Status", Notification.Type.WARNING_MESSAGE); } if (employeeService.checkIfEmployeeNoExist(employeeNo.getValue().trim().toLowerCase())) { Notification.show("EmployeeId already Exist!", Notification.Type.ERROR_MESSAGE); return; } Employee e = new Employee(); e.setEmployeeNo(employeeNo.getValue().trim().toLowerCase()); e.setFirstname(firstname.getValue().trim().toLowerCase()); e.setMiddlename(middlename.getValue().trim().toLowerCase()); e.setLastname(lastname.getValue().trim().toLowerCase()); e.setGender(gender.getValue().toString().trim().toLowerCase()); e.setPersonalStatus(status.getValue().toString()); boolean result = employeeService.createNewAccount(e); if (result) { close(); getHsplit().setFirstComponent(new EmployeesDataGridProperties(getHsplit(), "personal")); } }); f.addComponent(saveBtn); return f; }