List of usage examples for com.vaadin.ui Label setValue
public void setValue(String value)
From source file:com.haulmont.cuba.web.gui.components.WebComponentsHelper.java
License:Apache License
public static void setLabelText(com.vaadin.ui.Label label, Object value, Formatter formatter) { label.setValue(value == null ? "" : String.class.isInstance(value) ? (String) value : formatter != null ? formatter.format(value) : value.toString()); }
From source file:com.haulmont.cuba.web.log.LogWindow.java
License:Apache License
private void initUI() { ClientConfig clientConfig = AppBeans.<Configuration>get(Configuration.NAME).getConfig(ClientConfig.class); String closeShortcut = clientConfig.getCloseShortcut(); KeyCombination closeCombination = KeyCombination.create(closeShortcut); com.vaadin.event.ShortcutAction closeShortcutAction = new com.vaadin.event.ShortcutAction( "closeShortcutAction", closeCombination.getKey().getCode(), KeyCombination.Modifier.codes(closeCombination.getModifiers())); addActionHandler(new com.vaadin.event.Action.Handler() { @Override/* w w w.j a v a 2 s .c o m*/ public com.vaadin.event.Action[] getActions(Object target, Object sender) { return new com.vaadin.event.Action[] { closeShortcutAction }; } @Override public void handleAction(com.vaadin.event.Action action, Object sender, Object target) { if (Objects.equals(action, closeShortcutAction)) { close(); } } }); VerticalLayout layout = new VerticalLayout(); layout.setSpacing(true); layout.setSizeFull(); setContent(layout); Panel scrollablePanel = new Panel(); scrollablePanel.setSizeFull(); VerticalLayout scrollContent = new VerticalLayout(); scrollContent.setSizeUndefined(); scrollablePanel.setContent(scrollContent); final Label label = new Label(); label.setContentMode(ContentMode.HTML); label.setValue(writeLog()); label.setSizeUndefined(); label.setStyleName("c-log-content"); ((Layout) scrollablePanel.getContent()).addComponent(label); HorizontalLayout topLayout = new HorizontalLayout(); topLayout.setWidth("100%"); topLayout.setHeightUndefined(); Messages messages = AppBeans.get(Messages.NAME); Button refreshBtn = new CubaButton(messages.getMessage(getClass(), "logWindow.refreshBtn"), (Button.ClickListener) event -> label.setValue(writeLog())); topLayout.addComponent(refreshBtn); layout.addComponent(topLayout); layout.addComponent(scrollablePanel); layout.setExpandRatio(scrollablePanel, 1.0f); }
From source file:com.haulmont.cuba.web.WebWindowManager.java
License:Apache License
@Override public void showMessageDialog(String title, String message, MessageType messageType) { backgroundWorker.checkUIAccess();// w w w . j av a 2 s.c o m 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();// www .ja v a2s .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.hybridbpm.ui.MainMenu.java
License:Apache License
public void changeNotification(String viewUrl, Boolean visible, String message) { for (Component component : menuItemsLayout) { if (component instanceof CssLayout) { Component button = ((CssLayout) component).getComponent(0); if (button instanceof ValoMenuItemButton) { ValoMenuItemButton valoMenuItemButton = (ValoMenuItemButton) button; if (valoMenuItemButton.getView().getUrl().equals(viewUrl)) { Label label = (Label) ((CssLayout) component).getComponent(1); label.setValue(message); label.setVisible(visible); }/*from www.j ava2 s .c om*/ } } } }
From source file:com.klwork.explorer.ui.business.social.DiscussPopupWindow.java
License:Apache License
public VerticalLayout initMainLayout(final SocialUserWeibo userWeibo) { return new VerticalLayout() { {//from w w w . j av a 2s. co m setSizeFull(); setSpacing(true); setMargin(new MarginInfo(true, true, false, true)); Label descriptionField = new Label(); descriptionField.addStyleName("wb_text"); descriptionField.setContentMode(ContentMode.HTML); descriptionField.setValue( "@" + userWeibo.getUserScreenName() + ":" + mainPage.textTranslate(userWeibo.getText())); addComponent(descriptionField); addComponent(new HorizontalLayout() {// ?,? { setWidth("100%"); // Label inputFontField = initInputFontField(); addComponent(inputFontField); // setExpandRatio(image, 1.0f); setComponentAlignment(inputFontField, Alignment.MIDDLE_RIGHT); setExpandRatio(inputFontField, 0.2f); } }); // ? weiboContentTA = new TextArea(""); weiboContentTA.setWidth("100%"); weiboContentTA.setColumns(25); weiboContentTA.focus(); addComponent(weiboContentTA); scheduleEventFieldGroup.bind(weiboContentTA, "content"); // ? addComponent(new HorizontalLayout() { { setSpacing(true); // setSizeFull(); // setMargin(true); CheckBox simuField = CommonFieldHandler.createCheckBox(""); simuField.addValueChangeListener(new Property.ValueChangeListener() { private static final long serialVersionUID = -7104996493482558021L; @Override public void valueChange(ValueChangeEvent event) { Object value = event.getProperty().getValue(); } }); addComponent(simuField); // setExpandRatio(image, 1.0f); setComponentAlignment(simuField, Alignment.MIDDLE_LEFT); Label commentLable = new Label(); commentLable.setContentMode(ContentMode.HTML); commentLable.setValue("????"); addComponent(commentLable); // setExpandRatio(image, 1.0f); setComponentAlignment(commentLable, Alignment.MIDDLE_LEFT); Image image = initFaceComponet();// addComponent(image); } }); // HorizontalLayout buttonLayout = new HorizontalLayout() { { setSpacing(true); setSizeFull(); // setMargin(true); Button okButton = new Button(i18nManager.getMessage(Messages.BUTTON_OK)); addComponent(okButton); setComponentAlignment(okButton, Alignment.TOP_RIGHT); okButton.addClickListener(new ClickListener() { public void buttonClick(ClickEvent event) { BinderHandler.commit(scheduleEventFieldGroup); int ret = socialService.discussWeibo(weiboForwardSend); if (ret == 1) { Notification.show("??", Notification.Type.HUMANIZED_MESSAGE); } close(); } }); setExpandRatio(okButton, 1.0f); Button cancleButton = new Button(i18nManager.getMessage(Messages.BUTTON_CANCEL)); addComponent(cancleButton); setComponentAlignment(cancleButton, Alignment.TOP_RIGHT); cancleButton.addClickListener(new ClickListener() { public void buttonClick(ClickEvent event) { close(); } }); } }; addComponent(buttonLayout); setExpandRatio(buttonLayout, 1f); } }; }
From source file:com.klwork.explorer.ui.business.social.SaveToNotePopupWindow.java
License:Apache License
public VerticalLayout initMainLayout(final SocialUserWeibo userWeibo) { return new VerticalLayout() { {//from w w w . j a v a 2 s . c o m setSizeFull(); setSpacing(true); setMargin(new MarginInfo(true, true, false, true)); Label descriptionField = new Label(); descriptionField.addStyleName("wb_text"); descriptionField.setContentMode(ContentMode.HTML); descriptionField.setValue(""); addComponent(descriptionField); // ? weiboContentTA = new TextArea(""); weiboContentTA.setWidth("100%"); weiboContentTA.setColumns(25); weiboContentTA.focus(); addComponent(weiboContentTA); scheduleEventFieldGroup.bind(weiboContentTA, "content"); if (hasOrginWeibo) {// weiboContentTA.setValue("//@" + userWeibo.getUserScreenName() + ": " + userWeibo.getText()); } else { weiboContentTA.setValue(userWeibo.getText()); //+ mainPage.textTranslate(userWeibo.getText())); } //, addComponent(new VerticalLayout() { { setSpacing(true); TextField titleField = CommonFieldHandler.createTextField(""); scheduleEventFieldGroup.bind(titleField, "title"); //??? if (userWeibo.getText() != null && userWeibo.getText().length() > 10) { titleField.setValue(userWeibo.getText().substring(0, 10)); } addComponent(titleField); // setSizeFull(); // setMargin(true); SocialUserAccount noteAccount = socialUserAccountService .findSocialUserByType(socialUserAccount.getOwnUser(), DictDef.dictInt("evernote")); if (noteAccount != null) { noteEntity.setUserAccountId(noteAccount.getId()); } Map<String, String> map = socialEvernoteService.queryNotebook(noteAccount); ComboBox noteMap = CommonFieldHandler.createComBox("", map, ""); addComponent(noteMap); setComponentAlignment(noteMap, Alignment.MIDDLE_LEFT); } }); // HorizontalLayout buttonLayout = new HorizontalLayout() { { setSpacing(true); setSizeFull(); // setMargin(true); Button okButton = new Button(i18nManager.getMessage(Messages.BUTTON_OK)); addComponent(okButton); setComponentAlignment(okButton, Alignment.TOP_RIGHT); okButton.addClickListener(new ClickListener() { public void buttonClick(ClickEvent event) { BinderHandler.commit(scheduleEventFieldGroup); //? int ret = socialEvernoteService.saveWeiboToNotes(noteEntity); if (ret == 1) { Notification.show("??", Notification.Type.HUMANIZED_MESSAGE); } else { Notification.show("??!", Notification.Type.HUMANIZED_MESSAGE); } close(); } }); setExpandRatio(okButton, 1.0f); Button cancleButton = new Button(i18nManager.getMessage(Messages.BUTTON_CANCEL)); addComponent(cancleButton); setComponentAlignment(cancleButton, Alignment.TOP_RIGHT); cancleButton.addClickListener(new ClickListener() { public void buttonClick(ClickEvent event) { close(); } }); } }; addComponent(buttonLayout); setExpandRatio(buttonLayout, 1f); } }; }
From source file:com.klwork.explorer.ui.business.social.TransmitPopupWindow.java
License:Apache License
public TransmitPopupWindow(final SocialUserWeibo userWeibo, final AbstractWeiboDisplayPage mainPage) { super(mainPage.getSocialType()); this.socialUserWeiboService = ViewToolManager.getBean("socialUserWeiboService"); this.socialService = AbstractSocialService.querySocialClass(mainPage.getSocialType()); this.i18nManager = ViewToolManager.getI18nManager(); weiboForwardSend.setWeibId(userWeibo.getWeiboId()); weiboForwardSend.setUserAccountId(userWeibo.getUserAccountId()); this.userWeibo = userWeibo; if (userWeibo.getRetweetedId() != null) { orginWeibo = socialUserWeiboService.findSocialUserWeiboById(userWeibo.getRetweetedId()); hasOrginWeibo = true;/*ww w . java 2s .c o m*/ weiboForwardSend.setWeibId(orginWeibo.getId()); } scheduleEventFieldGroup.setBuffered(true); if (currentBeanItem != null) { scheduleEventFieldGroup.setItemDataSource(currentBeanItem); } mainLayout = new VerticalLayout() { { setSizeFull(); setSpacing(true); setMargin(new MarginInfo(true, true, false, true)); Label descriptionField = new Label(); descriptionField.addStyleName("wb_text"); descriptionField.setContentMode(ContentMode.HTML); descriptionField.setValue( "@" + userWeibo.getUserScreenName() + ":" + mainPage.textTranslate(userWeibo.getText())); if (hasOrginWeibo) { descriptionField.setValue("@" + orginWeibo.getUserScreenName() + ":" + mainPage.textTranslate(orginWeibo.getText())); } addComponent(descriptionField); addComponent(new HorizontalLayout() {// ?,? { // setSizeFull(); // setSpacing(true); setWidth("100%"); // setSpacing(true); // setMargin(true); /*Image image = initFaceComponet(); addComponent(image); setExpandRatio(image, 1.2f); setComponentAlignment(image, Alignment.MIDDLE_LEFT);*/ // Label inputFontField = initInputFontField(); addComponent(inputFontField); // setExpandRatio(image, 1.0f); setComponentAlignment(inputFontField, Alignment.MIDDLE_RIGHT); setExpandRatio(inputFontField, 0.2f); } }); // ? weiboContentTA.setWidth("100%"); weiboContentTA.setColumns(25); weiboContentTA.focus(); addComponent(weiboContentTA); scheduleEventFieldGroup.bind(weiboContentTA, "content"); if (hasOrginWeibo) {// weiboContentTA.setValue("//@" + userWeibo.getUserScreenName() + ": " + userWeibo.getText()); } // ? addComponent(new HorizontalLayout() { { setSpacing(true); // setSizeFull(); // setMargin(true); CheckBox simuField = CommonFieldHandler.createCheckBox(""); simuField.addValueChangeListener(new Property.ValueChangeListener() { private static final long serialVersionUID = -7104996493482558021L; @Override public void valueChange(ValueChangeEvent event) { Object value = event.getProperty().getValue(); } }); addComponent(simuField); // setExpandRatio(image, 1.0f); setComponentAlignment(simuField, Alignment.MIDDLE_LEFT); Label commentLable = new Label(); commentLable.setContentMode(ContentMode.HTML); commentLable.setValue("? " + "" + userWeibo.getUserScreenName()); addComponent(commentLable); // setExpandRatio(image, 1.0f); setComponentAlignment(commentLable, Alignment.MIDDLE_LEFT); Image image = initFaceComponet();// addComponent(image); } }); if (hasOrginWeibo) { // ? addComponent(new HorizontalLayout() { { // setSizeFull(); setSpacing(true); // setMargin(true); CheckBox simuOriginalField = CommonFieldHandler.createCheckBox(""); simuOriginalField.addValueChangeListener(new Property.ValueChangeListener() { private static final long serialVersionUID = -7104996493482558021L; @Override public void valueChange(ValueChangeEvent event) { Object value = event.getProperty().getValue(); } }); addComponent(simuOriginalField); // setExpandRatio(image, 1.0f); setComponentAlignment(simuOriginalField, Alignment.MIDDLE_LEFT); Label commentLable = new Label(); commentLable.setContentMode(ContentMode.HTML); commentLable .setValue("? " + "" + orginWeibo.getUserScreenName()); addComponent(commentLable); // setExpandRatio(image, 1.0f); setComponentAlignment(commentLable, Alignment.MIDDLE_LEFT); } }); } // HorizontalLayout buttonLayout = new HorizontalLayout() { { setSpacing(true); setSizeFull(); // setMargin(true); Button okButton = new Button(i18nManager.getMessage(Messages.BUTTON_OK)); addComponent(okButton); setComponentAlignment(okButton, Alignment.TOP_RIGHT); okButton.addClickListener(new ClickListener() { public void buttonClick(ClickEvent event) { BinderHandler.commit(scheduleEventFieldGroup); int ret = socialService.forwardWeibo(weiboForwardSend); if (ret == 1) { Notification.show("??", Notification.Type.HUMANIZED_MESSAGE); } close(); } }); setExpandRatio(okButton, 1.0f); Button cancleButton = new Button(i18nManager.getMessage(Messages.BUTTON_CANCEL)); addComponent(cancleButton); setComponentAlignment(cancleButton, Alignment.TOP_RIGHT); cancleButton.addClickListener(new ClickListener() { public void buttonClick(ClickEvent event) { // handleFormSubmit(); close(); } }); } }; addComponent(buttonLayout); setExpandRatio(buttonLayout, 1f); } }; setContent(mainLayout); setMainLayout(mainLayout); setWeiboContentTextArea(weiboContentTA); }
From source file:com.klwork.explorer.ui.custom.ToolBar.java
License:Apache License
public ToolBar() { entryMap = new HashMap<String, ToolbarEntry>(); actionButtons = new ArrayList<Button>(); additionalComponents = new ArrayList<Component>(); setWidth("100%"); setHeight(36, UNITS_PIXELS);//from w ww. ja va 2 s .c o m addStyleName(ExplorerLayout.STYLE_TOOLBAR); setSpacing(true); setMargin(ViewToolManager.currentCommMargin()); // Add label to fill excess space Label spacer = new Label(); spacer.setContentMode(Label.CONTENT_XHTML); spacer.setValue(" "); addComponent(spacer); setExpandRatio(spacer, 1.0f); }
From source file:com.klwork.explorer.ui.mainlayout.MainLayout.java
License:Apache License
protected void initFooter() { footer = new CssLayout(); footer.setWidth(100, Unit.PERCENTAGE); footer.addStyleName(ExplorerLayout.STYLE_MAIN_FOOTER); addComponent(footer);//w ww . j av a 2s. co m Label footerLabel = new Label(); footerLabel.setContentMode(ContentMode.HTML); footerLabel.setValue(i18nManager.getMessage(Messages.FOOTER_MESSAGE)); footerLabel.setWidth(100, Unit.PERCENTAGE); footer.addComponent(footerLabel); }