List of usage examples for com.vaadin.ui Button addClickListener
public Registration addClickListener(ClickListener listener)
From source file:com.etest.view.tq.TQCoverageWindow.java
FormLayout buildForms() { FormLayout form = new FormLayout(); form.setWidth("100%"); form.setMargin(true);/*from w w w. j av a 2 s. c om*/ int itemNo = 1; Label caseTopic; Label stem; Map<Integer, Map<Integer, Integer>> tqCoverage = tq.getTQCoverage(getTQCoverageId()); for (Map.Entry<Integer, Map<Integer, Integer>> tqCases : tqCoverage.entrySet()) { Integer tqCaseId = tqCases.getKey(); caseTopic = new Label(); caseTopic.setValue(ccs.getCellCaseById(tqCaseId).getCaseTopic()); caseTopic.setContentMode(ContentMode.HTML); form.addComponent(caseTopic); Map<Integer, Integer> value = tqCases.getValue(); for (Map.Entry<Integer, Integer> itemIds : value.entrySet()) { Integer itemId = itemIds.getKey(); Integer itemKeyId = itemIds.getValue(); List<String> keyList = k.getAllItemKey(itemId); if (keyList.isEmpty()) { ShowErrorNotification .error("No Item Key was found for STEM: \n" + cis.getCellItemById(itemId).getItem()); return null; } stem = new Label(); // stem.setValue(itemNo+". "+cis.getCellItemById(itemId).getItem().replace("{key}", keyList.get(0))); stem.setValue(itemNo + ". " + cis.getCellItemById(itemId).getItem().replace("{key}", k.getItemKeyById(itemKeyId))); stem.setContentMode(ContentMode.HTML); form.addComponent(stem); GridLayout glayout = new GridLayout(2, 2); glayout.setWidth("100%"); glayout.setSpacing(true); glayout.addComponent(new Label("A) " + cis.getCellItemById(itemId).getOptionA(), ContentMode.HTML), 0, 0); glayout.addComponent(new Label("C) " + cis.getCellItemById(itemId).getOptionC(), ContentMode.HTML), 0, 1); glayout.addComponent(new Label("B) " + cis.getCellItemById(itemId).getOptionB(), ContentMode.HTML), 1, 0); glayout.addComponent(new Label("D) " + cis.getCellItemById(itemId).getOptionD(), ContentMode.HTML), 1, 1); form.addComponent(glayout); itemNo++; } } HorizontalLayout h = new HorizontalLayout(); h.setWidth("100%"); Button delete = new Button("DELETE"); delete.setWidth("200px"); delete.setIcon(FontAwesome.TRASH_O); delete.addStyleName(ValoTheme.BUTTON_PRIMARY); delete.addStyleName(ValoTheme.BUTTON_SMALL); delete.addClickListener(buttonClickListener); h.addComponent(delete); Button approve = new Button("APPROVE"); approve.setWidth("200px"); approve.setIcon(FontAwesome.THUMBS_UP); approve.addStyleName(ValoTheme.BUTTON_PRIMARY); approve.addStyleName(ValoTheme.BUTTON_SMALL); approve.addClickListener(buttonClickListener); h.addComponent(approve); if (tq.isTQCoverageApproved(getTQCoverageId())) { approve.setVisible(false); } else { approve.setVisible(true); } form.addComponent(h); return form; }
From source file:com.etest.view.tq.TQCoverageWindow.java
Window confirmDeleteWindow() { Window sub = new Window("TQ Coverage"); sub.setWidth("250px"); sub.setResizable(false);/*from ww w . j a v a 2s .c o m*/ sub.setModal(true); sub.center(); VerticalLayout v = new VerticalLayout(); v.setWidth("100%"); v.setMargin(true); Button delete = new Button("DELETE TQ?"); delete.setWidth("100%"); delete.setIcon(FontAwesome.TRASH_O); delete.addStyleName(ValoTheme.BUTTON_PRIMARY); delete.addStyleName(ValoTheme.BUTTON_SMALL); delete.addClickListener((Button.ClickEvent event) -> { boolean result = tq.deleteTQCoverage(getTQCoverageId()); if (result) { sub.close(); close(); } }); v.addComponent(delete); sub.setContent(v); sub.getContent().setHeightUndefined(); return sub; }
From source file:com.etest.view.tq.TQListUI.java
public Table populateDataTable() { removeAllItems();/*from w w w . j av a 2s . c om*/ int i = 0; for (TQCoverage t : tq.getAllTQCoverage()) { VerticalLayout v = new VerticalLayout(); v.setWidth("100%"); Button view = new Button("view"); view.setSizeFull(); view.setData(t.getTqCoverageId()); view.setIcon(FontAwesome.VIDEO_CAMERA); view.addStyleName(ValoTheme.BUTTON_LINK); view.addStyleName(ValoTheme.BUTTON_TINY); view.addStyleName(ValoTheme.BUTTON_QUIET); view.addStyleName("button-container"); view.addClickListener(remarksBtnClickListener); v.addComponent(view); v.setComponentAlignment(view, Alignment.MIDDLE_LEFT); Button approve = new Button("status"); approve.setSizeFull(); approve.setData(t.getTqCoverageId()); approve.addStyleName(ValoTheme.BUTTON_LINK); approve.addStyleName(ValoTheme.BUTTON_TINY); approve.addStyleName(ValoTheme.BUTTON_QUIET); approve.addStyleName("button-container"); v.addComponent(approve); v.setComponentAlignment(approve, Alignment.MIDDLE_LEFT); // Button print = new Button("print"); // print.setSizeFull(); // print.setData(t.getTqCoverageId()); // print.setIcon(FontAwesome.PRINT); // print.addStyleName(ValoTheme.BUTTON_LINK); // print.addStyleName(ValoTheme.BUTTON_TINY); // print.addStyleName(ValoTheme.BUTTON_QUIET); // print.addStyleName("button-container"); // print.addClickListener(remarksBtnClickListener); // v.addComponent(print); // v.setComponentAlignment(print, Alignment.MIDDLE_LEFT); if (t.getStatus() == 0) { approve.setIcon(FontAwesome.THUMBS_DOWN); // print.setVisible(false); } else { approve.setIcon(FontAwesome.THUMBS_UP); // print.setVisible(true); } addItem(new Object[] { t.getExamTitle(), cs.getCurriculumById(t.getCurriculumId()).getSubject(), t.getDateCreated(), t.getTotalHoursCoverage(), t.getTotalItems(), v }, i); i++; } setPageLength(size()); return this; }
From source file:com.example.tomeevaadin.ui.BookUI.java
private HorizontalLayout addInputFields() { HorizontalLayout hl = new HorizontalLayout(); hl.addComponent(new Label("Enter a book")); TextField field = new TextField(stringModel); Button button = new Button("press this to save"); button.addClickListener(new Button.ClickListener() { @Override//from ww w.ja v a 2s . c om public void buttonClick(Button.ClickEvent event) { if (bookService == null) { System.out.println("uho, ejb is null"); } Notification.show("button is pressed " + stringModel.getValue()); Book book = new Book(); book.setBookTitle(stringModel.getValue()); bookService.addBook(book); updateBeanContainer(); } }); hl.addComponent(field); hl.addComponent(button); return hl; }
From source file:com.example.vaadindemo.AddItemPanel.java
public HorizontalLayout draw(BeanItemContainer<ShoppingList> container) { final HorizontalLayout x = new HorizontalLayout(); x.setId("addItemPanel"); Button persistNewItemButton = new Button("Dodaj"); final Item item = new Item(); BeanItem<Item> personBean = new BeanItem<Item>(item); final FormLayout formLayout = new FormLayout(); final FieldGroup form = new FieldGroup(); //new name: form form.setItemDataSource(personBean);//w ww . ja va 2s . c om form.setBuffered(true); Field imieField = form.buildAndBind("Name", "firstName"); imieField.setRequired(true); imieField.addValidator(new StringLengthValidator("bad length", 2, 5, false)); formLayout.addComponent(imieField); //Container final BeanItemContainer<Item> beanContainer = new BeanItemContainer<Item>(Item.class); //beanContainer.addBean(new Item(); //beanContainer.addBean(new Item("Bolek")); //beanContainer.addBean(new Person("Lolek", 1933)); // Put some example data in it container.addItem(new ShoppingList("Mercury", null, null)); //container.addItem(new Planet(2, "Venus")); //container.addItem(new Planet(3, "Earth")); //container.addItem(new Planet(4, "Mars")); // Create a selection component bound to the container final ComboBox select = new ComboBox("Planets", container); // Set the caption mode to read the caption directly // from the 'name' property of the bean select.setItemCaptionMode(ItemCaptionMode.PROPERTY); select.setItemCaptionPropertyId("name"); select.setImmediate(true); final Label ldd = new Label(); x.addComponent(select); x.addComponent(formLayout); x.addComponent(persistNewItemButton); x.addComponent(ldd); persistNewItemButton.addClickListener(new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { Label l = new Label("jsdcbsc"); x.addComponent(l); //ldd.setValue(select.getItem(item.firstName).toString()); } }); select.addValueChangeListener(new Property.ValueChangeListener() { @Override public void valueChange(Property.ValueChangeEvent event) { ldd.setValue(select.getItemCaption(event.getProperty().getValue())); } }); return x; }
From source file:com.firstbanknigeria.ofsaaenhancers.UI.AdjustmentUI.java
public AdjustmentUI() { super("Load Adjustments"); this.setWidth("1000px"); this.setHeight("250px"); objectContext = ObjectStore.getObjectContext(VaadinSession.getCurrent().getSession().getId()); final VerticalLayout layout = new VerticalLayout(); layout.setDefaultComponentAlignment(Alignment.MIDDLE_CENTER); layout.setSpacing(true);/*from w w w.j a va 2s .co m*/ AdjustmentFileProcessor adjFileProcessor = new AdjustmentFileProcessor(); adjFileProcessor.setAdjustmentUI(this); Upload uploadComponent = new Upload("", adjFileProcessor); uploadComponent.addSucceededListener(adjFileProcessor); uploadComponent.setButtonCaption("Upload Adjustments"); uploadComponent.setImmediate(true); Button runAdjustmenstButton = new Button("Run Adjustments"); runAdjustmenstButton.addClickListener(new Button.ClickListener() { public void buttonClick(Button.ClickEvent e) { ProcedureQuery query = new ProcedureQuery("RUN_ADJUSTMENTS"); QueryResponse response = objectContext.performGenericQuery(query); } }); layout.addComponents(uploadComponent, runAdjustmenstButton); layout.setMargin(true); layout.setSpacing(true); setContent(layout); }
From source file:com.fnc.view.ui.AlphaListMainUI.java
Button alphaListButton() { Button button = new Button("ALPHA LIST"); button.setWidth("100%"); button.setIcon(FontAwesome.SPINNER); button.addStyleName(ValoTheme.BUTTON_PRIMARY); button.addStyleName(ValoTheme.BUTTON_SMALL); button.addClickListener((Button.ClickEvent event) -> { status.setValue(" Loading..."); current = 0.0;/*w w w . j av a2s. c o m*/ dataSize = es.getEmployeeByBranch(getBranchId()).size(); populateDataGrid(); }); return button; }
From source file:com.fnc.view.ui.thirteenth.ThirteenthMonthUI.java
Button button() { Button button = new Button("ALPHA LIST"); button.setWidth("100%"); button.setIcon(FontAwesome.SPINNER); button.addStyleName(ValoTheme.BUTTON_PRIMARY); button.addStyleName(ValoTheme.BUTTON_SMALL); button.addClickListener((Button.ClickEvent event) -> { status.setValue(" Loading..."); current = 0.0;/*w w w. j a va 2 s. c o m*/ // dataSize = es.getEmployeeByBranch(getBranchId()).size(); // populateDataGrid(); }); return button; }
From source file:com.foc.web.modules.admin.FocUser_HomePage_Form.java
License:Apache License
@Override protected void afterLayoutConstruction() { super.afterLayoutConstruction(); Button mobileCheckBox = (Button) getComponentByName("MOBILE_CHECKBOX"); if (mobileCheckBox != null) { }/*from ww w. j av a 2s . c o m*/ if (!Globals.isValo()) { /*Button userCredentialsButton = (Button) getComponentByName("OPEN_USER_CREDENTIALS");*/ Object object = getComponentByName("HOME_PAGE_HORIZONTAL_LAYOUT"); if (object != null && object instanceof HorizontalLayout) { HorizontalLayout mainPageHorizontalLayout = (HorizontalLayout) object; Button userCredentialsButton = new Button("Modify"); mainPageHorizontalLayout.addComponent(userCredentialsButton); if (userCredentialsButton != null) { userCredentialsButton.addClickListener(new ClickListener() { @Override public void buttonClick(ClickEvent event) { popupUserCredintionals(getMainWindow()); } }); } } } }
From source file:com.foc.web.modules.business.PrnLayout_Table.java
License:Apache License
@Override protected void afterLayoutConstruction() { super.afterLayoutConstruction(); if (getPrintLogoCheckBox() != null) { getPrintLogoCheckBox().setValue(true); }/*from w w w . jav a2 s . c o m*/ adjustAddButtonVisibilityDependingOnGroupRights(); TableTreeDelegate tableTreeDelegate = getTableTreeDelegate(); if (tableTreeDelegate != null) { if (isShowRTFPrinting()) { tableTreeDelegate.getTable().addGeneratedColumn("PRINT_RTF_BUTTON", new Table.ColumnGenerator() { @Override public Object generateCell(Table source, Object itemId, Object columnId) { Button button = new Button("RTF"); if (getFocList() != null && itemId != null) { PrnLayout layout = (PrnLayout) getFocList().searchByReference((long) itemId); if (layout != null) { BrowserWindowOpener browserWindowOpener = new BrowserWindowOpener( new PrnLayout_BrowserWindowOpenerStreamResource(layout, PrnLayout_Table.this.getPrintingAction(), PrnLayout_BrowserWindowOpenerStreamResource.RTF) { protected boolean isWithLogo() { if (getPrintLogoCheckBox() != null) { return getPrintLogoCheckBox().getValue(); } return true; } }); browserWindowOpener.extend(button); } } return button; } }); tableTreeDelegate.getTable().setColumnHeader("PRINT_RTF_BUTTON", "RTF"); } if (isShowWordPrinting()) { tableTreeDelegate.getTable().addGeneratedColumn("PRINT_WORD_BUTTON", new Table.ColumnGenerator() { @Override public Object generateCell(Table source, Object itemId, Object columnId) { Button button = new Button("MS Word"); if (getFocList() != null && itemId != null) { PrnLayout layout = (PrnLayout) getFocList().searchByReference((long) itemId); if (layout != null) { BrowserWindowOpener browserWindowOpener = new BrowserWindowOpener( new PrnLayout_BrowserWindowOpenerStreamResource(layout, PrnLayout_Table.this.getPrintingAction(), PrnLayout_BrowserWindowOpenerStreamResource.DOC) { protected boolean isWithLogo() { if (getPrintLogoCheckBox() != null) { return getPrintLogoCheckBox().getValue(); } return true; } }); browserWindowOpener.extend(button); } } return button; } }); tableTreeDelegate.getTable().setColumnHeader("PRINT_WORD_BUTTON", "MS Word"); } tableTreeDelegate.getTable().addGeneratedColumn("PRINT_BUTTON", new Table.ColumnGenerator() { @Override public Object generateCell(Table source, Object itemId, Object columnId) { Button button = new Button("PDF"); PrnLayout layout = (PrnLayout) getFocList().searchByReference((long) itemId); if (layout != null) { BrowserWindowOpener browserWindowOpener = new BrowserWindowOpener( new PrnLayout_BrowserWindowOpenerStreamResource(layout, PrnLayout_Table.this.getPrintingAction())) { protected boolean isWithLogo() { if (getPrintLogoCheckBox() != null) { return getPrintLogoCheckBox().getValue(); } return true; } }; browserWindowOpener.extend(button); } return button; } }); tableTreeDelegate.getTable().setColumnHeader("PRINT_BUTTON", "PDF"); if (isShowEMailSending()) { tableTreeDelegate.getTable().addGeneratedColumn("SEND_EMAIL_BUTTON", new Table.ColumnGenerator() { @Override public Object generateCell(Table source, final Object itemId, Object columnId) { FVButton button = new FVButton("Send Email"); button.addClickListener(new ClickListener() { @Override public void buttonClick(ClickEvent event) { PrintingAction printingAction = getPrintingAction(); if (getFocList() != null && itemId != null && printingAction != null) { PrnLayout prnLayout = (PrnLayout) getFocList().searchByReference((Long) itemId); if (prnLayout != null) { boolean withLogo = false; if (getPrintLogoCheckBox() != null) { withLogo = getPrintLogoCheckBox().getValue(); } FocNotificationEmailTemplate template = (FocNotificationEmailTemplate) BusinessConfig .getInstance().getGeneralEmailTemplate(); FocNotificationEmail email = new FocNotificationEmail( new FocConstructor(FocNotificationEmailDesc.getInstance(), null)); email.init(template, printingAction.getObjectToPrint()); prnLayout.attachToEmail(email, printingAction, withLogo); email.fill(); email.send(); email.setCreated(true); email.validate(true); // Globals.popup(email, false, FocNotificationEmailDesc.getInstance().getStorageName(), XMLViewKey.TYPE_FORM, XMLViewKey.CONTEXT_DEFAULT, XMLViewKey.VIEW_DEFAULT); } } } }); return button; } }); tableTreeDelegate.getTable().setColumnHeader("SEND_EMAIL_BUTTON", "Send Email"); } } }