List of usage examples for com.vaadin.ui Button addListener
@Override
public Registration addListener(Component.Listener listener)
From source file:com.liferay.mail.vaadin.Folders.java
License:Open Source License
public void setFolders(List<Folder> folders) { for (Folder folder : folders) { Button b = new Button(folder.getDisplayName()); b.setStyleName(BaseTheme.BUTTON_LINK); b.setData(folder);//from w ww . j a va 2s . c o m b.addListener(new ClickListener() { public void buttonClick(ClickEvent event) { showFolder(((Folder) event.getButton().getData())); } }); } }
From source file:com.liferay.mail.vaadin.MessageView.java
License:Open Source License
public void showMessage(Message msg) { if (msg == null) { messageLabel.setVisible(false);// w w w . jav a2s.co m headersAndAttachmentLayout.setVisible(false); return; } else { messageLabel.setVisible(true); headersAndAttachmentLayout.setVisible(true); } // Body String text = ""; if (msg != null) { text = msg.getBody(); } messageLabel.setValue(text); // Headers headersLayout = new FormLayout(); headersLayout.setSpacing(false); headersLayout.setMargin(false); if (msg != null) { String to = msg.getTo(); String cc = msg.getCc(); // String replyTo = msg.get(); Label subject = new Label(msg.getSubject()); subject.setCaption(Lang.get("subject")); headersLayout.addComponent(subject); Label from = new Label(msg.getSender()); from.setCaption(Lang.get("from")); headersLayout.addComponent(from); if (to != null && !to.equals("")) { Label toLabel = new Label(to); toLabel.setCaption(Lang.get("to")); headersLayout.addComponent(toLabel); } if (cc != null && !cc.equals("")) { Label ccLabel = new Label(cc); ccLabel.setCaption(Lang.get("cc")); headersLayout.addComponent(ccLabel); } Label date = new Label(formatDate(msg.getSentDate())); date.setCaption(Lang.get("date")); headersLayout.addComponent(date); if (MessageUtil.isImportant(msg)) { Label flag = new Label(Lang.get("important")); flag.setStyleName(MessageList.STYLE_IMPORTANT); flag.setCaption(Lang.get("flag")); headersLayout.addComponent(flag); } } // Attachments try { headersAndAttachmentLayout.removeAllComponents(); headersAndAttachmentLayout.addComponent(headersLayout); Controller controller = Controller.get(); List<Attachment> attachments = AttachmentLocalServiceUtil.getAttachments(msg.getMessageId()); if (attachments != null && !attachments.isEmpty()) { for (Attachment attachment : attachments) { Button attachmentDownload = new Button(); attachmentDownload.setStyleName(BaseTheme.BUTTON_LINK); attachmentDownload.setCaption(attachment.getFileName() + " " + MessageUtil.formatSize(attachment.getSize(), controller.getUserLocale())); attachmentDownload.setData(attachment); attachmentDownload.addListener(this); headersAndAttachmentLayout.addComponent(attachmentDownload); } } } catch (SystemException e) { _log.debug(e); } }
From source file:com.liferay.mail.vaadin.PreferencesView.java
License:Open Source License
public PreferencesView(final Controller controller) { this.controller = controller; setSpacing(true);// w w w . j a v a 2s.c om accountPanel = new Panel(Lang.get("your-email-accounts")); updateAccountList(); addComponent(accountPanel); HorizontalLayout buttons = new HorizontalLayout(); buttons.setSpacing(true); addComponent(buttons); Button createAccountButton = new Button(Lang.get("create-account")); createAccountButton.addListener(new ClickListener() { public void buttonClick(ClickEvent event) { editAccount(null); } }); buttons.addComponent(createAccountButton); Button createGmailButton = new Button("Create GMail account"); createGmailButton.addListener(new ClickListener() { public void buttonClick(ClickEvent event) { editGmailAccount(null); } }); buttons.addComponent(createGmailButton); Link poweredByVaadin = new Link("", new ExternalResource("http://vaadin.com")); poweredByVaadin.setIcon(new PortletResource("images/vaadin/powered-by-vaadin.png")); poweredByVaadin.setDescription("Mail portlet interface created using Vaadin - RIA's with pure Java."); addComponent(poweredByVaadin); }
From source file:com.liferay.mail.vaadin.PreferencesView.java
License:Open Source License
private void updateAccountList() { try {/*from ww w.j a v a2 s . co m*/ accountPanel.removeAllComponents(); List<Account> accounts = controller.getAccountManager().getAccounts(controller.getUser()); if (accounts.size() > 0) { GridLayout grid = new GridLayout(3, accounts.size()); grid.setSpacing(true); for (final Account account : accounts) { grid.addComponent(new Label(account.getAddress())); Button editButton = new Button(Lang.get("edit-account")); editButton.setStyleName("small"); editButton.addListener(new ClickListener() { public void buttonClick(ClickEvent event) { editAccount(account); } }); grid.addComponent(editButton); Button deleteButton = new Button(Lang.get("delete-account")); deleteButton.setStyleName("small"); deleteButton.addListener(new ClickListener() { public void buttonClick(ClickEvent event) { deleteAccount(account); } }); grid.addComponent(deleteButton); } accountPanel.addComponent(grid); } } catch (SystemException e) { // unable to read account information controller.showUnexpectedError(e); } }
From source file:com.mil.MyVaadinApplication.java
License:Apache License
@Override public void init() { window = new Window("My Vaadin Application"); setMainWindow(window);// w w w . j a v a2 s .c o m Button button = new Button("Click M e"); button.addListener(new Button.ClickListener() { public void buttonClick(ClickEvent event) { window.addComponent(new Label("Thank you for clicking")); } }); window.addComponent(button); }
From source file:com.morevaadin.vaadin7.springsecurity.ui.LoginView.java
License:Apache License
public LoginView(final EventBus eventBus) { setMargin(true);/*from w ww.j ava2s . c om*/ addComponent(loginField); addComponent(passwordField); Button button = new Button("Let me in"); button.addListener(new ClickListener() { @Override public void buttonClick(ClickEvent clickEvent) { LoginEvent loginEvent = new LoginEvent(loginField.getValue(), passwordField.getValue()); eventBus.post(loginEvent); loginField.setValue(""); passwordField.setValue(""); } }); addComponent(button); }
From source file:com.morevaadin.vaadin7.springsecurity.ui.MainView.java
License:Apache License
public MainView(final EventBus eventBus) { label = new Label(); addComponent(label);/* w w w . j a v a 2 s. c o m*/ Button button = new Button("Logout"); button.addListener(new ClickListener() { @Override public void buttonClick(ClickEvent event) { eventBus.post(new LogoutEvent()); } }); addComponent(button); }
From source file:com.mymita.vaadlets.demo.AddonDemoApplication.java
License:Apache License
@Override public void init() { try {/* w ww . j av a 2s.c om*/ final VaadletsBuilder vaadletsBuilder = VaadletsBuilder.build(new InputStreamReader( new ClassPathResource("demo.xml", AddonDemoApplication.class).getInputStream())); final Window root = (Window) vaadletsBuilder.getRoot(); setMainWindow(root); setTheme("vaadlets"); final Button testButton = vaadletsBuilder.getComponent("test"); testButton.addListener(new ClickListener() { @Override public void buttonClick(final ClickEvent event) { final Panel content = vaadletsBuilder.getComponent("content"); final TextField editor = vaadletsBuilder.getComponent("editor"); content.getContent().removeAllComponents(); try { final VaadletsBuilder v = VaadletsBuilder .build(CharStreams.newReaderSupplier((String) editor.getValue()).getInput()); if (v.getRoot() instanceof Window) { final Window w = (Window) v.getRoot(); root.addWindow(w); } else { content.getContent().addComponent(v.getRoot()); } } catch (final Exception e) { LOG.error("error", e); content.addComponent(createStackTraceLabel(e)); } } }); final Button resetButton = vaadletsBuilder.getComponent("reset"); resetButton.addListener(new ClickListener() { @Override public void buttonClick(final ClickEvent event) { fillEditorWithDefaultXML(vaadletsBuilder); } }); fillEditorWithDefaultXML(vaadletsBuilder); } catch (final IOException e) { } }
From source file:com.openhris.administrator.ChangePassword.java
public ComponentContainer layout() { VerticalLayout vlayout = new VerticalLayout(); vlayout.setSpacing(true);/* www .jav a 2 s .c o m*/ vlayout.setMargin(true); vlayout.setSizeFull(); vlayout.setImmediate(true); final PasswordField currentPassword = createPasswordField("Current Password: "); vlayout.addComponent(currentPassword); final PasswordField newPassword = createPasswordField("New Password: "); vlayout.addComponent(newPassword); final PasswordField rePassword = createPasswordField("Re-enter Password: "); vlayout.addComponent(rePassword); Button changeBtn = new Button("UPDATE PASSWORD"); changeBtn.setWidth("100%"); changeBtn.addListener(new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { if (!adminService.checkEnteredPasswordIfCorrect(getUserId(), currentPassword.getValue().toString().toLowerCase().trim())) { getWindow().showNotification("Incorrect Password, contact your Administrator!", Window.Notification.TYPE_WARNING_MESSAGE); return; } if (!newPassword.getValue().toString().toLowerCase().trim() .equals(rePassword.getValue().toString().toLowerCase().trim())) { getWindow().showNotification("Entered Password do not Match!", Window.Notification.TYPE_WARNING_MESSAGE); return; } boolean result = adminService.updateUserPassword(getUserId(), rePassword.getValue().toString().toLowerCase().trim()); if (result) { GlobalVariables.setLogoutAfterPasswordChange(true); close(); } else { GlobalVariables.setLogoutAfterPasswordChange(false); getWindow().showNotification("Change Password SQL Error!, Contact your DBA", Window.Notification.TYPE_ERROR_MESSAGE); return; } } }); vlayout.addComponent(changeBtn); return vlayout; }
From source file:com.openhris.administrator.SpecialAccessControl.java
public SpecialAccessControl() { setMargin(true);//from w w w .j ava2 s .c om setSpacing(true); addComponent(userList()); allowedBackwardInputAttendance.setCaption("Allow user to enter previous attendance."); allowedBackwardInputAttendance.addListener(new ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { if (event.getButton().booleanValue()) { val = 1; } else { val = 0; } } }); allowedBackwardInputAttendance.setImmediate(true); addComponent(allowedBackwardInputAttendance); Button button = new Button("UPDATE"); button.setWidth("200px"); button.addListener(new ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { if (users.getValue() == null) { getWindow().showNotification("Select a User!", Window.Notification.TYPE_WARNING_MESSAGE); return; } boolean isUserAllowed = service.updateUserAllowedToEnterPreviousAttendance( util.convertStringToInteger(users.getValue().toString()), isAllowed()); if (isUserAllowed) { getWindow().showNotification("User is allowed to Enter Previous Attendance!", Window.Notification.TYPE_TRAY_NOTIFICATION); } } }); button.setImmediate(true); addComponent(button); }