List of usage examples for com.vaadin.ui TextArea TextArea
public TextArea(ValueChangeListener<String> valueChangeListener)
From source file:edu.kit.dama.ui.admin.workflow.property.LinuxSoftwareMapPropertyConfigurationPanel.java
License:Apache License
/** * Get the platforms field.//from ww w. jav a 2 s. co m */ private TextArea getPlatformsArea() { if (platformsArea == null) { platformsArea = new TextArea("PLATFORMS"); platformsArea.setWidth("100%"); platformsArea.setRows(5); platformsArea.setImmediate(true); platformsArea.setNullRepresentation(""); platformsArea.addStyleName(CSSTokenContainer.BOLD_CAPTION); platformsArea.setInputPrompt("e.g. unusual software or hardware required"); } return platformsArea; }
From source file:edu.nps.moves.mmowgli.modules.actionplans.HelpWantedDialog.java
License:Open Source License
@SuppressWarnings("serial") @HibernateSessionThreadLocalConstructor//from w ww. j a v a 2s .co m public HelpWantedDialog(final Object aplnId, boolean interested) { setCaption(interested ? "Express Interest in Action Plan" : "Offer Assistance with Action Plan"); setModal(true); setSizeUndefined(); setWidth("500px"); setHeight("550px"); VerticalLayout vLay = new VerticalLayout(); setContent(vLay); vLay.setMargin(true); vLay.setSpacing(true); vLay.setSizeFull(); StringBuilder sb = new StringBuilder(); ActionPlan ap = ActionPlan.getTL(aplnId); String s = ap.getHelpWanted(); if (s != null) { vLay.addComponent(new Label(msg1)); Label helpWantedLab = new Label(s); helpWantedLab.addStyleName("m-helpWantedLabel"); helpWantedLab.setWidth("100%"); vLay.addComponent(helpWantedLab); } vLay.addComponent(new Label(msg2)); final TextArea toTA = new TextArea("To"); toTA.addStyleName("m-textareaboldcaption"); toTA.setWidth("100%"); toTA.setRows(1); toTA.setNullRepresentation(""); toTA.setValue(getAuthors(sb, ap)); vLay.addComponent(toTA); final TextArea ccTA = new TextArea("CC"); ccTA.addStyleName("m-textareaboldcaption"); ccTA.setWidth("100%"); ccTA.setRows(1); ccTA.setNullRepresentation(""); PagesData pd = new PagesData(); ccTA.setValue(pd.gettroubleMailto()); vLay.addComponent(ccTA); final TextArea subjTA = new TextArea("Subject"); subjTA.addStyleName("m-textareaboldcaption"); subjTA.setWidth("100%"); subjTA.setRows(2); subjTA.setNullRepresentation(""); sb.setLength(0); sb.append("My interest in Action Plan "); sb.append(ap.getId()); sb.append(", \""); sb.append(ap.getTitle()); sb.append('"'); subjTA.setValue(sb.toString()); vLay.addComponent(subjTA); final TextArea msgTA = new TextArea("Message"); msgTA.addStyleName("m-textareaboldcaption"); msgTA.setWidth("100%"); msgTA.setHeight("100%"); msgTA.setNullRepresentation(""); vLay.addComponent(msgTA); vLay.setExpandRatio(msgTA, 1.0f); HorizontalLayout buttLay = new HorizontalLayout(); vLay.addComponent(buttLay); buttLay.setSpacing(true); buttLay.setWidth("100%"); Label sp; buttLay.addComponent(sp = new Label()); sp.setHeight("1px"); buttLay.setExpandRatio(sp, 1.0f); Button canButt = new Button("Cancel"); buttLay.addComponent(canButt); Button sendButt = new Button("Send to authors"); buttLay.addComponent(sendButt); canButt.addClickListener(new ClickListener() { @Override public void buttonClick(ClickEvent event) { UI.getCurrent().removeWindow(HelpWantedDialog.this); } }); sendButt.addClickListener(new ClickListener() { @Override @MmowgliCodeEntry @HibernateOpened @HibernateClosed public void buttonClick(ClickEvent event) { Object tos = toTA.getValue(); if (tos == null || tos.toString().length() <= 0) { Notification.show("No recipients", Notification.Type.ERROR_MESSAGE); return; } Object cc = ccTA.getValue(); if (cc == null || cc.toString().length() <= 0) cc = null; Object msg = msgTA.getValue(); if (msg == null || msg.toString().length() <= 0) { Notification.show("No Message", Notification.Type.ERROR_MESSAGE); return; } Object subj = subjTA.getValue(); if (subj == null) subj = ""; HSess.init(); List<User> authors = parseAuthorsTL(tos.toString().trim()); MmowgliSessionGlobals globs = Mmowgli2UI.getGlobals(); MailManager mmgr = AppMaster.instance().getMailManager(); User me = globs.getUserTL(); for (User u : authors) { mmgr.mailToUserTL(me.getId(), u.getId(), subj.toString(), msg.toString()); } if (cc == null) mmgr.mailToUserTL(me.getId(), me.getId(), "(CC:)" + subj.toString(), msg.toString()); else mmgr.mailToUserTL(me.getId(), me.getId(), subj.toString(), msg.toString(), cc.toString(), MailManager.Channel.BOTH); // the cc is an email, not a user name UI.getCurrent().removeWindow(HelpWantedDialog.this); Notification.show("Message(s) sent", Notification.Type.HUMANIZED_MESSAGE); // fixed 21 Jan 2015 HSess.close(); } }); }
From source file:edu.nps.moves.mmowgli.modules.actionplans.RfeDialog.java
License:Open Source License
@HibernateSessionThreadLocalConstructor @SuppressWarnings("serial") public RfeDialog(Object aplnId) { this.apId = aplnId; setCaption("Request for Expertise"); setModal(true);/*from www .j av a2 s.co m*/ setSizeUndefined(); setWidth("500px"); setHeight("400px"); VerticalLayout vLay = new VerticalLayout(); setContent(vLay); vLay.setMargin(true); vLay.setSpacing(true); vLay.setSizeFull(); IDButton searchButt = new IDButton("Option 1: Search for players with needed expertise", SEARCHCLICK, null); searchButt.enableAction(false); // do manually searchButt.addClickListener(new SearchListener()); vLay.addComponent(searchButt); VerticalLayout nuts = new VerticalLayout(); vLay.addComponent(nuts); nuts.setSizeFull(); vLay.setExpandRatio(nuts, 1.0f); Label lab; /*vLay*/nuts.addComponent(lab = new Label("Option 2: Post help-wanted notice to action plan")); lab.addStyleName("m-font-bold11"); final VerticalLayout helpWantedPan = new VerticalLayout(); /*vLay*/nuts.addComponent(helpWantedPan); helpWantedPan.addStyleName("m-greyborder"); helpWantedPan.setWidth("99%"); helpWantedPan.setHeight("99%"); helpWantedPan.setSpacing(true); helpWantedPan.setMargin(true); /*vLay*/nuts.setExpandRatio(helpWantedPan, 1.0f); helpWantedTA = new TextArea("Current posting"); helpWantedTA.setWidth("100%"); helpWantedTA.setHeight("100%"); helpWantedTA.setNullRepresentation(""); helpWantedPan.addComponent(helpWantedTA); helpWantedPan.setExpandRatio(helpWantedTA, 1.0f); HorizontalLayout buttLay = new HorizontalLayout(); helpWantedPan.addComponent(buttLay); buttLay.setSpacing(true); buttLay.setWidth("100%"); buttLay.addComponent(lab = new Label()); lab.setWidth("10px"); clearButt = new Button("Clear"); buttLay.addComponent(clearButt); clearButt.addClickListener(clearButtLis = new ClickListener() { @Override @MmowgliCodeEntry @HibernateOpened @HibernateClosed public void buttonClick(ClickEvent event) { HSess.init(); ActionPlan ap = ActionPlan.getTL(apId); helpWantedTA.setValue(null); if (null != ap.getHelpWanted()) { ap.setHelpWanted(null); ActionPlan.updateTL(ap); Notification notif = new Notification("Cleared"); notif.setDelayMsec(3000); notif.show(Page.getCurrent()); GameEventLogger.logHelpWantedTL(ap); notifyAuthorsOfChangeTL(ap); } HSess.close(); } }); buttLay.addComponent(lab = new Label()); buttLay.setExpandRatio(lab, 1.0f); postButt = new Button("Post"); buttLay.addComponent(postButt); postButt.addClickListener(new ClickListener() { @Override @MmowgliCodeEntry @HibernateOpened @HibernateClosed public void buttonClick(ClickEvent event) { Object val = helpWantedTA.getValue(); if (val == null || val.toString().length() <= 0) { clearButtLis.buttonClick(event); return; } HSess.init(); String s = val.toString(); ActionPlan ap = ActionPlan.getTL(apId); if (s == null ? ap.getHelpWanted() != null : !s.equals(ap.getHelpWanted())) { ap.setHelpWanted(s); ActionPlan.updateTL(ap); Notification notif = new Notification("Posted"); notif.setDelayMsec(3000); notif.show(Page.getCurrent()); GameEventLogger.logHelpWantedTL(ap); notifyAuthorsOfChangeTL(ap); } HSess.close(); } }); buttLay.addComponent(lab = new Label()); lab.setWidth("10px"); helpWantedPan.addComponent(lab = new Label()); lab.setHeight("10px"); IDButton troubleButt = new IDButton("Option 3: Post Trouble Report", POSTTROUBLECLICK, null); troubleButt.enableAction(false); // managed manually troubleButt.addClickListener(new TroubleListener()); vLay.addComponent(troubleButt); Button closeButt = new Button("Close"); vLay.addComponent(closeButt); closeButt.addClickListener(new CloseListener()); vLay.setComponentAlignment(closeButt, Alignment.MIDDLE_RIGHT); ActionPlan ap = ActionPlan.getTL(apId); String s = ap.getHelpWanted(); helpWantedTA.setValue(s); }
From source file:edu.nps.moves.mmowgli.modules.registrationlogin.RoleSelectionPage.java
License:Open Source License
public RoleSelectionPage(ClickListener listener, Long uId) { super(listener); super.initGui(); this.localUserId = uId; setTitleString("Last Step: tell others of your interests"); //"Role Selection"); contentVLayout.setSpacing(true);//from w w w . j a v a2 s. com contentVLayout.setMargin(true); contentVLayout.addStyleName("m-role-page"); Label lab; contentVLayout.addComponent(lab = new HtmlLabel( " This optional information is revealed to other players.")); lab.addStyleName(labelStyle); contentVLayout.addComponent(lab = new Label()); lab.setHeight("10px"); expertiseTf = new TextField(); expertiseTf.addStyleName("m-noleftmargin"); expertiseTf.setCaption("Enter a short description of your pertinent expertise."); expertiseTf.setColumns(38); expertiseTf.setInputPrompt("optional"); contentVLayout.addComponent(expertiseTf); Game game = Game.getTL(); ques = game.getQuestion(); ansTf = new TextArea(ques.getQuestion()); ansTf.setWidth("98%"); ansTf.setRows(10); ansTf.setInputPrompt("(optional, but worth 10 points if you answer)"); contentVLayout.addComponent(ansTf); emailCb = new CheckBox("I agree to receive private email during game play."); contentVLayout.addComponent(emailCb); emailCb.addStyleName(labelStyle); emailCb.addStyleName("m-nopaddingormargin"); emailCb.setValue(true); messagesCb = new CheckBox("I agree to receive private in-game messages during game play."); contentVLayout.addComponent(messagesCb); messagesCb.addStyleName(labelStyle); messagesCb.addStyleName("m-nopaddingormargin"); messagesCb.setValue(true); HorizontalLayout buttPan = new HorizontalLayout(); buttPan.setWidth("100%"); buttPan.setSpacing(true); buttPan.addComponent(lab = new Label("OK great, thanks for registering! Let's play.")); lab.addStyleName(labelStyle); lab.addStyleName("m-nopaddingormargin"); lab.setSizeUndefined(); Label spacer; buttPan.addComponent(spacer = new Label()); spacer.setWidth("1px"); buttPan.setExpandRatio(spacer, 1.0f); buttPan.addComponent(continueButt = new NativeButton(null)); Mmowgli2UI.getGlobals().mediaLocator().decorateGetABriefingButton(continueButt); Label sp; buttPan.addComponent(sp = new Label()); sp.setWidth("10px"); contentVLayout.addComponent(buttPan); continueButt.addClickListener(new ContinueListener()); continueButt.setClickShortcut(KeyCode.ENTER); expertiseTf.focus(); }
From source file:eu.lod2.EPoolPartyExtractor.java
License:Apache License
public EPoolPartyExtractor(LOD2DemoState st) { // The internal state state = st;/*from ww w . j a v a2s .c o m*/ // second component VerticalLayout panel = new VerticalLayout(); Label description = new Label( "This service will identify text elements (tags) which correspond to concepts in a given controlled vocabulary using the PoolParty Extractor (PPX).\n" + "At the moment we have fixed the controlled vocabulary to be the Social Semantic Web thesaurus also available at CKAN.\n" + "The identified concepts will be inserted as triples in the current graph.\n"); panel.addComponent(description); Form t2f = new Form(); t2f.setDebugId(this.getClass().getSimpleName() + "_t2f"); exportGraph = new ExportSelector3(state, true); exportGraph.setDebugId(this.getClass().getSimpleName() + "_exportGraph"); t2f.getLayout().addComponent(exportGraph); ppProjectId = new TextField("PoolParty project Id:"); ppProjectId.setDebugId(this.getClass().getSimpleName() + "_ppProjectId"); ppProjectId.setDescription( "The unique identifier of the PoolParty project to use for the extraction (usually a UUID like d06bd0f8-03e4-45e0-8683-fed428fca242) "); t2f.getLayout().addComponent(ppProjectId); textLanguage = new ComboBox("Language of the text:"); textLanguage.setDebugId(this.getClass().getSimpleName() + "_textLanguage"); textLanguage .setDescription("This is the language of the text. Language can be en (english) or de (german)."); textLanguage.addItem("en"); textLanguage.addItem("de"); t2f.getLayout().addComponent(textLanguage); TextArea textToAnnotateField = new TextArea("text:"); textToAnnotateField.setDebugId(this.getClass().getSimpleName() + "_textToAnnotateField"); textToAnnotateField.setImmediate(false); textToAnnotateField.addListener(this); textToAnnotateField.setWidth("100%"); textToAnnotateField.setRows(10); t2f.getLayout().addComponent(textToAnnotateField); // initialize the footer area of the form HorizontalLayout t2ffooterlayout = new HorizontalLayout(); t2f.setFooter(t2ffooterlayout); annotateButton = new Button("Extract concepts", new ClickListener() { public void buttonClick(ClickEvent event) { annotateText(event); } }); annotateButton.setDebugId(this.getClass().getSimpleName() + "_annotateButton"); annotateButton .setDescription("Extract the relevant concepts w.r.t. the controlled vocabulary in PoolParty"); annotateButton.setEnabled(false); t2f.getFooter().addComponent(annotateButton); panel.addComponent(t2f); // The composition root MUST be set setCompositionRoot(panel); }
From source file:eu.lod2.EPoolPartyLabel.java
License:Apache License
public EPoolPartyLabel(LOD2DemoState st) { // The internal state state = st;//ww w. j a v a 2s . c o m // second component VerticalLayout panel = new VerticalLayout(); Label description = new Label( "This service will identify text elements (tags) which correspond to concepts in a given controlled vocabulary using the PoolParty Extractor (PPX).\n" + "At the moment we have fixed the controlled vocabulary to be the Social Semantic Web thesaurus also available at CKAN.\n" + "The identified concepts will be inserted as triples in the current graph.\n"); panel.addComponent(description); Form t2f = new Form(); t2f.setDebugId(this.getClass().getSimpleName() + "_t2f"); exportGraph = new ExportSelector3(state); exportGraph.setDebugId(this.getClass().getSimpleName() + "_exportGraph"); t2f.getLayout().addComponent(exportGraph); ppProjectId = new TextField("PoolParty project Id:"); ppProjectId.setDebugId(this.getClass().getSimpleName() + "_ppProjectId"); ppProjectId.setDescription( "The unique identifier of the PoolParty project to use for the extraction (usually a UUID like d06bd0f8-03e4-45e0-8683-fed428fca242) "); t2f.getLayout().addComponent(ppProjectId); textLanguage = new ComboBox("Language of the text:"); textLanguage.setDebugId(this.getClass().getSimpleName() + "_textLanguage"); textLanguage .setDescription("This is the language of the text. Language can be en (english) or de (german)."); textLanguage.addItem("en"); textLanguage.addItem("de"); t2f.getLayout().addComponent(textLanguage); TextArea textToAnnotateField = new TextArea("text:"); textToAnnotateField.setDebugId(this.getClass().getSimpleName() + "_textToAnnotateField"); textToAnnotateField.setImmediate(false); textToAnnotateField.addListener(this); textToAnnotateField.setWidth("100%"); textToAnnotateField.setRows(10); t2f.getLayout().addComponent(textToAnnotateField); // initialize the footer area of the form HorizontalLayout t2ffooterlayout = new HorizontalLayout(); t2f.setFooter(t2ffooterlayout); annotateButton = new Button("Extract concepts", new ClickListener() { public void buttonClick(ClickEvent event) { annotateText(event); } }); annotateButton.setDebugId(this.getClass().getSimpleName() + "_annotateButton"); annotateButton .setDescription("Extract the relevant concepts w.r.t. the controlled vocabulary in PoolParty"); annotateButton.setEnabled(false); t2f.getFooter().addComponent(annotateButton); panel.addComponent(t2f); // The composition root MUST be set setCompositionRoot(panel); }
From source file:eu.lod2.ESpotlight.java
License:Apache License
public ESpotlight(LOD2DemoState st) { // The internal state and state = st;//from ww w .j a v a2s . c om VerticalLayout panel = new VerticalLayout(); // Spotlight form start // annotate a plain text // TODO: and add the result as RDF to the default graph Form t2f = new Form(); t2f.setDebugId(this.getClass().getSimpleName() + "_t2f"); t2f.setCaption("Annotate plain text"); TextArea textToAnnotateField = new TextArea("text:"); textToAnnotateField.setDebugId(this.getClass().getSimpleName() + "_textToAnnotateField"); textToAnnotateField.setImmediate(false); textToAnnotateField.addListener(this); textToAnnotateField.setColumns(50); textToAnnotateField.setRows(10); t2f.getLayout().addComponent(textToAnnotateField); annotatedTextField = new Label("annotated text", Label.CONTENT_XHTML); t2f.getLayout().addComponent(annotatedTextField); // initialize the footer area of the form HorizontalLayout t2ffooterlayout = new HorizontalLayout(); t2f.setFooter(t2ffooterlayout); annotateButton = new Button("Annotate with Spotlight", new ClickListener() { public void buttonClick(ClickEvent event) { annotateText(event); } }); annotateButton.setDebugId(this.getClass().getSimpleName() + "_annotateButton"); annotateButton.setDescription("Annotate the text with Spotlight"); annotateButton.setEnabled(false); t2f.getFooter().addComponent(annotateButton); panel.addComponent(t2f); // Spotlight form end // The composition root MUST be set setCompositionRoot(panel); }
From source file:eu.lod2.EXML.java
License:Apache License
public EXML(LOD2DemoState st) { this();// w w w . j a va 2 s . c o m state = st; // The internal state and panel = new VerticalLayout(); Label desc = new Label("This page aids the extraction of RDF out of an XML document.<br/>" + "This is done by defining an XSLT transformation which transforms the XML document into a set of RDF triples.<br/>" + "The resulting triples are uploaded in the share RDF store.<br/>" + "This pages is the simplified flow where you paste your document and XSLT transformation and see the result immediately.", Label.CONTENT_XHTML); xmlText = new TextArea("Enter your xml code:"); xmlText.setDebugId(this.getClass().getSimpleName() + "_xmlText"); xmlText.setImmediate(false); xmlText.setColumns(100); xmlText.setRows(25); xmlText.setRequired(true); xsltText = new TextArea("Enter your xslt code:"); xsltText.setDebugId(this.getClass().getSimpleName() + "_xsltText"); xsltText.setImmediate(false); xsltText.setColumns(100); xsltText.setRows(25); xsltText.setRequired(true); exportGraph = new ExportSelector(st); exportGraph.setDebugId(this.getClass().getSimpleName() + "_exportGraph"); uploadButton = new Button("Upload result to RDF Store", (Button.ClickListener) this); uploadButton.setDebugId(this.getClass().getSimpleName() + "_uploadButton"); transformButton = new Button("transform XML to RDF", (Button.ClickListener) this); transformButton.setDebugId(this.getClass().getSimpleName() + "_transformButton"); errorMsg = new Label(""); panel.addComponent(desc); panel.addComponent(xmlText); panel.addComponent(xsltText); panel.addComponent(transformButton); panel.addComponent(exportGraph); panel.addComponent(uploadButton); panel.addComponent(errorMsg); errorMsg.setVisible(false); t2f = new Form(); t2f.setDebugId(this.getClass().getSimpleName() + "_t2f"); t2f.setCaption(""); annotatedTextField = new Label("Extracted RDF", Label.CONTENT_XHTML); t2f.getLayout().addComponent(annotatedTextField); rdfResultField = new TextArea(); rdfResultField.setDebugId(this.getClass().getSimpleName() + "_rdfResultField"); rdfResultField.setImmediate(false); rdfResultField.setColumns(100); rdfResultField.setRows(25); t2f.getLayout().addComponent(rdfResultField); panel.addComponent(t2f); t2f.setVisible(false); // The composition root MUST be set setCompositionRoot(panel); }
From source file:eu.lod2.SesameSPARQL.java
License:Apache License
public SesameSPARQL(LOD2DemoState st) { sparqlResult.setDebugId(this.getClass().getSimpleName() + "_sparqlResult"); // The internal state and state = st;//w ww.j ava 2 s . co m VerticalLayout queryingTab = new VerticalLayout(); query = new TextArea("SPARQL Query"); query.setDebugId(this.getClass().getSimpleName() + "_query"); // configure & add to layout query.setValue("Select * from <" + state.getCurrentGraph() + "> where {?s ?p ?o} limit 100"); query.setImmediate(false); query.addListener(this); query.setColumns(30); query.setRows(10); query.setRequired(true); query.setRequiredError("The query is missing. No call will be issued."); query.setSizeFull(); Button okbutton = new Button("evaluate", new ClickListener() { public void buttonClick(ClickEvent event) { extractionQuery(event); } }); okbutton.setDebugId(this.getClass().getSimpleName() + "_okbutton"); okbutton.setDescription("View the result from the SPARQL query"); // okbutton.addListener(this); // react to tclicks queryingTab.addComponent(query); queryingTab.addComponent(okbutton); queryingTab.addComponent(sparqlResult); // The composition root MUST be set setCompositionRoot(queryingTab); }
From source file:eu.maxschuster.vaadin.signaturefield.demo.DemoUI.java
License:Apache License
@Override protected void init(VaadinRequest request) { getPage().setTitle(pageTitle);//from www. ja v a 2s.c o m final VerticalLayout margin = new VerticalLayout(); setContent(margin); final VerticalLayout layout = new VerticalLayout(); layout.setMargin(true); layout.setSpacing(true); layout.setWidth("658px"); margin.addComponent(layout); margin.setComponentAlignment(layout, Alignment.TOP_CENTER); final Label header1 = new Label(pageTitle); header1.addStyleName("h1"); header1.setSizeUndefined(); layout.addComponent(header1); layout.setComponentAlignment(header1, Alignment.TOP_CENTER); final TabSheet tabSheet = new TabSheet(); tabSheet.setWidth("100%"); layout.addComponent(tabSheet); layout.setComponentAlignment(tabSheet, Alignment.TOP_CENTER); final Panel signaturePanel = new Panel(); signaturePanel.addStyleName("signature-panel"); signaturePanel.setWidth("100%"); tabSheet.addTab(signaturePanel, "Demo"); final VerticalLayout signatureLayout = new VerticalLayout(); signatureLayout.setMargin(true); signatureLayout.setSpacing(true); signatureLayout.setSizeFull(); signaturePanel.setContent(signatureLayout); final SignatureField signatureField = new SignatureField(); signatureField.setWidth("100%"); signatureField.setHeight("318px"); signatureField.setPenColor(Color.ULTRAMARINE); signatureField.setBackgroundColor("white"); signatureField.setConverter(new StringToDataUrlConverter()); signatureField.setPropertyDataSource(dataUrlProperty); signatureField.setVelocityFilterWeight(0.7); signatureLayout.addComponent(signatureField); signatureLayout.setComponentAlignment(signatureField, Alignment.MIDDLE_CENTER); final HorizontalLayout buttonLayout = new HorizontalLayout(); buttonLayout.setSpacing(true); buttonLayout.setWidth("100%"); signatureLayout.addComponent(buttonLayout); final Button clearButton = new Button("Clear", new ClickListener() { @Override public void buttonClick(ClickEvent event) { signatureField.clear(); } }); buttonLayout.addComponent(clearButton); buttonLayout.setComponentAlignment(clearButton, Alignment.MIDDLE_LEFT); final Label message = new Label("Sign above"); message.setSizeUndefined(); buttonLayout.addComponent(message); buttonLayout.setComponentAlignment(message, Alignment.MIDDLE_CENTER); final ButtonLink saveButtonLink = new ButtonLink("Save", null); saveButtonLink.setTargetName("_blank"); buttonLayout.addComponent(saveButtonLink); buttonLayout.setComponentAlignment(saveButtonLink, Alignment.MIDDLE_RIGHT); final Panel optionsPanel = new Panel(); optionsPanel.setSizeFull(); tabSheet.addTab(optionsPanel, "Options"); final FormLayout optionsLayout = new FormLayout(); optionsLayout.setMargin(true); optionsLayout.setSpacing(true); optionsPanel.setContent(optionsLayout); final ComboBox mimeTypeComboBox = new ComboBox(null, mimeTypeContainer); optionsLayout.addComponent(mimeTypeComboBox); mimeTypeComboBox.setItemCaptionPropertyId("mimeType"); mimeTypeComboBox.setNullSelectionAllowed(false); mimeTypeComboBox.addValueChangeListener(new ValueChangeListener() { @Override public void valueChange(ValueChangeEvent event) { MimeType mimeType = (MimeType) event.getProperty().getValue(); signatureField.setMimeType(mimeType); } }); mimeTypeComboBox.setValue(MimeType.PNG); mimeTypeComboBox.setCaption("Result MIME-Type"); final CheckBox immediateCheckBox = new CheckBox("immediate", false); optionsLayout.addComponent(immediateCheckBox); immediateCheckBox.addValueChangeListener(new ValueChangeListener() { @Override public void valueChange(ValueChangeEvent event) { boolean immediate = (Boolean) event.getProperty().getValue(); signatureField.setImmediate(immediate); } }); final CheckBox readOnlyCheckBox = new CheckBox("readOnly", false); optionsLayout.addComponent(readOnlyCheckBox); readOnlyCheckBox.addValueChangeListener(new ValueChangeListener() { @Override public void valueChange(ValueChangeEvent event) { boolean readOnly = (Boolean) event.getProperty().getValue(); signatureField.setReadOnly(readOnly); mimeTypeComboBox.setReadOnly(readOnly); clearButton.setEnabled(!readOnly); } }); final CheckBox requiredCheckBox = new CheckBox("required (causes bug that clears field)", false); optionsLayout.addComponent(requiredCheckBox); requiredCheckBox.addValueChangeListener(new ValueChangeListener() { @Override public void valueChange(ValueChangeEvent event) { boolean required = (Boolean) event.getProperty().getValue(); signatureField.setRequired(required); } }); final CheckBox clearButtonEnabledButton = new CheckBox("clearButtonEnabled", false); optionsLayout.addComponent(clearButtonEnabledButton); clearButtonEnabledButton.addValueChangeListener(new ValueChangeListener() { @Override public void valueChange(ValueChangeEvent event) { boolean clearButtonEnabled = (Boolean) event.getProperty().getValue(); signatureField.setClearButtonEnabled(clearButtonEnabled); } }); final Panel resultPanel = new Panel("Results:"); resultPanel.setWidth("100%"); layout.addComponent(resultPanel); final VerticalLayout resultLayout = new VerticalLayout(); resultLayout.setMargin(true); resultPanel.setContent(resultLayout); final Image stringPreviewImage = new Image("String preview image:"); stringPreviewImage.setWidth("500px"); resultLayout.addComponent(stringPreviewImage); final Image dataUrlPreviewImage = new Image("DataURL preview image:"); dataUrlPreviewImage.setWidth("500px"); resultLayout.addComponent(dataUrlPreviewImage); final TextArea textArea = new TextArea("DataURL:"); textArea.setWidth("100%"); textArea.setHeight("300px"); resultLayout.addComponent(textArea); final Label emptyLabel = new Label(); emptyLabel.setCaption("Is Empty:"); emptyLabel.setValue(String.valueOf(signatureField.isEmpty())); resultLayout.addComponent(emptyLabel); signatureField.addValueChangeListener(new ValueChangeListener() { @Override public void valueChange(ValueChangeEvent event) { String signature = (String) event.getProperty().getValue(); stringPreviewImage.setSource(signature != null ? new ExternalResource(signature) : null); textArea.setValue(signature); emptyLabel.setValue(String.valueOf(signatureField.isEmpty())); } }); dataUrlProperty.addValueChangeListener(new ValueChangeListener() { @Override public void valueChange(ValueChangeEvent event) { try { final DataUrl signature = (DataUrl) event.getProperty().getValue(); dataUrlPreviewImage.setSource( signature != null ? new ExternalResource(serializer.serialize(signature)) : null); StreamResource streamResource = null; if (signature != null) { StreamSource streamSource = new StreamSource() { @Override public InputStream getStream() { return new ByteArrayInputStream(signature.getData()); } }; MimeType mimeType = MimeType.valueOfMimeType(signature.getMimeType()); String extension = null; switch (mimeType) { case JPEG: extension = "jpg"; break; case PNG: extension = "png"; break; } streamResource = new StreamResource(streamSource, "signature." + extension); streamResource.setMIMEType(signature.getMimeType()); streamResource.setCacheTime(0); } saveButtonLink.setResource(streamResource); } catch (MalformedURLException e) { logger.error(e.getMessage(), e); } } }); }