List of usage examples for com.vaadin.ui Button.ClickListener Button.ClickListener
Button.ClickListener
From source file:com.esofthead.mycollab.vaadin.web.ui.NotificationComponent.java
License:Open Source License
private Component buildComponentFromNotification(AbstractNotification item) { final MHorizontalLayout wrapper = new MHorizontalLayout(); wrapper.setData(item);/*w w w . j av a2 s .com*/ wrapper.setDefaultComponentAlignment(Alignment.TOP_LEFT); if (item instanceof NewUpdateAvailableNotification) { final NewUpdateAvailableNotification notification = (NewUpdateAvailableNotification) item; Span spanEl = new Span(); spanEl.appendText( AppContext.getMessage(ShellI18nEnum.OPT_HAVING_NEW_VERSION, notification.getVersion())); Label lbl = new Label(FontAwesome.INFO_CIRCLE.getHtml() + " " + spanEl.write(), ContentMode.HTML); lbl.setWidth("100%"); CssLayout lblWrapper = new CssLayout(); lblWrapper.addComponent(lbl); wrapper.addComponent(lblWrapper); wrapper.expand(lblWrapper); if (AppContext.isAdmin()) { Button upgradeBtn = new Button(AppContext.getMessage(ShellI18nEnum.ACTION_UPGRADE), new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { UI.getCurrent().addWindow(new UpgradeConfirmWindow(notification.getVersion(), notification.getManualDownloadLink(), notification.getInstallerFile())); NotificationComponent.this.setPopupVisible(false); } }); upgradeBtn.addStyleName(UIConstants.BUTTON_BLOCK); wrapper.addComponent(upgradeBtn); } } else if (item instanceof RequestUploadAvatarNotification) { wrapper.addComponent(new Label(FontAwesome.EXCLAMATION_TRIANGLE.getHtml() + " " + AppContext.getMessage(ShellI18nEnum.OPT_REQUEST_UPLOAD_AVATAR), ContentMode.HTML)); Button uploadAvatarBtn = new Button(AppContext.getMessage(ShellI18nEnum.ACTION_UPLOAD_AVATAR), new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { EventBusFactory.getInstance() .post(new ShellEvent.GotoUserAccountModule(this, new String[] { "preview" })); NotificationComponent.this.setPopupVisible(false); } }); uploadAvatarBtn.setStyleName(UIConstants.BUTTON_BLOCK); wrapper.add(uploadAvatarBtn); } else if (item instanceof SmtpSetupNotification) { Button smtpBtn = new Button(AppContext.getMessage(GenericI18Enum.ACTION_SETUP), new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent clickEvent) { EventBusFactory.getInstance() .post(new ShellEvent.GotoUserAccountModule(this, new String[] { "setup" })); NotificationComponent.this.setPopupVisible(false); } }); smtpBtn.setStyleName(UIConstants.BUTTON_BLOCK); Label lbl = new Label(FontAwesome.EXCLAMATION_TRIANGLE.getHtml() + " " + AppContext.getMessage(ShellI18nEnum.ERROR_NO_SMTP_SETTING), ContentMode.HTML); MCssLayout lblWrapper = new MCssLayout(lbl); wrapper.with(lblWrapper, smtpBtn).expand(lblWrapper); } else { LOG.error("Do not render notification " + item); } return wrapper; }
From source file:com.esofthead.mycollab.vaadin.web.ui.SavedFilterComboBox.java
License:Open Source License
@Override protected Component initContent() { componentsText = new TextField(); componentsText.setNullRepresentation(""); componentsText.setReadOnly(true);/*from w w w . j a v a2 s . c om*/ componentsText.addStyleName("noBorderRight"); componentsText.setWidth("100%"); componentPopupSelection = new PopupButton(); componentPopupSelection.addStyleName(UIConstants.MULTI_SELECT_BG); componentPopupSelection.setDirection(Alignment.TOP_LEFT); componentPopupSelection.addClickListener(new Button.ClickListener() { private static final long serialVersionUID = 1L; @Override public void buttonClick(final Button.ClickEvent event) { SavedFilterComboBox.this.initContentPopup(); } }); popupContent = new OptionPopupContent(); componentPopupSelection.setContent(popupContent); MHorizontalLayout content = new MHorizontalLayout().withSpacing(true).with(componentsText) .withAlign(componentsText, Alignment.MIDDLE_LEFT); MHorizontalLayout multiSelectComp = new MHorizontalLayout().withSpacing(false) .with(componentsText, componentPopupSelection).expand(componentsText); content.with(multiSelectComp); return content; }
From source file:com.esofthead.mycollab.web.AdWindow.java
License:Open Source License
public AdWindow() { super("Buy MyCollab Pro edition"); this.setWidth("700px"); this.setModal(true); this.setResizable(false); RestTemplate restTemplate = new RestTemplate(); MVerticalLayout content = new MVerticalLayout(); try {//ww w .j a v a2 s. c o m String result = restTemplate.getForObject("https://api.mycollab.com/api/storeweb", String.class); Label webPage = new Label(result, ContentMode.HTML); webPage.setHeight("600px"); this.setContent(content.with(webPage).withAlign(webPage, Alignment.TOP_CENTER)); } catch (Exception e) { Div informDiv = new Div() .appendText("Can not load the store page. You can check the online edition at ") .appendChild(new A("https://www.mycollab.com/pricing/download/", "_blank").appendText("here")); Label webPage = new Label(informDiv.write(), ContentMode.HTML); this.setContent(content.with(webPage).withAlign(webPage, Alignment.TOP_CENTER)); } LicenseResolver licenseResolver = AppContextUtil.getSpringBean(LicenseResolver.class); if (licenseResolver != null) { Button editLicenseBtn = new Button("Enter license code", new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent clickEvent) { Window activateWindow = ViewManager.getCacheComponent(AbstractLicenseActivationWindow.class); UI.getCurrent().addWindow(activateWindow); close(); } }); editLicenseBtn.addStyleName(UIConstants.BUTTON_ACTION); content.with(editLicenseBtn).withAlign(editLicenseBtn, Alignment.MIDDLE_CENTER); } }
From source file:com.esofthead.mycollab.web.BuyPremiumSoftwareWindow.java
License:Open Source License
public BuyPremiumSoftwareWindow() { super("Buy MyCollab Pro edition"); this.setWidth("700px"); this.setModal(true); this.setResizable(false); RestTemplate restTemplate = new RestTemplate(); MVerticalLayout content = new MVerticalLayout(); try {/*from w ww .j av a2 s .c o m*/ String result = restTemplate.getForObject("https://api.mycollab.com/api/linktobuy", String.class); Label webPage = new Label(result, ContentMode.HTML); webPage.setHeight("600px"); this.setContent(content.with(webPage).withAlign(webPage, Alignment.TOP_CENTER)); } catch (Exception e) { String result = FileUtils.readFileAsPlainString("buying.html"); Label webPage = new Label(result, ContentMode.HTML); this.setContent(content.with(webPage).withAlign(webPage, Alignment.TOP_CENTER)); } LicenseResolver licenseResolver = AppContextUtil.getSpringBean(LicenseResolver.class); if (licenseResolver != null) { Button editLicenseBtn = new Button("Enter license code", new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent clickEvent) { Window activateWindow = ViewManager.getCacheComponent(AbstractLicenseActivationWindow.class); UI.getCurrent().addWindow(activateWindow); close(); } }); editLicenseBtn.addStyleName(UIConstants.BUTTON_ACTION); content.with(editLicenseBtn).withAlign(editLicenseBtn, Alignment.MIDDLE_CENTER); } }
From source file:com.example.BasicMongoDemo.java
License:Apache License
protected void initButtons() { disable(btnEdit, btnRemove);/*w w w .j ava 2 s . c o m*/ btnRemove.addClickListener(new Button.ClickListener() { public void buttonClick(Button.ClickEvent event) { Object id = table.getValue(); int index = mongoContainer.indexOfId(id); table.removeItem(id); table.select(mongoContainer.getIdByIndex(index)); } }); btnEdit.addClickListener(new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { Object id = table.getValue(); BeanItem<Person> item = mongoContainer.getItem(id); EditingWindow w = new BasicEditingWindow(item, mongoOperations, table); UI.getCurrent().addWindow(w); } }); btnAdd.addClickListener(new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { BeanItem<Person> beanItem = new BeanItem<Person>(new Person(), "firstName", "lastName"); beanItem.addNestedProperty("address.street"); beanItem.addNestedProperty("address.zipCode"); beanItem.addNestedProperty("address.city"); beanItem.addNestedProperty("address.state"); EditingWindow w = new BasicEditingWindow(beanItem, mongoOperations, table); UI.getCurrent().addWindow(w); } }); table.addValueChangeListener(new Property.ValueChangeListener() { @Override public void valueChange(Property.ValueChangeEvent event) { if (null == event.getProperty().getValue()) { disable(btnEdit, btnRemove); } else { enable(btnEdit, btnRemove); } } }); }
From source file:com.example.BufferedMongoDemo.java
License:Apache License
@Override protected void initButtons() { disable(btnEdit, btnRemove);//from w ww . j a va 2s. co m btnRemove.addClickListener(new Button.ClickListener() { public void buttonClick(Button.ClickEvent event) { Object id = table.getValue(); table.removeItem(id); } }); btnEdit.addClickListener(new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { Object id = table.getValue(); BeanItem<Person> item = mongoContainer.getItem(id); EditingWindow w = new BufferedEditingWindow((ObjectId) id, item, mongoOperations, mongoContainer, table); UI.getCurrent().addWindow(w); } }); btnAdd.addClickListener(new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { ObjectId objectId = mongoContainer.addItem(); BeanItem<Person> item = mongoContainer.getItem(objectId); EditingWindow w = new BufferedEditingWindow(objectId, item, mongoOperations, mongoContainer, table); UI.getCurrent().addWindow(w); } }); table.addValueChangeListener(new Property.ValueChangeListener() { @Override public void valueChange(Property.ValueChangeEvent event) { if (null == event.getProperty().getValue()) { disable(btnEdit, btnRemove); } else { enable(btnEdit, btnRemove); } } }); btnCommit.addClickListener(new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { // table.commit(); mongoContainer.commit(); Object id = table.getValue(); if (id != null && !table.getVisibleItemIds().contains(id)) { table.setCurrentPageFirstItemId(id); } msgCommit.show(UI.getCurrent().getPage()); } }); btnDiscard.addClickListener(new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { mongoContainer.discard(); msgDiscard.show(UI.getCurrent().getPage()); } }); }
From source file:com.example.EditingWindow.java
License:Apache License
public EditingWindow(final BeanItem<Person> item, final MongoOperations mongoOperations, final Table table) { super("Edit"); this.mongoOperations = mongoOperations; this.table = table; center();/*from w w w .j av a2s .com*/ setWidth("400px"); setResizable(false); this.beanItem = item; this.person = item.getBean(); this.layout = new VerticalLayout(); this.layout.setMargin(true); this.fieldGroup = new BeanFieldGroup<Person>(Person.class); this.layout.addComponent(makeFormLayout(fieldGroup, item)); this.layout.addComponent(makeFooter()); this.setContent(this.layout); this.btnCancel.addClickListener(new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { EditingWindow.this.close(); } }); this.btnOK.addClickListener(new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { onOKButtonClick(); } }); }
From source file:com.expressui.core.view.form.TypedForm.java
License:Open Source License
/** * Makes the component collapsible by wrapping it with a layout and button for toggling * the component's visibility. This allows the user to expand/collapse the given component in order * to free space for viewing other components. * * @param component component to show/hide * @param useVerticalLayout true if toggle button should be laid out vertically next to animated component * @return the newly created layout that contains the toggle button and animated component *//*from ww w .ja va2 s . com*/ protected Component makeCollapsible(String caption, Component component, boolean useVerticalLayout) { formAnimator = new Animator(component); formAnimator.setSizeUndefined(); AbstractOrderedLayout animatorLayout; if (useVerticalLayout) { animatorLayout = new VerticalLayout(); } else { animatorLayout = new HorizontalLayout(); } setDebugId(animatorLayout, "animatorLayout"); animatorLayout.setMargin(false, false, false, false); animatorLayout.setSpacing(false); toggleFormCollapseButton = new Button(null, new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { setFormVisible(!isFormVisible()); } }); toggleFormCollapseButton.setDescription(uiMessageSource.getToolTip("typedForm.toggleSearchForm.toolTip")); toggleFormCollapseButton.setIcon(new ThemeResource("../expressui/icons/collapse-icon.png")); toggleFormCollapseButton.addStyleName("borderless"); if (useVerticalLayout) { HorizontalLayout toggleFormButtonAndCaption = new HorizontalLayout(); setDebugId(toggleFormButtonAndCaption, "toggleFormButtonAndCaption"); toggleFormButtonAndCaption.setSizeUndefined(); toggleFormButtonAndCaption.addComponent(toggleFormCollapseButton); Label label = new Label(caption); label.setSizeUndefined(); toggleFormButtonAndCaption.addComponent(label); animatorLayout.addComponent(toggleFormButtonAndCaption); animatorLayout.addComponent(formAnimator); } else { animatorLayout.addComponent(toggleFormCollapseButton); animatorLayout.addComponent(formAnimator); } return animatorLayout; }
From source file:com.expressui.core.view.util.CodePopup.java
License:Open Source License
/** * Creates a popup code button./*from www.j ava 2s . c om*/ * * @param classes classes for displaying related source code and Javadoc. If * class is within com.expressui.core or com.expressui.domain, * then Javadoc is displayed, otherwise source code. * @return popup code button */ public Button createPopupCodeButton(final Class... classes) { Button codeButton = new Button(null, new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { open(classes); } }); codeButton.setIcon(new ThemeResource("../expressui/icons/32/java.png")); codeButton.setStyleName(BaseTheme.BUTTON_LINK); codeButton.setDescription(uiMessageSource.getToolTip("codePopup.toolTip")); return codeButton; }
From source file:com.garyclayburg.vconsole.VConsole.java
License:Open Source License
private void createNotifyButton() { notify = new Button(); notify.setDescription("No errors in policy"); // notify.addStyleName("borderless"); notify.addStyleName("notifications"); notify.addStyleName("unread"); notify.addStyleName("icon-only"); notify.addStyleName("icon-bell"); notify.addClickListener(new Button.ClickListener() { @Override/* ww w.ja va 2 s .co m*/ public void buttonClick(Button.ClickEvent event) { log.info("clicked on notifications"); if (notifications.getUI() != null) { notifications.close(); log.debug("closed notifications"); } else { buildNotifications(event); getUI().addWindow(notifications); notifications.focus(); ((VerticalLayout) getUI().getContent()) .addLayoutClickListener(new LayoutEvents.LayoutClickListener() { @Override public void layoutClick(LayoutEvents.LayoutClickEvent event) { notifications.close(); ((VerticalLayout) getUI().getContent()).removeLayoutClickListener(this); } }); } } }); }