List of usage examples for com.vaadin.ui Button addClickListener
public Registration addClickListener(ClickListener listener)
From source file:com.coatl.pruebas.datastore.DataStoreUI.java
@Override protected void init(VaadinRequest vaadinRequest) { this.principal = new VerticalLayout(); {//w ww. j av a 2 s . c o m principal.addComponent(new Label("Pruebas de DataStore")); HorizontalLayout superior = new HorizontalLayout(); principal.addComponent(superior); this.forma = new FormLayout(); superior.addComponent(forma); { this.tabla = new TextField("Tabla"); tabla.setValue("iq3_usuarios"); forma.addComponents(tabla); this.nombre = new TextField("Nombre"); forma.addComponents(nombre); this.ap1 = new TextField("Apellido Paterno"); forma.addComponents(ap1); this.ap2 = new TextField("Apellido Materno"); forma.addComponents(ap2); this.renglones = new Label("Renglones"); forma.addComponents(renglones); } FormLayout botones = new FormLayout(); /* botones.addComponent(new Label(" ")); botones.addComponent(new Label("Acciones:")); */ superior.addComponent(botones); Button recargar = new Button("Recargar"); botones.addComponent(recargar); recargar.addClickListener(new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { listarObjetos(); } }); Button guardar = new Button("Guardar"); botones.addComponent(guardar); guardar.addClickListener(new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { Map m = new HashMap(); m.put("nombre", nombre.getValue()); m.put("ap1", ap1.getValue()); m.put("ap2", ap2.getValue()); m.put("id", nombre.getValue()); IU7.ds.guardar(tabla.getValue(), m); System.out.println("Objeto guardado"); listarObjetos(); } }); Button borrar = new Button("Borrar"); botones.addComponent(borrar); borrar.addClickListener(new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { borrar(); } }); Button mil = new Button("Hacer 1,000"); botones.addComponent(mil); mil.addClickListener(new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { for (int i = 0; i < 1000; i++) { Map m = new HashMap(); String id = "ID_" + i + "_" + Math.random(); m.put("id", id); m.put("nombre", "Nombre_" + id + "_" + Math.random()); m.put("ap1", "Ap1_" + id + "_" + Math.random()); m.put("ap2", "Ap2_" + id + "_" + Math.random()); IU7.ds.guardar(tabla.getValue(), m); System.out.println(" >" + id); } } }); } VerticalSplitPanel vsl = new VerticalSplitPanel(); setContent(vsl); vsl.setFirstComponent(principal); grid.setSizeFull(); grid.setComponenteSuperior(new Label("primer panel")); //grid.setComponenteMedio(new Label("segundo panel")); //grid.setComponenteInferior(new Label("tercer panel")); grid.setNombreTabla(tabla.getValue()); grid.setColumnas("id,nombre,ap1,ap2"); grid.setColumnasVisibles("nombre,ap1,ap2"); vsl.setSecondComponent(grid); //grid.setComponenteMedio(grid); this.listarObjetos(); }
From source file:com.coatl.pruebas.MyUI.java
@Override protected void init(VaadinRequest vaadinRequest) { final VerticalLayout layout = new VerticalLayout(); final TextField name = new TextField(); name.setCaption("Escribe algo aqu:"); Button button = new Button("Dime que escrib"); button.addClickListener(new Button.ClickListener() { @Override//from ww w .ja v a2s.c om public void buttonClick(Button.ClickEvent event) { System.out.println("Click!"); layout.addComponent(new Label("Usted escribi> " + name.getValue())); } }); layout.addComponents(name, button); layout.setMargin(true); layout.setSpacing(true); setContent(layout); }
From source file:com.constellio.app.ui.pages.base.MainLayoutImpl.java
private ConstellioMenuButton buildButton(final NavigationItem item) { ComponentState state = presenter.getStateFor(item); Button button = new Button($("MainLayout." + item.getCode())); button.setVisible(state.isVisible()); button.setEnabled(state.isEnabled()); button.addStyleName(item.getCode()); if (item.getFontAwesome() != null) { button.setIcon(item.getFontAwesome()); }//from w ww . j a v a2 s . co m button.addClickListener(new ClickListener() { @Override public void buttonClick(ClickEvent event) { item.activate(navigate()); } }); return new ConstellioMenuButton(item.getViewGroup(), button); }
From source file:com.cxplonka.feature.ui.vaadin.VaadinUI.java
private Button createNavigationButton(String caption, final String viewName) { Button button = new Button(caption); button.addStyleName(ValoTheme.BUTTON_SMALL); button.addClickListener(e -> getUI().getNavigator().navigateTo(viewName)); return button; }
From source file:com.demo.tutorial.agenda.ui.SearchView.java
public SearchView(final MyUI app) { this.app = app; setCaption("Buscar Contactos"); setSizeFull();/* w w w. j a v a 2s . c o m*/ addStyleName("view"); /* Usar un FormLayout como layout principal para este Panel*/ FormLayout formLayout = new FormLayout(); /* Creando componente UI */ txtTextField = new TextField("Buscar"); cmbFieldtoSearch = new NativeSelect("Campo por buscar"); chkSaveSearch = new CheckBox("Guardar Bsqueda"); txtSearchName = new TextField("Buscar nombre"); Button btnBuscar = new Button("Buscar"); btnBuscar.addClickListener(new ClickListener() { @Override public void buttonClick(ClickEvent event) { performSearch(); } }); /* Inicializar combo */ for (int i = 0; i < PersonContainer.NATURAL_COL_ORDER.length; i++) { cmbFieldtoSearch.addItem(PersonContainer.NATURAL_COL_ORDER[i]); cmbFieldtoSearch.setItemCaption(PersonContainer.NATURAL_COL_ORDER[i], PersonContainer.COL_HEADERS_ENGLISH[i]); } cmbFieldtoSearch.setValue("apPaterno"); cmbFieldtoSearch.setNullSelectionAllowed(false); /* Inicializando save checkbox */ chkSaveSearch.setValue(true); chkSaveSearch.setImmediate(true); chkSaveSearch.addListener(new Property.ValueChangeListener() { @Override public void valueChange(ValueChangeEvent event) { boolean value = (Boolean) event.getProperty().getValue(); txtSearchName.setVisible(value); } }); /* chkSaveSearch.addValueChangeListener(new Property.ValueChangeListener() { @Override public void valueChange(ValueChangeEvent event) { boolean value = (Boolean) event.getProperty().getValue(); txtSearchName.setVisible(value); } });*/ /* Aadiendo los componentes creados al formulario */ formLayout.addComponent(txtTextField); formLayout.addComponent(cmbFieldtoSearch); formLayout.addComponent(chkSaveSearch); formLayout.addComponent(txtSearchName); formLayout.addComponent(btnBuscar); setContent(formLayout); }
From source file:com.demo.tutorial.agenda.ui.SharingOptions.java
public SharingOptions() { setModal(true);/*from w w w. ja va 2s .c om*/ setWidth("50%"); center(); setCaption("Sharing Options"); VerticalLayout subContent = new VerticalLayout(); subContent.addComponent(new Label(SHARING_HTML_SNNIPET)); subContent.addComponent(new CheckBox("Gmail")); subContent.addComponent(new CheckBox(".Mac")); Button close = new Button("Ok"); close.addClickListener(new Button.ClickListener() { public void buttonClick(ClickEvent event) { close(); } }); subContent.addComponent(close); setContent(subContent); }
From source file:com.esofthead.mycollab.common.ui.components.CommentRowDisplayHandler.java
License:Open Source License
@Override public Component generateRow(final SimpleComment comment, int rowIndex) { final MHorizontalLayout layout = new MHorizontalLayout().withSpacing(true).withMargin(false) .withWidth("100%").withStyleName("message"); MVerticalLayout userBlock = new MVerticalLayout().withSpacing(true).withMargin(false).withWidth("80px"); userBlock.setDefaultComponentAlignment(Alignment.TOP_CENTER); ClickListener gotoUser = new ClickListener() { private static final long serialVersionUID = 1L; @Override/*from w w w . j av a 2s.co m*/ public void buttonClick(ClickEvent event) { EventBusFactory.getInstance().post(new ProjectMemberEvent.GotoRead(this, comment.getCreateduser())); } }; Button userAvatarBtn = UserAvatarControlFactory.createUserAvatarButtonLink(comment.getOwnerAvatarId(), comment.getOwnerFullName()); userAvatarBtn.addClickListener(gotoUser); userBlock.addComponent(userAvatarBtn); Button userName = new Button(comment.getOwnerFullName()); userName.setStyleName("user-name"); userName.addStyleName("link"); userName.addStyleName(UIConstants.WORD_WRAP); userName.addClickListener(gotoUser); userBlock.addComponent(userName); layout.addComponent(userBlock); CssLayout rowLayout = new CssLayout(); rowLayout.setStyleName("message-container"); rowLayout.setWidth("100%"); MHorizontalLayout messageHeader = new MHorizontalLayout().withSpacing(true) .withMargin(new MarginInfo(true, true, false, true)).withWidth("100%") .withStyleName("message-header"); messageHeader.setDefaultComponentAlignment(Alignment.MIDDLE_LEFT); Label timePostLbl = new Label( AppContext.getMessage(GenericI18Enum.EXT_ADDED_COMMENT, comment.getOwnerFullName(), DateTimeUtils.getPrettyDateValue(comment.getCreatedtime(), AppContext.getUserLocale())), ContentMode.HTML); timePostLbl.setDescription(AppContext.formatDateTime(comment.getCreatedtime())); timePostLbl.setSizeUndefined(); timePostLbl.setStyleName("time-post"); messageHeader.addComponent(timePostLbl); messageHeader.setExpandRatio(timePostLbl, 1.0f); // Message delete button Button msgDeleteBtn = new Button(); msgDeleteBtn.setIcon(FontAwesome.TRASH_O); msgDeleteBtn.setStyleName(UIConstants.BUTTON_ICON_ONLY); messageHeader.addComponent(msgDeleteBtn); if (hasDeletePermission(comment)) { msgDeleteBtn.setVisible(true); msgDeleteBtn.addClickListener(new Button.ClickListener() { private static final long serialVersionUID = 1L; @Override public void buttonClick(ClickEvent event) { ConfirmDialogExt.show(UI.getCurrent(), AppContext.getMessage(GenericI18Enum.DIALOG_DELETE_TITLE, SiteConfiguration.getSiteName()), AppContext.getMessage(GenericI18Enum.DIALOG_DELETE_SINGLE_ITEM_MESSAGE), AppContext.getMessage(GenericI18Enum.BUTTON_YES), AppContext.getMessage(GenericI18Enum.BUTTON_NO), new ConfirmDialog.Listener() { private static final long serialVersionUID = 1L; @Override public void onClose(ConfirmDialog dialog) { if (dialog.isConfirmed()) { CommentService commentService = ApplicationContextUtil .getSpringBean(CommentService.class); commentService.removeWithSession(comment.getId(), AppContext.getUsername(), AppContext.getAccountId()); CommentRowDisplayHandler.this.owner.removeRow(layout); } } }); } }); } else { msgDeleteBtn.setVisible(false); } rowLayout.addComponent(messageHeader); Label messageContent = new UrlDetectableLabel(comment.getComment()); messageContent.setStyleName("message-body"); rowLayout.addComponent(messageContent); List<Content> attachments = comment.getAttachments(); if (!CollectionUtils.isEmpty(attachments)) { MVerticalLayout messageFooter = new MVerticalLayout().withSpacing(false).withMargin(true) .withWidth("100%").withStyleName("message-footer"); AttachmentDisplayComponent attachmentDisplay = new AttachmentDisplayComponent(attachments); attachmentDisplay.setWidth("100%"); messageFooter.addComponent(attachmentDisplay); messageFooter.setComponentAlignment(attachmentDisplay, Alignment.MIDDLE_RIGHT); rowLayout.addComponent(messageFooter); } layout.addComponent(rowLayout); layout.setExpandRatio(rowLayout, 1.0f); return layout; }
From source file:com.esofthead.mycollab.mobile.module.crm.ui.NotesList.java
License:Open Source License
private void initUI() { noteList = new BeanList<NoteService, NoteSearchCriteria, SimpleNote>(noteService, NoteRowDisplayHandler.class); noteList.setDisplayEmptyListText(false); noteList.setStyleName("noteList"); noteListContainer = new VerticalLayout(); this.setContent(noteListContainer); displayNotes();//from w w w .j a v a2 s. c om HorizontalLayout commentBox = new HorizontalLayout(); commentBox.setSizeFull(); commentBox.setStyleName("comment-box"); commentBox.setSpacing(true); commentBox.setDefaultComponentAlignment(Alignment.MIDDLE_LEFT); final TextArea noteInput = new TextArea(); noteInput.setInputPrompt(AppContext.getMessage(GenericI18Enum.M_NOTE_INPUT_PROMPT)); noteInput.setSizeFull(); commentBox.addComponent(noteInput); commentBox.setExpandRatio(noteInput, 1.0f); Button postBtn = new Button(AppContext.getMessage(GenericI18Enum.M_BUTTON_SEND)); postBtn.setStyleName("submit-btn"); postBtn.setWidthUndefined(); postBtn.addClickListener(new Button.ClickListener() { private static final long serialVersionUID = -5095455325725786794L; @Override public void buttonClick(Button.ClickEvent event) { final Note note = new Note(); note.setCreateduser(AppContext.getUsername()); note.setNote(noteInput.getValue()); note.setSaccountid(AppContext.getAccountId()); note.setSubject(""); note.setType(type); note.setTypeid(typeid); note.setCreatedtime(new GregorianCalendar().getTime()); note.setLastupdatedtime(new GregorianCalendar().getTime()); noteService.saveWithSession(note, AppContext.getUsername()); // Save Relay Email -- having time must refact to // Aop // ------------------------------------------------------ RelayEmailNotification relayNotification = new RelayEmailNotification(); relayNotification.setChangeby(AppContext.getUsername()); relayNotification.setChangecomment(noteInput.getValue()); relayNotification.setSaccountid(AppContext.getAccountId()); relayNotification.setType(type); relayNotification.setAction(MonitorTypeConstants.ADD_COMMENT_ACTION); relayNotification.setTypeid("" + typeid); if (type.equals(CrmTypeConstants.ACCOUNT)) { relayNotification.setEmailhandlerbean(AccountRelayEmailNotificationAction.class.getName()); } else if (type.equals(CrmTypeConstants.CONTACT)) { relayNotification.setEmailhandlerbean(ContactRelayEmailNotificationAction.class.getName()); } else if (type.equals(CrmTypeConstants.CAMPAIGN)) { relayNotification.setEmailhandlerbean(CampaignRelayEmailNotificationAction.class.getName()); } else if (type.equals(CrmTypeConstants.LEAD)) { relayNotification.setEmailhandlerbean(LeadRelayEmailNotificationAction.class.getName()); } else if (type.equals(CrmTypeConstants.OPPORTUNITY)) { relayNotification.setEmailhandlerbean(OpportunityRelayEmailNotificationAction.class.getName()); } else if (type.equals(CrmTypeConstants.CASE)) { relayNotification.setEmailhandlerbean(CaseRelayEmailNotificationAction.class.getName()); } else if (type.equals(CrmTypeConstants.TASK)) { relayNotification.setEmailhandlerbean(TaskRelayEmailNotificationAction.class.getName()); } else if (type.equals(CrmTypeConstants.MEETING)) { relayNotification.setEmailhandlerbean(MeetingRelayEmailNotificationAction.class.getName()); } else if (type.equals(CrmTypeConstants.CALL)) { relayNotification.setEmailhandlerbean(CallRelayEmailNotificationAction.class.getName()); } RelayEmailNotificationService relayEmailNotificationService = ApplicationContextUtil .getSpringBean(RelayEmailNotificationService.class); relayEmailNotificationService.saveWithSession(relayNotification, AppContext.getUsername()); noteInput.setValue(""); displayNotes(); } }); commentBox.addComponent(postBtn); this.setToolbar(commentBox); }
From source file:com.esofthead.mycollab.mobile.module.crm.view.account.AccountListViewImpl.java
License:Open Source License
@Override protected Component createRightComponent() { Button addAccount = new Button(); addAccount.addClickListener(new Button.ClickListener() { private static final long serialVersionUID = 1L; @Override//from www . j a v a2s . c o m public void buttonClick(Button.ClickEvent arg0) { EventBusFactory.getInstance().post(new AccountEvent.GotoAdd(this, null)); } }); addAccount.setStyleName("add-btn"); return addAccount; }
From source file:com.esofthead.mycollab.mobile.module.crm.view.account.AccountReadViewImpl.java
License:Open Source License
@Override protected ComponentContainer createBottomPanel() { HorizontalLayout toolbarLayout = new HorizontalLayout(); toolbarLayout.setDefaultComponentAlignment(Alignment.MIDDLE_LEFT); toolbarLayout.setSpacing(true);/* w ww.ja v a 2s. c o m*/ Button relatedContacts = new Button(); relatedContacts.setCaption("<span aria-hidden=\"true\" data-icon=\"" + IconConstants.CRM_CONTACT + "\"></span><div class=\"screen-reader-text\">" + AppContext.getMessage(CrmCommonI18nEnum.TAB_CONTACT) + "</div>"); relatedContacts.setHtmlContentAllowed(true); relatedContacts.addClickListener(new Button.ClickListener() { private static final long serialVersionUID = 7589415773039335559L; @Override public void buttonClick(ClickEvent arg0) { EventBusFactory.getInstance().post( new AccountEvent.GoToRelatedItems(this, new CrmRelatedItemsScreenData(associateContacts))); } }); toolbarLayout.addComponent(relatedContacts); Button relatedOpportunities = new Button(); relatedOpportunities.setCaption("<span aria-hidden=\"true\" data-icon=\"" + IconConstants.CRM_OPPORTUNITY + "\"></span><div class=\"screen-reader-text\">" + AppContext.getMessage(CrmCommonI18nEnum.TAB_OPPORTUNITY) + "</div>"); relatedOpportunities.setHtmlContentAllowed(true); relatedOpportunities.addClickListener(new Button.ClickListener() { private static final long serialVersionUID = 7589415773039335559L; @Override public void buttonClick(ClickEvent arg0) { EventBusFactory.getInstance().post(new AccountEvent.GoToRelatedItems(this, new CrmRelatedItemsScreenData(associateOpportunities))); } }); toolbarLayout.addComponent(relatedOpportunities); Button relatedLeads = new Button(); relatedLeads.setCaption("<span aria-hidden=\"true\" data-icon=\"" + IconConstants.CRM_LEAD + "\"></span><div class=\"screen-reader-text\">" + AppContext.getMessage(CrmCommonI18nEnum.TAB_LEAD) + "</div>"); relatedLeads.setHtmlContentAllowed(true); relatedLeads.addClickListener(new Button.ClickListener() { private static final long serialVersionUID = 7589415773039335559L; @Override public void buttonClick(ClickEvent arg0) { EventBusFactory.getInstance().post( new AccountEvent.GoToRelatedItems(this, new CrmRelatedItemsScreenData(associateLeads))); } }); toolbarLayout.addComponent(relatedLeads); Button relatedNotes = new Button(); relatedNotes.setCaption("<span aria-hidden=\"true\" data-icon=\"" + IconConstants.CRM_DOCUMENT + "\"></span><div class=\"screen-reader-text\">" + AppContext.getMessage(CrmCommonI18nEnum.TAB_NOTE) + "</div>"); relatedNotes.setHtmlContentAllowed(true); relatedNotes.addClickListener(new Button.ClickListener() { private static final long serialVersionUID = 7589415773039335559L; @Override public void buttonClick(ClickEvent arg0) { EventBusFactory.getInstance().post( new AccountEvent.GoToRelatedItems(this, new CrmRelatedItemsScreenData(associateNotes))); } }); toolbarLayout.addComponent(relatedNotes); Button relatedActivities = new Button(); relatedActivities.setCaption("<span aria-hidden=\"true\" data-icon=\"" + IconConstants.CRM_ACTIVITY + "\"></span><div class=\"screen-reader-text\">" + AppContext.getMessage(CrmCommonI18nEnum.TAB_ACTIVITY) + "</div>"); relatedActivities.setHtmlContentAllowed(true); relatedActivities.addClickListener(new Button.ClickListener() { private static final long serialVersionUID = 7589415773039335559L; @Override public void buttonClick(ClickEvent arg0) { EventBusFactory.getInstance().post(new AccountEvent.GoToRelatedItems(this, new CrmRelatedItemsScreenData(associateActivities))); } }); toolbarLayout.addComponent(relatedActivities); return toolbarLayout; }