List of usage examples for com.vaadin.ui Button setCaption
@Override public void setCaption(String caption)
From source file:com.haulmont.cuba.web.WebWindowManager.java
License:Apache License
@Override public void showMessageDialog(String title, String message, MessageType messageType) { backgroundWorker.checkUIAccess();/*from ww w . j a va 2s . c om*/ final com.vaadin.ui.Window vWindow = new CubaWindow(title); if (ui.isTestMode()) { vWindow.setCubaId("messageDialog"); vWindow.setId(ui.getTestIdManager().getTestId("messageDialog")); } String closeShortcut = clientConfig.getCloseShortcut(); KeyCombination closeCombination = KeyCombination.create(closeShortcut); vWindow.addAction(new ShortcutListener("Esc", closeCombination.getKey().getCode(), KeyCombination.Modifier.codes(closeCombination.getModifiers())) { @Override public void handleAction(Object sender, Object target) { vWindow.close(); } }); vWindow.addAction(new ShortcutListener("Enter", ShortcutAction.KeyCode.ENTER, null) { @Override public void handleAction(Object sender, Object target) { vWindow.close(); } }); VerticalLayout layout = new VerticalLayout(); layout.setStyleName("c-app-message-dialog"); layout.setSpacing(true); if (messageType.getWidth() != null && messageType.getWidth() == AUTO_SIZE_PX) { layout.setWidthUndefined(); } vWindow.setContent(layout); Label messageLab = new CubaLabel(); messageLab.setValue(message); if (MessageType.isHTML(messageType)) { messageLab.setContentMode(ContentMode.HTML); } else { messageLab.setContentMode(ContentMode.TEXT); } if (messageType.getWidth() != null && messageType.getWidth() == AUTO_SIZE_PX) { messageLab.setWidthUndefined(); } layout.addComponent(messageLab); DialogAction action = new DialogAction(Type.OK); Button button = WebComponentsHelper.createButton(); button.setCaption(action.getCaption()); button.setIcon(WebComponentsHelper.getIcon(action.getIcon())); button.addStyleName(WebButton.ICON_STYLE); button.addClickListener(event -> vWindow.close()); button.focus(); layout.addComponent(button); layout.setComponentAlignment(button, Alignment.BOTTOM_RIGHT); float width; SizeUnit unit; DialogParams dialogParams = getDialogParams(); if (messageType.getWidth() != null) { width = messageType.getWidth(); unit = messageType.getWidthUnit(); } else if (dialogParams.getWidth() != null) { width = dialogParams.getWidth(); unit = dialogParams.getWidthUnit(); } else { SizeWithUnit size = SizeWithUnit .parseStringSize(app.getThemeConstants().get("cuba.web.WebWindowManager.messageDialog.width")); width = size.getSize(); unit = size.getUnit(); } vWindow.setWidth(width, unit != null ? WebWrapperUtils.toVaadinUnit(unit) : Unit.PIXELS); vWindow.setResizable(false); boolean modal = true; if (!hasModalWindow()) { if (messageType.getModal() != null) { modal = messageType.getModal(); } else if (dialogParams.getModal() != null) { modal = dialogParams.getModal(); } } vWindow.setModal(modal); boolean closeOnClickOutside = false; if (vWindow.isModal()) { if (messageType.getCloseOnClickOutside() != null) { closeOnClickOutside = messageType.getCloseOnClickOutside(); } } ((CubaWindow) vWindow).setCloseOnClickOutside(closeOnClickOutside); if (messageType.getMaximized() != null) { if (messageType.getMaximized()) { vWindow.setWindowMode(WindowMode.MAXIMIZED); } else { vWindow.setWindowMode(WindowMode.NORMAL); } } dialogParams.reset(); ui.addWindow(vWindow); vWindow.center(); vWindow.focus(); }
From source file:com.haulmont.cuba.web.WebWindowManager.java
License:Apache License
@Override public void showOptionDialog(String title, String message, MessageType messageType, Action[] actions) { backgroundWorker.checkUIAccess();// w w w . ja v a 2 s. co m final com.vaadin.ui.Window window = new CubaWindow(title); if (ui.isTestMode()) { window.setCubaId("optionDialog"); window.setId(ui.getTestIdManager().getTestId("optionDialog")); } window.setClosable(false); Label messageLab = new CubaLabel(); messageLab.setValue(message); if (MessageType.isHTML(messageType)) { messageLab.setContentMode(ContentMode.HTML); } else { messageLab.setContentMode(ContentMode.TEXT); } if (messageType.getWidth() != null && messageType.getWidth() == AUTO_SIZE_PX) { messageLab.setWidthUndefined(); } float width; SizeUnit unit; if (messageType.getWidth() != null) { width = messageType.getWidth(); unit = messageType.getWidthUnit(); } else if (getDialogParams().getWidth() != null) { width = getDialogParams().getWidth(); unit = getDialogParams().getWidthUnit(); } else { SizeWithUnit size = SizeWithUnit .parseStringSize(app.getThemeConstants().get("cuba.web.WebWindowManager.optionDialog.width")); width = size.getSize(); unit = size.getUnit(); } if (messageType.getModal() != null) { log.warn("MessageType.modal is not supported for showOptionDialog"); } getDialogParams().reset(); window.setWidth(width, unit != null ? WebWrapperUtils.toVaadinUnit(unit) : Unit.PIXELS); window.setResizable(false); window.setModal(true); boolean closeOnClickOutside = false; if (window.isModal()) { if (messageType.getCloseOnClickOutside() != null) { closeOnClickOutside = messageType.getCloseOnClickOutside(); } } ((CubaWindow) window).setCloseOnClickOutside(closeOnClickOutside); if (messageType.getMaximized() != null) { if (messageType.getMaximized()) { window.setWindowMode(WindowMode.MAXIMIZED); } else { window.setWindowMode(WindowMode.NORMAL); } } VerticalLayout layout = new VerticalLayout(); layout.setStyleName("c-app-option-dialog"); layout.setSpacing(true); if (messageType.getWidth() != null && messageType.getWidth() == AUTO_SIZE_PX) { layout.setWidthUndefined(); } window.setContent(layout); HorizontalLayout buttonsContainer = new HorizontalLayout(); buttonsContainer.setSpacing(true); boolean hasPrimaryAction = false; Map<Action, Button> buttonMap = new HashMap<>(); for (Action action : actions) { Button button = WebComponentsHelper.createButton(); button.setCaption(action.getCaption()); button.addClickListener(event -> { try { action.actionPerform(null); } finally { ui.removeWindow(window); } }); if (StringUtils.isNotEmpty(action.getIcon())) { button.setIcon(WebComponentsHelper.getIcon(action.getIcon())); button.addStyleName(WebButton.ICON_STYLE); } if (action instanceof AbstractAction && ((AbstractAction) action).isPrimary()) { button.addStyleName("c-primary-action"); button.focus(); hasPrimaryAction = true; } if (ui.isTestMode()) { button.setCubaId("optionDialog_" + action.getId()); button.setId(ui.getTestIdManager().getTestId("optionDialog_" + action.getId())); } buttonsContainer.addComponent(button); buttonMap.put(action, button); } assignDialogShortcuts(buttonMap); if (!hasPrimaryAction && actions.length > 0) { ((Button) buttonsContainer.getComponent(0)).focus(); } layout.addComponent(messageLab); layout.addComponent(buttonsContainer); layout.setExpandRatio(messageLab, 1); layout.setComponentAlignment(buttonsContainer, Alignment.BOTTOM_RIGHT); ui.addWindow(window); window.center(); }
From source file:com.jiangyifen.ec2.ui.mgr.system.tabsheet.SystemLicence.java
/** * added by chb 20140520// w w w . ja v a 2s . c o m * @return */ private VerticalLayout updateLicenseComponent() { VerticalLayout licenseUpdateLayout = new VerticalLayout(); final VerticalLayout textAreaPlaceHolder = new VerticalLayout(); final HorizontalLayout buttonPlaceHolder = new HorizontalLayout(); buttonPlaceHolder.setSpacing(true); // final Button updateButton = new Button("License"); updateButton.setData("show"); // final Button cancelButton = new Button("?"); // final TextArea licenseTextArea = new TextArea(); licenseTextArea.setColumns(30); licenseTextArea.setRows(5); licenseTextArea.setWordwrap(true); licenseTextArea.setInputPrompt("??"); //Layout buttonPlaceHolder.addComponent(updateButton); licenseUpdateLayout.addComponent(textAreaPlaceHolder); licenseUpdateLayout.addComponent(buttonPlaceHolder); // cancelButton.addListener(new Button.ClickListener() { @Override public void buttonClick(ClickEvent event) { textAreaPlaceHolder.removeAllComponents(); buttonPlaceHolder.removeComponent(cancelButton); updateButton.setData("show"); updateButton.setCaption("License"); } }); updateButton.addListener(new Button.ClickListener() { @Override public void buttonClick(ClickEvent event) { if (((String) event.getButton().getData()).equals("show")) { textAreaPlaceHolder.removeAllComponents(); textAreaPlaceHolder.addComponent(licenseTextArea); buttonPlaceHolder.addComponent(cancelButton); event.getButton().setData("updateAndHide"); event.getButton().setCaption("??"); } else if (((String) event.getButton().getData()).equals("updateAndHide")) { StringReader stringReader = new StringReader( StringUtils.trimToEmpty((String) licenseTextArea.getValue())); Properties props = new Properties(); try { props.load(stringReader); } catch (IOException e) { e.printStackTrace(); } stringReader.close(); // Boolean isValidvalidateLicense(licenseTextArea.getValue()); String license_date = props.getProperty(LicenseManager.LICENSE_DATE); String license_count = props.getProperty(LicenseManager.LICENSE_COUNT); String license_localmd5 = props.getProperty(LicenseManager.LICENSE_LOCALMD5); // Boolean isMatch = regexMatchCheck(license_date, license_count, license_localmd5); if (isMatch) { Map<String, String> licenseMap = new HashMap<String, String>(); //?? // String license_count = (String)props.get(LicenseManager.LICENSE_COUNT); license_count = license_count == null ? "" : license_count; licenseMap.put(LicenseManager.LICENSE_COUNT, license_count); //? // String license_date = (String)props.get(LicenseManager.LICENSE_DATE); license_date = license_date == null ? "" : license_date; licenseMap.put(LicenseManager.LICENSE_DATE, license_date); //??? // String license_localmd5 = (String)props.get(LicenseManager.LICENSE_LOCALMD5); license_localmd5 = license_localmd5 == null ? "" : license_localmd5; licenseMap.put(LicenseManager.LICENSE_LOCALMD5, license_localmd5); //?License Map<String, String> resultMap = LicenseManager.licenseValidate(licenseMap); String validateResult = resultMap.get(LicenseManager.LICENSE_VALIDATE_RESULT); if (LicenseManager.LICENSE_VALID.equals(validateResult)) { //continue } else { NotificationUtil.showWarningNotification(SystemLicence.this, "License ?License"); return; } try { URL resourceurl = SystemLicence.class.getResource(LicenseManager.LICENSE_FILE); //System.err.println("chb: SystemLicense"+resourceurl.getPath()); OutputStream fos = new FileOutputStream(resourceurl.getPath()); props.store(fos, "license"); } catch (Exception e) { e.printStackTrace(); NotificationUtil.showWarningNotification(SystemLicence.this, "License "); return; } textAreaPlaceHolder.removeAllComponents(); buttonPlaceHolder.removeComponent(cancelButton); updateButton.setData("show"); updateButton.setCaption("License"); LicenseManager.loadLicenseFile(LicenseManager.LICENSE_FILE.substring(1)); // LicenseManager.loadLicenseFile(licenseFilename) refreshLicenseInfo(); NotificationUtil.showWarningNotification(SystemLicence.this, "License ?,?"); } else { NotificationUtil.showWarningNotification(SystemLicence.this, "License ??"); } } } /** * license ? * @param license_date * @param license_count * @param license_localmd5 * @return */ private Boolean regexMatchCheck(String license_date, String license_count, String license_localmd5) { if (StringUtils.isEmpty(license_date) || StringUtils.isEmpty(license_count) || StringUtils.isEmpty(license_localmd5)) { return false; } String date_regex = "^\\d{4}-\\d{2}-\\d{2}\\s\\d{2}:\\d{2}:\\d{2}$"; //? String count_regex = "^\\d+$"; //? String md5_32_regex = "^\\w{32}$"; //? return license_localmd5.matches(md5_32_regex) && license_date.matches(date_regex) && license_count.matches(count_regex); } }); return licenseUpdateLayout; }
From source file:com.klwork.explorer.ui.business.flow.act.MyTaskRelatedContentComponent.java
License:Apache License
protected Button getAddButton() { // Add content button Button addRelatedContentButton = new Button(); addRelatedContentButton.setCaption(""); ////from ww w . ja va 2 s .c o m //addRelatedContentButton.addStyleName(ExplorerLayout.STYLE_ADD); addRelatedContentButton.addClickListener(new com.vaadin.ui.Button.ClickListener() { private static final long serialVersionUID = 1L; public void buttonClick(com.vaadin.ui.Button.ClickEvent event) { CreateAttachmentPopupWindow popup = new CreateAttachmentPopupWindow(); //?? if (task.getProcessInstanceId() != null) { popup.setProcessInstanceId(task.getProcessInstanceId()); } // Add listener to update attachments when added popup.addListener(new SubmitEventListener() { private static final long serialVersionUID = 1L; @Override protected void submitted(SubmitEvent event) { taskForm.notifyRelatedContentChanged(); } @Override protected void cancelled(SubmitEvent event) { // No attachment was added so updating UI isn't // needed. } }); ViewToolManager.showPopupWindow(popup); } }); return addRelatedContentButton; }
From source file:com.klwork.explorer.ui.business.flow.act.UploadWorkTaskContentComponent.java
License:Apache License
protected Button getAddButton() { // Add content button Button addRelatedContentButton = new Button(); addRelatedContentButton.setCaption("?"); ////from ww w. ja v a 2 s.co m //addRelatedContentButton.addStyleName(ExplorerLayout.STYLE_ADD); addRelatedContentButton.addClickListener(new com.vaadin.ui.Button.ClickListener() { private static final long serialVersionUID = 1L; public void buttonClick(com.vaadin.ui.Button.ClickEvent event) { List types = new ArrayList(); types.add("file"); CreateAttachmentPopupWindow popup = new CreateAttachmentPopupWindow(types); //?? popup.setTaskId(taskId); // Add listener to update attachments when added popup.addListener(new SubmitEventListener() { private static final long serialVersionUID = 1L; @Override protected void submitted(SubmitEvent event) { //taskForm.notifyRelatedContentChanged(); refreshTaskAttachments(); } @Override protected void cancelled(SubmitEvent event) { // No attachment was added so updating UI isn't // needed. } }); ViewToolManager.showPopupWindow(popup); } }); return addRelatedContentButton; }
From source file:com.klwork.explorer.ui.business.organization.GroupMenuBar.java
License:Apache License
protected void initActions() { Button newCaseButton = new Button(); newCaseButton.setCaption(i18nManager.getMessage(Messages.EXPAND_MENU_INVITE)); //WW_TODO Fix newCaseButton.setIcon(Images.TASK_16); addButton(newCaseButton);/*from w w w. j ava2 s. c o m*/ newCaseButton.addClickListener(new ClickListener() { public void buttonClick(ClickEvent event) { } }); }
From source file:com.klwork.explorer.ui.business.outproject.OutProjectManagerMenuBar.java
License:Apache License
protected void initActions() { Button newCaseButton = new Button(); newCaseButton.setCaption(i18nManager.getMessage(Messages.EXPAND_MENU_INVITE)); // WW_TODO Fix newCaseButton.setIcon(Images.TASK_16); addButton(newCaseButton);//from w w w . j a va2 s.c o m newCaseButton.addClickListener(new ClickListener() { public void buttonClick(ClickEvent event) { } }); }
From source file:com.klwork.explorer.ui.task.TaskMenuBar.java
License:Apache License
protected void initActions() { Button newCaseButton = new Button(); newCaseButton.setCaption(i18nManager.getMessage(Messages.TASK_NEW)); //WW_TODO Fix newCaseButton.setIcon(Images.TASK_16); addButton(newCaseButton);//from ww w. j av a2s .c o m newCaseButton.addClickListener(new ClickListener() { public void buttonClick(ClickEvent event) { NewTaskPopupWindow newTaskPopupWindow = new NewTaskPopupWindow(); ViewToolManager.showPopupWindow(newTaskPopupWindow); } }); }
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 ww . ja v a 2 s. com*/ 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.mycollab.mobile.module.crm.view.account.AccountReadViewImpl.java
License:Open Source License
@Override protected ComponentContainer createBottomPanel() { HorizontalLayout toolbarLayout = new HorizontalLayout(); toolbarLayout.setDefaultComponentAlignment(Alignment.MIDDLE_LEFT); toolbarLayout.setSpacing(true);/*from w ww . j av a2s . c o m*/ Button relatedContacts = new Button(); relatedContacts.setCaption("<span aria-hidden=\"true\" data-icon=\"" + IconConstants.CRM_CONTACT + "\"></span><div class=\"screen-reader-text\">" + UserUIContext.getMessage(ContactI18nEnum.LIST) + "</div>"); relatedContacts.setHtmlContentAllowed(true); relatedContacts.addClickListener(clickEvent -> EventBusFactory.getInstance() .post(new AccountEvent.GoToRelatedItems(this, new CrmRelatedItemsScreenData(associateContacts)))); toolbarLayout.addComponent(relatedContacts); Button relatedOpportunities = new Button(); relatedOpportunities.setCaption("<span aria-hidden=\"true\" data-icon=\"" + IconConstants.CRM_OPPORTUNITY + "\"></span><div class=\"screen-reader-text\">" + UserUIContext.getMessage(OpportunityI18nEnum.LIST) + "</div>"); relatedOpportunities.setHtmlContentAllowed(true); relatedOpportunities.addClickListener(clickEvent -> EventBusFactory.getInstance().post( new AccountEvent.GoToRelatedItems(this, new CrmRelatedItemsScreenData(associateOpportunities)))); toolbarLayout.addComponent(relatedOpportunities); Button relatedLeads = new Button(); relatedLeads.setCaption("<span aria-hidden=\"true\" data-icon=\"" + IconConstants.CRM_LEAD + "\"></span><div class=\"screen-reader-text\">" + UserUIContext.getMessage(LeadI18nEnum.LIST) + "</div>"); relatedLeads.setHtmlContentAllowed(true); relatedLeads.addClickListener(clickEvent -> EventBusFactory.getInstance() .post(new AccountEvent.GoToRelatedItems(this, new CrmRelatedItemsScreenData(associateLeads)))); toolbarLayout.addComponent(relatedLeads); Button relatedActivities = new Button(); relatedActivities.setCaption("<span aria-hidden=\"true\" data-icon=\"" + IconConstants.CRM_ACTIVITY + "\"></span><div class=\"screen-reader-text\">" + UserUIContext.getMessage(CrmCommonI18nEnum.TAB_ACTIVITY) + "</div>"); relatedActivities.setHtmlContentAllowed(true); relatedActivities.addClickListener(clickEvent -> EventBusFactory.getInstance() .post(new AccountEvent.GoToRelatedItems(this, new CrmRelatedItemsScreenData(associateActivities)))); toolbarLayout.addComponent(relatedActivities); return toolbarLayout; }