List of usage examples for com.vaadin.ui Button addClickListener
public Registration addClickListener(ClickListener listener)
From source file:com.esofthead.mycollab.shell.view.MainView.java
License:Open Source License
private CustomLayout createFooter() { final CustomLayout footer = CustomLayoutExt.createLayout("footer"); Link companyLink = new Link("eSoftHead", new ExternalResource("http://www.esofthead.com")); companyLink.setTargetName("_blank"); footer.addComponent(companyLink, "company-url"); Calendar currentCal = Calendar.getInstance(); Label currentYear = new Label(String.valueOf(currentCal.get(Calendar.YEAR))); currentYear.setSizeUndefined();/*from w w w.ja va2s . c o m*/ footer.addComponent(currentYear, "current-year"); HorizontalLayout footerRight = new HorizontalLayout(); footerRight.setSpacing(true); final Button sendFeedback = new Button("Feedback"); sendFeedback.setStyleName("link"); sendFeedback.addClickListener(new ClickListener() { private static final long serialVersionUID = 1L; @Override public void buttonClick(final ClickEvent event) { UI.getCurrent().addWindow(new FeedbackWindow()); } }); Link blogLink = new Link("Blog", new ExternalResource("https://www.mycollab.com/blog")); blogLink.setTargetName("_blank"); Link forumLink = new Link("Forum", new ExternalResource("http://forum.mycollab.com")); forumLink.setTargetName("_blank"); Link wikiLink = new Link("Knowledge Base", new ExternalResource("https://www.mycollab.com/help/")); wikiLink.setTargetName("_blank"); footerRight.addComponent(blogLink); footerRight.addComponent(forumLink); footerRight.addComponent(wikiLink); footerRight.addComponent(sendFeedback); footer.addComponent(footerRight, "footer-right"); return footer; }
From source file:com.esofthead.mycollab.shell.view.MainView.java
License:Open Source License
private CustomLayout createTopMenu() { final CustomLayout layout = CustomLayoutExt.createLayout("topNavigation"); layout.setStyleName("topNavigation"); layout.setHeight("40px"); layout.setWidth("100%"); Button accountLogo = AccountLogoFactory .createAccountLogoImageComponent(ThemeManager.loadLogoPath(AppContext.getAccountId()), 150); accountLogo.addClickListener(new ClickListener() { private static final long serialVersionUID = 1L; @Override//from w w w . ja va 2 s.c o m public void buttonClick(final ClickEvent event) { final UserPreference pref = AppContext.getUserPreference(); if (pref.getLastmodulevisit() == null || ModuleNameConstants.PRJ.equals(pref.getLastmodulevisit())) { EventBusFactory.getInstance().post(new ShellEvent.GotoProjectModule(this, null)); } else if (ModuleNameConstants.CRM.equals(pref.getLastmodulevisit())) { EventBusFactory.getInstance().post(new ShellEvent.GotoCrmModule(this, null)); } else if (ModuleNameConstants.ACCOUNT.equals(pref.getLastmodulevisit())) { EventBusFactory.getInstance().post(new ShellEvent.GotoUserAccountModule(this, null)); } else if (ModuleNameConstants.FILE.equals(pref.getLastmodulevisit())) { EventBusFactory.getInstance().post(new ShellEvent.GotoFileModule(this, null)); } } }); layout.addComponent(accountLogo, "mainLogo"); serviceMenu = new ServiceMenu(); serviceMenu.addStyleName("topNavPopup"); serviceMenu.addService(AppContext.getMessage(GenericI18Enum.MODULE_CRM), MyCollabResource.newResource(WebResourceIds._16_customer), new Button.ClickListener() { private static final long serialVersionUID = 1L; @Override public void buttonClick(final ClickEvent event) { EventBusFactory.getInstance().post(new ShellEvent.GotoCrmModule(this, null)); } }); serviceMenu.addService(AppContext.getMessage(GenericI18Enum.MODULE_PROJECT), MyCollabResource.newResource(WebResourceIds._16_project), new Button.ClickListener() { private static final long serialVersionUID = 1L; @Override public void buttonClick(final ClickEvent event) { if (!event.isCtrlKey() && !event.isMetaKey()) { EventBusFactory.getInstance().post(new ShellEvent.GotoProjectModule(this, null)); } } }); serviceMenu.addService(AppContext.getMessage(GenericI18Enum.MODULE_DOCUMENT), MyCollabResource.newResource(WebResourceIds._16_document), new Button.ClickListener() { private static final long serialVersionUID = 1L; @Override public void buttonClick(final ClickEvent event) { EventBusFactory.getInstance().post(new ShellEvent.GotoFileModule(this, null)); } }); serviceMenu.addService(AppContext.getMessage(GenericI18Enum.MODULE_PEOPLE), MyCollabResource.newResource(WebResourceIds._16_account), new Button.ClickListener() { private static final long serialVersionUID = 1L; @Override public void buttonClick(final ClickEvent event) { EventBusFactory.getInstance() .post(new ShellEvent.GotoUserAccountModule(this, new String[] { "user", "list" })); } }); layout.addComponent(serviceMenu, "serviceMenu"); final MHorizontalLayout accountLayout = new MHorizontalLayout() .withMargin(new MarginInfo(false, true, false, false)); accountLayout.setDefaultComponentAlignment(Alignment.MIDDLE_LEFT); final Label accountNameLabel = new Label(AppContext.getSubDomain()); accountNameLabel.setStyleName("subdomain"); accountLayout.addComponent(accountNameLabel); // display trial box if user in trial mode SimpleBillingAccount billingAccount = AppContext.getBillingAccount(); if (AccountStatusConstants.TRIAL.equals(billingAccount.getStatus())) { Label informLbl = new Label("", ContentMode.HTML); informLbl.addStyleName("trialEndingNotification"); informLbl.setHeight("100%"); HorizontalLayout informBox = new HorizontalLayout(); informBox.addStyleName("trialInformBox"); informBox.setSizeFull(); informBox.addComponent(informLbl); informBox.setMargin(new MarginInfo(false, true, false, false)); informBox.addLayoutClickListener(new LayoutEvents.LayoutClickListener() { private static final long serialVersionUID = 1L; @Override public void layoutClick(LayoutClickEvent event) { EventBusFactory.getInstance() .post(new ShellEvent.GotoUserAccountModule(this, new String[] { "billing" })); } }); accountLayout.addComponent(informBox); accountLayout.setSpacing(true); accountLayout.setComponentAlignment(informBox, Alignment.MIDDLE_LEFT); Date createdTime = billingAccount.getCreatedtime(); long timeDeviation = System.currentTimeMillis() - createdTime.getTime(); int daysLeft = (int) Math.floor(timeDeviation / (1000 * 60 * 60 * 24)); if (daysLeft > 30) { BillingService billingService = ApplicationContextUtil.getSpringBean(BillingService.class); BillingPlan freeBillingPlan = billingService.getFreeBillingPlan(); billingAccount.setBillingPlan(freeBillingPlan); informLbl.setValue("<div class='informBlock'>TRIAL ENDING<br>" + " 0 DAYS LEFT</div><div class='informBlock'>>></div>"); } else { if (AppContext.isAdmin()) { informLbl.setValue("<div class='informBlock'>TRIAL ENDING<br>" + (30 - daysLeft) + " DAYS LEFT</div><div class='informBlock'>>></div>"); } else { informLbl.setValue("<div class='informBlock'>TRIAL ENDING<br>" + (30 - daysLeft) + " DAYS LEFT</div><div class='informBlock'>>></div>"); } } } NotificationButton notificationButton = new NotificationButton(); accountLayout.addComponent(notificationButton); if (AppContext.getSession().getTimezone() == null) { EventBusFactory.getInstance().post(new ShellEvent.NewNotification(this, new TimezoneNotification())); } if (StringUtils.isBlank(AppContext.getSession().getAvatarid())) { EventBusFactory.getInstance() .post(new ShellEvent.NewNotification(this, new RequestUploadAvatarNotification())); } if (SiteConfiguration.getDeploymentMode() != DeploymentMode.site && AppContext.isAdmin()) { try { Client client = ClientBuilder.newBuilder().build(); WebTarget target = client.target("https://api.mycollab.com/api/checkupdate"); Response response = target.request().get(); String values = response.readEntity(String.class); Gson gson = new Gson(); Properties props = gson.fromJson(values, Properties.class); String version = props.getProperty("version"); if (!MyCollabVersion.getVersion().equals(version)) { EventBusFactory.getInstance() .post(new ShellEvent.NewNotification(this, new NewUpdateNotification(props))); } } catch (Exception e) { LOG.error("Error when call remote api", e); } } UserAvatarComp userAvatar = new UserAvatarComp(); accountLayout.addComponent(userAvatar); accountLayout.setComponentAlignment(userAvatar, Alignment.MIDDLE_LEFT); final PopupButton accountMenu = new PopupButton(AppContext.getSession().getDisplayName()); final VerticalLayout accLayout = new VerticalLayout(); accLayout.setWidth("140px"); final Button myProfileBtn = new Button(AppContext.getMessage(AdminI18nEnum.VIEW_PROFILE), new Button.ClickListener() { private static final long serialVersionUID = 1L; @Override public void buttonClick(final ClickEvent event) { accountMenu.setPopupVisible(false); EventBusFactory.getInstance() .post(new ShellEvent.GotoUserAccountModule(this, new String[] { "preview" })); } }); myProfileBtn.setIcon(SettingAssetsManager.getAsset(SettingUIConstants.PROFILE)); myProfileBtn.setStyleName("link"); accLayout.addComponent(myProfileBtn); final Button myAccountBtn = new Button(AppContext.getMessage(AdminI18nEnum.VIEW_BILLING), new Button.ClickListener() { private static final long serialVersionUID = 1L; @Override public void buttonClick(final ClickEvent event) { accountMenu.setPopupVisible(false); EventBusFactory.getInstance() .post(new ShellEvent.GotoUserAccountModule(this, new String[] { "billing" })); } }); myAccountBtn.setStyleName("link"); myAccountBtn.setIcon(SettingAssetsManager.getAsset(SettingUIConstants.BILLING)); accLayout.addComponent(myAccountBtn); final Button userMgtBtn = new Button(AppContext.getMessage(AdminI18nEnum.VIEW_USERS_AND_ROLES), new Button.ClickListener() { private static final long serialVersionUID = 1L; @Override public void buttonClick(final ClickEvent event) { accountMenu.setPopupVisible(false); EventBusFactory.getInstance() .post(new ShellEvent.GotoUserAccountModule(this, new String[] { "user", "list" })); } }); userMgtBtn.setStyleName("link"); userMgtBtn.setIcon(SettingAssetsManager.getAsset(SettingUIConstants.USERS)); accLayout.addComponent(userMgtBtn); final Button signoutBtn = new Button(AppContext.getMessage(GenericI18Enum.BUTTON_SIGNOUT), new Button.ClickListener() { private static final long serialVersionUID = 1L; @Override public void buttonClick(final ClickEvent event) { AppContext.getInstance().clearSession(); EventBusFactory.getInstance().post(new ShellEvent.LogOut(this, null)); } }); signoutBtn.setStyleName("link"); signoutBtn.setIcon(FontAwesome.SIGN_OUT); accLayout.addComponent(signoutBtn); accountMenu.setContent(accLayout); accountMenu.setStyleName("accountMenu"); accountMenu.addStyleName("topNavPopup"); accountLayout.addComponent(accountMenu); layout.addComponent(accountLayout, "accountMenu"); return layout; }
From source file:com.esofthead.mycollab.vaadin.ui.CommonUIFactory.java
License:Open Source License
public static Button createButtonTooltip(String caption, String description, Button.ClickListener listener) { Button btn = new Button(caption); btn.setDescription(description);/*w ww. jav a 2s . c o m*/ btn.addClickListener(listener); return btn; }
From source file:com.esofthead.mycollab.vaadin.ui.ProjectPreviewFormControlsGenerator.java
License:Open Source License
public void addOptionButton(Button button) { button.setStyleName(UIConstants.THEME_LINK); button.addClickListener(new Button.ClickListener() { private static final long serialVersionUID = 2710916670115028630L; @Override/*from ww w. jav a2 s .co m*/ public void buttonClick(ClickEvent event) { optionBtn.setPopupVisible(false); } }); popupButtonsControl.addComponent(button); }
From source file:com.esofthead.mycollab.vaadin.ui.ToggleButtonGroup.java
License:Open Source License
@Override public Button addButton(Button button) { super.addButton(button); button.addClickListener(new Button.ClickListener() { private static final long serialVersionUID = -411946964127842982L; @Override// w ww . j a va 2s . c om public void buttonClick(Button.ClickEvent event) { if (!event.getButton().equals(selectedBtn)) { selectedBtn = event.getButton(); Iterator<Component> iterator = ToggleButtonGroup.this.iterator(); while (iterator.hasNext()) { iterator.next().removeStyleName(UIConstants.BTN_ACTIVE); } selectedBtn.addStyleName(UIConstants.BTN_ACTIVE); } } }); return button; }
From source file:com.esofthead.mycollab.vaadin.web.ui.ProjectPreviewFormControlsGenerator.java
License:Open Source License
public void addOptionButton(Button button) { button.addClickListener(new Button.ClickListener() { private static final long serialVersionUID = 2710916670115028630L; @Override// w w w. ja v a2s . c o m public void buttonClick(ClickEvent event) { optionBtn.setPopupVisible(false); } }); popupButtonsControl.addOption(button); }
From source file:com.esofthead.mycollab.vaadin.web.ui.SplitButton.java
License:Open Source License
public SplitButton(Button parentButton) { this.setImmediate(true); HorizontalLayout contentLayout = new HorizontalLayout(); contentLayout.setStyleName("splitbutton"); this.parentButton = parentButton; parentButton.addStyleName("parent-button"); parentButton.setImmediate(true);/* w w w . jav a 2s. co m*/ parentButton.addClickListener(new ClickListener() { private static final long serialVersionUID = 1L; @Override public void buttonClick(ClickEvent event) { fireEvent(new SplitButtonClickEvent(SplitButton.this)); } }); popupButton = new PopupButton(); popupButton.addClickListener(new ClickListener() { private static final long serialVersionUID = 1L; @Override public void buttonClick(ClickEvent event) { isPopupVisible = !isPopupVisible; fireEvent(new SplitButtonPopupVisibilityEvent(SplitButton.this, isPopupVisible)); } }); contentLayout.addComponent(parentButton); contentLayout.addComponent(popupButton); this.setCompositionRoot(contentLayout); }
From source file:com.esofthead.mycollab.vaadin.web.ui.ToggleButtonGroup.java
License:Open Source License
@Override public Button addButton(Button button) { super.addButton(button); button.addClickListener(new Button.ClickListener() { private static final long serialVersionUID = -411946964127842982L; @Override//from ww w .ja v a2 s .c om public void buttonClick(Button.ClickEvent event) { if (!event.getButton().equals(selectedBtn)) { selectedBtn = event.getButton(); Iterator<Component> iterator = ToggleButtonGroup.this.iterator(); while (iterator.hasNext()) { iterator.next().removeStyleName(UIConstants.BTN_ACTIVE); } selectedBtn.addStyleName(UIConstants.BTN_ACTIVE); } } }); return button; }
From source file:com.etest.valo.CommonParts.java
License:Apache License
Panel loadingIndicators() { Panel p = new Panel("Loading Indicator"); final VerticalLayout content = new VerticalLayout(); p.setContent(content);/*from www . j a v a 2 s. com*/ content.setSpacing(true); content.setMargin(true); content.addComponent(new Label("You can test the loading indicator by pressing the buttons.")); CssLayout group = new CssLayout(); group.setCaption("Show the loading indicator for"); group.addStyleName("v-component-group"); content.addComponent(group); Button loading = new Button("0.8"); loading.addClickListener(new ClickListener() { @Override public void buttonClick(final ClickEvent event) { try { Thread.sleep(800); } catch (InterruptedException e) { } } }); group.addComponent(loading); Button delay = new Button("3"); delay.addClickListener(new ClickListener() { @Override public void buttonClick(final ClickEvent event) { try { Thread.sleep(3000); } catch (InterruptedException e) { } } }); group.addComponent(delay); Button wait = new Button("15"); wait.addClickListener(new ClickListener() { @Override public void buttonClick(final ClickEvent event) { try { Thread.sleep(15000); } catch (InterruptedException e) { } } }); wait.addStyleName("last"); group.addComponent(wait); Label label = new Label(" seconds", ContentMode.HTML); label.setSizeUndefined(); group.addComponent(label); Label spinnerDesc = new Label( "The theme also provides a mixin that you can use to include a spinner anywhere in your application. The button below reveals a Label with a custom style name, for which the spinner mixin is added."); spinnerDesc.addStyleName("small"); spinnerDesc.setCaption("Spinner"); content.addComponent(spinnerDesc); if (!MainUI.isTestMode()) { final Label spinner = new Label(); spinner.addStyleName("spinner"); Button showSpinnerButton = new Button("Show spinner", new ClickListener() { @Override public void buttonClick(final ClickEvent event) { content.replaceComponent(event.getComponent(), spinner); } }); content.addComponent(showSpinnerButton); } return p; }
From source file:com.etest.view.notification.NotificationMainUI.java
public NotificationMainUI() { setSizeFull();//w ww.j a va 2s .co m setSpacing(true); if (VaadinSession.getCurrent().getAttribute("userId") == null) { Page.getCurrent().setLocation("http://localhost:8080/"); } else { addComponent(populateNoficationTable()); } HorizontalLayout h = new HorizontalLayout(); h.setWidth("950px"); Button sendMsgBtn = new Button("Send Message"); sendMsgBtn.setWidthUndefined(); sendMsgBtn.addStyleName(ValoTheme.BUTTON_SMALL); sendMsgBtn.addStyleName(ValoTheme.BUTTON_PRIMARY); sendMsgBtn.addClickListener((Button.ClickEvent event) -> { Notification.show("Send Message!"); }); h.addComponent(sendMsgBtn); h.setComponentAlignment(sendMsgBtn, Alignment.MIDDLE_RIGHT); addComponent(h); }