{ "cells": [ { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true }, "outputs": [], "source": [ "val form : EasyForm = new EasyForm(\"Form and Run\")\n", "form.addTextField(\"First\", 250)\n", "form.addTextField(\"Last\", 250)\n", "form.addButton(\"Go!\", \"run\")\n", "\n", "form" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "tags": [ "run" ] }, "outputs": [], "source": [ "\"Good morning \" + form.get(\"First\") + \" \" + form.get(\"Last\")" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true }, "outputs": [], "source": [ "val h = new EasyForm(\"Form and Run\")\n", "h.addTextField(\"first\", 380)\n", "h.addTextArea(\"Text Area\",500,200)\n", "h" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true }, "outputs": [], "source": [ "val g2 = new EasyForm(\"Field Types\")\n", "val options = List(\"a\", \"b\", \"c\", \"d\")\n", "g2.addList(\"List Single\", options, false)\n", "g2.addList(\"List Two Row\", options, 2)\n", "g2" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true }, "outputs": [], "source": [ "//You can use onInit and onChange to handle component events. For button events use actionPerfromed or addAction.\n", "val f1 = new EasyForm(\"Form and Run\")\n", "val first = f1.addTextField(\"first\", 15)\n", "first.onInit(_ => first.setLabel(\"New Label\")).onChange(_ => first.setValue(\"Changed!\"))\n", "val last = f1.addTextField(\"last\", 15)\n", "\n", "val button = f1.addButton(\"action button\")\n", "\n", "button.actionPerformed = _ => {first.setValue(\"Pressed!\"); last.setValue(\"Pressed!\")}\n", "\n", "f1" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true }, "outputs": [], "source": [ "//All Kinds of Fields\n", "\n", "val g = new EasyForm(\"Field Types\")\n", "g.addTextField(\"Short Text Field\", 10)\n", "g.addTextField(\"Text Field\")\n", "g.addTextArea(\"Text Area\")\n", "g.addCheckBox(\"Check Box\")\n", "val options = List(\"a\", \"b\", \"c\", \"d\")\n", "g.addComboBox(\"Combo Box\", options)\n", "g.addComboBox(\"Editable Combo\", options, true)\n", "\n", "g.addList(\"List\", options)\n", "g.addList(\"List Single\", options, false)\n", "g.addList(\"List Two Row\", options, 2)\n", "\n", "g.addCheckBoxes(\"Check Boxes\", options)\n", "g.addCheckBoxes(\"Check Boxes H\", options, EasyForm.HORIZONTAL)\n", "\n", "g.addRadioButtons(\"Radio Buttons\", options)\n", "g.addRadioButtons(\"Radio Buttons H\", options, EasyForm.HORIZONTAL)\n", "\n", "g.addDatePicker(\"Date\")\n", "\n", "g.addButton(\"Go!\", \"run2\")\n", "g" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true }, "outputs": [], "source": [ "val gdp = new EasyForm(\"Field Types\")\n", "val date = gdp.addDatePicker(\"Date\")\n", "gdp" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true }, "outputs": [], "source": [ "date.getValue()" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "form.put(\"First\", \"Micheal\")\n", "form.put(\"Last\", \"Fox\")\n", "// Read values from form\n", "val firstName = form.get(\"First\")\n", "val lastName = form.get(\"Last\")\n", "\n", "print(\"Good morning \" + firstName + \" \" + lastName)" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true }, "outputs": [], "source": [] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true }, "outputs": [], "source": [] } ], "metadata": { "beakerx_kernel_parameters": { "classpath": [], "imports": [ "com.twosigma.beaker.chart.xychart.*", "com.twosigma.beaker.easyform.EasyForm", "com.twosigma.beaker.chart.Filter", "com.twosigma.beaker.chart.Color", "com.twosigma.beaker.NamespaceClient", "com.twosigma.beaker.fileloader.CsvPlotReader", "com.twosigma.beaker.chart.treemap.*", "com.twosigma.beaker.jvm.object.OutputCell", "com.twosigma.beaker.chart.treemap.util.*", "com.twosigma.beaker.chart.categoryplot.plotitem.*", "com.twosigma.beaker.chart.categoryplot.*", "com.twosigma.beaker.scala.easyform.EasyForm", "com.twosigma.beaker.chart.xychart.plotitem.*", "com.twosigma.beaker.table.*", "com.twosigma.beaker.chart.GradientColor", "com.twosigma.beaker.chart.legend.*", "net.sf.jtreemap.swing.*", "com.twosigma.beaker.chart.histogram.*", "com.twosigma.beaker.chart.heatmap.HeatMap" ] }, "kernelspec": { "display_name": "Scala", "language": "scala", "name": "scala" }, "language_info": { "codemirror_mode": "text/x-scala", "file_extension": ".scala", "mimetype": "", "name": "Scala", "nbconverter_exporter": "", "version": "2.12.2" } }, "nbformat": 4, "nbformat_minor": 2 }