List of usage examples for com.vaadin.ui TextArea setValue
@Override public void setValue(String value)
From source file:annis.gui.AboutWindow.java
License:Apache License
public AboutWindow() { setSizeFull();//ww w . j av a 2s . co m layout = new VerticalLayout(); setContent(layout); layout.setSizeFull(); layout.setMargin(true); HorizontalLayout hLayout = new HorizontalLayout(); Embedded logoAnnis = new Embedded(); logoAnnis.setSource(new ThemeResource("images/annis-logo-128.png")); logoAnnis.setType(Embedded.TYPE_IMAGE); hLayout.addComponent(logoAnnis); Embedded logoSfb = new Embedded(); logoSfb.setSource(new ThemeResource("images/sfb-logo.jpg")); logoSfb.setType(Embedded.TYPE_IMAGE); hLayout.addComponent(logoSfb); Link lnkFork = new Link(); lnkFork.setResource(new ExternalResource("https://github.com/korpling/ANNIS")); lnkFork.setIcon( new ExternalResource("https://s3.amazonaws.com/github/ribbons/forkme_right_red_aa0000.png")); lnkFork.setTargetName("_blank"); hLayout.addComponent(lnkFork); hLayout.setComponentAlignment(logoAnnis, Alignment.MIDDLE_LEFT); hLayout.setComponentAlignment(logoSfb, Alignment.MIDDLE_RIGHT); hLayout.setComponentAlignment(lnkFork, Alignment.TOP_RIGHT); layout.addComponent(hLayout); layout.addComponent(new Label( "ANNIS is a project of the " + "<a href=\"http://www.sfb632.uni-potsdam.de/\">SFB632</a>.", Label.CONTENT_XHTML)); layout.addComponent(new Label("Homepage: " + "<a href=\"http://corpus-tools.org/annis/\">" + "http://corpus-tools.org/annis/</a>.", Label.CONTENT_XHTML)); layout.addComponent(new Label("Version: " + VersionInfo.getVersion())); layout.addComponent(new Label("Vaadin-Version: " + Version.getFullVersion())); TextArea txtThirdParty = new TextArea(); txtThirdParty.setSizeFull(); StringBuilder sb = new StringBuilder(); sb.append("The ANNIS team wants to thank these third party software that " + "made the ANNIS GUI possible:\n"); File thirdPartyFolder = new File(VaadinService.getCurrent().getBaseDirectory(), "THIRD-PARTY"); if (thirdPartyFolder.isDirectory()) { for (File c : thirdPartyFolder.listFiles((FileFilter) new WildcardFileFilter("*.txt"))) { if (c.isFile()) { try { sb.append(FileUtils.readFileToString(c)).append("\n"); } catch (IOException ex) { log.error("Could not read file", ex); } } } } txtThirdParty.setValue(sb.toString()); txtThirdParty.setReadOnly(true); txtThirdParty.addStyleName("shared-text"); txtThirdParty.setWordwrap(false); layout.addComponent(txtThirdParty); btClose = new Button("Close"); final AboutWindow finalThis = this; btClose.addClickListener(new OkClickListener(finalThis)); layout.addComponent(btClose); layout.setComponentAlignment(hLayout, Alignment.MIDDLE_CENTER); layout.setComponentAlignment(btClose, Alignment.MIDDLE_CENTER); layout.setExpandRatio(txtThirdParty, 1.0f); }
From source file:annis.gui.CitationWindow.java
License:Apache License
public CitationWindow(String query, Set<String> corpora, int contextLeft, int contextRight) { super("Citation"); VerticalLayout wLayout = new VerticalLayout(); setContent(wLayout);// w ww .j a v a 2s . c o m wLayout.setSizeFull(); String url = Helper.generateCitation(query, corpora, contextLeft, contextRight, null, 0, 10); TextArea txtCitation = new TextArea(); txtCitation.setWidth("100%"); txtCitation.setHeight("100%"); txtCitation.addStyleName(ChameleonTheme.TEXTFIELD_BIG); txtCitation.addStyleName("citation"); txtCitation.setValue(url); txtCitation.setWordwrap(true); txtCitation.setReadOnly(true); wLayout.addComponent(txtCitation); Button btOk = new Button("OK"); btOk.addListener((Button.ClickListener) this); btOk.setSizeUndefined(); wLayout.addComponent(btOk); wLayout.setExpandRatio(txtCitation, 1.0f); wLayout.setComponentAlignment(btOk, Alignment.BOTTOM_CENTER); setWidth("400px"); setHeight("200px"); }
From source file:annis.gui.ShareQueryReferenceWindow.java
License:Apache License
public ShareQueryReferenceWindow(DisplayedResultQuery query, boolean shorten) { super("Query reference link"); VerticalLayout wLayout = new VerticalLayout(); setContent(wLayout);/* ww w. j a v a2 s .c o m*/ wLayout.setSizeFull(); wLayout.setMargin(true); Label lblInfo = new Label( "<p style=\"font-size: 18px\" >" + "<strong>Share your query:</strong> " + "1. Copy the generated link 2. Share this link with your peers. " + "</p>", ContentMode.HTML); wLayout.addComponent(lblInfo); wLayout.setExpandRatio(lblInfo, 0.0f); String shortURL = "ERROR"; if (query != null) { URI url = Helper.generateCitation(query.getQuery(), query.getCorpora(), query.getLeftContext(), query.getRightContext(), query.getSegmentation(), query.getBaseText(), query.getOffset(), query.getLimit(), query.getOrder(), query.getSelectedMatches()); if (shorten) { shortURL = Helper.shortenURL(url); } else { shortURL = url.toASCIIString(); } } TextArea txtCitation = new TextArea(); txtCitation.setWidth("100%"); txtCitation.setHeight("100%"); txtCitation.addStyleName(ValoTheme.TEXTFIELD_LARGE); txtCitation.addStyleName("shared-text"); txtCitation.setValue(shortURL); txtCitation.setWordwrap(true); txtCitation.setReadOnly(true); wLayout.addComponent(txtCitation); Button btClose = new Button("Close"); btClose.addClickListener((Button.ClickListener) this); btClose.setSizeUndefined(); wLayout.addComponent(btClose); wLayout.setExpandRatio(txtCitation, 1.0f); wLayout.setComponentAlignment(btClose, Alignment.BOTTOM_CENTER); setWidth("400px"); setHeight("300px"); }
From source file:annis.visualizers.htmlvis.HTMLVis.java
License:Apache License
@Override public Panel createComponent(VisualizerInput vi, VisualizationToggle vt) { Panel scrollPanel = new Panel(); scrollPanel.setSizeFull();/*from w w w.j a va2s .c om*/ Label lblResult = new Label("ERROR", ContentMode.HTML); lblResult.setSizeUndefined(); List<String> corpusPath = CommonHelper.getCorpusPath(vi.getDocument().getGraph(), vi.getDocument()); String corpusName = corpusPath.get(corpusPath.size() - 1); corpusName = urlPathEscape.escape(corpusName); String wrapperClassName = "annis-wrapped-htmlvis-" + corpusName.replaceAll("[^0-9A-Za-z-]", "_"); scrollPanel.addStyleName(wrapperClassName); String visConfigName = vi.getMappings().getProperty("config"); String hitMarkConfig = vi.getMappings().getProperty("hitmark", "true"); hitMark = Boolean.parseBoolean(hitMarkConfig); mc = vi.getMarkedAndCovered(); VisualizationDefinition[] definitions = parseDefinitions(corpusName, vi.getMappings()); if (definitions != null) { lblResult.setValue(createHTML(vi.getSResult().getDocumentGraph(), definitions)); String labelClass = vi.getMappings().getProperty("class", "htmlvis"); lblResult.addStyleName(labelClass); InputStream inStreamCSSRaw = null; if (visConfigName == null) { inStreamCSSRaw = HTMLVis.class.getResourceAsStream("htmlvis.css"); } else { WebResource resBinary = Helper.getAnnisWebResource().path("query/corpora/").path(corpusName) .path(corpusName).path("binary").path(visConfigName + ".css"); ClientResponse response = resBinary.get(ClientResponse.class); if (response.getStatus() == ClientResponse.Status.OK.getStatusCode()) { inStreamCSSRaw = response.getEntityInputStream(); } } if (inStreamCSSRaw != null) { try (InputStream inStreamCSS = inStreamCSSRaw) { String cssContent = IOUtils.toString(inStreamCSS); UI currentUI = UI.getCurrent(); if (currentUI instanceof AnnisBaseUI) { // do not add identical CSS files ((AnnisBaseUI) currentUI).injectUniqueCSS(cssContent, wrapperClassName); } } catch (IOException ex) { log.error("Could not parse the HTML visualizer CSS file", ex); Notification.show("Could not parse the HTML visualizer CSS file", ex.getMessage(), Notification.Type.ERROR_MESSAGE); } } } if (vi.getMappings().containsKey("debug")) { TextArea txtDebug = new TextArea(); txtDebug.setValue(lblResult.getValue()); txtDebug.setReadOnly(true); txtDebug.setWidth("100%"); Label sep = new Label("<hr/>", ContentMode.HTML); VerticalLayout layout = new VerticalLayout(txtDebug, sep, lblResult); layout.setSizeUndefined(); scrollPanel.setContent(layout); } else { scrollPanel.setContent(lblResult); } return scrollPanel; }
From source file:com.cavisson.gui.dashboard.components.controls.Forms.java
License:Apache License
public Forms() { setSpacing(true);//w ww . j a va 2s . c o m setMargin(true); Label title = new Label("Forms"); title.addStyleName("h1"); addComponent(title); final FormLayout form = new FormLayout(); form.setMargin(false); form.setWidth("800px"); form.addStyleName("light"); addComponent(form); Label section = new Label("Personal Info"); section.addStyleName("h2"); section.addStyleName("colored"); form.addComponent(section); StringGenerator sg = new StringGenerator(); TextField name = new TextField("Name"); name.setValue(sg.nextString(true) + " " + sg.nextString(true)); name.setWidth("50%"); form.addComponent(name); DateField birthday = new DateField("Birthday"); birthday.setValue(new Date(80, 0, 31)); form.addComponent(birthday); TextField username = new TextField("Username"); username.setValue(sg.nextString(false) + sg.nextString(false)); username.setRequired(true); form.addComponent(username); OptionGroup sex = new OptionGroup("Sex"); sex.addItem("Female"); sex.addItem("Male"); sex.select("Male"); sex.addStyleName("horizontal"); form.addComponent(sex); section = new Label("Contact Info"); section.addStyleName("h3"); section.addStyleName("colored"); form.addComponent(section); TextField email = new TextField("Email"); email.setValue(sg.nextString(false) + "@" + sg.nextString(false) + ".com"); email.setWidth("50%"); email.setRequired(true); form.addComponent(email); TextField location = new TextField("Location"); location.setValue(sg.nextString(true) + ", " + sg.nextString(true)); location.setWidth("50%"); location.setComponentError(new UserError("This address doesn't exist")); form.addComponent(location); TextField phone = new TextField("Phone"); phone.setWidth("50%"); form.addComponent(phone); HorizontalLayout wrap = new HorizontalLayout(); wrap.setSpacing(true); wrap.setDefaultComponentAlignment(Alignment.MIDDLE_LEFT); wrap.setCaption("Newsletter"); CheckBox newsletter = new CheckBox("Subscribe to newsletter", true); wrap.addComponent(newsletter); ComboBox period = new ComboBox(); period.setTextInputAllowed(false); period.addItem("Daily"); period.addItem("Weekly"); period.addItem("Montly"); period.setNullSelectionAllowed(false); period.select("Weekly"); period.addStyleName("small"); period.setWidth("10em"); wrap.addComponent(period); form.addComponent(wrap); section = new Label("Additional Info"); section.addStyleName("h4"); section.addStyleName("colored"); form.addComponent(section); TextField website = new TextField("Website"); website.setInputPrompt("http://"); website.setWidth("100%"); form.addComponent(website); TextArea shortbio = new TextArea("Short Bio"); shortbio.setValue( "Quis aute iure reprehenderit in voluptate velit esse. Cras mattis iudicium purus sit amet fermentum."); shortbio.setWidth("100%"); shortbio.setRows(2); form.addComponent(shortbio); final RichTextArea bio = new RichTextArea("Bio"); bio.setWidth("100%"); bio.setValue( "<div><p><span>Integer legentibus erat a ante historiarum dapibus.</span> <span>Vivamus sagittis lacus vel augue laoreet rutrum faucibus.</span> <span>A communi observantia non est recedendum.</span> <span>Morbi fringilla convallis sapien, id pulvinar odio volutpat.</span> <span>Ab illo tempore, ab est sed immemorabili.</span> <span>Quam temere in vitiis, legem sancimus haerentia.</span></p><p><span>Morbi odio eros, volutpat ut pharetra vitae, lobortis sed nibh.</span> <span>Quam diu etiam furor iste tuus nos eludet?</span> <span>Cum sociis natoque penatibus et magnis dis parturient.</span> <span>Quam diu etiam furor iste tuus nos eludet?</span> <span>Tityre, tu patulae recubans sub tegmine fagi dolor.</span></p><p><span>Curabitur blandit tempus ardua ridiculus sed magna.</span> <span>Phasellus laoreet lorem vel dolor tempus vehicula.</span> <span>Etiam habebis sem dicantur magna mollis euismod.</span> <span>Hi omnes lingua, institutis, legibus inter se differunt.</span></p></div>"); form.addComponent(bio); form.setReadOnly(true); bio.setReadOnly(true); Button edit = new Button("Edit", new ClickListener() { @Override public void buttonClick(ClickEvent event) { boolean readOnly = form.isReadOnly(); if (readOnly) { bio.setReadOnly(false); form.setReadOnly(false); form.removeStyleName("light"); event.getButton().setCaption("Save"); event.getButton().addStyleName("primary"); } else { bio.setReadOnly(true); form.setReadOnly(true); form.addStyleName("light"); event.getButton().setCaption("Edit"); event.getButton().removeStyleName("primary"); } } }); HorizontalLayout footer = new HorizontalLayout(); footer.setMargin(new MarginInfo(true, false, true, false)); footer.setSpacing(true); footer.setDefaultComponentAlignment(Alignment.MIDDLE_LEFT); form.addComponent(footer); footer.addComponent(edit); Label lastModified = new Label("Last modified by you a minute ago"); lastModified.addStyleName("light"); footer.addComponent(lastModified); }
From source file:com.cavisson.gui.dashboard.components.controls.TextFields.java
License:Apache License
public TextFields() { setMargin(true);/* w ww . ja va 2 s . c om*/ Label h1 = new Label("Text Fields"); h1.addStyleName("h1"); addComponent(h1); HorizontalLayout row = new HorizontalLayout(); row.addStyleName("wrapping"); row.setSpacing(true); addComponent(row); TextField tf = new TextField("Normal"); tf.setInputPrompt("First name"); tf.setIcon(testIcon.get()); row.addComponent(tf); tf = new TextField("Custom color"); tf.setInputPrompt("Email"); tf.addStyleName("color1"); row.addComponent(tf); tf = new TextField("User Color"); tf.setInputPrompt("Gender"); tf.addStyleName("color2"); row.addComponent(tf); tf = new TextField("Themed"); tf.setInputPrompt("Age"); tf.addStyleName("color3"); row.addComponent(tf); tf = new TextField("Error"); tf.setValue("Somethings wrong"); tf.setComponentError(new UserError("Fix it, now!")); row.addComponent(tf); tf = new TextField("Error, borderless"); tf.setValue("Somethings wrong"); tf.setComponentError(new UserError("Fix it, now!")); tf.addStyleName("borderless"); row.addComponent(tf); tf = new TextField("Read-only"); tf.setInputPrompt("Nationality"); tf.setValue("Finnish"); tf.setReadOnly(true); row.addComponent(tf); tf = new TextField("Small"); tf.setValue("Field value"); tf.addStyleName("small"); row.addComponent(tf); tf = new TextField("Large"); tf.setValue("Field value"); tf.addStyleName("large"); tf.setIcon(testIcon.get(true)); row.addComponent(tf); tf = new TextField("Icon inside"); tf.setInputPrompt("Ooh, an icon"); tf.addStyleName("inline-icon"); tf.setIcon(testIcon.get()); row.addComponent(tf); tf = new TextField("Large, Icon inside"); tf.setInputPrompt("Ooh, an icon"); tf.addStyleName("large"); tf.addStyleName("inline-icon"); tf.setIcon(testIcon.get()); row.addComponent(tf); tf = new TextField("Small, Icon inside"); tf.setInputPrompt("Ooh, an icon"); tf.addStyleName("small"); tf.addStyleName("inline-icon"); tf.setIcon(testIcon.get()); row.addComponent(tf); tf = new TextField("16px supported by default"); tf.setInputPrompt("Image icon"); tf.addStyleName("inline-icon"); tf.setIcon(testIcon.get(true, 16)); row.addComponent(tf); tf = new TextField(); tf.setValue("Font, no caption"); tf.addStyleName("inline-icon"); tf.setIcon(testIcon.get()); row.addComponent(tf); tf = new TextField(); tf.setValue("Image, no caption"); tf.addStyleName("inline-icon"); tf.setIcon(testIcon.get(true, 16)); row.addComponent(tf); CssLayout group = new CssLayout(); group.addStyleName("v-component-group"); row.addComponent(group); tf = new TextField(); tf.setInputPrompt("Grouped with a button"); tf.addStyleName("inline-icon"); tf.setIcon(testIcon.get()); tf.setWidth("260px"); group.addComponent(tf); Button button = new Button("Do It"); // button.addStyleName("primary"); group.addComponent(button); tf = new TextField("Borderless"); tf.setInputPrompt("Write here"); tf.addStyleName("inline-icon"); tf.addStyleName("borderless"); tf.setIcon(testIcon.get()); row.addComponent(tf); tf = new TextField("Right-aligned"); tf.setValue("1,234"); tf.addStyleName("align-right"); row.addComponent(tf); tf = new TextField("Centered"); tf.setInputPrompt("Guess what?"); tf.addStyleName("align-center"); row.addComponent(tf); PasswordField pwf = new PasswordField("Password"); pwf.setInputPrompt("Secret words"); pwf.addStyleName("inline-icon"); pwf.setIcon(FontAwesome.LOCK); row.addComponent(pwf); pwf = new PasswordField("Password, right-aligned"); pwf.setInputPrompt("Secret words"); pwf.addStyleName("inline-icon"); pwf.addStyleName("align-right"); pwf.setIcon(FontAwesome.LOCK); row.addComponent(pwf); pwf = new PasswordField("Password, centered"); pwf.setInputPrompt("Secret words"); pwf.addStyleName("inline-icon"); pwf.addStyleName("align-center"); pwf.setIcon(FontAwesome.LOCK); row.addComponent(pwf); tf = new TextField("Tiny"); tf.setValue("Field value"); tf.addStyleName("tiny"); row.addComponent(tf); tf = new TextField("Huge"); tf.setValue("Field value"); tf.addStyleName("huge"); row.addComponent(tf); h1 = new Label("Text Areas"); h1.addStyleName("h1"); addComponent(h1); row = new HorizontalLayout(); row.addStyleName("wrapping"); row.setSpacing(true); addComponent(row); TextArea ta = new TextArea("Normal"); ta.setInputPrompt("Write your comment"); row.addComponent(ta); ta = new TextArea("Inline icon"); ta.setInputPrompt("Inline icon not really working"); ta.addStyleName("inline-icon"); ta.setIcon(testIcon.get()); row.addComponent(ta); ta = new TextArea("Custom color"); ta.addStyleName("color1"); ta.setInputPrompt("Write your comment"); row.addComponent(ta); ta = new TextArea("Custom color, read-only"); ta.addStyleName("color2"); ta.setValue("Field value, spanning multiple lines of text"); ta.setReadOnly(true); row.addComponent(ta); ta = new TextArea("Custom color"); ta.addStyleName("color3"); ta.setValue("Field value, spanning multiple lines of text"); row.addComponent(ta); ta = new TextArea("Small"); ta.addStyleName("small"); ta.setInputPrompt("Write your comment"); row.addComponent(ta); ta = new TextArea("Large"); ta.addStyleName("large"); ta.setInputPrompt("Write your comment"); row.addComponent(ta); ta = new TextArea("Borderless"); ta.addStyleName("borderless"); ta.setInputPrompt("Write your comment"); row.addComponent(ta); ta = new TextArea("Right-aligned"); ta.addStyleName("align-right"); ta.setValue("Field value, spanning multiple lines of text"); row.addComponent(ta); ta = new TextArea("Centered"); ta.addStyleName("align-center"); ta.setValue("Field value, spanning multiple lines of text"); row.addComponent(ta); ta = new TextArea("Tiny"); ta.addStyleName("tiny"); ta.setInputPrompt("Write your comment"); row.addComponent(ta); ta = new TextArea("Huge"); ta.addStyleName("huge"); ta.setInputPrompt("Write your comment"); row.addComponent(ta); RichTextArea rta = new RichTextArea(); rta.setValue("<b>Some</b> <i>rich</i> content"); row.addComponent(rta); rta = new RichTextArea("Read-only"); rta.setValue("<b>Some</b> <i>rich</i> content"); rta.setReadOnly(true); row.addComponent(rta); }
From source file:com.constellio.app.ui.pages.management.updates.UpdateManagerViewImpl.java
private Component buildMessagePanel() { VerticalLayout verticalLayout = new VerticalLayout(); UpdateRecoveryImpossibleCause cause = presenter.isUpdateWithRecoveryPossible(); if (cause != null) { verticalLayout.addComponent(new Label( "<p style=\"color:red\">" + $("UpdateManagerViewImpl." + cause) + "</p>", ContentMode.HTML)); } else {/* w ww . java 2s. c om*/ UpdateNotRecommendedReason updateNotRecommendedReason = presenter.getUpdateNotRecommendedReason(); if (updateNotRecommendedReason != null) { verticalLayout.addComponent(new Label("<p style=\"color:red\">" + $("UpdateManagerViewImpl." + updateNotRecommendedReason) + "</p>", ContentMode.HTML)); } } final String exceptionDuringLastUpdate = presenter.getExceptionDuringLastUpdate(); if (StringUtils.isNotBlank(exceptionDuringLastUpdate)) { verticalLayout.addComponent(new Label( "<p style=\"color:red\">" + $("UpdateManagerViewImpl.exceptionCausedByLastVersion") + "</p>", ContentMode.HTML)); WindowButton windowButton = new WindowButton($("details"), $("details"), WindowConfiguration.modalDialog("90%", "90%")) { @Override protected Component buildWindowContent() { TextArea textArea = new TextArea(); textArea.setSizeFull(); textArea.setValue(exceptionDuringLastUpdate); return textArea; } }; windowButton.addStyleName(ValoTheme.BUTTON_LINK); verticalLayout.addComponent(windowButton); verticalLayout.addComponent(new Label("<p style=\"color:red\">" + "" + "</p>", ContentMode.HTML)); } return verticalLayout; }
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 .ja v a2 s . c o m*/ 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.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 ww w.ja v a 2s . com*/ 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.valo.Forms.java
License:Apache License
public Forms() { setSpacing(true);//from ww w. ja va 2 s . c o m setMargin(true); Label title = new Label("Forms"); title.addStyleName("h1"); addComponent(title); final FormLayout form = new FormLayout(); form.setMargin(false); form.setWidth("800px"); form.addStyleName("light"); addComponent(form); Label section = new Label("Personal Info"); section.addStyleName("h2"); section.addStyleName("colored"); form.addComponent(section); StringGenerator sg = new StringGenerator(); TextField name = new TextField("Name"); name.setValue(sg.nextString(true) + " " + sg.nextString(true)); name.setWidth("50%"); form.addComponent(name); DateField birthday = new DateField("Birthday"); birthday.setValue(new Date(80, 0, 31)); form.addComponent(birthday); TextField username = new TextField("Username"); username.setValue(sg.nextString(false) + sg.nextString(false)); username.setRequired(true); form.addComponent(username); OptionGroup sex = new OptionGroup("Sex"); sex.addItem("Female"); sex.addItem("Male"); sex.select("Male"); sex.addStyleName("horizontal"); form.addComponent(sex); section = new Label("Contact Info"); section.addStyleName("h3"); section.addStyleName("colored"); form.addComponent(section); TextField email = new TextField("Email"); email.setValue(sg.nextString(false) + "@" + sg.nextString(false) + ".com"); email.setWidth("50%"); email.setRequired(true); form.addComponent(email); TextField location = new TextField("Location"); location.setValue(sg.nextString(true) + ", " + sg.nextString(true)); location.setWidth("50%"); location.setComponentError(new UserError("This address doesn't exist")); form.addComponent(location); TextField phone = new TextField("Phone"); phone.setWidth("50%"); form.addComponent(phone); HorizontalLayout wrap = new HorizontalLayout(); wrap.setSpacing(true); wrap.setDefaultComponentAlignment(Alignment.MIDDLE_LEFT); wrap.setCaption("Newsletter"); CheckBox newsletter = new CheckBox("Subscribe to newsletter", true); wrap.addComponent(newsletter); ComboBox period = new ComboBox(); period.setTextInputAllowed(false); period.addItem("Daily"); period.addItem("Weekly"); period.addItem("Monthly"); period.setNullSelectionAllowed(false); period.select("Weekly"); period.addStyleName("small"); period.setWidth("10em"); wrap.addComponent(period); form.addComponent(wrap); section = new Label("Additional Info"); section.addStyleName("h4"); section.addStyleName("colored"); form.addComponent(section); TextField website = new TextField("Website"); website.setInputPrompt("http://"); website.setWidth("100%"); form.addComponent(website); TextArea shortbio = new TextArea("Short Bio"); shortbio.setValue( "Quis aute iure reprehenderit in voluptate velit esse. Cras mattis iudicium purus sit amet fermentum."); shortbio.setWidth("100%"); shortbio.setRows(2); form.addComponent(shortbio); final RichTextArea bio = new RichTextArea("Bio"); bio.setWidth("100%"); bio.setValue( "<div><p><span>Integer legentibus erat a ante historiarum dapibus.</span> <span>Vivamus sagittis lacus vel augue laoreet rutrum faucibus.</span> <span>A communi observantia non est recedendum.</span> <span>Morbi fringilla convallis sapien, id pulvinar odio volutpat.</span> <span>Ab illo tempore, ab est sed immemorabili.</span> <span>Quam temere in vitiis, legem sancimus haerentia.</span></p><p><span>Morbi odio eros, volutpat ut pharetra vitae, lobortis sed nibh.</span> <span>Quam diu etiam furor iste tuus nos eludet?</span> <span>Cum sociis natoque penatibus et magnis dis parturient.</span> <span>Quam diu etiam furor iste tuus nos eludet?</span> <span>Tityre, tu patulae recubans sub tegmine fagi dolor.</span></p><p><span>Curabitur blandit tempus ardua ridiculus sed magna.</span> <span>Phasellus laoreet lorem vel dolor tempus vehicula.</span> <span>Etiam habebis sem dicantur magna mollis euismod.</span> <span>Hi omnes lingua, institutis, legibus inter se differunt.</span></p></div>"); form.addComponent(bio); form.setReadOnly(true); bio.setReadOnly(true); Button edit = new Button("Edit", new ClickListener() { @Override public void buttonClick(ClickEvent event) { boolean readOnly = form.isReadOnly(); if (readOnly) { bio.setReadOnly(false); form.setReadOnly(false); form.removeStyleName("light"); event.getButton().setCaption("Save"); event.getButton().addStyleName("primary"); } else { bio.setReadOnly(true); form.setReadOnly(true); form.addStyleName("light"); event.getButton().setCaption("Edit"); event.getButton().removeStyleName("primary"); } } }); HorizontalLayout footer = new HorizontalLayout(); footer.setMargin(new MarginInfo(true, false, true, false)); footer.setSpacing(true); footer.setDefaultComponentAlignment(Alignment.MIDDLE_LEFT); form.addComponent(footer); footer.addComponent(edit); Label lastModified = new Label("Last modified by you a minute ago"); lastModified.addStyleName("light"); footer.addComponent(lastModified); }