List of usage examples for com.vaadin.ui Button.ClickListener Button.ClickListener
Button.ClickListener
From source file:annis.gui.SearchUI.java
License:Apache License
@Override protected void init(VaadinRequest request) { super.init(request); this.instanceConfig = getInstanceConfig(request); getPage().setTitle(instanceConfig.getInstanceDisplayName() + " (ANNIS Corpus Search)"); queryController = new QueryController(this); refresh = new Refresher(); // deactivate refresher by default refresh.setRefreshInterval(-1);/*from ww w. java2 s . c o m*/ refresh.addListener(queryController); addExtension(refresh); // always get the resize events directly setImmediate(true); VerticalLayout mainLayout = new VerticalLayout(); setContent(mainLayout); mainLayout.setSizeFull(); mainLayout.setMargin(false); final ScreenshotMaker screenshot = new ScreenshotMaker(this); addExtension(screenshot); css = new CSSInject(this); HorizontalLayout layoutToolbar = new HorizontalLayout(); layoutToolbar.setWidth("100%"); layoutToolbar.setHeight("-1px"); mainLayout.addComponent(layoutToolbar); layoutToolbar.addStyleName("toolbar"); layoutToolbar.addStyleName("border-layout"); Button btAboutAnnis = new Button("About ANNIS"); btAboutAnnis.addStyleName(ChameleonTheme.BUTTON_SMALL); btAboutAnnis.setIcon(new ThemeResource("info.gif")); btAboutAnnis.addClickListener(new AboutClickListener()); btBugReport = new Button("Report Bug"); btBugReport.addStyleName(ChameleonTheme.BUTTON_SMALL); btBugReport.setDisableOnClick(true); btBugReport.setIcon(new ThemeResource("../runo/icons/16/email.png")); btBugReport.addListener(new Button.ClickListener() { @Override public void buttonClick(ClickEvent event) { screenshot.makeScreenshot(); btBugReport.setCaption("bug report is initialized..."); } }); String bugmail = (String) VaadinSession.getCurrent().getAttribute("bug-e-mail"); if (bugmail != null && !bugmail.isEmpty() && !bugmail.startsWith("${") && new EmailValidator("").isValid(bugmail)) { this.bugEMailAddress = bugmail; } btBugReport.setVisible(this.bugEMailAddress != null); lblUserName = new Label("not logged in"); lblUserName.setWidth("-1px"); lblUserName.setHeight("-1px"); lblUserName.addStyleName("right-aligned-text"); btLoginLogout = new Button("Login", new Button.ClickListener() { @Override public void buttonClick(ClickEvent event) { if (isLoggedIn()) { // logout Helper.setUser(null); Notification.show("Logged out", Notification.Type.TRAY_NOTIFICATION); updateUserInformation(); } else { showLoginWindow(); } } }); btLoginLogout.setSizeUndefined(); btLoginLogout.setStyleName(ChameleonTheme.BUTTON_SMALL); btLoginLogout.setIcon(new ThemeResource("../runo/icons/16/user.png")); Button btOpenSource = new Button("Help us to make ANNIS better!"); btOpenSource.setStyleName(BaseTheme.BUTTON_LINK); btOpenSource.addListener(new Button.ClickListener() { @Override public void buttonClick(ClickEvent event) { Window w = new HelpUsWindow(); w.setCaption("Help us to make ANNIS better!"); w.setModal(true); w.setResizable(true); w.setWidth("600px"); w.setHeight("500px"); addWindow(w); w.center(); } }); layoutToolbar.addComponent(btAboutAnnis); layoutToolbar.addComponent(btBugReport); layoutToolbar.addComponent(btOpenSource); layoutToolbar.addComponent(lblUserName); layoutToolbar.addComponent(btLoginLogout); layoutToolbar.setSpacing(true); layoutToolbar.setComponentAlignment(btAboutAnnis, Alignment.MIDDLE_LEFT); layoutToolbar.setComponentAlignment(btBugReport, Alignment.MIDDLE_LEFT); layoutToolbar.setComponentAlignment(btOpenSource, Alignment.MIDDLE_CENTER); layoutToolbar.setComponentAlignment(lblUserName, Alignment.MIDDLE_RIGHT); layoutToolbar.setComponentAlignment(btLoginLogout, Alignment.MIDDLE_RIGHT); layoutToolbar.setExpandRatio(btOpenSource, 1.0f); //HorizontalLayout hLayout = new HorizontalLayout(); final HorizontalSplitPanel hSplit = new HorizontalSplitPanel(); hSplit.setSizeFull(); mainLayout.addComponent(hSplit); mainLayout.setExpandRatio(hSplit, 1.0f); AutoGeneratedQueries autoGenQueries = new AutoGeneratedQueries("example queries", this); controlPanel = new ControlPanel(queryController, instanceConfig, autoGenQueries); controlPanel.setWidth(100f, Layout.Unit.PERCENTAGE); controlPanel.setHeight(100f, Layout.Unit.PERCENTAGE); hSplit.setFirstComponent(controlPanel); tutorial = new TutorialPanel(); tutorial.setHeight("99%"); mainTab = new TabSheet(); mainTab.setSizeFull(); mainTab.addTab(autoGenQueries, "example queries"); mainTab.addTab(tutorial, "Tutorial"); queryBuilder = new QueryBuilderChooser(queryController, this, instanceConfig); mainTab.addTab(queryBuilder, "Query Builder"); hSplit.setSecondComponent(mainTab); hSplit.setSplitPosition(CONTROL_PANEL_WIDTH, Unit.PIXELS); hSplit.addSplitterClickListener(new AbstractSplitPanel.SplitterClickListener() { @Override public void splitterClick(AbstractSplitPanel.SplitterClickEvent event) { if (event.isDoubleClick()) { if (hSplit.getSplitPosition() == CONTROL_PANEL_WIDTH) { // make small hSplit.setSplitPosition(0.0f, Unit.PIXELS); } else { // reset to default width hSplit.setSplitPosition(CONTROL_PANEL_WIDTH, Unit.PIXELS); } } } }); // hLayout.setExpandRatio(mainTab, 1.0f); addAction(new ShortcutListener("^Query builder") { @Override public void handleAction(Object sender, Object target) { mainTab.setSelectedTab(queryBuilder); } }); addAction(new ShortcutListener("Tutor^eial") { @Override public void handleAction(Object sender, Object target) { mainTab.setSelectedTab(tutorial); } }); getPage().addUriFragmentChangedListener(this); getSession().addRequestHandler(new RequestHandler() { @Override public boolean handleRequest(VaadinSession session, VaadinRequest request, VaadinResponse response) throws IOException { checkCitation(request); if (request.getPathInfo() != null && request.getPathInfo().startsWith("/vis-iframe-res/")) { String uuidString = StringUtils.removeStart(request.getPathInfo(), "/vis-iframe-res/"); UUID uuid = UUID.fromString(uuidString); IFrameResourceMap map = VaadinSession.getCurrent().getAttribute(IFrameResourceMap.class); if (map == null) { response.setStatus(404); } else { IFrameResource res = map.get(uuid); if (res != null) { response.setStatus(200); response.setContentType(res.getMimeType()); response.getOutputStream().write(res.getData()); } } return true; } return false; } }); getSession().setAttribute(MediaController.class, new MediaControllerImpl()); getSession().setAttribute(PDFController.class, new PDFControllerImpl()); loadInstanceFonts(); checkCitation(request); lastQueriedFragment = ""; evaluateFragment(getPage().getUriFragment()); updateUserInformation(); }
From source file:at.meikel.nentis.Nentis.java
License:Apache License
private void initMain(TabSheet tabSheet) { final VerticalLayout mainTab = new VerticalLayout(); tabSheet.addTab(mainTab);/*from www. jav a2 s . co m*/ tabSheet.getTab(mainTab).setCaption("Main"); final HorizontalLayout buttons = new HorizontalLayout(); mainTab.addComponent(buttons); final VerticalLayout state = new VerticalLayout(); mainTab.addComponent(state); final VerticalLayout info = new VerticalLayout(); mainTab.addComponent(info); Button createTicket = new Button("Create a new ticket"); createTicket.addListener(new Button.ClickListener() { public void buttonClick(ClickEvent clickEvent) { state.removeAllComponents(); Ticket ticket = nentisApi.createTicket("Ticket (" + new Date() + ")"); state.addComponent( new Label("Ticket #" + ticket.getId() + " [" + ticket.getDescription() + "] created.")); } }); buttons.addComponent(createTicket); Button listAllTickets = new Button("List all existing tickets"); listAllTickets.addListener(new Button.ClickListener() { public void buttonClick(ClickEvent clickEvent) { state.removeAllComponents(); List<Ticket> allTickets = nentisApi.getAllTickets(); info.removeAllComponents(); if (allTickets != null) { for (Ticket ticket : allTickets) { info.addComponent(new Label( "Ticket #" + ticket.getId() + " [" + ticket.getDescription() + "] created.")); } } } }); buttons.addComponent(listAllTickets); final Button openSubWindow = new Button("Open a sub window"); openSubWindow.addListener(new Button.ClickListener() { public void buttonClick(ClickEvent clickEvent) { buttons.removeComponent(openSubWindow); Window subWindow = new Window("Sub window"); mainWindow.addWindow(subWindow); } }); buttons.addComponent(openSubWindow); }
From source file:by.bigvova.LoginUI.java
License:Apache License
@Override protected void init(VaadinRequest request) { getPage().setTitle("Vaadin Shared Security Demo Login"); FormLayout loginForm = new FormLayout(); loginForm.setSizeUndefined();//from w w w .j a v a 2s . co m userName = new TextField("Username"); passwordField = new PasswordField("Password"); rememberMe = new CheckBox("Remember me"); login = new Button("Login"); Label label = new Label("Name: User / Password: password"); loginForm.addComponent(userName); loginForm.addComponent(passwordField); loginForm.addComponent(rememberMe); loginForm.addComponent(login); login.addStyleName(ValoTheme.BUTTON_PRIMARY); login.setDisableOnClick(true); login.setClickShortcut(ShortcutAction.KeyCode.ENTER); login.addClickListener(new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { login(); } }); VerticalLayout loginLayout = new VerticalLayout(); loginLayout.setSpacing(true); loginLayout.setSizeUndefined(); if (request.getParameter("logout") != null) { loggedOutLabel = new Label("You have been logged out!"); loggedOutLabel.addStyleName(ValoTheme.LABEL_SUCCESS); loggedOutLabel.setSizeUndefined(); loginLayout.addComponent(loggedOutLabel); loginLayout.setComponentAlignment(loggedOutLabel, Alignment.BOTTOM_CENTER); } loginLayout.addComponent(loginFailedLabel = new Label()); loginLayout.setComponentAlignment(loginFailedLabel, Alignment.BOTTOM_CENTER); loginFailedLabel.setSizeUndefined(); loginFailedLabel.addStyleName(ValoTheme.LABEL_FAILURE); loginFailedLabel.setVisible(false); loginLayout.addComponent(label); loginLayout.addComponent(loginForm); loginLayout.setComponentAlignment(loginForm, Alignment.TOP_CENTER); VerticalLayout rootLayout = new VerticalLayout(loginLayout); rootLayout.setSizeFull(); rootLayout.setComponentAlignment(loginLayout, Alignment.MIDDLE_CENTER); setContent(rootLayout); setSizeFull(); }
From source file:by.bigvova.ui.LoginUI.java
License:Apache License
private Component buildFields() { final VerticalLayout layout = new VerticalLayout(); HorizontalLayout fields = new HorizontalLayout(); fields.setSpacing(true);/*from www . ja va2s . c om*/ fields.addStyleName("fields"); final TextField username = new TextField("Username"); username.setIcon(FontAwesome.USER); username.addStyleName(ValoTheme.TEXTFIELD_INLINE_ICON); final PasswordField password = new PasswordField("Password"); password.setIcon(FontAwesome.LOCK); password.addStyleName(ValoTheme.TEXTFIELD_INLINE_ICON); final Button signin = new Button("Sign In"); signin.addStyleName(ValoTheme.BUTTON_PRIMARY); signin.setClickShortcut(ShortcutAction.KeyCode.ENTER); signin.focus(); final CheckBox checkBox = new CheckBox("Remember me", true); signin.addClickListener(new Button.ClickListener() { @Override public void buttonClick(final Button.ClickEvent event) { login(username.getValue(), password.getValue(), checkBox.getValue()); } }); fields.addComponents(username, password, signin); fields.setComponentAlignment(signin, Alignment.BOTTOM_LEFT); layout.setSpacing(true); layout.addComponent(fields); layout.addComponent(checkBox); return layout; }
From source file:com.arcusys.liferay.vaadinplugin.ui.AdditionalDependenciesWindow.java
License:Apache License
private Button createCloseButton() { closeButton = new Button("Close", new Button.ClickListener() { public void buttonClick(Button.ClickEvent event) { close();//from ww w .jav a 2s. c om } }); return closeButton; }
From source file:com.compomics.sigpep.webapp.MyVaadinApplication.java
License:Apache License
@Override public void init() { iApplication = this; iSigPepSessionFactory = ApplicationLocator.getInstance().getApplication().getSigPepSessionFactory(); //add theme// ww w. ja v a 2 s . co m setTheme("sigpep"); //add main window Window lMainwindow = new Window("Sigpep Application"); setMainWindow(lMainwindow); lMainwindow.addStyleName("v-app-my"); //add notification component iNotifique = new Notifique(Boolean.FALSE); CustomOverlay lCustomOverlay = new CustomOverlay(iNotifique, getMainWindow()); getMainWindow().addComponent(lCustomOverlay); //add form help iFormHelp = new FormHelp(); iFormHelp.setFollowFocus(Boolean.TRUE); this.getMainWindow().getContent().addComponent(iFormHelp); //add panels iCenterLeft = new Panel(); iCenterLeft.addStyleName(Reindeer.PANEL_LIGHT); iCenterLeft.setHeight("400px"); iCenterLeft.setWidth("100%"); iCenterRight = new Panel(); iCenterRight.addStyleName(Reindeer.PANEL_LIGHT); iCenterRight.setHeight("400px"); iCenterRight.setWidth("75%"); //add form tabs iFormTabSheet = new FormTabSheet(this); iCenterLeft.addComponent(iFormTabSheet); iBottomLayoutResults = new VerticalLayout(); if (PropertiesConfigurationHolder.showTestDemoFolder()) { Button lButton = new Button("load test data"); lButton.addListener(new Button.ClickListener() { public void buttonClick(Button.ClickEvent event) { new BackgroundThread().run(); } }); iBottomLayoutResults.addComponent(lButton); } // Add the selector component iSelectionComponent = new TransitionSelectionComponent(MyVaadinApplication.this); iCenterRight.addComponent(iSelectionComponent); iHeaderLayout = new HorizontalLayout(); iHeaderLayout.setSizeFull(); iHeaderLayout.setHeight("100px"); iHeaderLayout.addStyleName("v-header"); VerticalLayout lVerticalLayout = new VerticalLayout(); GridLayout lGridLayout = new GridLayout(2, 1); lGridLayout.setSpacing(true); lGridLayout.setSizeFull(); lGridLayout.addComponent(iCenterLeft, 0, 0); lGridLayout.setComponentAlignment(iCenterLeft, Alignment.TOP_LEFT); lGridLayout.addComponent(iCenterRight, 1, 0); lGridLayout.setComponentAlignment(iCenterRight, Alignment.TOP_CENTER); lVerticalLayout.addComponent(iHeaderLayout); lVerticalLayout.addComponent(lGridLayout); lVerticalLayout.addComponent(iBottomLayoutResults); lVerticalLayout.setComponentAlignment(iHeaderLayout, Alignment.MIDDLE_CENTER); lVerticalLayout.setComponentAlignment(lGridLayout, Alignment.MIDDLE_CENTER); lVerticalLayout.setComponentAlignment(iBottomLayoutResults, Alignment.MIDDLE_CENTER); lMainwindow.addComponent(lVerticalLayout); lMainwindow.addComponent(pusher); // Create a tracker for vaadin.com domain. String lDomainName = PropertiesConfigurationHolder.getInstance().getString("analytics.domain"); String lPageId = PropertiesConfigurationHolder.getInstance().getString("analytics.page"); GoogleAnalyticsTracker tracker = new GoogleAnalyticsTracker("UA-26252212-1", lDomainName); lMainwindow.addComponent(tracker); tracker.trackPageview(lPageId); /** * Sets an UncaughtExceptionHandler and executes the thread by the ExecutorsService */ Thread.setDefaultUncaughtExceptionHandler(new MyUncaughtExceptionHandler()); parseSessionId(); }
From source file:com.concur.ui.WebApp.java
License:Apache License
private Window createWindow() { FormLayout fl = new FormLayout(); // final SessionGuard sg = new SessionGuard(); // sg.setKeepalive(true); // fl.addComponent(sg); fl.setSizeFull();//www . j a v a 2 s . c o m fl.setMargin(true); fl.addComponent(new Label("<h2>ATS Tuple Store -- Demo App<h2/>", Label.CONTENT_XML)); actionField = new NativeSelect("Action:"); actionField.addItem("Authenticate"); actionField.addItem("GetTuple"); actionField.addItem("PutTuple"); actionField.addItem("GetConfigurations"); actionField.select("Authenticate"); fl.addComponent(actionField); tokenField = new TextField("Authentication Token:"); tokenField.setColumns(40); fl.addComponent(tokenField); tupleKeyField = new TextField("TupleKey:"); tupleKeyField.setColumns(40); fl.addComponent(tupleKeyField); tupleDataArea = new TextArea("TupleData:"); tupleDataArea.setColumns(40); tupleDataArea.setRows(5); fl.addComponent(tupleDataArea); Button b = new Button("Send Request"); b.addListener(new Button.ClickListener() { public void buttonClick(ClickEvent event) { submit(); } }); fl.addComponent(b); final Window w = new Window("ATS Tuple Store -- DEMO"); w.setContent(fl); return w; }
From source file:com.digitallabs.demos.Vaadin6BootstrapThemeDemo.java
License:Apache License
@Override public void init() { setTheme("bootstrap"); window = new Window("My Vaadin Application"); setMainWindow(window);// www. j a v a 2s.com Button button = new Button("Click Me"); button.addListener(new Button.ClickListener() { public void buttonClick(ClickEvent event) { window.addComponent(new Label("Thank you for clicking")); } }); CssLayout container = new CssLayout(); container.setWidth("100%"); container.addStyleName("container"); typography(container); tables(container); forms(container); buttons(container); window.setContent(container); }
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 a va 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.common.ui.components.notification.SmtpSetupNotification.java
License:Open Source License
@Override public Component renderContent() { MHorizontalLayout layout = new MHorizontalLayout(); layout.setDefaultComponentAlignment(Alignment.MIDDLE_LEFT); Button smtpBtn = new Button("Setup", new Button.ClickListener() { @Override/*from w w w . j a v a2 s . c om*/ public void buttonClick(Button.ClickEvent clickEvent) { UI.getCurrent().addWindow(new SmtpConfigurationWindow()); } }); smtpBtn.setStyleName("link"); layout.with(new Label("You did not set up a SMTP account yet."), smtpBtn); return layout; }