private void initLayout() { layout.setMargin(true); setContent(layout); form.setCaption("Employee Details "); PropertysetItem item = new PropertysetItem(); item.addItemProperty("Name", new ObjectProperty<String>("")); item.addItemProperty("Address", new ObjectProperty<String>("")); ComboBox combobox = new ComboBox("Sex"); combobox.setInvalidAllowed(true); combobox.setNullSelectionAllowed(false); combobox.addItem("Male"); combobox.addItem("Female"); item.addItemProperty("Age", new ObjectProperty<String>("")); item.addItemProperty("Email", new ObjectProperty<String>("")); item.addItemProperty("Mobile No", new ObjectProperty<String>("")); Form form = new Form(); final Form reader = new Form(); form.setCaption("Fill Your Details"); form.setItemDataSource(item); reader.setItemDataSource(item); reader.setCaption("Your registation details"); reader.setReadOnly(true); button.addClickListener( new Button.ClickListener() { public void buttonClick(ClickEvent event) { Label message = new Label("You are Registered"); layout.addComponent(message); layout.addComponent(reader); } }); layout.addComponent(form); final RichTextArea area = new RichTextArea(); area.setValue("Add more details here"); layout.addComponent(area); layout.addComponent(button); }
public DescriptionCellEditor() { super(); ensureResources(); setStyleName(""); addCloseHandler( new CloseHandler<PopupPanel>() { @Override public void onClose(CloseEvent<PopupPanel> event) { if (event.isAutoClosed()) { commit(); hide(); } } }); VerticalPanel verticalPanel = new VerticalPanel(); textArea = new RichTextArea(); textArea.setTabIndex(0); textArea.addStyleName(resources.style().bDescriptionCellEditor__editor()); textArea.addKeyDownHandler( new KeyDownHandler() { @Override public void onKeyDown(KeyDownEvent event) { int keyCode = event.getNativeKeyCode(); if (keyCode == KeyCodes.KEY_ESCAPE) { cancelButton.setFocus(true); // or grid did not get back focus hide(); } else if (keyCode == KeyCodes.KEY_ENTER && event.isControlKeyDown()) { okButton.setFocus(true); // or grid did not get back focus okButton.click(); } } }); VerticalPanel textAreaPanel = new VerticalPanel(); textAreaPanel.add(textArea); HorizontalPanel buttonPanel = new HorizontalPanel(); okButton = new Button(strings.ok()); okButton.addStyleName(resources.style().bDescriptionCellEditor__ok()); okButton.addClickHandler( new ClickHandler() { @Override public void onClick(ClickEvent event) { commit(); hide(); } }); buttonPanel.add(okButton); cancelButton = new Button(strings.cancel()); cancelButton.addStyleName(resources.style().bDescriptionCellEditor__cancel()); cancelButton.addClickHandler( new ClickHandler() { @Override public void onClick(ClickEvent event) { hide(); } }); buttonPanel.add(cancelButton); textAreaPanel.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_RIGHT); textAreaPanel.add(buttonPanel); RichTextToolbar textToolbar = new RichTextToolbar(textArea); SimplePanel toolBarPanel = new SimplePanel(textToolbar); toolBarPanel.addStyleName(resources.style().bDescriptionCellEditor__toolbar()); verticalPanel.add(toolBarPanel); verticalPanel.add(textAreaPanel); add(verticalPanel); }
@Override public void proceedSettingReadonly() { textArea.setEnabled(!isReadonly()); }
/** Focus on the text area editor */ public void focus() { textArea.setFocus(true); }
public void setTextAreaWidth(int width) { textArea.setWidth(width + "px"); }
public int getTextAreaOffsetTop() { return textArea.getAbsoluteTop() - getAbsoluteTop(); }
public int getTextAreaOffsetLeft() { return textArea.getAbsoluteLeft() - getAbsoluteLeft(); }
private void commit() { this.fireEvent(new ValueChangedEvent<String>(textArea.getHTML())); }
private void initUI() { GridLayout mainLayout = new GridLayout(1, 5); mainLayout.setWidth("100%"); mainLayout.setMargin(true); mainLayout.setSpacing(true); CssLayout inputPanel = new CssLayout(); inputPanel.setWidth("100%"); inputPanel.setStyleName("mail-panel"); inputLayout = new GridLayout(3, 4); inputLayout.setSpacing(true); inputLayout.setWidth("100%"); inputLayout.setColumnExpandRatio(0, 1.0f); inputPanel.addComponent(inputLayout); mainLayout.addComponent(inputPanel); tokenFieldMailTo = new EmailTokenField(); inputLayout.addComponent(createTextFieldMail("To:", tokenFieldMailTo), 0, 0); if (lstMail != null) { for (String mail : lstMail) { if (StringUtils.isNotBlank(mail)) { if (mail.indexOf("<") > -1) { String strMail = mail.substring(mail.indexOf("<") + 1, mail.lastIndexOf(">")); if (strMail != null && !strMail.equalsIgnoreCase("null")) {} } else { } } } } final TextField subject = new TextField(); subject.setRequired(true); subject.setWidth("100%"); subjectField = createTextFieldMail("Subject:", subject); inputLayout.addComponent(subjectField, 0, 1); initButtonLinkCcBcc(); ccField = createTextFieldMail("Cc:", tokenFieldMailCc); bccField = createTextFieldMail("Bcc:", tokenFieldMailBcc); final RichTextArea noteArea = new RichTextArea(); noteArea.setWidth("100%"); noteArea.setHeight("200px"); mainLayout.addComponent(noteArea, 0, 1); mainLayout.setComponentAlignment(noteArea, Alignment.MIDDLE_CENTER); HorizontalLayout controlsLayout = new HorizontalLayout(); controlsLayout.setWidth("100%"); final AttachmentPanel attachments = new AttachmentPanel(); attachments.setWidth("500px"); MultiFileUploadExt uploadExt = new MultiFileUploadExt(attachments); uploadExt.addComponent(attachments); controlsLayout.addComponent(uploadExt); controlsLayout.setExpandRatio(uploadExt, 1.0f); controlsLayout.setSpacing(true); Button cancelBtn = new Button( AppContext.getMessage(GenericI18Enum.BUTTON_CANCEL), new Button.ClickListener() { private static final long serialVersionUID = 1L; @Override public void buttonClick(ClickEvent event) { MailFormWindow.this.close(); } }); cancelBtn.setStyleName(UIConstants.THEME_GRAY_LINK); controlsLayout.addComponent(cancelBtn); controlsLayout.setComponentAlignment(cancelBtn, Alignment.MIDDLE_RIGHT); Button sendBtn = new Button( "Send", new Button.ClickListener() { private static final long serialVersionUID = 1L; @Override public void buttonClick(ClickEvent event) { if (tokenFieldMailTo.getListRecipient().size() <= 0 || subject.getValue().equals("")) { NotificationUtil.showErrorNotification( "To Email field and Subject field must be not empty! Please fulfil them before sending email."); return; } if (AppContext.getUser().getEmail() != null && AppContext.getUser().getEmail().length() > 0) { ExtMailService systemMailService = ApplicationContextUtil.getSpringBean(ExtMailService.class); List<File> listFile = attachments.files(); List<EmailAttachementSource> emailAttachmentSource = null; if (listFile != null && listFile.size() > 0) { emailAttachmentSource = new ArrayList<>(); for (File file : listFile) { emailAttachmentSource.add(new FileEmailAttachmentSource(file)); } } systemMailService.sendHTMLMail( AppContext.getUser().getEmail(), AppContext.getUser().getDisplayName(), tokenFieldMailTo.getListRecipient(), tokenFieldMailCc.getListRecipient(), tokenFieldMailBcc.getListRecipient(), subject.getValue().toString(), noteArea.getValue().toString(), emailAttachmentSource); MailFormWindow.this.close(); } else { NotificationUtil.showErrorNotification( "Your email is empty value, please fulfil it before sending email!"); } } }); sendBtn.setIcon(FontAwesome.SEND); sendBtn.setStyleName(UIConstants.BUTTON_ACTION); controlsLayout.addComponent(sendBtn); controlsLayout.setComponentAlignment(sendBtn, Alignment.MIDDLE_RIGHT); mainLayout.addComponent(controlsLayout, 0, 2); this.setContent(mainLayout); }