List of usage examples for com.vaadin.ui TextArea getValue
@Override
public String getValue()
From source file:com.cms.utils.CommonValidator.java
public static boolean checkMaxlength(TextArea field, int length, boolean allowNull) { if (allowNull == true) { return false; } else {// w w w . j a va2 s . c o m if (field.getValue().trim().length() > length) { Notification.show(BundleUtils.getString("message.error.overlengthString"), Notification.Type.WARNING_MESSAGE); field.focus(); return true; } } return false; }
From source file:com.esofthead.mycollab.mobile.module.crm.ui.NotesList.java
License:Open Source License
private void initUI() { noteList = new BeanList<NoteService, NoteSearchCriteria, SimpleNote>(noteService, NoteRowDisplayHandler.class); noteList.setDisplayEmptyListText(false); noteList.setStyleName("noteList"); noteListContainer = new VerticalLayout(); this.setContent(noteListContainer); displayNotes();/*from w w w. j a v a 2 s . c om*/ HorizontalLayout commentBox = new HorizontalLayout(); commentBox.setSizeFull(); commentBox.setStyleName("comment-box"); commentBox.setSpacing(true); commentBox.setDefaultComponentAlignment(Alignment.MIDDLE_LEFT); final TextArea noteInput = new TextArea(); noteInput.setInputPrompt(AppContext.getMessage(GenericI18Enum.M_NOTE_INPUT_PROMPT)); noteInput.setSizeFull(); commentBox.addComponent(noteInput); commentBox.setExpandRatio(noteInput, 1.0f); Button postBtn = new Button(AppContext.getMessage(GenericI18Enum.M_BUTTON_SEND)); postBtn.setStyleName("submit-btn"); postBtn.setWidthUndefined(); postBtn.addClickListener(new Button.ClickListener() { private static final long serialVersionUID = -5095455325725786794L; @Override public void buttonClick(Button.ClickEvent event) { final Note note = new Note(); note.setCreateduser(AppContext.getUsername()); note.setNote(noteInput.getValue()); note.setSaccountid(AppContext.getAccountId()); note.setSubject(""); note.setType(type); note.setTypeid(typeid); note.setCreatedtime(new GregorianCalendar().getTime()); note.setLastupdatedtime(new GregorianCalendar().getTime()); noteService.saveWithSession(note, AppContext.getUsername()); // Save Relay Email -- having time must refact to // Aop // ------------------------------------------------------ RelayEmailNotification relayNotification = new RelayEmailNotification(); relayNotification.setChangeby(AppContext.getUsername()); relayNotification.setChangecomment(noteInput.getValue()); relayNotification.setSaccountid(AppContext.getAccountId()); relayNotification.setType(type); relayNotification.setAction(MonitorTypeConstants.ADD_COMMENT_ACTION); relayNotification.setTypeid("" + typeid); if (type.equals(CrmTypeConstants.ACCOUNT)) { relayNotification.setEmailhandlerbean(AccountRelayEmailNotificationAction.class.getName()); } else if (type.equals(CrmTypeConstants.CONTACT)) { relayNotification.setEmailhandlerbean(ContactRelayEmailNotificationAction.class.getName()); } else if (type.equals(CrmTypeConstants.CAMPAIGN)) { relayNotification.setEmailhandlerbean(CampaignRelayEmailNotificationAction.class.getName()); } else if (type.equals(CrmTypeConstants.LEAD)) { relayNotification.setEmailhandlerbean(LeadRelayEmailNotificationAction.class.getName()); } else if (type.equals(CrmTypeConstants.OPPORTUNITY)) { relayNotification.setEmailhandlerbean(OpportunityRelayEmailNotificationAction.class.getName()); } else if (type.equals(CrmTypeConstants.CASE)) { relayNotification.setEmailhandlerbean(CaseRelayEmailNotificationAction.class.getName()); } else if (type.equals(CrmTypeConstants.TASK)) { relayNotification.setEmailhandlerbean(TaskRelayEmailNotificationAction.class.getName()); } else if (type.equals(CrmTypeConstants.MEETING)) { relayNotification.setEmailhandlerbean(MeetingRelayEmailNotificationAction.class.getName()); } else if (type.equals(CrmTypeConstants.CALL)) { relayNotification.setEmailhandlerbean(CallRelayEmailNotificationAction.class.getName()); } RelayEmailNotificationService relayEmailNotificationService = ApplicationContextUtil .getSpringBean(RelayEmailNotificationService.class); relayEmailNotificationService.saveWithSession(relayNotification, AppContext.getUsername()); noteInput.setValue(""); displayNotes(); } }); commentBox.addComponent(postBtn); this.setToolbar(commentBox); }
From source file:com.esofthead.mycollab.module.project.view.kanban.AddNewColumnWindow.java
License:Open Source License
public AddNewColumnWindow(final IKanbanView kanbanView, final String type, final String fieldGroup) { super(AppContext.getMessage(TaskI18nEnum.ACTION_NEW_COLUMN)); this.setWidth("800px"); this.setModal(true); this.setResizable(false); this.center(); MVerticalLayout layout = new MVerticalLayout().withMargin(new MarginInfo(false, false, true, false)); GridFormLayoutHelper gridFormLayoutHelper = GridFormLayoutHelper.defaultFormLayoutHelper(1, 4); this.setContent(layout); final TextField stageField = new TextField(); final CheckBox defaultProject = new CheckBox(); defaultProject.setEnabled(AppContext.canBeYes(RolePermissionCollections.GLOBAL_PROJECT_SETTINGS)); final ColorPicker colorPicker = new ColorPicker("", new com.vaadin.shared.ui.colorpicker.Color( DEFAULT_COLOR.getRed(), DEFAULT_COLOR.getGreen(), DEFAULT_COLOR.getBlue())); final TextArea description = new TextArea(); gridFormLayoutHelper.addComponent(stageField, AppContext.getMessage(GenericI18Enum.FORM_NAME), 0, 0); gridFormLayoutHelper.addComponent(defaultProject, AppContext.getMessage(TaskI18nEnum.FORM_COLUMN_DEFAULT_FOR_NEW_PROJECT), 0, 1); gridFormLayoutHelper.addComponent(colorPicker, AppContext.getMessage(TaskI18nEnum.FORM_COLUMN_COLOR), 0, 2); gridFormLayoutHelper.addComponent(description, AppContext.getMessage(GenericI18Enum.FORM_DESCRIPTION), 0, 3);//from w w w.ja v a 2s .c o m Button saveBtn = new Button(AppContext.getMessage(GenericI18Enum.BUTTON_SAVE), new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent clickEvent) { OptionVal optionVal = new OptionVal(); optionVal.setCreatedtime(new GregorianCalendar().getTime()); optionVal.setCreateduser(AppContext.getUsername()); optionVal.setDescription(description.getValue()); com.vaadin.shared.ui.colorpicker.Color color = colorPicker.getColor(); String cssColor = color.getCSS(); if (cssColor.startsWith("#")) { cssColor = cssColor.substring(1); } optionVal.setColor(cssColor); if (defaultProject.getValue()) { optionVal.setIsdefault(true); } else { optionVal.setIsdefault(false); optionVal.setExtraid(CurrentProjectVariables.getProjectId()); } optionVal.setSaccountid(AppContext.getAccountId()); optionVal.setType(type); optionVal.setTypeval(stageField.getValue()); optionVal.setFieldgroup(fieldGroup); OptionValService optionService = AppContextUtil.getSpringBean(OptionValService.class); int optionValId = optionService.saveWithSession(optionVal, AppContext.getUsername()); if (optionVal.getIsdefault()) { optionVal.setId(null); optionVal.setIsdefault(false); optionVal.setRefoption(optionValId); optionVal.setExtraid(CurrentProjectVariables.getProjectId()); optionService.saveWithSession(optionVal, AppContext.getUsername()); } kanbanView.addColumn(optionVal); close(); } }); saveBtn.setIcon(FontAwesome.SAVE); saveBtn.setStyleName(UIConstants.BUTTON_ACTION); Button cancelBtn = new Button(AppContext.getMessage(GenericI18Enum.BUTTON_CANCEL), new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent clickEvent) { close(); } }); cancelBtn.setStyleName(UIConstants.BUTTON_OPTION); MHorizontalLayout controls = new MHorizontalLayout().with(cancelBtn, saveBtn) .withMargin(new MarginInfo(false, true, false, false)); layout.with(gridFormLayoutHelper.getLayout(), controls).withAlign(controls, Alignment.BOTTOM_RIGHT); }
From source file:com.esspl.datagen.ui.ResultView.java
License:Open Source License
public ResultView(final DataGenApplication dataGenApplication, ArrayList<GeneratorBean> rowList) { log.debug("ResultView constructor start"); VerticalLayout layout = (VerticalLayout) this.getContent(); layout.setMargin(false);//from w w w . j ava 2s .c om layout.setSpacing(false); layout.setHeight("500px"); layout.setWidth("600px"); Button close = new Button("Close", new ClickListener() { public void buttonClick(ClickEvent event) { log.info("ResultView - Close Button clicked"); dataGenApplication.getMainWindow().removeWindow(event.getButton().getWindow()); } }); close.setIcon(DataGenConstant.CLOSE_ICON); String dataOption = dataGenApplication.generateType.getValue().toString(); Generator genrator = null; if (dataOption.equalsIgnoreCase("xml")) { genrator = new XmlDataGenerator(); } else if (dataOption.equalsIgnoreCase("sql")) { genrator = new SqlDataGenerator(); } else if (dataOption.equalsIgnoreCase("csv")) { genrator = new CsvDataGenerator(); } if (genrator == null) { log.info("ResultView - genrator object is null"); dataGenApplication.getMainWindow().removeWindow(this); return; } //Data generated from respective command class and shown in the modal window final TextArea message = new TextArea(); message.setSizeFull(); message.setHeight("450px"); message.setWordwrap(false); message.setStyleName("noResizeTextArea"); message.setValue(genrator.generate(dataGenApplication, rowList)); layout.addComponent(message); Button copy = new Button("Copy", new ClickListener() { public void buttonClick(ClickEvent event) { log.info("ResultView - Copy Button clicked"); //As on Unix environment, it gives headless exception we need to handle it try { //StringSelection stringSelection = new StringSelection(message.getValue().toString()); Transferable tText = new StringSelection(message.getValue().toString()); Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard(); clipboard.setContents(tText, null); } catch (HeadlessException e) { dataGenApplication.getMainWindow() .showNotification("Due to some problem Text could not be copied."); e.printStackTrace(); } } }); copy.setIcon(DataGenConstant.COPY_ICON); Button execute = new Button("Execute", new ClickListener() { public void buttonClick(ClickEvent event) { log.info("ResultView - Execute Button clicked"); dataGenApplication.tabSheet.setSelectedTab(dataGenApplication.executor); dataGenApplication.executor.setScript(message.getValue().toString()); dataGenApplication.getMainWindow().removeWindow(event.getButton().getWindow()); } }); execute.setIcon(DataGenConstant.EXECUTOR_ICON); Button export = new Button("Export to File", new ClickListener() { public void buttonClick(ClickEvent event) { log.info("ResultView - Export to File Button clicked"); String dataOption = dataGenApplication.generateType.getValue().toString(); DataGenStreamUtil resource = null; try { if (dataOption.equalsIgnoreCase("xml")) { File tempFile = File.createTempFile("tmp", ".xml"); BufferedWriter out = new BufferedWriter(new FileWriter(tempFile)); out.write(message.getValue().toString()); out.close(); resource = new DataGenStreamUtil(dataGenApplication, "data.xml", "text/xml", tempFile); } else if (dataOption.equalsIgnoreCase("csv")) { File tempFile = File.createTempFile("tmp", ".csv"); BufferedWriter out = new BufferedWriter(new FileWriter(tempFile)); out.write(message.getValue().toString()); out.close(); resource = new DataGenStreamUtil(dataGenApplication, "data.csv", "text/csv", tempFile); } else if (dataOption.equalsIgnoreCase("sql")) { File tempFile = File.createTempFile("tmp", ".sql"); BufferedWriter out = new BufferedWriter(new FileWriter(tempFile)); out.write(message.getValue().toString()); out.close(); resource = new DataGenStreamUtil(dataGenApplication, "data.sql", "text/plain", tempFile); } getWindow().open(resource, "_self"); } catch (FileNotFoundException e) { log.info("ResultView - Export to File Error - " + e.getMessage()); e.printStackTrace(); } catch (IOException e) { log.info("ResultView - Export to File Error - " + e.getMessage()); e.printStackTrace(); } catch (Exception e) { log.info("ResultView - Export to File Error - " + e.getMessage()); e.printStackTrace(); } } }); export.setIcon(DataGenConstant.EXPORT_ICON); HorizontalLayout bttnBar = new HorizontalLayout(); if (dataOption.equalsIgnoreCase("sql")) { bttnBar.addComponent(execute); } bttnBar.addComponent(export); bttnBar.addComponent(copy); bttnBar.addComponent(close); layout.addComponent(bttnBar); layout.setComponentAlignment(bttnBar, Alignment.MIDDLE_CENTER); log.debug("ResultView constructor end"); }
From source file:com.etest.view.testbank.CellCaseWindow.java
Window modifyCaseWindow(CellCase cellCase) { VerticalLayout v = new VerticalLayout(); v.setWidth("100%"); v.setMargin(true);/*from w w w . j a v a 2 s. c o m*/ v.setSpacing(true); Window sub = new Window("MODIFY"); sub.setWidth("400px"); sub.setModal(true); sub.center(); ComboBox actionDone = new ComboBox("Action: "); actionDone.setWidth("70%"); actionDone.addStyleName(ValoTheme.COMBOBOX_SMALL); actionDone.setNullSelectionAllowed(false); actionDone.addItem("resolved"); actionDone.addItem("clarified"); actionDone.addItem("modified"); actionDone.setImmediate(true); v.addComponent(actionDone); TextArea remarks = new TextArea("Remarks: "); remarks.setWidth("100%"); remarks.setRows(3); v.addComponent(remarks); Button modify = new Button("UPDATE"); modify.setWidth("70%"); modify.setIcon(FontAwesome.EDIT); modify.addStyleName(ValoTheme.BUTTON_PRIMARY); modify.addStyleName(ValoTheme.BUTTON_SMALL); modify.addClickListener((Button.ClickEvent event) -> { if (remarks.getValue() == null || remarks.getValue().trim().isEmpty()) { Notification.show("Add remarks!", Notification.Type.WARNING_MESSAGE); return; } if (actionDone.getValue() == null) { Notification.show("Add action!", Notification.Type.WARNING_MESSAGE); return; } cellCase.setActionDone(actionDone.getValue().toString()); cellCase.setRemarks(remarks.getValue().trim()); boolean result = ccs.modifyCellCase(cellCase); if (result) { Notification.show("Case has been Modified!", Notification.Type.TRAY_NOTIFICATION); sub.close(); close(); } }); v.addComponent(modify); sub.setContent(v); sub.getContent().setHeightUndefined(); return sub; }
From source file:com.etest.view.testbank.cellitem.CellItemWindow.java
Window modifyCellItemWindow(CellItem ci) { VerticalLayout v = new VerticalLayout(); v.setWidth("100%"); v.setMargin(true);//from w ww. j a v a2 s .co m v.setSpacing(true); Window sub = new Window("MODIFY"); sub.setWidth("400px"); sub.setModal(true); sub.center(); ComboBox actionDone = new ComboBox("Action: "); actionDone.setWidth("70%"); actionDone.addStyleName(ValoTheme.COMBOBOX_SMALL); actionDone.setNullSelectionAllowed(false); actionDone.addItem("resolved"); actionDone.addItem("clarified"); actionDone.addItem("modified"); actionDone.setImmediate(true); v.addComponent(actionDone); TextArea remarks = new TextArea("Remarks: "); remarks.setWidth("100%"); remarks.setRows(3); v.addComponent(remarks); Button modify = new Button("UPDATE"); modify.setWidth("70%"); modify.setIcon(FontAwesome.EDIT); modify.addStyleName(ValoTheme.BUTTON_PRIMARY); modify.addStyleName(ValoTheme.BUTTON_SMALL); modify.addClickListener((Button.ClickEvent event) -> { if (remarks.getValue() == null || remarks.getValue().trim().isEmpty()) { Notification.show("Add remarks!", Notification.Type.WARNING_MESSAGE); return; } if (actionDone.getValue() == null) { Notification.show("Add action!", Notification.Type.WARNING_MESSAGE); return; } ci.setRemarks(remarks.getValue().trim()); ci.setActionDone(actionDone.getValue().toString()); boolean result = cis.modifyCellItem(ci); if (result) { sub.close(); close(); } }); v.addComponent(modify); sub.setContent(v); sub.getContent().setHeightUndefined(); return sub; }
From source file:com.etest.view.testbank.cellitem.CellItemWindow.java
Window modifyKeyWindow(int itemKeyId, int cellItemId, String keyValue, String optionValue, boolean isOptionKeyExist) { VerticalLayout v = new VerticalLayout(); v.setWidth("100%"); v.setMargin(true);/* w w w. j av a2 s .c om*/ v.setSpacing(true); Window sub = new Window("MODIFY"); sub.setWidth("400px"); sub.setModal(true); sub.center(); ComboBox actionDone = new ComboBox("Action: "); actionDone.setWidth("70%"); actionDone.addStyleName(ValoTheme.COMBOBOX_SMALL); actionDone.setNullSelectionAllowed(false); actionDone.addItem("resolved"); actionDone.addItem("clarified"); actionDone.addItem("modified"); actionDone.setImmediate(true); v.addComponent(actionDone); TextArea remarks = new TextArea("Remarks: "); remarks.setWidth("100%"); remarks.setRows(3); v.addComponent(remarks); Button modify = new Button("UPDATE"); modify.setWidth("70%"); modify.setIcon(FontAwesome.EDIT); modify.addStyleName(ValoTheme.BUTTON_PRIMARY); modify.addStyleName(ValoTheme.BUTTON_SMALL); modify.addClickListener((Button.ClickEvent event) -> { if (remarks.getValue() == null || remarks.getValue().trim().isEmpty()) { Notification.show("Add remarks!", Notification.Type.WARNING_MESSAGE); return; } if (actionDone.getValue() == null) { Notification.show("Add action!", Notification.Type.WARNING_MESSAGE); return; } boolean result = k.modifyItemKey(itemKeyId, cellItemId, keyValue, optionValue, isOptionKeyExist, remarks.getValue().trim(), actionDone.getValue().toString()); if (result) { Notification.show("Key SUCCESSFULLY modified", Notification.Type.TRAY_NOTIFICATION); sub.close(); } }); v.addComponent(modify); sub.setContent(v); sub.getContent().setHeightUndefined(); return sub; }
From source file:com.jiangyifen.ec2.ui.mgr.system.tabsheet.SystemLicence.java
/** * added by chb 20140520/*from w w w. j a 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.task.TaskDetailPanel.java
License:Apache License
protected void initDescription(HorizontalLayout layout) { final CssLayout descriptionLayout = new CssLayout(); descriptionLayout.setWidth(100, Unit.PERCENTAGE); layout.addComponent(descriptionLayout); layout.setExpandRatio(descriptionLayout, 1.0f); layout.setComponentAlignment(descriptionLayout, Alignment.MIDDLE_LEFT); String descriptionText = null; if (task.getDescription() != null && !"".equals(task.getDescription())) { descriptionText = task.getDescription(); } else {//?? descriptionText = i18nManager.getMessage(Messages.TASK_NO_DESCRIPTION); }//from w w w . j av a 2 s . c o m final Label descriptionLabel = new Label(descriptionText); descriptionLabel.addStyleName(ExplorerLayout.STYLE_CLICKABLE); descriptionLayout.addComponent(descriptionLabel); descriptionLayout.addLayoutClickListener(new LayoutClickListener() { public void layoutClick(LayoutClickEvent event) { if (event.getClickedComponent() != null && event.getClickedComponent().equals(descriptionLabel)) { // layout for textarea + ok button final VerticalLayout editLayout = new VerticalLayout(); editLayout.setSpacing(true); // textarea final TextArea descriptionTextArea = new TextArea(); // descriptionTextArea.setNullRepresentation(""); descriptionTextArea.setWidth(100, Unit.PERCENTAGE); descriptionTextArea.setValue(task.getDescription()); editLayout.addComponent(descriptionTextArea); // ok button Button okButton = new Button(i18nManager.getMessage(Messages.BUTTON_OK)); editLayout.addComponent(okButton); editLayout.setComponentAlignment(okButton, Alignment.BOTTOM_RIGHT); // replace descriptionLayout.replaceComponent(descriptionLabel, editLayout); // When OK is clicked -> update task data + ui okButton.addClickListener(new ClickListener() { public void buttonClick(ClickEvent event) { // Update data task.setDescription(descriptionTextArea.getValue().toString()); taskService.saveTask(task); // Update UI descriptionLabel.setValue(task.getDescription()); descriptionLayout.replaceComponent(editLayout, descriptionLabel); } }); } } }); }
From source file:com.mechanicshop.components.TableLayout.java
public void createCustomMessage() { final TextArea textArea = new TextArea(); textArea.setImmediate(true);//from www .ja v a 2 s . c om textArea.setColumns(30); textArea.setRows(10); textArea.addStyleName(ValoTheme.TEXTAREA_SMALL); textArea.setRequired(true); final Window subWindow = new Window(); subWindow.setModal(true); subWindow.setHeight("350px"); subWindow.setWidth("500px"); subWindow.setCaption("Insert Message"); subWindow.setStyleName(ValoTheme.WINDOW_TOP_TOOLBAR); subWindow.setClosable(false); subWindow.setResizable(false); HorizontalLayout layoutButtons = new HorizontalLayout(); layoutButtons.setMargin(false); Button sendBtn = new Button("Send"); sendBtn.addClickListener(new ClickListener() { @Override public void buttonClick(ClickEvent event) { try { textArea.validate(); String message = textArea.getValue(); smsSenderService.sendMessageMassive(message); subWindow.close(); Notification.show("Message Sent"); } catch (Exception e) { } } }); sendBtn.setImmediate(true); sendBtn.setStyleName(ValoTheme.BUTTON_TINY); sendBtn.addStyleName(ValoTheme.BUTTON_FRIENDLY); Button cancelBtn = new Button("Cancel"); cancelBtn.setStyleName(ValoTheme.BUTTON_TINY); cancelBtn.addStyleName(ValoTheme.BUTTON_DANGER); cancelBtn.setImmediate(true); cancelBtn.addClickListener(new ClickListener() { @Override public void buttonClick(ClickEvent event) { subWindow.close(); } }); layoutButtons.setSizeUndefined(); layoutButtons.setSpacing(true); layoutButtons.addComponents(cancelBtn, sendBtn); VerticalLayout layout = new VerticalLayout(); layout.setSpacing(true); layout.setMargin(true); layout.addComponent(textArea); layout.addComponent(layoutButtons); layout.setComponentAlignment(textArea, Alignment.MIDDLE_CENTER); layout.setComponentAlignment(layoutButtons, Alignment.MIDDLE_RIGHT); layout.setExpandRatio(textArea, 3); layout.setSizeFull(); subWindow.setContent(layout); subWindow.center(); getUI().addWindow(subWindow); }