List of usage examples for com.vaadin.ui Button addClickListener
public Registration addClickListener(ClickListener listener)
From source file:com.mycompany.project.components.NewContactForm.java
public NewContactForm() { VerticalLayout mainVLayout = new VerticalLayout(); mainVLayout.setMargin(true);/*from w w w . j a va 2 s. c om*/ mainVLayout.setSpacing(true); mainVLayout.addStyleName(boostrap.Forms.FORM.styleName()); setContent(mainVLayout); // field properties tfName.setSizeFull(); tfPhone.setSizeFull(); tfemail.setSizeFull(); tfName.focus(); mainVLayout.addComponent(tfName); mainVLayout.addComponent(tfPhone); mainVLayout.addComponent(tfemail); Button btnSave = new Button("Guardar"); mainVLayout.addComponent(btnSave); btnSave.addClickListener(new ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { // get hold of the business logic String name = tfName.getValue(); String phone = tfPhone.getValue(); String email = tfemail.getValue(); BusinessLogic bl = ((MyVaadinUI) getUI()).getBusinessLogic(); String newContactId = bl.saveNewContact(name, phone, email); if (newContactId != null) { //saved successfully Notification.show("Success", name + " saved", Notification.Type.TRAY_NOTIFICATION); //reset fields resetFields(); } else { //something bad happened Notification.show("Error", "\nContact could not be saved", Notification.Type.ERROR_MESSAGE); } } }); }
From source file:com.mycompany.project.components.NewGroupForm.java
public NewGroupForm() { VerticalLayout mainVLayout = new VerticalLayout(); mainVLayout.setMargin(true);/* w ww . j a v a 2 s . co m*/ mainVLayout.setSpacing(true); setContent(mainVLayout); // field properties tfName.setSizeFull(); mainVLayout.addComponent(tfName); Button btnSave = new Button("Save"); mainVLayout.addComponent(btnSave); btnSave.addClickListener(new ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { // get hold of the business logic String name = tfName.getValue(); BusinessLogic bl = ((MyVaadinUI) getUI()).getBusinessLogic(); String newGroupId = bl.saveNewGroup(name); if (newGroupId != null) { //saved successfully Notification.show("Success", name + " saved", Notification.Type.TRAY_NOTIFICATION); resetFields(); } else { //something bad happened Notification.show("Error", "\nGroup could not be saved", Notification.Type.ERROR_MESSAGE); } } }); }
From source file:com.mycompany.project.views.ContactsView.java
public ContactsView() { VerticalLayout mainVLayout = new VerticalLayout(); mainVLayout.setMargin(true);/*w w w .j a va2s . c om*/ mainVLayout.setSpacing(true); setContent(mainVLayout); // view header Label header = new Label("<div align=\"center\" style=\"font-size:12pt;\">Contactos</div>"); header.setContentMode(ContentMode.HTML); mainVLayout.addComponent(header); // set window properties window.setWidth("400px"); window.setCaption("Nuevo Contacto"); window.setModal(true); window.setContent(newContactForm); // add new cotact button Button btnNew = new Button("Agregar Nuevo Contacto"); mainVLayout.addComponent(btnNew); // clicking the button should display the NewContactForm btnNew.addClickListener(new ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { if (window.getParent() == null) { getUI().addWindow(window); } } }); //add a horozontal layout - left has a table, right has a ContactDetail component HorizontalLayout hLayout = new HorizontalLayout(); hLayout.setSizeFull(); hLayout.setSpacing(true); mainVLayout.addComponent(hLayout); //add a table table.setWidth("600px"); table.setImmediate(true); hLayout.addComponent(table); // how does table get its data beanContainer.setBeanIdProperty("id"); table.setContainerDataSource(beanContainer); //set columns final Object[] NATURAL_COL_ORDER = new Object[] { "name", "phone", "email" }; final String[] COL_HEADERS_ENGLISH = new String[] { "Name", "Phone", "Email" }; table.setSelectable(true); table.setColumnCollapsingAllowed(true); table.setRowHeaderMode(RowHeaderMode.INDEX); table.setVisibleColumns(NATURAL_COL_ORDER); table.setColumnHeaders(COL_HEADERS_ENGLISH); // selecting a table row should enable/disale the ContactDetails component table.addValueChangeListener(new ValueChangeListener() { @Override public void valueChange(Property.ValueChangeEvent event) { String contactId = (String) table.getValue(); contactDetails.setContactId(contactId); } }); //add a ContactDetails component // contactDetails.setWidth("500px"); hLayout.addComponent(contactDetails); // let the table fill the entire remaining width hLayout.setExpandRatio(contactDetails, 1); }
From source file:com.mycompany.project.views.GroupsView.java
public GroupsView() { VerticalLayout mainVLayout = new VerticalLayout(); mainVLayout.setMargin(true);//from w w w .j a v a 2s.c o m mainVLayout.setSpacing(true); setContent(mainVLayout); // view header Label header = new Label("<div align=\"center\" style=\"font-size:12pt;\">Grupos</div>"); header.setContentMode(ContentMode.HTML); mainVLayout.addComponent(header); // set window properties window.setWidth("400px"); window.setCaption("New Group"); window.setModal(true); window.setContent(newGroupForm); // add new cotact button Button btnNew = new Button("Add New Group"); mainVLayout.addComponent(btnNew); // clicking the button should display the NewContactForm btnNew.addClickListener(new ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { if (window.getParent() == null) { getUI().addWindow(window); } } }); //add a horozontal layout - left has a table, right has a ContactDetail component HorizontalLayout hLayout = new HorizontalLayout(); hLayout.setSizeFull(); hLayout.setSpacing(true); mainVLayout.addComponent(hLayout); //add a table table.setWidth("600px"); table.setImmediate(true); hLayout.addComponent(table); // how does table get its data beanContainer.setBeanIdProperty("id"); table.setContainerDataSource(beanContainer); //set columns final Object[] NATURAL_COL_ORDER = new Object[] { "name" }; final String[] COL_HEADERS_ENGLISH = new String[] { "Name" }; table.setSelectable(true); table.setColumnCollapsingAllowed(true); table.setRowHeaderMode(RowHeaderMode.INDEX); table.setVisibleColumns(NATURAL_COL_ORDER); table.setColumnHeaders(COL_HEADERS_ENGLISH); // selecting a table row should enable/disale the ContactDetails component table.addValueChangeListener(new ValueChangeListener() { @Override public void valueChange(Property.ValueChangeEvent event) { String groupId = (String) table.getValue(); groupDetails.setGroupId(groupId); } }); //add a ContactDetails component // contactDetails.setWidth("500px"); hLayout.addComponent(groupDetails); // let the table fill the entire remaining width hLayout.setExpandRatio(groupDetails, 1); }
From source file:com.mycompany.views.FirstView.java
public FirstView(final Navigator nav) { Label l = new Label("This is the first view in Navigator"); Button btn = new Button("Using this you can go to next page"); btn.addClickListener(new Button.ClickListener() { @Override/*from ww w .j a v a 2s .c o m*/ public void buttonClick(Button.ClickEvent event) { nav.navigateTo(SecondView.NAME); } }); this.addComponent(l); this.addComponent(btn); }
From source file:com.mycompany.views.SecondView.java
public SecondView(final Navigator nav) { Label l = new Label("This is the second view in Navigator"); Button btn = new Button("Using this you can go back"); btn.addClickListener(new Button.ClickListener() { @Override//from w ww.java2 s . com public void buttonClick(Button.ClickEvent event) { nav.navigateTo(FirstView.NAME); } }); this.addComponent(l); this.addComponent(btn); }
From source file:com.naoset.framework.frontend.component.profile.CustomerEditWindowView.java
private Component builtButton() { HorizontalLayout hLayout = new HorizontalLayout(); Button bSave = new Button("Guardar"); Button bCancel = new Button("Cancelar"); bSave.addStyleName(ValoTheme.BUTTON_PRIMARY); bSave.addClickListener(new Button.ClickListener() { @Override/*from w ww . ja va2s.c om*/ public void buttonClick(Button.ClickEvent event) { } }); hLayout.addComponent(bSave); hLayout.addComponent(bCancel); return hLayout; }
From source file:com.naoset.framework.frontend.view.window.DialogWindow.java
public void setFooterButtons(DialogButton... buttons) { footer.removeAllComponents();/*from w ww. j a v a2s .c o m*/ HorizontalLayout innerLayout = new HorizontalLayout(); innerLayout.setSpacing(true); footer.addComponent(innerLayout); footer.setComponentAlignment(innerLayout, Alignment.TOP_RIGHT); for (DialogButton button : buttons) { Button btn = new Button(); if (button.equals(DialogButton.OK)) { btn.setCaption("OK"); btn.addStyleName(ValoTheme.BUTTON_PRIMARY); btn.addClickListener(new Button.ClickListener() { @Override public void buttonClick(final Button.ClickEvent event) { onButtonOKClicked(); } }); okButton = btn; } if (button.equals(DialogButton.CANCEL)) { btn.setCaption("CANCEL"); btn.addStyleName(ValoTheme.BUTTON_PRIMARY); btn.addClickListener(new Button.ClickListener() { @Override public void buttonClick(final Button.ClickEvent event) { onButtonCancelClicked(); } }); cancelButton = btn; } if (button.equals(DialogButton.YES)) { btn.setCaption("YES"); btn.addStyleName(ValoTheme.BUTTON_PRIMARY); btn.addClickListener(new Button.ClickListener() { @Override public void buttonClick(final Button.ClickEvent event) { onButtonYesClicked(); } }); yesButton = btn; } if (button.equals(DialogButton.NO)) { btn.setCaption("NO"); btn.addStyleName(ValoTheme.BUTTON_PRIMARY); btn.addClickListener(new Button.ClickListener() { @Override public void buttonClick(final Button.ClickEvent event) { onButtonNoClicked(); } }); noButton = btn; } if (button.equals(DialogButton.CLOSE)) { btn.setCaption("CLOSE"); btn.addStyleName(ValoTheme.BUTTON_PRIMARY); btn.addClickListener(new Button.ClickListener() { @Override public void buttonClick(final Button.ClickEvent event) { onButtonCloseClicked(); } }); closeButton = btn; } innerLayout.addComponent(btn); } }
From source file:com.naoset.framework.frontend.view.window.Window.java
private HorizontalLayout buildFooter() { HorizontalLayout layout = new HorizontalLayout(); layout.addStyleName(ValoTheme.WINDOW_BOTTOM_TOOLBAR); layout.setWidth(100.0f, Unit.PERCENTAGE); //Si el objeto a mostrar hereda de Widget, mostraremos su cabecera con el men en la ventana. if (Widget.class.isInstance(body)) { //if (details.getClass().isInstance(Widget.class)) { Widget aux = (Widget) body;// www. ja v a 2 s. c o m HorizontalLayout header = aux.getHeader(); header.setWidth(100.0f, Unit.PERCENTAGE); layout.addComponent(header); //layout.setComponentAlignment(header, Alignment.TOP_LEFT); layout.setExpandRatio(header, 1); } Button ok = new Button("Cerrar"); ok.addStyleName(ValoTheme.BUTTON_PRIMARY); ok.addClickListener(new Button.ClickListener() { @Override public void buttonClick(final Button.ClickEvent event) { Boolean canClose = true; if (Widget.class.isInstance(body)) { Widget aux = (Widget) body; canClose = !aux.isModified(); } if (canClose) { close(); } else { buildConfirmCloseDialog(); } } }); ok.focus(); layout.addComponent(ok); layout.setComponentAlignment(ok, Alignment.TOP_RIGHT); return layout; }
From source file:com.neatresults.mgnltweaks.app.status.ConfigStatusViewImpl.java
License:Open Source License
@Override public void build() { Component totalExtends = buildAndBind(ConfigStatusView.EXTENDS_COUNT, translator.translate("neatconfiguration.app.status.extendscount")); Component absoluteExtends = buildAndBind(ConfigStatusView.ABS_EXTENDS_COUNT, translator.translate("neatconfiguration.app.status.absoluteextendscount")); Component relativeExtends = buildAndBind(ConfigStatusView.REL_EXTENDS_COUNT, translator.translate("neatconfiguration.app.status.relativeextendscount")); Component overrideExtends = buildAndBind(ConfigStatusView.OVR_EXTENDS_COUNT, translator.translate("neatconfiguration.app.status.overrideextendscount")); Component unresolvedExtends = buildAndBind(ConfigStatusView.EXTENDS_FAIL_COUNT, translator.translate("neatconfiguration.app.status.extendsfailcount")); Component unresolvedExtendsList = buildAndBindList(ConfigStatusView.EXTENDS_FAIL_LIST, translator.translate("neatconfiguration.app.status.extendsfaillist")); unresolvedExtendsList.addStyleName("neat-extends-list"); // top title//from w ww . j ava2s. c om FormLayout layout = new FormLayout(); Label sectionTitle = new Label(translator.translate("neatconfiguration.app.status.top.title")); sectionTitle.addStyleName("section-title"); layout.addComponent(sectionTitle); root.addSection(layout); // extends layout = new FormLayout(); layout.addComponent( createFieldsetTitle(translator.translate("neatconfiguration.app.status.extends.title"))); layout.addComponent(totalExtends); layout.addComponent(absoluteExtends); layout.addComponent(relativeExtends); layout.addComponent(overrideExtends); layout.addComponent(unresolvedExtends); layout.addComponent(unresolvedExtendsList); root.addSection(layout); // refresh layout = new FormLayout(); Button refreshButton = new Button(translator.translate("neatconfiguration.app.status.refresh.caption")); refreshButton.addStyleName("v-button-smallapp"); refreshButton.addStyleName("commit"); refreshButton.addClickListener(new ClickListener() { @Override public void buttonClick(ClickEvent event) { getListener().refreshData(); refresh(); } }); layout.addComponent(refreshButton); root.addSection(layout); }