List of usage examples for com.vaadin.ui Button addClickListener
public Registration addClickListener(ClickListener listener)
From source file:com.github.djabry.platform.vaadin.view.BannerView.java
License:Open Source License
private Button buildLogoutButton() { Button logout = new Button("Sign out"); logout.setIcon(FontAwesome.SIGN_OUT); logout.addStyleName(ValoTheme.BUTTON_PRIMARY); logout.addClickListener(new ClickListener() { public void buttonClick(Button.ClickEvent event) { logoutAction.run();// ww w .ja v a 2s . c o m } }); logout.setVisible(false); return logout; }
From source file:com.github.djabry.platform.vaadin.view.LoginView.java
License:Open Source License
private Component buildFields() { HorizontalLayout fields = new HorizontalLayout(); fields.setSpacing(true);//from w w w.j a va 2 s .co m userField = new TextField("Username"); userField.setIcon(FontAwesome.USER); userField.addStyleName(ValoTheme.TEXTFIELD_INLINE_ICON); //username.addStyleName(ValoTheme.TEXTFIELD_TINY); passwordField = new PasswordField("Password"); passwordField.setIcon(FontAwesome.LOCK); passwordField.addStyleName(ValoTheme.TEXTFIELD_INLINE_ICON); //password.addStyleName(ValoTheme.TEXTFIELD_TINY); final Button signin = new Button("Sign In"); signin.addStyleName(ValoTheme.BUTTON_PRIMARY); signin.setClickShortcut(ShortcutAction.KeyCode.ENTER); //signin.addStyleName(ValoTheme.BUTTON_TINY); signin.focus(); fields.addComponents(userField, passwordField, signin); fields.setComponentAlignment(signin, Alignment.BOTTOM_LEFT); signin.addClickListener(new Button.ClickListener() { @Override public void buttonClick(final Button.ClickEvent event) { loginAction.login(userField.getValue(), passwordField.getValue()); } }); return fields; }
From source file:com.github.fbhd.view.MainView.java
private void createButtons() { buttonLayout = new HorizontalLayout(); buttonLayout.setSpacing(true);/*from w ww . ja v a 2s . com*/ Button btnLogin = new Button("Login"); btnLogin.setStyleName(ValoTheme.BUTTON_PRIMARY); btnLogin.addClickListener((Button.ClickEvent event) -> { doLogin(); }); Button btnCancel = new Button("Cancel"); btnCancel.addClickListener((Button.ClickEvent event) -> { }); buttonLayout.addComponents(btnLogin, btnCancel); mainLayout.addComponent(buttonLayout); }
From source file:com.github.fbhd.view.TicketView.java
private void createButtons() { buttonLayout = new HorizontalLayout(); buttonLayout.setSpacing(true);/* w ww. j a v a2 s . co m*/ Button btnSubmit = new Button("Submit"); btnSubmit.setStyleName(ValoTheme.BUTTON_PRIMARY); btnSubmit.addClickListener((Button.ClickEvent event) -> { persistAndContinue(ConfirmationView.VIEW_NAME); }); Button btnCancel = new Button("Cancel"); btnCancel.addClickListener((Button.ClickEvent event) -> { }); buttonLayout.addComponents(btnSubmit, btnCancel); mainLayout.addComponent(buttonLayout); }
From source file:com.github.tempora.view.MainView.java
License:Apache License
public MainView() { VerticalLayout vlayout = new VerticalLayout(); vlayout.addStyleName("outlined"); vlayout.addStyleName("bg"); vlayout.setSizeFull();//from w ww .ja v a2 s .c om vlayout.setMargin(true); HorizontalLayout hlayout = new HorizontalLayout(); hlayout.addStyleName("outlined"); hlayout.setSizeFull(); setContent(vlayout); // Title Label caption = new Label("Tempora"); caption.setStyleName("logo-label", true); caption.setWidth(null); vlayout.addComponent(caption); vlayout.setExpandRatio(caption, 0.2f); vlayout.setComponentAlignment(caption, Alignment.MIDDLE_CENTER); vlayout.addComponent(hlayout); vlayout.setExpandRatio(hlayout, 0.7f); // // General information about the User's mailbox // final Panel generalInfoPanel = new Panel("<center>General Information</center>"); generalInfoPanel.addStyleName("frame-bg-general-info"); generalInfoPanel.setSizeFull(); this.currentHistoryId = new Label("0"); currentHistoryId.setStyleName("general-info-count", true); currentHistoryId.setCaption("History ID"); this.messagesTotal = new Label("0"); messagesTotal.setStyleName("general-info-count", true); messagesTotal.setCaption("Messages Total"); this.threadsTotal = new Label("0"); threadsTotal.setCaption("Threads Total"); threadsTotal.setStyleName("general-info-count", true); FormLayout mailboxInfoLayout = new FormLayout(messagesTotal, currentHistoryId, threadsTotal); VerticalLayout mailboxInfoMainLayout = new VerticalLayout(mailboxInfoLayout); mailboxInfoMainLayout.setSizeFull(); mailboxInfoMainLayout.setMargin(true); generalInfoPanel.setContent(mailboxInfoMainLayout); // // Stats // final Panel statsPanel = new Panel("<center>Statistics</center>"); statsPanel.addStyleName("frame-bg-stats"); statsPanel.setSizeFull(); this.bodyAvgSize = new Label("0"); bodyAvgSize.setCaption("Body Avg. Size"); bodyAvgSize.setStyleName("stats-count", true); FormLayout statsLayout = new FormLayout(bodyAvgSize); VerticalLayout statsMainLayout = new VerticalLayout(statsLayout); statsMainLayout.setSizeFull(); statsMainLayout.setMargin(true); statsPanel.setContent(statsMainLayout); // // Top 5 // Panel top5Panel = new Panel("<center>Top 5</center>"); top5Panel.addStyleName("frame-bg-top5"); // Top 5 Senders Panel top5SendersPanel = new Panel("<center>Senders</center>"); top5SendersPanel.addStyleName("frame-bg-top5"); top5SendersPanel.setSizeFull(); this.top5Senders = new Label("NO DATA", ContentMode.PREFORMATTED); top5Senders.setSizeUndefined(); top5SendersPanel.setContent(top5Senders); // Top 5 Title Tags Panel top5TitleTagsPanel = new Panel("<center>Title Tags</center>"); top5TitleTagsPanel.addStyleName("frame-bg-top5"); top5TitleTagsPanel.setSizeFull(); this.top5TitleTags = new Label("NO DATA", ContentMode.PREFORMATTED); top5TitleTags.setSizeUndefined(); top5TitleTagsPanel.setContent(top5TitleTags); top5Panel.setSizeFull(); VerticalLayout top5MainLayout = new VerticalLayout(top5SendersPanel, top5TitleTagsPanel); top5MainLayout.setMargin(true); top5MainLayout.setSpacing(true); top5MainLayout.setSizeFull(); top5MainLayout.setComponentAlignment(top5SendersPanel, Alignment.MIDDLE_CENTER); top5MainLayout.setComponentAlignment(top5TitleTagsPanel, Alignment.MIDDLE_CENTER); top5Panel.setContent(top5MainLayout); hlayout.setSpacing(true); hlayout.addComponent(generalInfoPanel); hlayout.addComponent(statsPanel); hlayout.addComponent(top5Panel); this.currentUserEmail = new Label("-"); currentUserEmail.setCaption("Email"); Button reloadButton = new Button("\u27F3 Reload"); reloadButton.addClickListener(e -> { getSession().getSession().invalidate(); getUI().getPage().reload(); }); HorizontalLayout infoHLayout = new HorizontalLayout(); infoHLayout.addStyleName("outlined"); infoHLayout.setSizeFull(); infoHLayout.setSpacing(true); infoHLayout.setMargin(true); infoHLayout.addComponent(reloadButton); reloadButton.setWidth(null); infoHLayout.setComponentAlignment(reloadButton, Alignment.BOTTOM_LEFT); infoHLayout.addComponent(currentUserEmail); currentUserEmail.setWidth(null); infoHLayout.setComponentAlignment(currentUserEmail, Alignment.BOTTOM_RIGHT); vlayout.addComponent(infoHLayout); vlayout.setExpandRatio(infoHLayout, 0.5f); }
From source file:com.hack23.cia.web.impl.ui.application.views.admin.datasummary.pagemode.DataSummaryOverviewPageModContentFactoryImpl.java
License:Apache License
@Secured({ "ROLE_ADMIN" }) @Override/*from ww w. j a v a 2 s . c o m*/ public Layout createContent(final String parameters, final MenuBar menuBar, final Panel panel) { final VerticalLayout content = createPanelContent(); getMenuItemFactory().createMainPageMenuBar(menuBar); LabelFactory.createHeader2Label(content, ADMIN_DATA_SUMMARY); final Table createDataSummaryTable = tableFactory.createDataSummaryTable(); content.addComponent(createDataSummaryTable); content.setExpandRatio(createDataSummaryTable, ContentRatio.LARGE); content.setSizeFull(); content.setMargin(false); content.setSpacing(true); final Button refreshViewsButton = new Button(REFRESH_VIEWS, FontAwesome.REFRESH); refreshViewsButton.addClickListener(event -> { final RefreshDataViewsRequest serviceRequest = new RefreshDataViewsRequest(); serviceRequest.setSessionId(RequestContextHolder.currentRequestAttributes().getSessionId()); getApplicationManager().asyncService(serviceRequest); Notification.show(REFRESH_VIEWS_STARTED); }); content.addComponent(refreshViewsButton); content.setExpandRatio(refreshViewsButton, ContentRatio.SMALL); final Button updateSearchIndexButton = new Button(UPDATE_SEARCH_INDEX, FontAwesome.REFRESH); updateSearchIndexButton.addClickListener(event -> { final UpdateSearchIndexRequest serviceRequest = new UpdateSearchIndexRequest(); serviceRequest.setSessionId(RequestContextHolder.currentRequestAttributes().getSessionId()); getApplicationManager().asyncService(serviceRequest); Notification.show(UPDATE_SEARCH_INDEX_STARTED); }); content.addComponent(updateSearchIndexButton); content.setExpandRatio(updateSearchIndexButton, ContentRatio.SMALL); return content; }
From source file:com.hack23.cia.web.impl.ui.application.views.common.AbstractView.java
License:Apache License
/** * Creates the basic layout with panel and footer. * * @param panelName//from www.j a va 2s . c om * the panel name */ protected final void createBasicLayoutWithPanelAndFooter(final String panelName) { final VerticalLayout layout = new VerticalLayout(); layout.setMargin(true); layout.setSpacing(true); layout.setWidth(100, Unit.PERCENTAGE); layout.setHeight(100, Unit.PERCENTAGE); final VerticalLayout pageModeContent = new VerticalLayout(); pageModeContent.setMargin(true); pageModeContent.setSpacing(true); pageModeContent.setWidth(100, Unit.PERCENTAGE); pageModeContent.setHeight(100, Unit.PERCENTAGE); layout.addComponent(pageModeContent); final ThemeResource ciaLogoResource = new ThemeResource("cia-logo.png"); final Image ciaLogoImage = new Image(null, ciaLogoResource); final HorizontalLayout topHeader = new HorizontalLayout(); topHeader.addComponent(ciaLogoImage); ciaLogoImage.setWidth("75px"); ciaLogoImage.setHeight("75px"); topHeader.setComponentAlignment(ciaLogoImage, Alignment.MIDDLE_LEFT); topHeader.setExpandRatio(ciaLogoImage, ContentRatio.SMALL); final HorizontalLayout topTitleHeadertPanel = new HorizontalLayout(); final Label titleLabel = new Label("Citizen Intelligence Agency"); titleLabel.setStyleName("Header"); topTitleHeadertPanel.addComponent(titleLabel); topTitleHeadertPanel.setComponentAlignment(titleLabel, Alignment.MIDDLE_LEFT); final Label sloganLabel = new Label("// Tracking politicians like bugs!"); sloganLabel.setStyleName("HeaderSlogan"); topTitleHeadertPanel.addComponent(sloganLabel); topTitleHeadertPanel.setComponentAlignment(sloganLabel, Alignment.MIDDLE_RIGHT); topHeader.addComponent(topTitleHeadertPanel); topHeader.setComponentAlignment(topTitleHeadertPanel, Alignment.MIDDLE_LEFT); topHeader.setExpandRatio(topTitleHeadertPanel, ContentRatio.GRID); topHeaderRightPanel.removeAllComponents(); topHeader.addComponent(topHeaderRightPanel); topHeader.setComponentAlignment(topHeaderRightPanel, Alignment.MIDDLE_RIGHT); topHeader.setExpandRatio(topHeaderRightPanel, ContentRatio.LARGE); if (UserContextUtil.allowRoleInSecurityContext(ROLE_ADMIN) || UserContextUtil.allowRoleInSecurityContext(ROLE_USER)) { final Link userHomePageLink = pageLinkFactory.createUserHomeViewPageLink(); topHeaderRightPanel.addComponent(userHomePageLink); topHeaderRightPanel.setComponentAlignment(userHomePageLink, Alignment.MIDDLE_RIGHT); final Button logoutButton = new Button(LOGOUT, FontAwesome.SIGN_OUT); final LogoutRequest logoutRequest = new LogoutRequest(); logoutRequest.setSessionId(RequestContextHolder.currentRequestAttributes().getSessionId()); logoutButton.addClickListener(new LogoutClickListener(logoutRequest, applicationManager)); topHeaderRightPanel.addComponent(logoutButton); topHeaderRightPanel.setComponentAlignment(logoutButton, Alignment.MIDDLE_RIGHT); } else { final Link createRegisterPageLink = pageLinkFactory.createRegisterPageLink(); topHeaderRightPanel.addComponent(createRegisterPageLink); topHeaderRightPanel.setComponentAlignment(createRegisterPageLink, Alignment.MIDDLE_RIGHT); final Link createLoginPageLink = pageLinkFactory.createLoginPageLink(); topHeaderRightPanel.addComponent(createLoginPageLink); topHeaderRightPanel.setComponentAlignment(createLoginPageLink, Alignment.MIDDLE_RIGHT); } topHeaderRightPanel.setWidth("100%"); topHeaderRightPanel.setHeight("60px"); topHeader.setWidth("100%"); topHeader.setHeight("60px"); pageModeContent.addComponent(topHeader); pageModeContent.setComponentAlignment(topHeader, Alignment.TOP_CENTER); pageModeContent.addComponent(getBarmenu()); pageModeContent.setComponentAlignment(getBarmenu(), Alignment.TOP_CENTER); panel = new Panel(panelName); panel.setSizeFull(); pageModeContent.addComponent(panel); pageModeContent.setExpandRatio(panel, ContentRatio.FULL_SIZE); pageModeContent.addComponent(pageLinkFactory.createMainViewPageLink()); setContent(layout); setWidth(100, Unit.PERCENTAGE); setHeight(100, Unit.PERCENTAGE); setSizeFull(); }
From source file:com.hack23.cia.web.impl.ui.application.views.common.menufactory.impl.AbstractMenuItemFactoryImpl.java
License:Apache License
protected final void createButtonLink(final GridLayout panelContent, final String linkText, final Resource icon, final ClickListener command, final String description) { final GridLayout grid = new GridLayout(2, 1); grid.setWidth(100, Unit.PERCENTAGE); grid.setHeight(100, Unit.PERCENTAGE); grid.setColumnExpandRatio(0, 1);/* www . j a v a 2 s . c o m*/ grid.setColumnExpandRatio(1, 2); final Button b = new Button(linkText); b.setStyleName("link"); b.addClickListener(command); b.setWidth(100, Unit.PERCENTAGE); b.setIcon(icon); b.setWidth(100, Unit.PERCENTAGE); grid.addComponent(b, 0, 0); grid.setComponentAlignment(b, Alignment.MIDDLE_LEFT); final Label descriptionLabel = new Label(description); descriptionLabel.setWidth(100, Unit.PERCENTAGE); grid.addComponent(descriptionLabel, 1, 0); grid.setComponentAlignment(descriptionLabel, Alignment.MIDDLE_LEFT); panelContent.addComponent(grid); panelContent.setComponentAlignment(grid, Alignment.MIDDLE_LEFT); }
From source file:com.hack23.cia.web.impl.ui.application.views.user.home.pagemode.UserHomeOverviewPageModContentFactoryImpl.java
License:Apache License
@Secured({ "ROLE_USER", "ROLE_ADMIN" }) @Override/*ww w .j av a2 s . co m*/ public Layout createContent(final String parameters, final MenuBar menuBar, final Panel panel) { final VerticalLayout panelContent = createPanelContent(); final String pageId = getPageId(parameters); userHomeMenuItemFactory.createUserHomeMenuBar(menuBar, pageId); LabelFactory.createHeader2Label(panelContent, OVERVIEW); final Button logoutButton = new Button(LOGOUT, FontAwesome.SIGN_OUT); final LogoutRequest logoutRequest = new LogoutRequest(); logoutRequest.setSessionId(RequestContextHolder.currentRequestAttributes().getSessionId()); logoutButton.addClickListener(new LogoutClickListener(logoutRequest, getApplicationManager())); panelContent.addComponent(logoutButton); final DataContainer<UserAccount, Long> dataContainer = getApplicationManager() .getDataContainer(UserAccount.class); final Long userIdFromSecurityContext = UserContextUtil.getUserInternalIdFromSecurityContext(); if (userIdFromSecurityContext == null) { UI.getCurrent().getNavigator().navigateTo(CommonsViews.MAIN_VIEW_NAME); } else { final UserAccount userAccount = dataContainer.load(userIdFromSecurityContext); getFormFactory().addFormPanelTextFields(panelContent, new BeanItem<>(userAccount), UserAccount.class, Arrays.asList( new String[] { "username", "createdDate", "email", "country", "numberOfVisits" })); final DataContainer<ApplicationActionEvent, Long> eventDataContainer = getApplicationManager() .getDataContainer(ApplicationActionEvent.class); final BeanItemContainer<ApplicationActionEvent> politicianDocumentDataSource = new BeanItemContainer<>( ApplicationActionEvent.class, eventDataContainer.findOrderedListByProperty(ApplicationActionEvent_.userId, userAccount.getUserId(), ApplicationActionEvent_.createdDate)); getGridFactory().createBasicBeanItemGrid(panelContent, politicianDocumentDataSource, "ApplicationActionEvent", new String[] { "hjid", "createdDate", "eventGroup", "applicationOperation", "actionName", "page", "pageMode", "elementId", "applicationMessage", "errorMessage", "modelObjectVersion" }, new String[] { "hjid", "userId", "sessionId", "modelObjectId", "modelObjectVersion" }, new PageItemPropertyClickListener(AdminViews.ADMIN_APPLICATIONS_EVENTS_VIEW_NAME, "hjid"), null, null); panelContent.setExpandRatio(logoutButton, ContentRatio.SMALL); } panel.setCaption(USERHOME); getPageActionEventHelper().createPageEvent(ViewAction.VISIT_USER_HOME_VIEW, ApplicationEventGroup.USER, NAME, parameters, pageId); return panelContent; }
From source file:com.hack23.cia.web.impl.ui.application.views.user.home.pagemode.UserHomeSecuritySettingsPageModContentFactoryImpl.java
License:Apache License
@Secured({ "ROLE_USER", "ROLE_ADMIN" }) @Override/*from w w w.j a v a 2 s. c o m*/ public Layout createContent(final String parameters, final MenuBar menuBar, final Panel panel) { final VerticalLayout panelContent = createPanelContent(); final String pageId = getPageId(parameters); userHomeMenuItemFactory.createUserHomeMenuBar(menuBar, pageId); LabelFactory.createHeader2Label(panelContent, SECURITY_SETTINGS); final Long userIdFromSecurityContext = UserContextUtil.getUserInternalIdFromSecurityContext(); if (userIdFromSecurityContext == null) { UI.getCurrent().getNavigator().navigateTo(CommonsViews.MAIN_VIEW_NAME); } else { final Button googleAuthButton = new Button(ENABLE_GOOGLE_AUTHENTICATOR, FontAwesome.USER_SECRET); googleAuthButton.setId(ENABLE_GOOGLE_AUTHENTICATOR); final SetGoogleAuthenticatorCredentialRequest googleAuthRequest = new SetGoogleAuthenticatorCredentialRequest(); googleAuthRequest.setSessionId(RequestContextHolder.currentRequestAttributes().getSessionId()); googleAuthButton.addClickListener( new SetGoogleAuthenticatorCredentialClickListener(googleAuthRequest, getApplicationManager())); panelContent.addComponent(googleAuthButton); } panel.setCaption(USERHOME + SECURITY_SETTINGS); getPageActionEventHelper().createPageEvent(ViewAction.VISIT_USER_HOME_VIEW, ApplicationEventGroup.USER, NAME, parameters, pageId); return panelContent; }