├── .classpath ├── .externalToolBuilders ├── Copy sources.launch └── Sass Compilation.launch ├── .gitignore ├── .project ├── .settings ├── org.eclipse.jdt.core.prefs ├── org.eclipse.wst.common.component └── org.eclipse.wst.common.project.facet.core.xml ├── README.md ├── WebContent ├── META-INF │ └── MANIFEST.MF ├── VAADIN │ └── themes │ │ ├── book-examples │ │ ├── .gitignore │ │ ├── Makefile │ │ ├── addons.scss │ │ ├── book-examples.scss │ │ ├── favicon.ico │ │ ├── fonts │ │ │ ├── 03805817-4611-4dbc-8c65-0f73031c3973.woff │ │ │ ├── 548e8c1d-b37a-43af-b197-a35e2f0c3d2f.ttf │ │ │ ├── c280ced9-704c-46b2-a66a-aff7ee1627bf.woff │ │ │ └── d5f9f72d-afb7-4c57-8348-b4bdac42edbb.ttf │ │ ├── icons │ │ │ ├── axe-16px.png │ │ │ ├── axe-32px.png │ │ │ ├── axe-8px.png │ │ │ ├── coffee-16px.png │ │ │ ├── coffee-20px.png │ │ │ ├── comment_yellow.gif │ │ │ ├── external-link.png │ │ │ ├── external-link.svg │ │ │ ├── magnifier.png │ │ │ ├── tea-16px.png │ │ │ ├── tea-20px.png │ │ │ ├── user.png │ │ │ ├── vaadin-arrow-down-white.png │ │ │ ├── vaadin-arrow-down.svg │ │ │ ├── vaadin-arrow-right-orange.png │ │ │ └── vaadin-arrow-right-orange.svg │ │ ├── img │ │ │ ├── Ripley_Scroll-300px.jpg │ │ │ ├── Ripley_Scroll.jpg │ │ │ ├── cat-128px.png │ │ │ ├── cat-16px.png │ │ │ ├── checkbox-checked.png │ │ │ ├── checkbox-checked.svg │ │ │ ├── checkbox-unchecked.png │ │ │ ├── checkbox-unchecked.svg │ │ │ ├── copernicus-128px.jpg │ │ │ ├── dog-128px.png │ │ │ ├── dog-16px.png │ │ │ ├── dog-32px.png │ │ │ ├── embedded-journalist.jpg │ │ │ ├── galileo-128px.jpg │ │ │ ├── image-sources.txt │ │ │ ├── kepler-128px.jpg │ │ │ ├── neocreo_Blue_World_Map_640x.png │ │ │ ├── nicubunu_Chain.png │ │ │ ├── penguin-128px.png │ │ │ ├── penguin-16px.png │ │ │ ├── pig-128px.png │ │ │ ├── pig-16px.png │ │ │ ├── pig-32px.png │ │ │ ├── planets │ │ │ │ ├── Earth.jpg │ │ │ │ ├── Earth_small.png │ │ │ │ ├── Earth_symbol.png │ │ │ │ ├── Jupiter.jpg │ │ │ │ ├── Jupiter_symbol.png │ │ │ │ ├── Mars.jpg │ │ │ │ ├── Mars_symbol.png │ │ │ │ ├── Mercury.jpg │ │ │ │ ├── Mercury_small.png │ │ │ │ ├── Mercury_symbol.png │ │ │ │ ├── Neptune.jpg │ │ │ │ ├── Neptune_symbol.png │ │ │ │ ├── Saturn.jpg │ │ │ │ ├── Saturn_symbol.png │ │ │ │ ├── Uranus.jpg │ │ │ │ ├── Uranus_symbol.png │ │ │ │ ├── Venus.jpg │ │ │ │ ├── Venus_small.png │ │ │ │ ├── Venus_symbol.png │ │ │ │ └── image-sources.txt │ │ │ ├── reindeer-128px.png │ │ │ ├── reindeer-16px.png │ │ │ ├── reindeer-256px.png │ │ │ ├── reindeer-32px.png │ │ │ ├── reindeer-64px.png │ │ │ ├── reindeer.svg │ │ │ ├── richtextarea-toolbar-fi.png │ │ │ ├── sheep-128px.png │ │ │ ├── sheep-16px.png │ │ │ ├── smiley.jpg │ │ │ ├── smiley2-128px.png │ │ │ ├── smiley2-20px.png │ │ │ ├── smiley2.svg │ │ │ ├── themeimage.png │ │ │ ├── tree-arrows-white.png │ │ │ ├── vaadin-logo.png │ │ │ └── vaadin_spin.swf │ │ ├── layouts │ │ │ ├── layoutname.html │ │ │ ├── printpage.html │ │ │ └── stylingexample.html │ │ ├── pdfexample.pdf │ │ └── styles.scss │ │ ├── mobiletheme │ │ ├── close64.png │ │ └── styles.css │ │ ├── myproject │ │ ├── .gitignore │ │ ├── addons.scss │ │ ├── myproject.scss │ │ └── styles.scss │ │ ├── mytheme │ │ ├── .gitignore │ │ ├── addons.scss │ │ ├── mytheme.scss │ │ └── styles.scss │ │ └── myvalotheme │ │ ├── .gitignore │ │ ├── addons.scss │ │ ├── myvalotheme.scss │ │ └── styles.scss ├── WEB-INF │ ├── applicationContext.xml │ ├── beans.xml │ ├── classes │ │ └── META-INF │ │ │ └── persistence.xml │ ├── exclusions.list │ ├── fop.xconf │ ├── images │ │ └── image.png │ ├── liferay-display.xml │ ├── liferay-plugin-package.properties │ ├── liferay-portlet.xml │ ├── portlet.xml │ └── web.xml ├── closed.html ├── embedding-in-div.html ├── embedding-in-jsp.jsp ├── examples │ ├── jscomponent-example.html │ └── mylibrary.js ├── images │ ├── datamodel │ │ └── beanitem-doublebinding-lo.png │ └── image.png ├── index.html ├── logout.html ├── multicoltest.html ├── pure-clientside.html └── static-login.html ├── build ├── bin │ └── trackchanges.py └── build.xml ├── ivy.xml ├── ivysettings.xml ├── src ├── com │ └── vaadin │ │ └── book │ │ ├── BookExamplesUI.java │ │ ├── LogFormatter.java │ │ ├── MyCustomServlet.java │ │ ├── applications │ │ ├── CookieExampleApplication.java │ │ ├── DynamicWindowUI.java │ │ ├── HelloWorld.java │ │ ├── HttpServletRequestApplication.java │ │ ├── IndexingExampleApplication.java │ │ ├── MyHierarchicalUI.java │ │ ├── MyPortletUI.java │ │ ├── PortletCustomModeExample.java │ │ ├── PortletModeExample.java │ │ ├── StaticLoginUI.java │ │ ├── ThreadLocalApplication.java │ │ └── UIToBeTested.java │ │ ├── examples │ │ ├── AbstractExampleItem.java │ │ ├── AnyBookExampleBundle.java │ │ ├── BookExample.java │ │ ├── BookExampleBundle.java │ │ ├── BookExampleLibrary.java │ │ ├── BrknExample.java │ │ ├── CaptionedExampleItem.java │ │ ├── Description.java │ │ ├── EmboExample.java │ │ ├── ExampleCtgr.java │ │ ├── RedirctItem.java │ │ ├── SourceFragment.java │ │ ├── addons │ │ │ ├── AddonTests.java │ │ │ ├── ChartsExample.java │ │ │ ├── charts │ │ │ │ ├── AxesExample.java │ │ │ │ ├── BoxPlotExample.java │ │ │ │ ├── ChartTypesExample.java │ │ │ │ ├── Charts3DExample.java │ │ │ │ ├── ChartsExample.java │ │ │ │ ├── FunnelExample.java │ │ │ │ ├── GaugeExample.java │ │ │ │ ├── HeatMapExample.java │ │ │ │ ├── PyramidExample.java │ │ │ │ ├── ScatterExample.java │ │ │ │ ├── TimelineExample.java │ │ │ │ ├── countrycoordinates-to-java.py │ │ │ │ ├── countrycoordinates.txt │ │ │ │ └── countrycoordinates.txt~ │ │ │ ├── jpacontainer │ │ │ │ ├── CelestialBody.java │ │ │ │ ├── Country.java │ │ │ │ ├── JPAContainerExample.java │ │ │ │ ├── JPAFieldFactoryExample.java │ │ │ │ ├── JPAFilteringExample.java │ │ │ │ ├── JPAHierarhicalExample.java │ │ │ │ └── Person.java │ │ │ ├── spreadsheet │ │ │ │ ├── SpreadsheetComponentsExample.java │ │ │ │ ├── SpreadsheetExample.java │ │ │ │ ├── SpreadsheetManagementExample.java │ │ │ │ └── SpreadsheetTablesExample.java │ │ │ └── touchkit │ │ │ │ ├── AdaptiveMobileUI.java │ │ │ │ ├── MyMobileWidgetSet.gwt.xml │ │ │ │ └── SimplePhoneUI.java │ │ ├── advanced │ │ │ ├── AnimalView.html │ │ │ ├── AppData.java │ │ │ ├── BrowserInfoExample.java │ │ │ ├── CustomViewProviderUI.java │ │ │ ├── DebugWindowExample.java │ │ │ ├── EmbeddingExample.java │ │ │ ├── FontIconExample.java │ │ │ ├── GlobalAccessExample.java │ │ │ ├── I18NExample.java │ │ │ ├── JSAPIExample.java │ │ │ ├── LoggingExample.java │ │ │ ├── LoginView.html │ │ │ ├── MainView.html │ │ │ ├── MyAppCaptions.java │ │ │ ├── MyAppCaptions_fi.java │ │ │ ├── NavigatorExample.java │ │ │ ├── NavigatorUI.java │ │ │ ├── PopupWindowExample.java │ │ │ ├── PrintingExample.java │ │ │ ├── RequestHandlerExample.java │ │ │ ├── RightToLeftStrings.java │ │ │ ├── RightToLeftStrings_ar.java │ │ │ ├── ServletRequestListenerExample.java │ │ │ ├── ShortcutExample.java │ │ │ ├── UriFragmentExample.java │ │ │ ├── cdi │ │ │ │ ├── BroadcastMessage.java │ │ │ │ ├── CDIBroadcaster.java │ │ │ │ ├── CDIChatUI.java │ │ │ │ ├── CDIEventUI.java │ │ │ │ ├── CDIExample.java │ │ │ │ ├── CDINavEventsUI.java │ │ │ │ ├── CDIProducerUI.java │ │ │ │ ├── CDIProducers.java │ │ │ │ ├── ChatBox.java │ │ │ │ ├── DisplayPanel.java │ │ │ │ ├── Greeter.java │ │ │ │ ├── HelpView.html │ │ │ │ ├── HelpView.java │ │ │ │ ├── InputPanel.java │ │ │ │ ├── LoginView.java │ │ │ │ ├── MainView.java │ │ │ │ ├── MyCDIComponentFactory.java │ │ │ │ ├── MyCDIUI.java │ │ │ │ ├── MyEvent.java │ │ │ │ └── User.java │ │ │ ├── dd │ │ │ │ ├── ComponentDnDExample.java │ │ │ │ ├── DiagramDnDExample.java │ │ │ │ ├── DragNDropTreeExample.java │ │ │ │ ├── ResizeDnDExample.java │ │ │ │ ├── TreeAndTableExample.java │ │ │ │ ├── resize-handle.png │ │ │ │ └── resize-handle.svg │ │ │ ├── push │ │ │ │ ├── Broadcaster.java │ │ │ │ ├── PushAroundUI.java │ │ │ │ ├── PushExample.java │ │ │ │ └── PushyUI.java │ │ │ └── spring │ │ │ │ ├── BroadcastMessage.java │ │ │ │ ├── ChatBox.java │ │ │ │ ├── DisplayPanel.java │ │ │ │ ├── Greeter.java │ │ │ │ ├── InputPanel.java │ │ │ │ ├── LoginView.java │ │ │ │ ├── MainView.java │ │ │ │ ├── MyAccessDeniedView.java │ │ │ │ ├── MyEvent.java │ │ │ │ ├── MySpringServlet.java │ │ │ │ ├── MySpringUI.java │ │ │ │ ├── SpringBroadcaster.java │ │ │ │ ├── SpringChatUI.java │ │ │ │ ├── SpringEventUI.java │ │ │ │ ├── SpringExample.java │ │ │ │ ├── SpringNavEventsUI.java │ │ │ │ ├── SpringProducerUI.java │ │ │ │ ├── SpringProducers.java │ │ │ │ └── User.java │ │ ├── application │ │ │ ├── ArchitectureExample.java │ │ │ ├── BuildingUIExample.java │ │ │ ├── ErrorIndicatorExample.java │ │ │ ├── EventListenerExample.java │ │ │ ├── LayoutClickListenerExample.java │ │ │ ├── LifecycleExample.java │ │ │ ├── MVCExample.java │ │ │ ├── NotificationExample.java │ │ │ ├── ResourceExample.java │ │ │ ├── calc │ │ │ │ ├── CalculatorModel.java │ │ │ │ ├── MVCCalculator.java │ │ │ │ └── MVPCalculator.java │ │ │ ├── declarative │ │ │ │ ├── CustomComponentDesign.html │ │ │ │ ├── DeclarativeComponents.html │ │ │ │ ├── DeclarativeUIExample.java │ │ │ │ ├── DeclarativeViewUI.java │ │ │ │ ├── DesignRootUI.java │ │ │ │ ├── ExampleComponent.java │ │ │ │ ├── InlineDesign.html │ │ │ │ ├── MyBasicDeclarativeUI.java │ │ │ │ ├── MyDeclarativeUI.html │ │ │ │ └── MyDeclarativeUI.java │ │ │ └── images │ │ │ │ └── image.png │ │ ├── client │ │ │ ├── ColorPicker.java │ │ │ ├── ColorPickerApplication.java │ │ │ ├── ColorpickerExample.java │ │ │ ├── MyComponent.java │ │ │ ├── MyComponentExample.java │ │ │ ├── clientside │ │ │ │ ├── MyModule.gwt.xml │ │ │ │ ├── MyModuleWidgetset.gwt.xml │ │ │ │ └── client │ │ │ │ │ ├── MyEntryPoint.java │ │ │ │ │ └── MyWidget.java │ │ │ ├── js │ │ │ │ ├── JSIntegrationExample.java │ │ │ │ ├── MyComponent.java │ │ │ │ ├── MyComponentState.java │ │ │ │ ├── mycomponent-connector.js │ │ │ │ └── mylibrary.js │ │ │ └── widgetset │ │ │ │ ├── ColorPickerWidgetSet.gwt.xml │ │ │ │ ├── client │ │ │ │ ├── colorpicker │ │ │ │ │ ├── ColorPickerConnector.java │ │ │ │ │ ├── ColorPickerState.java │ │ │ │ │ ├── GwtColorPicker.java │ │ │ │ │ └── VColorPicker.java │ │ │ │ ├── mycomponent │ │ │ │ │ ├── MyComponentClientRpc.java │ │ │ │ │ ├── MyComponentConnector.java │ │ │ │ │ ├── MyComponentServerRpc.java │ │ │ │ │ ├── MyComponentState.java │ │ │ │ │ └── MyComponentWidget.java │ │ │ │ └── renderer │ │ │ │ │ ├── CellValueChangeRpc.java │ │ │ │ │ ├── MyButtonRenderer.java │ │ │ │ │ ├── MyButtonRendererConnector.java │ │ │ │ │ ├── RendererTextBox.java │ │ │ │ │ ├── TextFieldRenderer.java │ │ │ │ │ └── TextFieldRendererConnector.java │ │ │ │ └── public │ │ │ │ └── colorpicker │ │ │ │ └── styles.css │ │ ├── component │ │ │ ├── BufferingExample.java │ │ │ ├── ButtonExample.java │ │ │ ├── CalendarExample.java │ │ │ ├── CheckBoxExample.java │ │ │ ├── ColorPickerExample.java │ │ │ ├── ComboBoxExample.java │ │ │ ├── CustomComponentExample.java │ │ │ ├── CustomFieldExample.java │ │ │ ├── DateFieldExample.java │ │ │ ├── EmbeddedExample.java │ │ │ ├── ImageExample.java │ │ │ ├── LabelExample.java │ │ │ ├── LinkExample.java │ │ │ ├── ListSelectExample.java │ │ │ ├── MenuBarExample.java │ │ │ ├── MenuNavigatorUI.java │ │ │ ├── MyCalendarEvent.java │ │ │ ├── NativeSelectExample.java │ │ │ ├── OptionGroupExample.java │ │ │ ├── PasswordFieldExample.java │ │ │ ├── ProgressBarExample.java │ │ │ ├── ProgressIndicatorExample.java │ │ │ ├── RichTextAreaExample.java │ │ │ ├── SelectExample.java │ │ │ ├── SliderExample.java │ │ │ ├── TextAreaExample.java │ │ │ ├── TextChangeEventsExample.java │ │ │ ├── TextFieldExample.java │ │ │ ├── TreeExample.java │ │ │ ├── TreeTableExample.java │ │ │ ├── TwinColSelectExample.java │ │ │ ├── UploadExample.java │ │ │ ├── grid │ │ │ │ ├── ColumnsExample.java │ │ │ │ ├── GridDataBindingExample.java │ │ │ │ ├── GridEditingExample.java │ │ │ │ ├── GridExample.java │ │ │ │ ├── GridSortBug.java │ │ │ │ ├── GridStyleExample.java │ │ │ │ ├── HierarchicalGridExample.java │ │ │ │ ├── MyButtonRenderer.java │ │ │ │ ├── RendererExample.java │ │ │ │ └── TextFieldRenderer.java │ │ │ ├── properties │ │ │ │ ├── CaptionExample.java │ │ │ │ ├── DescriptionExample.java │ │ │ │ ├── EnabledExample.java │ │ │ │ ├── FocusExample.java │ │ │ │ ├── IconExample.java │ │ │ │ ├── ListenerExample.java │ │ │ │ ├── LocaleExample.java │ │ │ │ ├── MultiSelectExample.java │ │ │ │ ├── ReadOnlyExample.java │ │ │ │ ├── RequiredExample.java │ │ │ │ ├── StyleNameExample.java │ │ │ │ ├── ValidationExample.java │ │ │ │ └── VisibleExample.java │ │ │ └── table │ │ │ │ ├── GeneratedColumnExample.java │ │ │ │ ├── TableEditingExample.java │ │ │ │ └── TableExample.java │ │ ├── datamodel │ │ │ ├── BeanContainerExample.java │ │ │ ├── BeanItemContainerExample.java │ │ │ ├── BeanValidationExample.java │ │ │ ├── ContainerExample.java │ │ │ ├── ContainerFilterExample.java │ │ │ ├── ConverterExample.java │ │ │ ├── FieldGroupExample.java │ │ │ ├── FilesystemContainerExample.java │ │ │ ├── HierarchicalExample.java │ │ │ ├── IndexedContainerExample.java │ │ │ ├── ItemExample.java │ │ │ └── PropertyExample.java │ │ ├── editor │ │ │ ├── CompositeExample.java │ │ │ ├── MyComponent.java │ │ │ ├── MyComponent2.java │ │ │ └── MyComposite3.java │ │ ├── gettingstarted │ │ │ ├── MyScalaUI.scala │ │ │ ├── MyprojectUI.java │ │ │ └── NewProjectExample.java │ │ ├── intro │ │ │ └── HelloWorldExample.java │ │ ├── layout │ │ │ ├── AbsoluteLayoutExample.java │ │ │ ├── AccordionExample.java │ │ │ ├── AlignmentExample.java │ │ │ ├── CssLayoutExample.java │ │ │ ├── CustomLayoutExample.java │ │ │ ├── ExpandRatioExample.java │ │ │ ├── FormLayoutExample.java │ │ │ ├── GridLayoutExample.java │ │ │ ├── LayoutExample.java │ │ │ ├── LayoutFeaturesExample.java │ │ │ ├── MarginExample.java │ │ │ ├── OrderedLayoutExample.java │ │ │ ├── PanelExample.java │ │ │ ├── PopupViewExample.java │ │ │ ├── SpacingExample.java │ │ │ ├── SplitPanelExample.java │ │ │ ├── SubWindowExample.java │ │ │ ├── TabSheetExample.java │ │ │ └── WindowExample.java │ │ ├── misc │ │ │ ├── ExceptionExamples.java │ │ │ ├── I18nPrototype.java │ │ │ ├── ItemContainerExample.java │ │ │ └── SerializationExample.java │ │ ├── portlet │ │ │ ├── IPCSessionReceiver.java │ │ │ ├── IPCSessionSender.java │ │ │ ├── MyPortletUI.java │ │ │ ├── Person.java │ │ │ ├── PortletCustomModeExample.java │ │ │ └── PortletModeExample.java │ │ └── themes │ │ │ ├── BuiltInThemeExample.java │ │ │ ├── ResponsiveExample.java │ │ │ ├── ScssThemeExample.java │ │ │ ├── ScssThemeUI.java │ │ │ ├── ThemeExample.java │ │ │ ├── ThemeTricksExample.java │ │ │ └── ValoThemeUI.java │ │ ├── js │ │ └── jquery-2.1.0.min.js │ │ ├── ui │ │ ├── AbstractExampleMenu.java │ │ ├── AccordionMenu.java │ │ ├── SourceListing.java │ │ └── TreeMenu.java │ │ └── widgetset │ │ └── BookExamplesWidgetSet.gwt.xml ├── logging.properties └── org │ └── vaadin │ └── itemcontainer │ └── ItemContainer.java └── tests └── com └── vaadin └── book └── examples ├── BookExampleTestcase.java ├── ForExample.java ├── application └── NotificationTest.java ├── component ├── ButtonTest.java ├── CalendarTest.java ├── ComboBoxTest.java ├── PasswordFieldTest.java ├── TableTest.java └── properties │ └── DescriptionTest.java ├── layout ├── PanelTest.java └── PopupViewTest.java └── testbench ├── SeleniumTestcase.java └── Testcase.java /.classpath: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /.externalToolBuilders/Copy sources.launch: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /.externalToolBuilders/Sass Compilation.launch: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .cache 2 | *~ 3 | -------------------------------------------------------------------------------- /.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | book-examples-v7 4 | 5 | 6 | 7 | 8 | 9 | org.eclipse.jdt.core.javabuilder 10 | 11 | 12 | 13 | 14 | com.vaadin.integration.eclipse.widgetsetBuilder 15 | 16 | 17 | 18 | 19 | com.vaadin.integration.eclipse.addonStylesBuilder 20 | 21 | 22 | 23 | 24 | org.eclipse.ui.externaltools.ExternalToolBuilder 25 | auto,full,incremental, 26 | 27 | 28 | LaunchConfigHandle 29 | <project>/.externalToolBuilders/Copy sources.launch 30 | 31 | 32 | 33 | 34 | org.eclipse.ui.externaltools.ExternalToolBuilder 35 | full,incremental, 36 | 37 | 38 | LaunchConfigHandle 39 | <project>/.externalToolBuilders/Sass Compilation.launch 40 | 41 | 42 | 43 | 44 | org.scala-ide.sdt.core.scalabuilder 45 | 46 | 47 | 48 | 49 | 50 | org.scala-ide.sdt.core.scalanature 51 | org.eclipse.jem.workbench.JavaEMFNature 52 | org.eclipse.wst.common.modulecore.ModuleCoreNature 53 | org.eclipse.wst.common.project.facet.core.nature 54 | org.eclipse.jdt.core.javanature 55 | org.eclipse.wst.jsdt.core.jsNature 56 | com.vaadin.integration.eclipse.widgetsetNature 57 | org.apache.ivyde.eclipse.ivynature 58 | 59 | 60 | -------------------------------------------------------------------------------- /.settings/org.eclipse.wst.common.component: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /.settings/org.eclipse.wst.common.project.facet.core.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /WebContent/META-INF/MANIFEST.MF: -------------------------------------------------------------------------------- 1 | Manifest-Version: 1.0 2 | Class-Path: 3 | 4 | -------------------------------------------------------------------------------- /WebContent/VAADIN/themes/book-examples/.gitignore: -------------------------------------------------------------------------------- 1 | styles.css 2 | -------------------------------------------------------------------------------- /WebContent/VAADIN/themes/book-examples/Makefile: -------------------------------------------------------------------------------- 1 | 2 | sass-compile: styles.scss book-examples.scss FORCE 3 | cd ../../../../build ; ant compile-theme 4 | cp ../../../../build/result/VAADIN/themes/book-examples/styles.css . 5 | 6 | FORCE: 7 | -------------------------------------------------------------------------------- /WebContent/VAADIN/themes/book-examples/addons.scss: -------------------------------------------------------------------------------- 1 | /* This file is automatically managed and will be overwritten from time to time. */ 2 | /* Do not manually edit this file. */ 3 | 4 | /* Provided by vaadin-spreadsheet-1.1.0.alpha1.jar */ 5 | @import "../../../VAADIN/addons/spreadsheet/spreadsheet.scss"; 6 | 7 | 8 | /* Import and include this mixin into your project theme to include the addon themes */ 9 | @mixin addons { 10 | @include spreadsheet; 11 | } 12 | 13 | -------------------------------------------------------------------------------- /WebContent/VAADIN/themes/book-examples/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vaadin/book-examples/435f8b377a946ad5a8129ed266289afe0e015790/WebContent/VAADIN/themes/book-examples/favicon.ico -------------------------------------------------------------------------------- /WebContent/VAADIN/themes/book-examples/fonts/03805817-4611-4dbc-8c65-0f73031c3973.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vaadin/book-examples/435f8b377a946ad5a8129ed266289afe0e015790/WebContent/VAADIN/themes/book-examples/fonts/03805817-4611-4dbc-8c65-0f73031c3973.woff -------------------------------------------------------------------------------- /WebContent/VAADIN/themes/book-examples/fonts/548e8c1d-b37a-43af-b197-a35e2f0c3d2f.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vaadin/book-examples/435f8b377a946ad5a8129ed266289afe0e015790/WebContent/VAADIN/themes/book-examples/fonts/548e8c1d-b37a-43af-b197-a35e2f0c3d2f.ttf -------------------------------------------------------------------------------- /WebContent/VAADIN/themes/book-examples/fonts/c280ced9-704c-46b2-a66a-aff7ee1627bf.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vaadin/book-examples/435f8b377a946ad5a8129ed266289afe0e015790/WebContent/VAADIN/themes/book-examples/fonts/c280ced9-704c-46b2-a66a-aff7ee1627bf.woff -------------------------------------------------------------------------------- /WebContent/VAADIN/themes/book-examples/fonts/d5f9f72d-afb7-4c57-8348-b4bdac42edbb.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vaadin/book-examples/435f8b377a946ad5a8129ed266289afe0e015790/WebContent/VAADIN/themes/book-examples/fonts/d5f9f72d-afb7-4c57-8348-b4bdac42edbb.ttf -------------------------------------------------------------------------------- /WebContent/VAADIN/themes/book-examples/icons/axe-16px.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vaadin/book-examples/435f8b377a946ad5a8129ed266289afe0e015790/WebContent/VAADIN/themes/book-examples/icons/axe-16px.png -------------------------------------------------------------------------------- /WebContent/VAADIN/themes/book-examples/icons/axe-32px.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vaadin/book-examples/435f8b377a946ad5a8129ed266289afe0e015790/WebContent/VAADIN/themes/book-examples/icons/axe-32px.png -------------------------------------------------------------------------------- /WebContent/VAADIN/themes/book-examples/icons/axe-8px.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vaadin/book-examples/435f8b377a946ad5a8129ed266289afe0e015790/WebContent/VAADIN/themes/book-examples/icons/axe-8px.png -------------------------------------------------------------------------------- /WebContent/VAADIN/themes/book-examples/icons/coffee-16px.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vaadin/book-examples/435f8b377a946ad5a8129ed266289afe0e015790/WebContent/VAADIN/themes/book-examples/icons/coffee-16px.png -------------------------------------------------------------------------------- /WebContent/VAADIN/themes/book-examples/icons/coffee-20px.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vaadin/book-examples/435f8b377a946ad5a8129ed266289afe0e015790/WebContent/VAADIN/themes/book-examples/icons/coffee-20px.png -------------------------------------------------------------------------------- /WebContent/VAADIN/themes/book-examples/icons/comment_yellow.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vaadin/book-examples/435f8b377a946ad5a8129ed266289afe0e015790/WebContent/VAADIN/themes/book-examples/icons/comment_yellow.gif -------------------------------------------------------------------------------- /WebContent/VAADIN/themes/book-examples/icons/external-link.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vaadin/book-examples/435f8b377a946ad5a8129ed266289afe0e015790/WebContent/VAADIN/themes/book-examples/icons/external-link.png -------------------------------------------------------------------------------- /WebContent/VAADIN/themes/book-examples/icons/magnifier.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vaadin/book-examples/435f8b377a946ad5a8129ed266289afe0e015790/WebContent/VAADIN/themes/book-examples/icons/magnifier.png -------------------------------------------------------------------------------- /WebContent/VAADIN/themes/book-examples/icons/tea-16px.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vaadin/book-examples/435f8b377a946ad5a8129ed266289afe0e015790/WebContent/VAADIN/themes/book-examples/icons/tea-16px.png -------------------------------------------------------------------------------- /WebContent/VAADIN/themes/book-examples/icons/tea-20px.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vaadin/book-examples/435f8b377a946ad5a8129ed266289afe0e015790/WebContent/VAADIN/themes/book-examples/icons/tea-20px.png -------------------------------------------------------------------------------- /WebContent/VAADIN/themes/book-examples/icons/user.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vaadin/book-examples/435f8b377a946ad5a8129ed266289afe0e015790/WebContent/VAADIN/themes/book-examples/icons/user.png -------------------------------------------------------------------------------- /WebContent/VAADIN/themes/book-examples/icons/vaadin-arrow-down-white.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vaadin/book-examples/435f8b377a946ad5a8129ed266289afe0e015790/WebContent/VAADIN/themes/book-examples/icons/vaadin-arrow-down-white.png -------------------------------------------------------------------------------- /WebContent/VAADIN/themes/book-examples/icons/vaadin-arrow-right-orange.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vaadin/book-examples/435f8b377a946ad5a8129ed266289afe0e015790/WebContent/VAADIN/themes/book-examples/icons/vaadin-arrow-right-orange.png -------------------------------------------------------------------------------- /WebContent/VAADIN/themes/book-examples/img/Ripley_Scroll-300px.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vaadin/book-examples/435f8b377a946ad5a8129ed266289afe0e015790/WebContent/VAADIN/themes/book-examples/img/Ripley_Scroll-300px.jpg -------------------------------------------------------------------------------- /WebContent/VAADIN/themes/book-examples/img/Ripley_Scroll.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vaadin/book-examples/435f8b377a946ad5a8129ed266289afe0e015790/WebContent/VAADIN/themes/book-examples/img/Ripley_Scroll.jpg -------------------------------------------------------------------------------- /WebContent/VAADIN/themes/book-examples/img/cat-128px.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vaadin/book-examples/435f8b377a946ad5a8129ed266289afe0e015790/WebContent/VAADIN/themes/book-examples/img/cat-128px.png -------------------------------------------------------------------------------- /WebContent/VAADIN/themes/book-examples/img/cat-16px.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vaadin/book-examples/435f8b377a946ad5a8129ed266289afe0e015790/WebContent/VAADIN/themes/book-examples/img/cat-16px.png -------------------------------------------------------------------------------- /WebContent/VAADIN/themes/book-examples/img/checkbox-checked.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vaadin/book-examples/435f8b377a946ad5a8129ed266289afe0e015790/WebContent/VAADIN/themes/book-examples/img/checkbox-checked.png -------------------------------------------------------------------------------- /WebContent/VAADIN/themes/book-examples/img/checkbox-unchecked.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vaadin/book-examples/435f8b377a946ad5a8129ed266289afe0e015790/WebContent/VAADIN/themes/book-examples/img/checkbox-unchecked.png -------------------------------------------------------------------------------- /WebContent/VAADIN/themes/book-examples/img/copernicus-128px.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vaadin/book-examples/435f8b377a946ad5a8129ed266289afe0e015790/WebContent/VAADIN/themes/book-examples/img/copernicus-128px.jpg -------------------------------------------------------------------------------- /WebContent/VAADIN/themes/book-examples/img/dog-128px.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vaadin/book-examples/435f8b377a946ad5a8129ed266289afe0e015790/WebContent/VAADIN/themes/book-examples/img/dog-128px.png -------------------------------------------------------------------------------- /WebContent/VAADIN/themes/book-examples/img/dog-16px.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vaadin/book-examples/435f8b377a946ad5a8129ed266289afe0e015790/WebContent/VAADIN/themes/book-examples/img/dog-16px.png -------------------------------------------------------------------------------- /WebContent/VAADIN/themes/book-examples/img/dog-32px.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vaadin/book-examples/435f8b377a946ad5a8129ed266289afe0e015790/WebContent/VAADIN/themes/book-examples/img/dog-32px.png -------------------------------------------------------------------------------- /WebContent/VAADIN/themes/book-examples/img/embedded-journalist.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vaadin/book-examples/435f8b377a946ad5a8129ed266289afe0e015790/WebContent/VAADIN/themes/book-examples/img/embedded-journalist.jpg -------------------------------------------------------------------------------- /WebContent/VAADIN/themes/book-examples/img/galileo-128px.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vaadin/book-examples/435f8b377a946ad5a8129ed266289afe0e015790/WebContent/VAADIN/themes/book-examples/img/galileo-128px.jpg -------------------------------------------------------------------------------- /WebContent/VAADIN/themes/book-examples/img/image-sources.txt: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- 3 | embedded-journalist.jpg 4 | 5 | http://en.wikipedia.org/wiki/File:Army.mil-2007-06-26-111327.jpg 6 | 7 | Staff Sgt. Michael L. Casteel 8 | 9 | This image is a work of a U.S. Army soldier or employee, taken or made 10 | during the course of the person's official duties. As a work of the 11 | U.S. federal government, the image is in the public domain. 12 | -------------------------------------------------------------------------------- 13 | nicubunu_Chain.png 14 | 15 | From OpenClipArt library 16 | http://www.openclipart.org/image/50px/svg_to_png/nicubunu_Chain.png 17 | -------------------------------------------------------------------------------- 18 | -------------------------------------------------------------------------------- /WebContent/VAADIN/themes/book-examples/img/kepler-128px.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vaadin/book-examples/435f8b377a946ad5a8129ed266289afe0e015790/WebContent/VAADIN/themes/book-examples/img/kepler-128px.jpg -------------------------------------------------------------------------------- /WebContent/VAADIN/themes/book-examples/img/neocreo_Blue_World_Map_640x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vaadin/book-examples/435f8b377a946ad5a8129ed266289afe0e015790/WebContent/VAADIN/themes/book-examples/img/neocreo_Blue_World_Map_640x.png -------------------------------------------------------------------------------- /WebContent/VAADIN/themes/book-examples/img/nicubunu_Chain.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vaadin/book-examples/435f8b377a946ad5a8129ed266289afe0e015790/WebContent/VAADIN/themes/book-examples/img/nicubunu_Chain.png -------------------------------------------------------------------------------- /WebContent/VAADIN/themes/book-examples/img/penguin-128px.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vaadin/book-examples/435f8b377a946ad5a8129ed266289afe0e015790/WebContent/VAADIN/themes/book-examples/img/penguin-128px.png -------------------------------------------------------------------------------- /WebContent/VAADIN/themes/book-examples/img/penguin-16px.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vaadin/book-examples/435f8b377a946ad5a8129ed266289afe0e015790/WebContent/VAADIN/themes/book-examples/img/penguin-16px.png -------------------------------------------------------------------------------- /WebContent/VAADIN/themes/book-examples/img/pig-128px.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vaadin/book-examples/435f8b377a946ad5a8129ed266289afe0e015790/WebContent/VAADIN/themes/book-examples/img/pig-128px.png -------------------------------------------------------------------------------- /WebContent/VAADIN/themes/book-examples/img/pig-16px.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vaadin/book-examples/435f8b377a946ad5a8129ed266289afe0e015790/WebContent/VAADIN/themes/book-examples/img/pig-16px.png -------------------------------------------------------------------------------- /WebContent/VAADIN/themes/book-examples/img/pig-32px.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vaadin/book-examples/435f8b377a946ad5a8129ed266289afe0e015790/WebContent/VAADIN/themes/book-examples/img/pig-32px.png -------------------------------------------------------------------------------- /WebContent/VAADIN/themes/book-examples/img/planets/Earth.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vaadin/book-examples/435f8b377a946ad5a8129ed266289afe0e015790/WebContent/VAADIN/themes/book-examples/img/planets/Earth.jpg -------------------------------------------------------------------------------- /WebContent/VAADIN/themes/book-examples/img/planets/Earth_small.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vaadin/book-examples/435f8b377a946ad5a8129ed266289afe0e015790/WebContent/VAADIN/themes/book-examples/img/planets/Earth_small.png -------------------------------------------------------------------------------- /WebContent/VAADIN/themes/book-examples/img/planets/Earth_symbol.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vaadin/book-examples/435f8b377a946ad5a8129ed266289afe0e015790/WebContent/VAADIN/themes/book-examples/img/planets/Earth_symbol.png -------------------------------------------------------------------------------- /WebContent/VAADIN/themes/book-examples/img/planets/Jupiter.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vaadin/book-examples/435f8b377a946ad5a8129ed266289afe0e015790/WebContent/VAADIN/themes/book-examples/img/planets/Jupiter.jpg -------------------------------------------------------------------------------- /WebContent/VAADIN/themes/book-examples/img/planets/Jupiter_symbol.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vaadin/book-examples/435f8b377a946ad5a8129ed266289afe0e015790/WebContent/VAADIN/themes/book-examples/img/planets/Jupiter_symbol.png -------------------------------------------------------------------------------- /WebContent/VAADIN/themes/book-examples/img/planets/Mars.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vaadin/book-examples/435f8b377a946ad5a8129ed266289afe0e015790/WebContent/VAADIN/themes/book-examples/img/planets/Mars.jpg -------------------------------------------------------------------------------- /WebContent/VAADIN/themes/book-examples/img/planets/Mars_symbol.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vaadin/book-examples/435f8b377a946ad5a8129ed266289afe0e015790/WebContent/VAADIN/themes/book-examples/img/planets/Mars_symbol.png -------------------------------------------------------------------------------- /WebContent/VAADIN/themes/book-examples/img/planets/Mercury.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vaadin/book-examples/435f8b377a946ad5a8129ed266289afe0e015790/WebContent/VAADIN/themes/book-examples/img/planets/Mercury.jpg -------------------------------------------------------------------------------- /WebContent/VAADIN/themes/book-examples/img/planets/Mercury_small.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vaadin/book-examples/435f8b377a946ad5a8129ed266289afe0e015790/WebContent/VAADIN/themes/book-examples/img/planets/Mercury_small.png -------------------------------------------------------------------------------- /WebContent/VAADIN/themes/book-examples/img/planets/Mercury_symbol.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vaadin/book-examples/435f8b377a946ad5a8129ed266289afe0e015790/WebContent/VAADIN/themes/book-examples/img/planets/Mercury_symbol.png -------------------------------------------------------------------------------- /WebContent/VAADIN/themes/book-examples/img/planets/Neptune.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vaadin/book-examples/435f8b377a946ad5a8129ed266289afe0e015790/WebContent/VAADIN/themes/book-examples/img/planets/Neptune.jpg -------------------------------------------------------------------------------- /WebContent/VAADIN/themes/book-examples/img/planets/Neptune_symbol.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vaadin/book-examples/435f8b377a946ad5a8129ed266289afe0e015790/WebContent/VAADIN/themes/book-examples/img/planets/Neptune_symbol.png -------------------------------------------------------------------------------- /WebContent/VAADIN/themes/book-examples/img/planets/Saturn.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vaadin/book-examples/435f8b377a946ad5a8129ed266289afe0e015790/WebContent/VAADIN/themes/book-examples/img/planets/Saturn.jpg -------------------------------------------------------------------------------- /WebContent/VAADIN/themes/book-examples/img/planets/Saturn_symbol.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vaadin/book-examples/435f8b377a946ad5a8129ed266289afe0e015790/WebContent/VAADIN/themes/book-examples/img/planets/Saturn_symbol.png -------------------------------------------------------------------------------- /WebContent/VAADIN/themes/book-examples/img/planets/Uranus.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vaadin/book-examples/435f8b377a946ad5a8129ed266289afe0e015790/WebContent/VAADIN/themes/book-examples/img/planets/Uranus.jpg -------------------------------------------------------------------------------- /WebContent/VAADIN/themes/book-examples/img/planets/Uranus_symbol.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vaadin/book-examples/435f8b377a946ad5a8129ed266289afe0e015790/WebContent/VAADIN/themes/book-examples/img/planets/Uranus_symbol.png -------------------------------------------------------------------------------- /WebContent/VAADIN/themes/book-examples/img/planets/Venus.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vaadin/book-examples/435f8b377a946ad5a8129ed266289afe0e015790/WebContent/VAADIN/themes/book-examples/img/planets/Venus.jpg -------------------------------------------------------------------------------- /WebContent/VAADIN/themes/book-examples/img/planets/Venus_small.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vaadin/book-examples/435f8b377a946ad5a8129ed266289afe0e015790/WebContent/VAADIN/themes/book-examples/img/planets/Venus_small.png -------------------------------------------------------------------------------- /WebContent/VAADIN/themes/book-examples/img/planets/Venus_symbol.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vaadin/book-examples/435f8b377a946ad5a8129ed266289afe0e015790/WebContent/VAADIN/themes/book-examples/img/planets/Venus_symbol.png -------------------------------------------------------------------------------- /WebContent/VAADIN/themes/book-examples/img/planets/image-sources.txt: -------------------------------------------------------------------------------- 1 | Original images from Wikipedia 2 | 3 | These are Public Domain pictures from NASA: 4 | 5 | 240px-Jupiter_by_Cassini-Huygens.jpg 6 | 240px-Mercury_in_color_-_Prockter07_centered.jpg 7 | 240px-Neptune.jpg 8 | 240px-Uranus2.jpg 9 | 240px-Venus-real.jpg 10 | 250px-Mars_Valles_Marineris.jpeg 11 | 250px-The_Earth_seen_from_Apollo_17.jpg 12 | 280px-Saturn_from_Cassini_Orbiter_(2004-10-06).jpg 13 | 14 | These are rather generic: 15 | 16 | Earth_small.png 17 | Earth_symbol.png 18 | Jupiter_symbol.png 19 | Mars_symbol.png 20 | Mercury_small.png 21 | Mercury_symbol.png 22 | Neptune_symbol.png 23 | Saturn_symbol.png 24 | Uranus_symbol.png 25 | Venus_small.png 26 | Venus_symbol.png 27 | -------------------------------------------------------------------------------- /WebContent/VAADIN/themes/book-examples/img/reindeer-128px.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vaadin/book-examples/435f8b377a946ad5a8129ed266289afe0e015790/WebContent/VAADIN/themes/book-examples/img/reindeer-128px.png -------------------------------------------------------------------------------- /WebContent/VAADIN/themes/book-examples/img/reindeer-16px.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vaadin/book-examples/435f8b377a946ad5a8129ed266289afe0e015790/WebContent/VAADIN/themes/book-examples/img/reindeer-16px.png -------------------------------------------------------------------------------- /WebContent/VAADIN/themes/book-examples/img/reindeer-256px.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vaadin/book-examples/435f8b377a946ad5a8129ed266289afe0e015790/WebContent/VAADIN/themes/book-examples/img/reindeer-256px.png -------------------------------------------------------------------------------- /WebContent/VAADIN/themes/book-examples/img/reindeer-32px.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vaadin/book-examples/435f8b377a946ad5a8129ed266289afe0e015790/WebContent/VAADIN/themes/book-examples/img/reindeer-32px.png -------------------------------------------------------------------------------- /WebContent/VAADIN/themes/book-examples/img/reindeer-64px.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vaadin/book-examples/435f8b377a946ad5a8129ed266289afe0e015790/WebContent/VAADIN/themes/book-examples/img/reindeer-64px.png -------------------------------------------------------------------------------- /WebContent/VAADIN/themes/book-examples/img/richtextarea-toolbar-fi.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vaadin/book-examples/435f8b377a946ad5a8129ed266289afe0e015790/WebContent/VAADIN/themes/book-examples/img/richtextarea-toolbar-fi.png -------------------------------------------------------------------------------- /WebContent/VAADIN/themes/book-examples/img/sheep-128px.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vaadin/book-examples/435f8b377a946ad5a8129ed266289afe0e015790/WebContent/VAADIN/themes/book-examples/img/sheep-128px.png -------------------------------------------------------------------------------- /WebContent/VAADIN/themes/book-examples/img/sheep-16px.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vaadin/book-examples/435f8b377a946ad5a8129ed266289afe0e015790/WebContent/VAADIN/themes/book-examples/img/sheep-16px.png -------------------------------------------------------------------------------- /WebContent/VAADIN/themes/book-examples/img/smiley.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vaadin/book-examples/435f8b377a946ad5a8129ed266289afe0e015790/WebContent/VAADIN/themes/book-examples/img/smiley.jpg -------------------------------------------------------------------------------- /WebContent/VAADIN/themes/book-examples/img/smiley2-128px.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vaadin/book-examples/435f8b377a946ad5a8129ed266289afe0e015790/WebContent/VAADIN/themes/book-examples/img/smiley2-128px.png -------------------------------------------------------------------------------- /WebContent/VAADIN/themes/book-examples/img/smiley2-20px.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vaadin/book-examples/435f8b377a946ad5a8129ed266289afe0e015790/WebContent/VAADIN/themes/book-examples/img/smiley2-20px.png -------------------------------------------------------------------------------- /WebContent/VAADIN/themes/book-examples/img/themeimage.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vaadin/book-examples/435f8b377a946ad5a8129ed266289afe0e015790/WebContent/VAADIN/themes/book-examples/img/themeimage.png -------------------------------------------------------------------------------- /WebContent/VAADIN/themes/book-examples/img/tree-arrows-white.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vaadin/book-examples/435f8b377a946ad5a8129ed266289afe0e015790/WebContent/VAADIN/themes/book-examples/img/tree-arrows-white.png -------------------------------------------------------------------------------- /WebContent/VAADIN/themes/book-examples/img/vaadin-logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vaadin/book-examples/435f8b377a946ad5a8129ed266289afe0e015790/WebContent/VAADIN/themes/book-examples/img/vaadin-logo.png -------------------------------------------------------------------------------- /WebContent/VAADIN/themes/book-examples/img/vaadin_spin.swf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vaadin/book-examples/435f8b377a946ad5a8129ed266289afe0e015790/WebContent/VAADIN/themes/book-examples/img/vaadin_spin.swf -------------------------------------------------------------------------------- /WebContent/VAADIN/themes/book-examples/layouts/layoutname.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 15 | 16 | 17 | 18 | 19 |
4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 |
User name:
Password:
14 |
-------------------------------------------------------------------------------- /WebContent/VAADIN/themes/book-examples/layouts/printpage.html: -------------------------------------------------------------------------------- 1 |
Here is some static content.
2 | 3 | 6 | -------------------------------------------------------------------------------- /WebContent/VAADIN/themes/book-examples/layouts/stylingexample.html: -------------------------------------------------------------------------------- 1 |
2 |
3 | -------------------------------------------------------------------------------- /WebContent/VAADIN/themes/book-examples/pdfexample.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vaadin/book-examples/435f8b377a946ad5a8129ed266289afe0e015790/WebContent/VAADIN/themes/book-examples/pdfexample.pdf -------------------------------------------------------------------------------- /WebContent/VAADIN/themes/book-examples/styles.scss: -------------------------------------------------------------------------------- 1 | @import "addons.scss"; 2 | @import "book-examples.scss"; 3 | 4 | @import url("//fast.fonts.com/t/1.css?apiType=css&projectid=e52198f4-e2bf-4f47-913d-d6a2747493f7"); 5 | @font-face{font-family:"Helvetica W01 Light";src:url("fonts/717f8140-20c9-4892-9815-38b48f14ce2b.eot?#iefix");src:url("fonts/717f8140-20c9-4892-9815-38b48f14ce2b.eot?#iefix") format("eot"),url("fonts/03805817-4611-4dbc-8c65-0f73031c3973.woff") format("woff"),url("fonts/d5f9f72d-afb7-4c57-8348-b4bdac42edbb.ttf") format("truetype"),url("fonts/05ad458f-263b-413f-b054-6001a987ff3e.svg#05ad458f-263b-413f-b054-6001a987ff3e") format("svg");} 6 | @font-face{font-family:"HelveticaW01-RoundedBd";font-weight:bold;src:url("fonts/79e78e0d-1e3d-4298-8913-6f12cf008e7d.eot?#iefix");src:url("fonts/79e78e0d-1e3d-4298-8913-6f12cf008e7d.eot?#iefix") format("eot"),url("fonts/c280ced9-704c-46b2-a66a-aff7ee1627bf.woff") format("woff"),url("fonts/548e8c1d-b37a-43af-b197-a35e2f0c3d2f.ttf") format("truetype"),url("fonts/5e9b82e3-aa53-4064-b984-f49aa751081d.svg#5e9b82e3-aa53-4064-b984-f49aa751081d") format("svg");} 7 | @font-face{font-family:"vaadin-icons";src:url("fonts/vaadin-icons/vaadin-icons.eot?#iefix");src:url("fonts/vaadin-icons/vaadin-icons.eot?#iefix") format("eot"),url("fonts/vaadin-icons/vaadin-icons.woff") format("woff"),url("fonts/vaadin-icons/vaadin-icons.ttf") format("truetype"),url("fonts/vaadin-icons/vaadin-icons.svg#vaadin-icons") format("svg");} 8 | 9 | .book-examples { 10 | @include addons; 11 | @include book-examples; 12 | } 13 | /* 14 | // Fix issue #14854 15 | .v-overlay-container .v-tooltip { 16 | z-index: 30000 !important; 17 | } 18 | */ -------------------------------------------------------------------------------- /WebContent/VAADIN/themes/mobiletheme/close64.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vaadin/book-examples/435f8b377a946ad5a8129ed266289afe0e015790/WebContent/VAADIN/themes/mobiletheme/close64.png -------------------------------------------------------------------------------- /WebContent/VAADIN/themes/mobiletheme/styles.css: -------------------------------------------------------------------------------- 1 | .stylishlabel { 2 | color: red; 3 | font-style: italic; 4 | } 5 | 6 | .slideshow .v-touchkit-navpanel-container { 7 | background: black; 8 | } -------------------------------------------------------------------------------- /WebContent/VAADIN/themes/myproject/.gitignore: -------------------------------------------------------------------------------- 1 | styles.css 2 | -------------------------------------------------------------------------------- /WebContent/VAADIN/themes/myproject/addons.scss: -------------------------------------------------------------------------------- 1 | /* This file is automatically managed and will be overwritten from time to time. */ 2 | /* Do not manually edit this file. */ 3 | 4 | /* Provided by vaadin-spreadsheet-1.1.0.alpha1.jar */ 5 | @import "../../../VAADIN/addons/spreadsheet/spreadsheet.scss"; 6 | 7 | 8 | /* Import and include this mixin into your project theme to include the addon themes */ 9 | @mixin addons { 10 | @include spreadsheet; 11 | } 12 | 13 | -------------------------------------------------------------------------------- /WebContent/VAADIN/themes/myproject/myproject.scss: -------------------------------------------------------------------------------- 1 | /* Import the valo theme.*/ 2 | /* This only allows us to use the mixins defined in it and does not add any styles by itself. */ 3 | @import "../valo/valo"; 4 | 5 | /* This contains all of your theme.*/ 6 | /* If somebody wants to extend the theme she will include this mixin. */ 7 | @mixin myproject { 8 | /* Include all the styles from the valo theme */ 9 | @include valo; 10 | 11 | /* Insert your theme rules here */ 12 | } 13 | -------------------------------------------------------------------------------- /WebContent/VAADIN/themes/myproject/styles.scss: -------------------------------------------------------------------------------- 1 | @import "addons.scss"; 2 | @import "myproject.scss"; 3 | 4 | /* This file prefixes all rules with the theme name to avoid causing conflicts with other themes. */ 5 | /* The actual styles should be defined in myproject.scss */ 6 | .myproject { 7 | @include addons; 8 | @include myproject; 9 | } 10 | -------------------------------------------------------------------------------- /WebContent/VAADIN/themes/mytheme/.gitignore: -------------------------------------------------------------------------------- 1 | styles.css 2 | -------------------------------------------------------------------------------- /WebContent/VAADIN/themes/mytheme/addons.scss: -------------------------------------------------------------------------------- 1 | /* This file is automatically managed and will be overwritten from time to time. */ 2 | /* Do not manually edit this file. */ 3 | 4 | /* Provided by vaadin-spreadsheet-1.1.0.alpha1.jar */ 5 | @import "../../../VAADIN/addons/spreadsheet/spreadsheet.scss"; 6 | 7 | 8 | /* Import and include this mixin into your project theme to include the addon themes */ 9 | @mixin addons { 10 | @include spreadsheet; 11 | } 12 | 13 | -------------------------------------------------------------------------------- /WebContent/VAADIN/themes/mytheme/mytheme.scss: -------------------------------------------------------------------------------- 1 | @import "../reindeer/reindeer.scss"; 2 | 3 | @mixin mytheme { 4 | @include reindeer; 5 | 6 | /* White background for the entire UI */ 7 | .v-ui { 8 | background: white; 9 | } 10 | 11 | /* All labels have white text on black background */ 12 | .v-label { 13 | background: black; 14 | color: white; 15 | font-size: 24pt; 16 | line-height: 24pt; 17 | padding: 5px; 18 | } 19 | 20 | /* All buttons have blue caption and some margin */ 21 | .v-button { 22 | margin: 10px; 23 | 24 | /* A nested selector to increase specificity */ 25 | .v-button-caption { 26 | color: blue; 27 | } 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /WebContent/VAADIN/themes/mytheme/styles.scss: -------------------------------------------------------------------------------- 1 | @import "addons.scss"; 2 | @import "mytheme.scss"; 3 | 4 | /* This file prefixes all rules with the theme name to avoid causing conflicts with other themes. */ 5 | /* The actual styles should be defined in myproject.scss */ 6 | .mytheme { 7 | @include addons; 8 | @include mytheme; 9 | } 10 | -------------------------------------------------------------------------------- /WebContent/VAADIN/themes/myvalotheme/.gitignore: -------------------------------------------------------------------------------- 1 | styles.css 2 | -------------------------------------------------------------------------------- /WebContent/VAADIN/themes/myvalotheme/addons.scss: -------------------------------------------------------------------------------- 1 | /* This file is automatically managed and will be overwritten from time to time. */ 2 | /* Do not manually edit this file. */ 3 | 4 | /* Provided by vaadin-spreadsheet-1.1.0.alpha1.jar */ 5 | @import "../../../VAADIN/addons/spreadsheet/spreadsheet.scss"; 6 | 7 | 8 | /* Import and include this mixin into your project theme to include the addon themes */ 9 | @mixin addons { 10 | @include spreadsheet; 11 | } 12 | 13 | -------------------------------------------------------------------------------- /WebContent/VAADIN/themes/myvalotheme/myvalotheme.scss: -------------------------------------------------------------------------------- 1 | /* Parameters for Valo */ 2 | 3 | $v-app-background-color: #ffffff; 4 | $v-font-family: 'Open Sans', sans-serif, 'Source Sans Pro'; 5 | // $v-font-color: black; 6 | 7 | /* Import the valo theme.*/ 8 | @import "../valo/valo"; 9 | 10 | /* This contains all of your theme.*/ 11 | /* If somebody wants to extend the theme she will include this mixin. */ 12 | @mixin myvalotheme { 13 | /* Include all the styles from the valo theme */ 14 | @include valo; 15 | 16 | /* Insert your theme rules here */ 17 | 18 | .v-label pre { 19 | font-family: 'Source Sans Pro', courier, monospace; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /WebContent/VAADIN/themes/myvalotheme/styles.scss: -------------------------------------------------------------------------------- 1 | @import "addons.scss"; 2 | @import "myvalotheme.scss"; 3 | 4 | /* This file prefixes all rules with the theme name to avoid causing conflicts with other themes. */ 5 | /* The actual styles should be defined in myproject.scss */ 6 | .myvalotheme { 7 | @include addons; 8 | @include myvalotheme; 9 | } 10 | -------------------------------------------------------------------------------- /WebContent/WEB-INF/applicationContext.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /WebContent/WEB-INF/beans.xml: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vaadin/book-examples/435f8b377a946ad5a8129ed266289afe0e015790/WebContent/WEB-INF/beans.xml -------------------------------------------------------------------------------- /WebContent/WEB-INF/images/image.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vaadin/book-examples/435f8b377a946ad5a8129ed266289afe0e015790/WebContent/WEB-INF/images/image.png -------------------------------------------------------------------------------- /WebContent/WEB-INF/liferay-display.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /WebContent/WEB-INF/liferay-plugin-package.properties: -------------------------------------------------------------------------------- 1 | name=Myportlet Application portlet 2 | short-description=My Portlet 3 | module-group-id=Vaadin 4 | module-incremental-version=1 5 | #change-log= 6 | #page-uri= 7 | #author= 8 | license=Proprietary 9 | portal-dependency-jars=\ 10 | vaadin.jar 11 | -------------------------------------------------------------------------------- /WebContent/WEB-INF/liferay-portlet.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Myportlet Application portlet 7 | true 8 | false 9 | 10 | 11 | PortletModeExample portlet 12 | true 13 | false 14 | 15 | 16 | IPC Session Sender 17 | true 18 | false 19 | 20 | 21 | IPC Session Receiver 22 | true 23 | false 24 | 25 | 26 | -------------------------------------------------------------------------------- /WebContent/closed.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Book of Vaadin Examples 7 | 30 | 31 | 32 | 33 |
34 | 35 |

Session Closed

36 | 37 |

You were inactive too long and the session was closed.

38 | 39 |

Go back in the examples

40 | 41 |
42 | 43 | 44 | -------------------------------------------------------------------------------- /WebContent/embedding-in-jsp.jsp: -------------------------------------------------------------------------------- 1 | <%@ page language="java" contentType="text/html; charset=UTF-8" 2 | pageEncoding="UTF-8"%> 3 | 4 | 5 | 6 | 7 | This is a JSP page 8 | 9 | 10 | 20 | 21 | 22 | 23 | 24 | 25 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 |

This is a JSP page

36 | 37 |

Time is now <%= new java.util.Date() %>.

38 | 39 |

And below is a Vaadin app.

40 | 41 | 42 | 43 |
44 | 45 |

<% 46 | for (int i=0; i<3; i++) 47 | out.println("Isn't it nice?"); 48 | %>

49 | 50 | 51 | -------------------------------------------------------------------------------- /WebContent/examples/jscomponent-example.html: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 8 | 9 | Using a JavaScript Component from HTML 10 | 11 | 12 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 |

Using a JavaScript Component from HTML

23 | 24 |

Below is a JavaScript component created in a <div> placeholder element (empty at first):

25 | 26 | 27 |
28 | 29 | 30 | 37 | 38 |

39 | Now, you can do the following: 40 |

41 | 42 |
    43 |
  1. Click here to run foo.setValue("New value")
  2. 44 |
  3. Enter some text in the input box and click "Click"
  4. 45 |
46 | 47 | 48 | -------------------------------------------------------------------------------- /WebContent/examples/mylibrary.js: -------------------------------------------------------------------------------- 1 | // Define the namespace 2 | var mylibrary = mylibrary || {}; 3 | 4 | mylibrary.MyComponent = function (element) { 5 | this.element = element; 6 | this.element.innerHTML = 7 | "
Hello, world!
" + 8 | "
Enter a value: " + 9 | "" + 10 | "" + 11 | "
"; 12 | 13 | // Style it 14 | this.element.style.border = "thin solid red"; 15 | this.element.style.display = "inline-block"; 16 | 17 | // Getter and setter for the value property 18 | this.getValue = function () { 19 | return this.element. 20 | getElementsByTagName("input")[0].value; 21 | }; 22 | this.setValue = function (value) { 23 | this.element.getElementsByTagName("input")[0].value = 24 | value; 25 | }; 26 | 27 | // Default implementation of the click handler 28 | this.click = function () { 29 | alert("Error: Must implement click() method"); 30 | }; 31 | 32 | // Set up button click 33 | var button = this.element.getElementsByTagName("input")[1]; 34 | var component = this; // Can't use this inside the function 35 | button.onclick = function () { 36 | component.click(); 37 | }; 38 | }; 39 | -------------------------------------------------------------------------------- /WebContent/images/datamodel/beanitem-doublebinding-lo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vaadin/book-examples/435f8b377a946ad5a8129ed266289afe0e015790/WebContent/images/datamodel/beanitem-doublebinding-lo.png -------------------------------------------------------------------------------- /WebContent/images/image.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vaadin/book-examples/435f8b377a946ad5a8129ed266289afe0e015790/WebContent/images/image.png -------------------------------------------------------------------------------- /WebContent/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Book of Vaadin Examples 7 | 30 | 31 | 32 | 33 |
34 | 35 |

Book of Vaadin Examples

36 | 37 |

Run the Book Examples online

38 | 39 |
40 | 41 | 42 | -------------------------------------------------------------------------------- /WebContent/logout.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Book of Vaadin Examples 7 | 19 | 20 | 21 |
22 |

Logged Out

23 | 24 |

You can now close this window.

25 | 26 | 39 |
40 | 41 | -------------------------------------------------------------------------------- /WebContent/pure-clientside.html: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 8 | 9 | Embedding a Vaadin Application in HTML Page 10 | 11 | 12 | 15 | 16 | 17 | 18 |

A Pure Client-Side Application

19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /WebContent/static-login.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | A Static HTML File 7 | 8 | 9 |

Static Login Page

10 | 11 |

This is static-login.html and below is a pure 12 | HTML login form:

13 | 14 | 15 | 16 | 17 | 18 |
19 | 20 | 21 | 22 | 23 | 24 | 25 |
Username:
26 |

Give anything to fail, "example" to log in.

27 | 28 |
29 | 30 | 31 | 32 | -------------------------------------------------------------------------------- /src/com/vaadin/book/LogFormatter.java: -------------------------------------------------------------------------------- 1 | package com.vaadin.book; 2 | 3 | import java.io.PrintWriter; 4 | import java.io.StringWriter; 5 | import java.text.DateFormat; 6 | import java.text.SimpleDateFormat; 7 | import java.util.Date; 8 | import java.util.logging.Formatter; 9 | import java.util.logging.LogRecord; 10 | 11 | public final class LogFormatter extends Formatter { 12 | DateFormat df = new SimpleDateFormat("yyyy-MM-dd'T'HH:mmZ"); 13 | 14 | @Override 15 | public String format(LogRecord record) { 16 | System.out.println("Logging..."); 17 | StringBuilder sb = new StringBuilder(); 18 | 19 | sb.append(df.format(new Date(record.getMillis()))) 20 | .append(" ") 21 | .append(record.getLevel().getLocalizedName()) 22 | .append(": ") 23 | .append(formatMessage(record)); 24 | 25 | if (record.getThrown() != null) { 26 | try { 27 | StringWriter sw = new StringWriter(); 28 | PrintWriter pw = new PrintWriter(sw); 29 | record.getThrown().printStackTrace(pw); 30 | pw.close(); 31 | sb.append(sw.toString()); 32 | } catch (Exception ex) { 33 | // ignore 34 | } 35 | } 36 | 37 | return sb.toString(); } 38 | } 39 | -------------------------------------------------------------------------------- /src/com/vaadin/book/applications/DynamicWindowUI.java: -------------------------------------------------------------------------------- 1 | package com.vaadin.book.applications; 2 | 3 | // BEGIN-EXAMPLE: advanced.applicationwindow.dynamic 4 | // TODO Vaadin 7: Fix 5 | import com.vaadin.server.VaadinRequest; 6 | import com.vaadin.ui.Label; 7 | import com.vaadin.ui.UI; 8 | import com.vaadin.ui.VerticalLayout; 9 | 10 | public class DynamicWindowUI extends UI { 11 | private static final long serialVersionUID = 1340937891969118454L; 12 | 13 | @Override 14 | protected void init(VaadinRequest request) { 15 | // Create the content root layout for the UI 16 | VerticalLayout layout = new VerticalLayout(); 17 | setContent(layout); 18 | 19 | // Create just the main window initially 20 | layout.addComponent(new Label("This is the main window.")); 21 | } 22 | 23 | // Puts some content in the window 24 | /* 25 | void initWindow(final UI window) { 26 | VerticalLayout layout = new VerticalLayout(); 27 | layout.setSpacing(true); 28 | window.setContent(layout); 29 | 30 | // A button to open a new window 31 | Link openNew = new Link("Open New Window", 32 | new ExternalResource(BookExamplesUI.APPCONTEXT + "/dynamicwindow/"), 33 | "_blank", 480, 100, Page.BORDER_DEFAULT); 34 | window.addComponent(openNew); 35 | 36 | // Demonstrate closing pop-up windows 37 | Button close = new Button("Close This Window"); 38 | close.addListener(new Button.ClickListener() { 39 | private static final long serialVersionUID = -86208708122352874L; 40 | 41 | public void buttonClick(ClickEvent event) { 42 | JavaScript.getCurrent().execute("close();"); 43 | } 44 | }); 45 | window.addComponent(close); 46 | } 47 | 48 | int windowCount = 0; 49 | */ 50 | } 51 | // END-EXAMPLE: advanced.applicationwindow.dynamic 52 | -------------------------------------------------------------------------------- /src/com/vaadin/book/applications/HelloWorld.java: -------------------------------------------------------------------------------- 1 | package com.vaadin.book.applications; 2 | 3 | // BEGIN-EXAMPLE: intro.walkthrough.helloworld 4 | import com.vaadin.annotations.Theme; 5 | import com.vaadin.annotations.Title; 6 | import com.vaadin.server.VaadinRequest; 7 | import com.vaadin.ui.Button; 8 | import com.vaadin.ui.Button.ClickEvent; 9 | import com.vaadin.ui.Button.ClickListener; 10 | import com.vaadin.ui.Label; 11 | import com.vaadin.ui.Notification; 12 | import com.vaadin.ui.UI; 13 | import com.vaadin.ui.VerticalLayout; 14 | 15 | @Title("My UI") 16 | @Theme("valo") 17 | public class HelloWorld extends UI { 18 | private static final long serialVersionUID = 511085335415683713L; 19 | 20 | @Override 21 | protected void init(VaadinRequest request) { 22 | // Create the content root layout for the UI 23 | VerticalLayout content = new VerticalLayout(); 24 | setContent(content); 25 | 26 | // Display the greeting 27 | content.addComponent(new Label("Hello World!")); 28 | 29 | // Have a clickable button 30 | content.addComponent(new Button("Push Me!", 31 | new ClickListener() { 32 | private static final long serialVersionUID = 5808429544582385114L; 33 | 34 | @Override 35 | public void buttonClick(ClickEvent event) { 36 | Notification.show("Pushed!"); 37 | } 38 | })); 39 | } 40 | } 41 | // END-EXAMPLE: intro.walkthrough.helloworld 42 | -------------------------------------------------------------------------------- /src/com/vaadin/book/applications/MyHierarchicalUI.java: -------------------------------------------------------------------------------- 1 | package com.vaadin.book.applications; 2 | 3 | import com.vaadin.annotations.Theme; 4 | import com.vaadin.book.examples.component.TreeExample; 5 | import com.vaadin.book.examples.component.table.TableExample; 6 | import com.vaadin.server.VaadinRequest; 7 | import com.vaadin.ui.HorizontalLayout; 8 | import com.vaadin.ui.Label; 9 | import com.vaadin.ui.Table; 10 | import com.vaadin.ui.Tree; 11 | import com.vaadin.ui.UI; 12 | import com.vaadin.ui.VerticalLayout; 13 | 14 | // BEGIN-EXAMPLE: application.architecture.hierarchical 15 | @Theme("valo") 16 | public class MyHierarchicalUI extends UI { 17 | private static final long serialVersionUID = 511085335415683713L; 18 | 19 | @Override 20 | protected void init(VaadinRequest request) { 21 | // The root of the component hierarchy 22 | VerticalLayout content = new VerticalLayout(); 23 | content.setSizeFull(); // Use entire window 24 | setContent(content); // Attach to the UI 25 | 26 | // Add some component 27 | content.addComponent(new Label("Hello!")); 28 | 29 | // Layout inside layout 30 | HorizontalLayout hor = new HorizontalLayout(); 31 | hor.setSizeFull(); // Use all available space 32 | 33 | // Couple of horizontally laid out components 34 | Tree tree = new Tree("My Tree", 35 | TreeExample.createTreeContent()); 36 | hor.addComponent(tree); 37 | 38 | Table table = new Table("My Table", 39 | TableExample.generateContent()); 40 | table.setSizeFull(); 41 | hor.addComponent(table); 42 | hor.setExpandRatio(table, 1); // Expand to fill 43 | 44 | content.addComponent(hor); 45 | content.setExpandRatio(hor, 1); // Expand to fill 46 | } 47 | } 48 | // END-EXAMPLE: application.architecture.hierarchical 49 | -------------------------------------------------------------------------------- /src/com/vaadin/book/applications/UIToBeTested.java: -------------------------------------------------------------------------------- 1 | package com.vaadin.book.applications; 2 | 3 | import com.vaadin.annotations.Theme; 4 | import com.vaadin.server.VaadinRequest; 5 | import com.vaadin.ui.Button; 6 | import com.vaadin.ui.Button.ClickEvent; 7 | import com.vaadin.ui.Button.ClickListener; 8 | import com.vaadin.ui.Label; 9 | import com.vaadin.ui.UI; 10 | import com.vaadin.ui.VerticalLayout; 11 | 12 | // BEGIN-EXAMPLE: testbench.application 13 | @Theme("valo") 14 | public class UIToBeTested extends UI { 15 | private static final long serialVersionUID = 511085335415683713L; 16 | 17 | @Override 18 | protected void init(VaadinRequest request) { 19 | setId("myui"); 20 | 21 | final VerticalLayout content = new VerticalLayout(); 22 | content.setMargin(true); 23 | content.setId("myui.content"); 24 | setContent(content); 25 | 26 | // Create a button 27 | Button button = new Button("Push Me!"); 28 | 29 | // Optional: give the button a unique ID 30 | button.setId("myui.content.pushmebutton"); 31 | 32 | // Set the tooltip 33 | button.setDescription("This is a tip"); 34 | 35 | // Do something when the button is clicked 36 | button.addClickListener(new ClickListener() { 37 | private static final long serialVersionUID = -8358743723903182533L; 38 | 39 | @Override 40 | public void buttonClick(ClickEvent event) { 41 | // This label will not have a set ID 42 | content.addComponent(new Label("Thanks!")); 43 | } 44 | }); 45 | content.addComponent(button); 46 | } 47 | } 48 | // END-EXAMPLE: testbench.application 49 | -------------------------------------------------------------------------------- /src/com/vaadin/book/examples/AbstractExampleItem.java: -------------------------------------------------------------------------------- 1 | package com.vaadin.book.examples; 2 | 3 | import java.io.Serializable; 4 | 5 | public class AbstractExampleItem implements Serializable { 6 | private static final long serialVersionUID = -6281280822803513663L; 7 | 8 | protected String exampleId; 9 | protected String context; 10 | private String parentId; 11 | private boolean collapsed; 12 | 13 | public AbstractExampleItem(String itemid) { 14 | if ("-".equals(itemid.substring(itemid.length()-1))) { 15 | this.collapsed = true; 16 | itemid = itemid.substring(0, itemid.length()-1); 17 | } else 18 | collapsed = false; 19 | 20 | this.exampleId = itemid; 21 | 22 | // Determine parent node and context 23 | int lastdot = itemid.lastIndexOf("."); 24 | if (lastdot != -1) { 25 | parentId = itemid.substring(0, lastdot); 26 | context = itemid.substring(lastdot+1); 27 | } else 28 | parentId = null; 29 | } 30 | 31 | public String getExampleId() { 32 | return exampleId; 33 | } 34 | 35 | public String getParentId() { 36 | return parentId; 37 | } 38 | 39 | public boolean isCollapsed() { 40 | return collapsed; 41 | } 42 | } -------------------------------------------------------------------------------- /src/com/vaadin/book/examples/AnyBookExampleBundle.java: -------------------------------------------------------------------------------- 1 | package com.vaadin.book.examples; 2 | 3 | import java.io.Serializable; 4 | 5 | public interface AnyBookExampleBundle extends Serializable { 6 | 7 | } 8 | -------------------------------------------------------------------------------- /src/com/vaadin/book/examples/BookExampleBundle.java: -------------------------------------------------------------------------------- 1 | package com.vaadin.book.examples; 2 | 3 | public interface BookExampleBundle extends AnyBookExampleBundle { 4 | public void init (String context); 5 | } 6 | -------------------------------------------------------------------------------- /src/com/vaadin/book/examples/BrknExample.java: -------------------------------------------------------------------------------- 1 | package com.vaadin.book.examples; 2 | 3 | import com.vaadin.ui.Component; 4 | import com.vaadin.ui.Label; 5 | 6 | 7 | public class BrknExample extends BookExample { 8 | private static final long serialVersionUID = -7260105851251039038L; 9 | 10 | public BrknExample(String exampleId, String shortName, Class exclass) { 11 | super(exampleId, shortName, exclass); 12 | } 13 | 14 | @Override 15 | public String getDescription() { 16 | return "

Broken Example

"; 17 | } 18 | 19 | @Override 20 | public Component invokeExample() { 21 | return new Label("SORRY - This example is broken at the moment and will be fixed later"); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/com/vaadin/book/examples/CaptionedExampleItem.java: -------------------------------------------------------------------------------- 1 | package com.vaadin.book.examples; 2 | 3 | /** Example category. */ 4 | abstract public class CaptionedExampleItem extends AbstractExampleItem { 5 | private static final long serialVersionUID = 418811233718496311L; 6 | 7 | /** A short display name of the example for the menu */ 8 | protected String shortName; 9 | 10 | /** Create a new redirection from an obsolete example ID to a new one. */ 11 | public CaptionedExampleItem(String itemid, String shortName) { 12 | super(itemid); 13 | 14 | this.shortName = shortName; 15 | } 16 | 17 | public String getShortName() { 18 | return shortName; 19 | } 20 | } -------------------------------------------------------------------------------- /src/com/vaadin/book/examples/Description.java: -------------------------------------------------------------------------------- 1 | package com.vaadin.book.examples; 2 | 3 | import java.lang.annotation.ElementType; 4 | import java.lang.annotation.Retention; 5 | import java.lang.annotation.RetentionPolicy; 6 | import java.lang.annotation.Target; 7 | 8 | /** 9 | * Description for an example. 10 | * 11 | * The annotation can be used for example methods in example bundles currently. 12 | * It is also allowed for UI classes embedded with {@link EmboExample}, but 13 | * reading those annotations is not yet supported. 14 | * 15 | * @author magi 16 | */ 17 | @Retention(RetentionPolicy.RUNTIME) 18 | @Target({ElementType.TYPE, ElementType.METHOD}) 19 | public @interface Description { 20 | public String title() default ""; 21 | public String value() default ""; 22 | } 23 | -------------------------------------------------------------------------------- /src/com/vaadin/book/examples/EmboExample.java: -------------------------------------------------------------------------------- 1 | package com.vaadin.book.examples; 2 | 3 | import com.vaadin.book.BookExamplesUI; 4 | import com.vaadin.server.BrowserWindowOpener; 5 | import com.vaadin.server.ExternalResource; 6 | import com.vaadin.ui.BrowserFrame; 7 | import com.vaadin.ui.Button; 8 | import com.vaadin.ui.Component; 9 | import com.vaadin.ui.UI; 10 | import com.vaadin.ui.VerticalLayout; 11 | 12 | /** 13 | * Example that is embedded in a browser frame or in a popup window. 14 | * 15 | * @author magi 16 | */ 17 | public class EmboExample extends BookExample { 18 | private static final long serialVersionUID = -5530635960986472866L; 19 | 20 | public enum EmbeddingType {FRAME, POPUP}; 21 | 22 | String servletPath; 23 | EmbeddingType type; 24 | int width; 25 | int height; 26 | Class exclass; 27 | 28 | public EmboExample(String exampleId, String shortName, Class exclass, String servletPath, EmbeddingType type, int width, int height) { 29 | super(exampleId, shortName, exclass); 30 | this.servletPath = servletPath; 31 | this.type = type; 32 | this.width = width; 33 | this.height = height; 34 | this.exclass = exclass; 35 | } 36 | 37 | @Override 38 | public Component invokeExample() { 39 | VerticalLayout layout = new VerticalLayout(); 40 | 41 | if (type == EmbeddingType.FRAME) { 42 | BrowserFrame frame = new BrowserFrame(description); 43 | frame.setSource(new ExternalResource(BookExamplesUI.APPCONTEXT + "/" + servletPath + "?restartApplication")); 44 | frame.setWidth("" + width + "px"); 45 | frame.setHeight("" + height + "px"); 46 | layout.addComponent(frame); 47 | } else { 48 | // TODO 49 | Button launch = new Button("Open Window"); 50 | BrowserWindowOpener opener = new BrowserWindowOpener(exclass); 51 | opener.extend(launch); 52 | } 53 | 54 | return layout; 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /src/com/vaadin/book/examples/ExampleCtgr.java: -------------------------------------------------------------------------------- 1 | package com.vaadin.book.examples; 2 | 3 | /** Example category. */ 4 | public class ExampleCtgr extends CaptionedExampleItem { 5 | private static final long serialVersionUID = 418811233718496311L; 6 | 7 | /** Create a new category. */ 8 | public ExampleCtgr(String itemid, String shortName) { 9 | super(itemid, shortName); 10 | } 11 | } -------------------------------------------------------------------------------- /src/com/vaadin/book/examples/RedirctItem.java: -------------------------------------------------------------------------------- 1 | package com.vaadin.book.examples; 2 | 3 | /** For redirecting obsolete example IDs. */ 4 | public class RedirctItem extends AbstractExampleItem { 5 | private static final long serialVersionUID = 418811233718496311L; 6 | public String redirectid; 7 | 8 | /** Create a new redirection from an obsolete example ID to a new one. */ 9 | public RedirctItem(String itemid, String redirectid) { 10 | super(itemid); 11 | 12 | this.redirectid = redirectid; 13 | } 14 | } -------------------------------------------------------------------------------- /src/com/vaadin/book/examples/addons/charts/countrycoordinates-to-java.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | 3 | import os,sys 4 | 5 | ################################################################################ 6 | def coordToFloat(coord): 7 | (deg, m, direction) = coord.split(" ") 8 | value = int(deg) + int(m)/60.0 9 | if direction == "S" or direction == "E": 10 | value = -value 11 | return value 12 | 13 | ################################################################################ 14 | 15 | fin = open("countrycoordinates.txt", "r") 16 | lines = map(lambda x: x.strip(), fin.readlines()) 17 | fin.close() 18 | 19 | print "HashMap coords = new HashMap();" 20 | for line in lines: 21 | (name, lat, lng) = map(lambda x: x.strip(), line.split(";")) 22 | lat = coordToFloat(lat) 23 | lng = coordToFloat(lng) 24 | print "coords.put(\"%s\", new Coordinate(%0.2f, %0.2f));" % (name, lat, lng) 25 | -------------------------------------------------------------------------------- /src/com/vaadin/book/examples/addons/jpacontainer/CelestialBody.java: -------------------------------------------------------------------------------- 1 | package com.vaadin.book.examples.addons.jpacontainer; 2 | 3 | import java.io.Serializable; 4 | 5 | import javax.persistence.Entity; 6 | import javax.persistence.GeneratedValue; 7 | import javax.persistence.GenerationType; 8 | import javax.persistence.Id; 9 | import javax.persistence.ManyToOne; 10 | 11 | // BEGIN-EXAMPLE: jpacontainer.hierarchical 12 | @Entity 13 | public class CelestialBody implements Serializable { 14 | private static final long serialVersionUID = -6425366814448671541L; 15 | 16 | @Id 17 | @GeneratedValue(strategy = GenerationType.IDENTITY) 18 | private Long id; 19 | 20 | private String name; 21 | 22 | @ManyToOne 23 | private CelestialBody parent; 24 | 25 | /** Default constructor required for JPA. */ 26 | public CelestialBody() { 27 | } 28 | 29 | public CelestialBody(String name, CelestialBody parent) { 30 | this.name = name; 31 | this.parent = parent; 32 | } 33 | 34 | public Long getId() { 35 | return id; 36 | } 37 | public void setId(Long id) { 38 | this.id = id; 39 | } 40 | public String getName() { 41 | return name; 42 | } 43 | public void setName(String name) { 44 | this.name = name; 45 | } 46 | public CelestialBody getParent() { 47 | return parent; 48 | } 49 | public void setParent(CelestialBody parent) { 50 | this.parent = parent; 51 | } 52 | } 53 | // END-EXAMPLE: jpacontainer.hierarchical 54 | -------------------------------------------------------------------------------- /src/com/vaadin/book/examples/addons/jpacontainer/Country.java: -------------------------------------------------------------------------------- 1 | package com.vaadin.book.examples.addons.jpacontainer; 2 | 3 | import java.io.Serializable; 4 | import java.util.HashSet; 5 | import java.util.Set; 6 | 7 | import javax.persistence.Entity; 8 | import javax.persistence.GeneratedValue; 9 | import javax.persistence.GenerationType; 10 | import javax.persistence.Id; 11 | import javax.persistence.OneToMany; 12 | 13 | // BEGIN-EXAMPLE: jpacontainer.basic 14 | @Entity 15 | public class Country implements Serializable { 16 | private static final long serialVersionUID = 508426585088564210L; 17 | 18 | @Id 19 | @GeneratedValue(strategy = GenerationType.IDENTITY) 20 | private Long id; 21 | 22 | private String name; 23 | 24 | @OneToMany(mappedBy = "country") 25 | private Set people; 26 | 27 | /** Default constructor is required by JPA */ 28 | public Country() { 29 | people = new HashSet(); 30 | } 31 | 32 | public Country(String name) { 33 | this.name = name; 34 | this.people = new HashSet(); 35 | } 36 | 37 | /** Adds a person to the country. */ 38 | public void addPerson(Person person) { 39 | people.add(person); 40 | } 41 | 42 | public Long getId() { 43 | return id; 44 | } 45 | public void setId(Long id) { 46 | this.id = id; 47 | } 48 | public String getName() { 49 | return name; 50 | } 51 | public void setName(String name) { 52 | this.name = name; 53 | } 54 | public Set getPeople() { 55 | return people; 56 | } 57 | public void setPeople(Set people) { 58 | this.people = people; 59 | } 60 | 61 | @Override 62 | public String toString() { 63 | return name; 64 | } 65 | } 66 | // END-EXAMPLE: jpacontainer.basic 67 | -------------------------------------------------------------------------------- /src/com/vaadin/book/examples/addons/jpacontainer/Person.java: -------------------------------------------------------------------------------- 1 | package com.vaadin.book.examples.addons.jpacontainer; 2 | 3 | import java.io.Serializable; 4 | 5 | import javax.persistence.Entity; 6 | import javax.persistence.GeneratedValue; 7 | import javax.persistence.GenerationType; 8 | import javax.persistence.Id; 9 | import javax.persistence.ManyToOne; 10 | 11 | /************************************************************************* 12 | * Basic Example 13 | *************************************************************************/ 14 | 15 | // BEGIN-EXAMPLE: jpacontainer.basic 16 | @Entity 17 | public class Person implements Serializable { 18 | private static final long serialVersionUID = -2740293361580718589L; 19 | 20 | @Id 21 | @GeneratedValue(strategy = GenerationType.IDENTITY) 22 | private Long id; 23 | 24 | private String name; 25 | private Integer age; 26 | 27 | @ManyToOne 28 | private Country country; 29 | 30 | /** Default constructor is required by JPA */ 31 | public Person() { 32 | } 33 | 34 | public Person(String name, int age) { 35 | this.name = name; 36 | this.age = age; 37 | } 38 | 39 | public Person(String name, int age, Country country) { 40 | this.name = name; 41 | this.age = age; 42 | this.country = country; 43 | country.addPerson(this); 44 | } 45 | 46 | public Long getId() { 47 | return id; 48 | } 49 | public void setId(Long id) { 50 | this.id = id; 51 | } 52 | public String getName() { 53 | return name; 54 | } 55 | public void setName(String name) { 56 | this.name = name; 57 | } 58 | public Integer getAge() { 59 | return age; 60 | } 61 | public void setAge(Integer age) { 62 | this.age = age; 63 | } 64 | public Country getCountry() { 65 | return country; 66 | } 67 | public void setCountry(Country country) { 68 | this.country = country; 69 | country.addPerson(this); 70 | } 71 | } 72 | // END-EXAMPLE: jpacontainer.basic 73 | -------------------------------------------------------------------------------- /src/com/vaadin/book/examples/addons/touchkit/MyMobileWidgetSet.gwt.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /src/com/vaadin/book/examples/advanced/AnimalView.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /src/com/vaadin/book/examples/advanced/EmbeddingExample.java: -------------------------------------------------------------------------------- 1 | package com.vaadin.book.examples.advanced; 2 | 3 | import com.vaadin.book.examples.BookExampleBundle; 4 | import com.vaadin.server.BrowserWindowOpener; 5 | import com.vaadin.ui.Button; 6 | import com.vaadin.ui.CustomComponent; 7 | import com.vaadin.ui.Label; 8 | import com.vaadin.ui.VerticalLayout; 9 | 10 | public class EmbeddingExample extends CustomComponent implements BookExampleBundle { 11 | private static final long serialVersionUID = 9754344337L; 12 | 13 | public void init(String context) { 14 | VerticalLayout layout = new VerticalLayout(); 15 | 16 | if ("div".equals(context)) 17 | div(layout); 18 | else 19 | setCompositionRoot(new Label("Invalid Context")); 20 | 21 | if (getCompositionRoot() == null) 22 | setCompositionRoot(layout); 23 | } 24 | 25 | void div (VerticalLayout layout) { 26 | // EXAMPLE-APPFILE: advanced.embedding.div embedding-in-div.html 27 | // BEGIN-EXAMPLE: advanced.embedding.div 28 | // A button to open the printer-friendly page. 29 | Button open = new Button("Open a Static HTML Page"); 30 | BrowserWindowOpener opener = new BrowserWindowOpener( 31 | "/book-examples-vaadin7/embedding-in-div.html"); 32 | opener.setFeatures("height=300,width=400,resizable"); 33 | opener.extend(open); 34 | // END-EXAMPLE: advanced.embedding.div 35 | 36 | setCompositionRoot(open); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /src/com/vaadin/book/examples/advanced/LoginView.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Login 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /src/com/vaadin/book/examples/advanced/MainView.html: -------------------------------------------------------------------------------- 1 | 2 | Animal Farm 3 | 4 | 5 | 6 | 7 | 8 | Logout 9 | 10 | -------------------------------------------------------------------------------- /src/com/vaadin/book/examples/advanced/MyAppCaptions.java: -------------------------------------------------------------------------------- 1 | package com.vaadin.book.examples.advanced; 2 | 3 | import java.io.Serializable; 4 | import java.util.ListResourceBundle; 5 | 6 | // BEGIN-EXAMPLE: advanced.i18n.bundles 7 | /** Caption IDs and default captions. */ 8 | public class MyAppCaptions extends ListResourceBundle 9 | implements Serializable { 10 | private static final long serialVersionUID = -2318529114498879757L; 11 | 12 | /* Caption ID definitions */ 13 | public static final String OkKey = generateId(); 14 | public static final String SaveKey = generateId(); 15 | public static final String CancelKey = generateId(); 16 | 17 | /* Captions for the default language */ 18 | static final Object[][] contents = { 19 | {OkKey, "OK"}, 20 | {SaveKey, "Save"}, 21 | {CancelKey, "Cancel"}, 22 | }; 23 | 24 | @Override 25 | public Object[][] getContents() { 26 | return contents; 27 | } 28 | 29 | /* Generates numeric IDs for the strings */ 30 | public static String generateId() { 31 | return new Integer(ids++).toString(); 32 | } 33 | 34 | static int ids = 0; 35 | } 36 | // END-EXAMPLE: advanced.i18n.bundles 37 | -------------------------------------------------------------------------------- /src/com/vaadin/book/examples/advanced/MyAppCaptions_fi.java: -------------------------------------------------------------------------------- 1 | package com.vaadin.book.examples.advanced; 2 | 3 | // BEGIN-EXAMPLE: advanced.i18n.bundles 4 | /** Finnish captions. */ 5 | public class MyAppCaptions_fi extends MyAppCaptions { 6 | private static final long serialVersionUID = -5034352379726640524L; 7 | 8 | static final Object[][] contents_fi = { 9 | {OkKey, "OK"}, 10 | {SaveKey, "Tallenna"}, 11 | {CancelKey, "Peruuta"}, 12 | }; 13 | 14 | /* Must override again to get the localized strings */ 15 | @Override 16 | public Object[][] getContents() { 17 | return contents_fi; 18 | } 19 | } 20 | // END-EXAMPLE: advanced.i18n.bundles 21 | -------------------------------------------------------------------------------- /src/com/vaadin/book/examples/advanced/NavigatorExample.java: -------------------------------------------------------------------------------- 1 | package com.vaadin.book.examples.advanced; 2 | 3 | import com.vaadin.book.examples.AnyBookExampleBundle; 4 | import com.vaadin.server.BrowserWindowOpener; 5 | import com.vaadin.server.VaadinServlet; 6 | import com.vaadin.ui.Button; 7 | import com.vaadin.ui.CustomComponent; 8 | import com.vaadin.ui.VerticalLayout; 9 | 10 | public class NavigatorExample extends CustomComponent implements AnyBookExampleBundle { 11 | private static final long serialVersionUID = 9754344337L; 12 | 13 | // EXAMPLE-REF: advanced.navigator.basic com.vaadin.book.examples.advanced.NavigatorUI advanced.navigator.basic 14 | public void basic (VerticalLayout layout) { 15 | Button button = new Button("Click to Open"); 16 | layout.addComponent(button); 17 | 18 | BrowserWindowOpener opener = new BrowserWindowOpener( 19 | VaadinServlet.getCurrent() 20 | .getServletContext().getContextPath() + 21 | "/navigator"); 22 | opener.setFeatures("width=640,height=480,resizable"); 23 | opener.extend(button); 24 | } 25 | 26 | // EXAMPLE-REF: advanced.navigator.customviewprovider com.vaadin.book.examples.advanced.CustomViewProviderUI advanced.navigator.customviewprovider 27 | public void customviewprovider (VerticalLayout layout) { 28 | Button button = new Button("Click to Open"); 29 | layout.addComponent(button); 30 | 31 | BrowserWindowOpener opener = new BrowserWindowOpener( 32 | VaadinServlet.getCurrent() 33 | .getServletContext().getContextPath() + 34 | "/customviewprovider"); 35 | opener.setFeatures("width=640,height=480,resizable"); 36 | opener.extend(button); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /src/com/vaadin/book/examples/advanced/RightToLeftStrings.java: -------------------------------------------------------------------------------- 1 | package com.vaadin.book.examples.advanced; 2 | 3 | import java.util.ListResourceBundle; 4 | 5 | /** Default captions. */ 6 | public class RightToLeftStrings extends ListResourceBundle { 7 | @Override 8 | public Object[][] getContents() { 9 | return contents; 10 | } 11 | static final Object[][] contents = { 12 | {"OkKey", "OK"}, 13 | {"Ipsum", "Lorem ipsum dolor sit amet, consectetur adipiscing elit"}, 14 | {"ShortIpsum", "Lorem ipsum dolor sit"}, 15 | {"Date", "Date"}, 16 | {"Name", "Name"}, 17 | }; 18 | } 19 | -------------------------------------------------------------------------------- /src/com/vaadin/book/examples/advanced/RightToLeftStrings_ar.java: -------------------------------------------------------------------------------- 1 | package com.vaadin.book.examples.advanced; 2 | 3 | import java.util.ListResourceBundle; 4 | 5 | /** Default captions. */ 6 | public class RightToLeftStrings_ar extends ListResourceBundle { 7 | @Override 8 | public Object[][] getContents() { 9 | return contents; 10 | } 11 | static final Object[][] contents = { 12 | {"OkKey", "موافق"}, 13 | {"Ipsum", "أي مدن هامش الستار جزيرتي, و واحدة إخضاع العام ذلك, معركة والتي الإستسلام إذ لان"}, 14 | {"ShortIpsum", "أي مدن هامش الستار"}, 15 | {"Date", "تاريخ"}, 16 | {"Name", "اسم"}, 17 | }; 18 | } 19 | -------------------------------------------------------------------------------- /src/com/vaadin/book/examples/advanced/cdi/BroadcastMessage.java: -------------------------------------------------------------------------------- 1 | package com.vaadin.book.examples.advanced.cdi; 2 | 3 | import java.io.Serializable; 4 | 5 | // BEGIN-EXAMPLE: advanced.cdi.broadcasting 6 | public class BroadcastMessage implements Serializable { 7 | private static final long serialVersionUID = 1448862418313292393L; 8 | 9 | private String text; 10 | private Object sender; 11 | 12 | public BroadcastMessage(String text, Object sender) { 13 | this.text = text; 14 | this.sender = sender; 15 | } 16 | 17 | public String getText() { 18 | return text; 19 | } 20 | 21 | public void setSender(Object sender) { 22 | this.sender = sender; 23 | } 24 | 25 | public Object getSender() { 26 | return sender; 27 | } 28 | } 29 | // END-EXAMPLE: advanced.cdi.broadcasting 30 | -------------------------------------------------------------------------------- /src/com/vaadin/book/examples/advanced/cdi/CDIBroadcaster.java: -------------------------------------------------------------------------------- 1 | package com.vaadin.book.examples.advanced.cdi; 2 | 3 | import static java.lang.annotation.ElementType.FIELD; 4 | import static java.lang.annotation.ElementType.PARAMETER; 5 | import static java.lang.annotation.RetentionPolicy.RUNTIME; 6 | 7 | import java.io.Serializable; 8 | import java.lang.annotation.Retention; 9 | import java.lang.annotation.Target; 10 | import java.util.Collection; 11 | import java.util.HashSet; 12 | import java.util.concurrent.ExecutorService; 13 | import java.util.concurrent.Executors; 14 | 15 | import javax.enterprise.context.ApplicationScoped; 16 | import javax.enterprise.event.Observes; 17 | import javax.inject.Inject; 18 | import javax.inject.Qualifier; 19 | 20 | import com.vaadin.ui.UI; 21 | 22 | // BEGIN-EXAMPLE: advanced.cdi.broadcasting 23 | @ApplicationScoped 24 | public class CDIBroadcaster implements Serializable { 25 | private static final long serialVersionUID = -368230891317363146L; 26 | 27 | private Collection uis = new HashSet(); 28 | 29 | public synchronized void register(UI listener) { 30 | uis.add(listener); 31 | } 32 | 33 | public synchronized void unregister(UI listener) { 34 | uis.remove(listener); 35 | } 36 | 37 | @Qualifier 38 | @Retention(RUNTIME) 39 | @Target({PARAMETER, FIELD}) 40 | public @interface OriginalSender {} 41 | 42 | // Inject event to be fired 43 | @Inject 44 | private javax.enterprise.event.Event 45 | messageEvent; 46 | 47 | ExecutorService executorService = 48 | Executors.newSingleThreadExecutor(); 49 | 50 | // Observe messages (only from clients) 51 | @SuppressWarnings("unused") 52 | private synchronized void observeMessage( 53 | @Observes @OriginalSender 54 | final BroadcastMessage message) { 55 | for (final UI listener: uis) 56 | executorService.execute(() -> 57 | listener.access(()-> 58 | messageEvent.fire(message))); 59 | } 60 | } 61 | // END-EXAMPLE: advanced.cdi.broadcasting 62 | -------------------------------------------------------------------------------- /src/com/vaadin/book/examples/advanced/cdi/CDIChatUI.java: -------------------------------------------------------------------------------- 1 | package com.vaadin.book.examples.advanced.cdi; 2 | 3 | import javax.inject.Inject; 4 | 5 | import com.vaadin.annotations.Push; 6 | import com.vaadin.annotations.Theme; 7 | import com.vaadin.cdi.CDIUI; 8 | import com.vaadin.server.VaadinRequest; 9 | import com.vaadin.ui.UI; 10 | 11 | // BEGIN-EXAMPLE: advanced.cdi.broadcasting 12 | @CDIUI("cdichat") 13 | @Push 14 | @Theme("valo") 15 | public class CDIChatUI extends UI { 16 | private static final long serialVersionUID = 390555781627137542L; 17 | 18 | @Inject 19 | CDIBroadcaster broadcaster; 20 | 21 | @Inject 22 | ChatBox chatbox; 23 | 24 | @Override 25 | protected void init(VaadinRequest request) { 26 | setContent(chatbox); 27 | 28 | // Register to receive broadcasts 29 | broadcaster.register(this); 30 | } 31 | 32 | // Must also unregister when the UI expires or is closed 33 | @Override 34 | public void detach() { 35 | broadcaster.unregister(this); 36 | super.detach(); 37 | } 38 | } 39 | // END-EXAMPLE: advanced.cdi.broadcasting 40 | -------------------------------------------------------------------------------- /src/com/vaadin/book/examples/advanced/cdi/CDIEventUI.java: -------------------------------------------------------------------------------- 1 | package com.vaadin.book.examples.advanced.cdi; 2 | 3 | import javax.inject.Inject; 4 | 5 | import com.vaadin.annotations.Theme; 6 | import com.vaadin.cdi.CDIUI; 7 | import com.vaadin.server.VaadinRequest; 8 | import com.vaadin.ui.HorizontalLayout; 9 | import com.vaadin.ui.Layout; 10 | import com.vaadin.ui.UI; 11 | 12 | //EXAMPLE-REF: advanced.cdi.events com.vaadin.book.examples.advanced.cdi.MyEvent advanced.cdi.events 13 | //EXAMPLE-REF: advanced.cdi.events com.vaadin.book.examples.advanced.cdi.InputPanel advanced.cdi.events 14 | //EXAMPLE-REF: advanced.cdi.events com.vaadin.book.examples.advanced.cdi.DisplayPanel advanced.cdi.events 15 | // BEGIN-EXAMPLE: advanced.cdi.events 16 | @CDIUI("cdievents") 17 | @Theme("valo") 18 | public class CDIEventUI extends UI { 19 | private static final long serialVersionUID = 390555781627137542L; 20 | 21 | @Inject 22 | InputPanel inputPanel; 23 | 24 | @Inject 25 | DisplayPanel display; 26 | 27 | @Override 28 | protected void init(VaadinRequest request) { 29 | Layout content = 30 | new HorizontalLayout(inputPanel, display); 31 | content.setSizeFull(); 32 | setContent(content); 33 | } 34 | } 35 | // END-EXAMPLE: advanced.cdi.events 36 | -------------------------------------------------------------------------------- /src/com/vaadin/book/examples/advanced/cdi/CDINavEventsUI.java: -------------------------------------------------------------------------------- 1 | package com.vaadin.book.examples.advanced.cdi; 2 | 3 | import com.vaadin.annotations.Theme; 4 | import com.vaadin.cdi.CDIUI; 5 | import com.vaadin.server.VaadinRequest; 6 | import com.vaadin.ui.UI; 7 | 8 | // BEGIN-EXAMPLE: advanced.cdi.producers 9 | @CDIUI("navevents") 10 | @Theme("valo") 11 | public class CDINavEventsUI extends UI { 12 | private static final long serialVersionUID = 390555781627137542L; 13 | 14 | 15 | @Override 16 | protected void init(VaadinRequest request) { 17 | } 18 | } 19 | // END-EXAMPLE: advanced.cdi.producers 20 | -------------------------------------------------------------------------------- /src/com/vaadin/book/examples/advanced/cdi/CDIProducerUI.java: -------------------------------------------------------------------------------- 1 | package com.vaadin.book.examples.advanced.cdi; 2 | 3 | import java.util.logging.Logger; 4 | 5 | import javax.inject.Inject; 6 | 7 | import com.vaadin.annotations.Theme; 8 | import com.vaadin.cdi.CDIUI; 9 | import com.vaadin.server.VaadinRequest; 10 | import com.vaadin.ui.UI; 11 | 12 | // BEGIN-EXAMPLE: advanced.cdi.producers 13 | @CDIUI("cdiproducers") 14 | @Theme("valo") 15 | public class CDIProducerUI extends UI { 16 | private static final long serialVersionUID = 390555781627137542L; 17 | 18 | @Inject 19 | Logger logger; 20 | 21 | @Override 22 | protected void init(VaadinRequest request) { 23 | logger.info("Initializing UI"); 24 | // setContent(new MyComponent(TableExample.generateContent())); 25 | } 26 | 27 | /* 28 | // Some class without a default constructor 29 | final class MyComponent extends Table { 30 | private static final long serialVersionUID = -278058594282382429L; 31 | 32 | public MyComponent(Container container) { 33 | super(null, container); 34 | } 35 | }*/ 36 | 37 | /* 38 | @Inject 39 | MyComponent myComponent; 40 | */ 41 | 42 | /* 43 | Container container = TableExample.generateContent(); 44 | 45 | @Produces 46 | private MyComponent createMyTable() { 47 | return new MyComponent(container); 48 | }*/ 49 | } 50 | // END-EXAMPLE: advanced.cdi.producers 51 | -------------------------------------------------------------------------------- /src/com/vaadin/book/examples/advanced/cdi/CDIProducers.java: -------------------------------------------------------------------------------- 1 | package com.vaadin.book.examples.advanced.cdi; 2 | 3 | import java.util.logging.Logger; 4 | 5 | import javax.enterprise.inject.Produces; 6 | import javax.enterprise.inject.spi.InjectionPoint; 7 | 8 | public class CDIProducers { 9 | @Produces Logger createLogger(InjectionPoint injectionPoint) { 10 | return Logger.getLogger( injectionPoint.getMember().getDeclaringClass().getName() ); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /src/com/vaadin/book/examples/advanced/cdi/DisplayPanel.java: -------------------------------------------------------------------------------- 1 | package com.vaadin.book.examples.advanced.cdi; 2 | 3 | import javax.enterprise.event.Observes; 4 | 5 | import com.vaadin.cdi.UIScoped; 6 | import com.vaadin.ui.Label; 7 | import com.vaadin.ui.Panel; 8 | 9 | @UIScoped 10 | class DisplayPanel extends Panel { 11 | private static final long serialVersionUID = -2410712515068052908L; 12 | 13 | Label display = new Label("-nothing to display-"); 14 | 15 | public DisplayPanel() { 16 | super("Display"); 17 | setContent(display); 18 | setSizeFull(); 19 | } 20 | 21 | //void myEventObserver(@Observes(notifyObserver = Reception.IF_EXISTS) MyEvent event) { 22 | void myEventObserver(@Observes MyEvent event) { 23 | display.setValue("Observed: " + event.getName()); 24 | } 25 | } -------------------------------------------------------------------------------- /src/com/vaadin/book/examples/advanced/cdi/Greeter.java: -------------------------------------------------------------------------------- 1 | package com.vaadin.book.examples.advanced.cdi; 2 | 3 | import javax.annotation.PostConstruct; 4 | import javax.inject.Inject; 5 | 6 | import com.vaadin.cdi.ViewScoped; 7 | import com.vaadin.ui.CustomComponent; 8 | import com.vaadin.ui.Label; 9 | import com.vaadin.ui.VerticalLayout; 10 | 11 | // BEGIN-EXAMPLE: advanced.cdi.navigation 12 | /** 13 | * A Vaadin component that can be injected in a view. 14 | * 15 | * @author magi 16 | */ 17 | @ViewScoped 18 | public class Greeter extends CustomComponent { 19 | private static final long serialVersionUID = -7461902820768542976L; 20 | 21 | @Inject 22 | User user; 23 | 24 | public Greeter() {} 25 | 26 | @PostConstruct 27 | void init() { 28 | VerticalLayout layout = new VerticalLayout(); 29 | layout.addComponent(new Label("Greeting, " + user.getName())); 30 | setCompositionRoot(layout); 31 | } 32 | } 33 | // END-EXAMPLE: advanced.cdi.navigation 34 | -------------------------------------------------------------------------------- /src/com/vaadin/book/examples/advanced/cdi/HelpView.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 6 | Insert title here 7 | 8 | 9 | 10 | This is a declarative help view 11 | 12 | 13 | 14 | 15 | Back 16 | 17 | 18 | -------------------------------------------------------------------------------- /src/com/vaadin/book/examples/advanced/cdi/InputPanel.java: -------------------------------------------------------------------------------- 1 | package com.vaadin.book.examples.advanced.cdi; 2 | 3 | import javax.inject.Inject; 4 | 5 | import com.vaadin.ui.Button; 6 | import com.vaadin.ui.Panel; 7 | import com.vaadin.ui.TextField; 8 | import com.vaadin.ui.VerticalLayout; 9 | 10 | // @UIScoped 11 | class InputPanel extends Panel { 12 | private static final long serialVersionUID = -3238668236117542557L; 13 | 14 | @Inject 15 | private javax.enterprise.event.Event event; 16 | 17 | public InputPanel() { 18 | super("Input"); 19 | 20 | TextField editor = new TextField(); 21 | Button save = new Button("Save", e -> // Java 8 22 | event.fire(new MyEvent(editor.getValue()))); 23 | 24 | VerticalLayout content = new VerticalLayout(editor, save); 25 | content.setMargin(true); 26 | content.setSpacing(true); 27 | setContent(content); 28 | setSizeFull(); 29 | } 30 | } -------------------------------------------------------------------------------- /src/com/vaadin/book/examples/advanced/cdi/LoginView.java: -------------------------------------------------------------------------------- 1 | package com.vaadin.book.examples.advanced.cdi; 2 | 3 | import javax.inject.Inject; 4 | 5 | import com.vaadin.cdi.CDIView; 6 | import com.vaadin.data.util.BeanItem; 7 | import com.vaadin.navigator.View; 8 | import com.vaadin.navigator.ViewChangeListener.ViewChangeEvent; 9 | import com.vaadin.ui.Button; 10 | import com.vaadin.ui.CustomComponent; 11 | import com.vaadin.ui.TextField; 12 | import com.vaadin.ui.VerticalLayout; 13 | 14 | // BEGIN-EXAMPLE: advanced.cdi.navigation 15 | @CDIView(LoginView.NAME) 16 | public class LoginView extends CustomComponent 17 | implements View { 18 | private static final long serialVersionUID = -7461902820768542976L; 19 | 20 | public final static String NAME = ""; 21 | 22 | // Here we inject to the constructor and actually do 23 | // not store the injected object to use it later 24 | @Inject 25 | public LoginView(User user) { 26 | VerticalLayout layout = new VerticalLayout(); 27 | 28 | // An input field for editing injected data 29 | BeanItem item = new BeanItem(user); 30 | TextField username = new TextField("User name", 31 | item.getItemProperty("name")); 32 | username.setNullRepresentation(""); 33 | layout.addComponent(username); 34 | 35 | // Login button (authentication omitted) / Java 8 36 | layout.addComponent(new Button("Login", e -> 37 | getUI().getNavigator(). 38 | navigateTo(MainView.NAME))); 39 | 40 | setCompositionRoot(layout); 41 | } 42 | 43 | @Override 44 | public void enter(ViewChangeEvent event) {} 45 | } 46 | // END-EXAMPLE: advanced.cdi.navigation 47 | -------------------------------------------------------------------------------- /src/com/vaadin/book/examples/advanced/cdi/MainView.java: -------------------------------------------------------------------------------- 1 | package com.vaadin.book.examples.advanced.cdi; 2 | 3 | import javax.inject.Inject; 4 | 5 | import com.vaadin.cdi.CDIView; 6 | import com.vaadin.navigator.View; 7 | import com.vaadin.navigator.ViewChangeListener.ViewChangeEvent; 8 | import com.vaadin.ui.Button; 9 | import com.vaadin.ui.CustomComponent; 10 | import com.vaadin.ui.Label; 11 | import com.vaadin.ui.VerticalLayout; 12 | 13 | // BEGIN-EXAMPLE: advanced.cdi.navigation 14 | @CDIView(value=MainView.NAME) 15 | public class MainView extends CustomComponent 16 | implements View { 17 | private static final long serialVersionUID = -7461902820768542976L; 18 | 19 | public final static String NAME = "main"; 20 | 21 | @Inject 22 | User user; 23 | 24 | Label greeting = new Label(); 25 | 26 | public MainView() { 27 | VerticalLayout layout = new VerticalLayout(); 28 | layout.addComponent(greeting); 29 | 30 | // On logout, navigate back to the login view 31 | layout.addComponent(new Button("Logout", e -> 32 | getUI().getNavigator(). 33 | navigateTo(LoginView.NAME))); 34 | 35 | // Another view 36 | layout.addComponent(new Button("Help", e -> 37 | getUI().getNavigator(). 38 | navigateTo(HelpView.NAME))); 39 | 40 | setCompositionRoot(layout); 41 | } 42 | 43 | @Override 44 | public void enter(ViewChangeEvent event) { 45 | greeting.setValue("Hello, " + user.getName()); 46 | } 47 | } 48 | // END-EXAMPLE: advanced.cdi.navigation 49 | -------------------------------------------------------------------------------- /src/com/vaadin/book/examples/advanced/cdi/MyCDIComponentFactory.java: -------------------------------------------------------------------------------- 1 | package com.vaadin.book.examples.advanced.cdi; 2 | 3 | import java.util.Set; 4 | 5 | import javax.annotation.PostConstruct; 6 | import javax.ejb.Singleton; 7 | import javax.ejb.Startup; 8 | import javax.enterprise.inject.Any; 9 | import javax.enterprise.inject.spi.Bean; 10 | import javax.enterprise.inject.spi.BeanManager; 11 | import javax.enterprise.util.AnnotationLiteral; 12 | 13 | import com.vaadin.cdi.internal.CDIUtil; 14 | import com.vaadin.ui.Component; 15 | import com.vaadin.ui.declarative.Design; 16 | import com.vaadin.ui.declarative.DesignContext; 17 | 18 | // BEGIN-EXAMPLE: advanced.cdi.navigation 19 | /* 20 | * This custom ComponentFactory allows the Design 21 | * to inject CDI bean components to a design root. 22 | */ 23 | @Singleton 24 | @Startup 25 | class MyCDIComponentFactory extends Design.DefaultComponentFactory { 26 | private static final long serialVersionUID = -8749567585647004426L; 27 | 28 | @PostConstruct 29 | public void setup() { 30 | // TODO Disabled because this doesn't work with non-CDI stuff... 31 | // Design.setComponentFactory(this); 32 | } 33 | 34 | @Override 35 | public Component createComponent(String fullyQualifiedClassName, 36 | DesignContext context) { 37 | Class cls = resolveComponentClass(fullyQualifiedClassName, 38 | context); 39 | 40 | // Try to get the component with CDI 41 | BeanManager beanManager = CDIUtil.lookupBeanManager(); 42 | Set> beans = beanManager.getBeans(cls, 43 | new AnnotationLiteral() { 44 | private static final long serialVersionUID = -8450753359910452915L; 45 | }); 46 | Bean bean = (Bean) beanManager.resolve(beans); 47 | if (bean == null) 48 | return super.createComponent(fullyQualifiedClassName, 49 | context); 50 | 51 | return (Component) beanManager.getReference(bean, cls, 52 | beanManager.createCreationalContext(bean)); 53 | } 54 | } 55 | // END-EXAMPLE: advanced.cdi.navigation 56 | -------------------------------------------------------------------------------- /src/com/vaadin/book/examples/advanced/cdi/MyCDIUI.java: -------------------------------------------------------------------------------- 1 | package com.vaadin.book.examples.advanced.cdi; 2 | 3 | import javax.inject.Inject; 4 | 5 | import com.vaadin.annotations.Theme; 6 | import com.vaadin.cdi.CDIUI; 7 | import com.vaadin.cdi.CDIViewProvider; 8 | import com.vaadin.cdi.URLMapping; 9 | import com.vaadin.navigator.Navigator; 10 | import com.vaadin.server.VaadinRequest; 11 | import com.vaadin.ui.UI; 12 | 13 | // BEGIN-EXAMPLE: advanced.cdi.navigation 14 | @CDIUI("") 15 | @URLMapping("mycdiuis") 16 | @Theme("valo") 17 | public class MyCDIUI extends UI { 18 | private static final long serialVersionUID = 390555781627137542L; 19 | 20 | @Inject 21 | CDIViewProvider viewProvider; 22 | 23 | @Override 24 | protected void init(VaadinRequest request) { 25 | Navigator navigator = new Navigator(this, this); 26 | navigator.addProvider(viewProvider); 27 | 28 | // Navigate to start view 29 | navigator.navigateTo(LoginView.NAME); 30 | } 31 | } 32 | // END-EXAMPLE: advanced.cdi.navigation 33 | -------------------------------------------------------------------------------- /src/com/vaadin/book/examples/advanced/cdi/MyEvent.java: -------------------------------------------------------------------------------- 1 | package com.vaadin.book.examples.advanced.cdi; 2 | 3 | import java.io.Serializable; 4 | 5 | public class MyEvent implements Serializable { 6 | private static final long serialVersionUID = 1448862418313292393L; 7 | 8 | private String text; 9 | 10 | public MyEvent(String text) { 11 | this.text = text; 12 | } 13 | 14 | public String getName() { 15 | return text; 16 | } 17 | } -------------------------------------------------------------------------------- /src/com/vaadin/book/examples/advanced/cdi/User.java: -------------------------------------------------------------------------------- 1 | package com.vaadin.book.examples.advanced.cdi; 2 | 3 | import java.io.Serializable; 4 | 5 | import javax.enterprise.context.SessionScoped; 6 | 7 | // BEGIN-EXAMPLE: advanced.cdi.navigation 8 | /** 9 | * A stateful bean. 10 | */ 11 | @SessionScoped 12 | public class User implements Serializable { 13 | private static final long serialVersionUID = -3963802566252092423L; 14 | 15 | private String name; 16 | 17 | public User() {} 18 | 19 | public void setName(String name) { 20 | this.name = name; 21 | } 22 | 23 | public String getName() { 24 | return name; 25 | } 26 | } 27 | // END-EXAMPLE: advanced.cdi.navigation 28 | -------------------------------------------------------------------------------- /src/com/vaadin/book/examples/advanced/dd/resize-handle.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vaadin/book-examples/435f8b377a946ad5a8129ed266289afe0e015790/src/com/vaadin/book/examples/advanced/dd/resize-handle.png -------------------------------------------------------------------------------- /src/com/vaadin/book/examples/advanced/push/Broadcaster.java: -------------------------------------------------------------------------------- 1 | package com.vaadin.book.examples.advanced.push; 2 | 3 | import java.io.Serializable; 4 | import java.util.LinkedList; 5 | import java.util.concurrent.ExecutorService; 6 | import java.util.concurrent.Executors; 7 | import java.util.function.Consumer; 8 | 9 | // BEGIN-EXAMPLE: advanced.push.pusharound 10 | public class Broadcaster implements Serializable { 11 | private static final long serialVersionUID = -368230891317363146L; 12 | 13 | static ExecutorService executorService = 14 | Executors.newSingleThreadExecutor(); 15 | 16 | // Java 8 17 | private static LinkedList> listeners = 18 | new LinkedList>(); 19 | 20 | public static synchronized void register( 21 | Consumer listener) { 22 | listeners.add(listener); 23 | } 24 | 25 | public static synchronized void unregister( 26 | Consumer listener) { 27 | listeners.remove(listener); 28 | } 29 | 30 | public static synchronized void broadcast( 31 | final String message) { 32 | for (final Consumer listener: listeners) 33 | executorService.execute(() -> 34 | listener.accept(message)); 35 | } 36 | } 37 | // END-EXAMPLE: advanced.push.pusharound 38 | -------------------------------------------------------------------------------- /src/com/vaadin/book/examples/advanced/spring/BroadcastMessage.java: -------------------------------------------------------------------------------- 1 | package com.vaadin.book.examples.advanced.spring; 2 | 3 | import java.io.Serializable; 4 | 5 | // BEGIN-EXAMPLE: advanced.cdi.broadcasting 6 | public class BroadcastMessage implements Serializable { 7 | private static final long serialVersionUID = 7612907361015425457L; 8 | 9 | private String text; 10 | private Object sender; 11 | 12 | public BroadcastMessage(String text, Object sender) { 13 | this.text = text; 14 | this.sender = sender; 15 | } 16 | 17 | public String getText() { 18 | return text; 19 | } 20 | 21 | public void setSender(Object sender) { 22 | this.sender = sender; 23 | } 24 | 25 | public Object getSender() { 26 | return sender; 27 | } 28 | } 29 | // END-EXAMPLE: advanced.cdi.broadcasting 30 | -------------------------------------------------------------------------------- /src/com/vaadin/book/examples/advanced/spring/DisplayPanel.java: -------------------------------------------------------------------------------- 1 | package com.vaadin.book.examples.advanced.spring; 2 | 3 | import javax.enterprise.event.Observes; 4 | 5 | import com.vaadin.spring.annotation.UIScope; 6 | import com.vaadin.ui.Label; 7 | import com.vaadin.ui.Panel; 8 | 9 | @UIScope 10 | class DisplayPanel extends Panel { 11 | private static final long serialVersionUID = -2410712515068052908L; 12 | 13 | Label display = new Label("-nothing to display-"); 14 | 15 | public DisplayPanel() { 16 | super("Display"); 17 | setContent(display); 18 | setSizeFull(); 19 | } 20 | 21 | //void myEventObserver(@Observes(notifyObserver = Reception.IF_EXISTS) MyEvent event) { 22 | // TODO Spring 23 | void myEventObserver(@Observes MyEvent event) { 24 | display.setValue("Observed: " + event.getName()); 25 | } 26 | } -------------------------------------------------------------------------------- /src/com/vaadin/book/examples/advanced/spring/Greeter.java: -------------------------------------------------------------------------------- 1 | package com.vaadin.book.examples.advanced.spring; 2 | 3 | import org.springframework.beans.factory.annotation.Autowired; 4 | 5 | import com.vaadin.spring.annotation.ViewScope; 6 | import com.vaadin.ui.CustomComponent; 7 | import com.vaadin.ui.Label; 8 | import com.vaadin.ui.VerticalLayout; 9 | 10 | /** 11 | * A Vaadin component that can be injected in a view. 12 | * 13 | * @author magi 14 | */ 15 | @ViewScope 16 | public class Greeter extends CustomComponent { 17 | private static final long serialVersionUID = -7461902820768542976L; 18 | 19 | @Autowired 20 | User user; 21 | 22 | public Greeter() { 23 | VerticalLayout layout = new VerticalLayout(); 24 | layout.addComponent(new Label("Geeting...")); 25 | setCompositionRoot(layout); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/com/vaadin/book/examples/advanced/spring/InputPanel.java: -------------------------------------------------------------------------------- 1 | package com.vaadin.book.examples.advanced.spring; 2 | 3 | import org.springframework.beans.factory.annotation.Autowired; 4 | 5 | import com.vaadin.ui.Button; 6 | import com.vaadin.ui.Panel; 7 | import com.vaadin.ui.TextField; 8 | import com.vaadin.ui.VerticalLayout; 9 | 10 | // @UIScoped 11 | class InputPanel extends Panel { 12 | private static final long serialVersionUID = -3238668236117542557L; 13 | 14 | @Autowired 15 | private javax.enterprise.event.Event event; 16 | 17 | public InputPanel() { 18 | super("Input"); 19 | 20 | TextField editor = new TextField(); 21 | Button save = new Button("Save", e -> // Java 8 22 | event.fire(new MyEvent(editor.getValue()))); 23 | 24 | VerticalLayout content = new VerticalLayout(editor, save); 25 | content.setMargin(true); 26 | content.setSpacing(true); 27 | setContent(content); 28 | setSizeFull(); 29 | } 30 | } -------------------------------------------------------------------------------- /src/com/vaadin/book/examples/advanced/spring/LoginView.java: -------------------------------------------------------------------------------- 1 | package com.vaadin.book.examples.advanced.spring; 2 | 3 | import org.springframework.beans.factory.annotation.Autowired; 4 | 5 | import com.vaadin.data.util.BeanItem; 6 | import com.vaadin.navigator.View; 7 | import com.vaadin.navigator.ViewChangeListener.ViewChangeEvent; 8 | import com.vaadin.spring.annotation.SpringView; 9 | import com.vaadin.ui.Button; 10 | import com.vaadin.ui.CustomComponent; 11 | import com.vaadin.ui.TextField; 12 | import com.vaadin.ui.VerticalLayout; 13 | 14 | // BEGIN-EXAMPLE: advanced.spring.navigation 15 | @SpringView(name = LoginView.NAME) 16 | public class LoginView extends CustomComponent 17 | implements View { 18 | private static final long serialVersionUID = -7461902820768542976L; 19 | 20 | public final static String NAME = ""; 21 | 22 | TextField username; 23 | 24 | // Here we inject to the constructor and actually do 25 | // not store the injected object to use it later 26 | @Autowired 27 | public LoginView(User user) { 28 | VerticalLayout layout = new VerticalLayout(); 29 | layout.setMargin(true); 30 | layout.setSpacing(true); 31 | 32 | // An input field for editing injected data 33 | BeanItem item = new BeanItem(user); 34 | username = new TextField("User name", 35 | item.getItemProperty("name")); 36 | username.setNullRepresentation(""); 37 | layout.addComponent(username); 38 | 39 | // Login button (authentication omitted) / Java 8 40 | layout.addComponent(new Button("Login", e -> 41 | getUI().getNavigator(). 42 | navigateTo(MainView.NAME))); 43 | 44 | setCompositionRoot(layout); 45 | } 46 | 47 | @Override 48 | public void enter(ViewChangeEvent event) { 49 | username.setValue(null); // Always reset 50 | } 51 | } 52 | // END-EXAMPLE: advanced.spring.navigation 53 | -------------------------------------------------------------------------------- /src/com/vaadin/book/examples/advanced/spring/MainView.java: -------------------------------------------------------------------------------- 1 | package com.vaadin.book.examples.advanced.spring; 2 | 3 | import org.springframework.beans.factory.annotation.Autowired; 4 | 5 | import com.vaadin.navigator.View; 6 | import com.vaadin.navigator.ViewChangeListener.ViewChangeEvent; 7 | import com.vaadin.spring.access.ViewAccessControl; 8 | import com.vaadin.spring.annotation.SpringView; 9 | import com.vaadin.ui.Button; 10 | import com.vaadin.ui.CustomComponent; 11 | import com.vaadin.ui.Label; 12 | import com.vaadin.ui.UI; 13 | import com.vaadin.ui.VerticalLayout; 14 | 15 | // BEGIN-EXAMPLE: advanced.spring.navigation 16 | @SpringView(name=MainView.NAME) 17 | public class MainView extends CustomComponent 18 | implements View, ViewAccessControl { 19 | private static final long serialVersionUID = -7461902820768542976L; 20 | 21 | public final static String NAME = "main"; 22 | 23 | User user; 24 | 25 | Label greeting = new Label(); 26 | 27 | @Autowired 28 | public MainView(User user) { 29 | this.user = user; 30 | 31 | VerticalLayout layout = new VerticalLayout(); 32 | layout.setMargin(true); 33 | layout.addComponent(greeting); 34 | 35 | // On logout, navigate back to the login view 36 | layout.addComponent(new Button("Logout", e -> 37 | getUI().getNavigator().navigateTo(LoginView.NAME))); 38 | 39 | setCompositionRoot(layout); 40 | } 41 | 42 | @Override 43 | public void enter(ViewChangeEvent event) { 44 | greeting.setValue("Hello, " + user.getName()); 45 | } 46 | 47 | @Override 48 | public boolean isAccessGranted(UI ui, String beanName) { 49 | if (user.getName().isEmpty()) 50 | return true; 51 | else 52 | return true; 53 | } 54 | } 55 | // END-EXAMPLE: advanced.spring.navigation 56 | -------------------------------------------------------------------------------- /src/com/vaadin/book/examples/advanced/spring/MyAccessDeniedView.java: -------------------------------------------------------------------------------- 1 | package com.vaadin.book.examples.advanced.spring; 2 | 3 | import com.vaadin.navigator.View; 4 | import com.vaadin.navigator.ViewChangeListener.ViewChangeEvent; 5 | import com.vaadin.spring.annotation.SpringView; 6 | import com.vaadin.ui.Button; 7 | import com.vaadin.ui.CustomComponent; 8 | import com.vaadin.ui.Label; 9 | import com.vaadin.ui.VerticalLayout; 10 | 11 | // BEGIN-EXAMPLE: advanced.spring.navigation 12 | @SpringView(name=MyAccessDeniedView.NAME) 13 | public class MyAccessDeniedView extends CustomComponent 14 | implements View { 15 | private static final long serialVersionUID = -3349770763697923092L; 16 | 17 | public final static String NAME = "accessdenied"; 18 | 19 | Button back = new Button("Go Back"); 20 | 21 | public MyAccessDeniedView() { 22 | VerticalLayout layout = new VerticalLayout(); 23 | layout.setMargin(true); 24 | 25 | layout.addComponents(new Label("Access Denied!"), 26 | back); 27 | 28 | setCompositionRoot(layout); 29 | } 30 | 31 | @Override 32 | public void enter(ViewChangeEvent event) { 33 | // UI.getCurrent().getNavigator().navigateTo(event.getOldView(), null, null); 34 | } 35 | } 36 | // END-EXAMPLE: advanced.spring.navigation 37 | -------------------------------------------------------------------------------- /src/com/vaadin/book/examples/advanced/spring/MyEvent.java: -------------------------------------------------------------------------------- 1 | package com.vaadin.book.examples.advanced.spring; 2 | 3 | import java.io.Serializable; 4 | 5 | public class MyEvent implements Serializable { 6 | private static final long serialVersionUID = 1448862418313292393L; 7 | 8 | private String text; 9 | 10 | public MyEvent(String text) { 11 | this.text = text; 12 | } 13 | 14 | public String getName() { 15 | return text; 16 | } 17 | } -------------------------------------------------------------------------------- /src/com/vaadin/book/examples/advanced/spring/MySpringServlet.java: -------------------------------------------------------------------------------- 1 | package com.vaadin.book.examples.advanced.spring; 2 | 3 | import javax.servlet.annotation.WebServlet; 4 | 5 | import com.vaadin.spring.server.SpringVaadinServlet; 6 | 7 | @WebServlet(value = "/myspringuis/*", asyncSupported = true) 8 | public class MySpringServlet extends SpringVaadinServlet { 9 | 10 | } 11 | -------------------------------------------------------------------------------- /src/com/vaadin/book/examples/advanced/spring/MySpringUI.java: -------------------------------------------------------------------------------- 1 | package com.vaadin.book.examples.advanced.spring; 2 | 3 | import javax.servlet.annotation.WebListener; 4 | 5 | import org.springframework.beans.factory.annotation.Autowired; 6 | import org.springframework.context.annotation.Configuration; 7 | import org.springframework.web.context.ContextLoaderListener; 8 | 9 | import com.vaadin.annotations.Theme; 10 | import com.vaadin.navigator.Navigator; 11 | import com.vaadin.server.VaadinRequest; 12 | import com.vaadin.spring.annotation.EnableVaadin; 13 | import com.vaadin.spring.annotation.SpringUI; 14 | import com.vaadin.spring.navigator.SpringViewProvider; 15 | import com.vaadin.ui.UI; 16 | 17 | // BEGIN-EXAMPLE: advanced.spring.navigation 18 | @SpringUI 19 | @Theme("valo") 20 | public class MySpringUI extends UI { 21 | private static final long serialVersionUID = 390555781627137542L; 22 | 23 | @WebListener 24 | public static class MyContextLoaderListener extends ContextLoaderListener { 25 | } 26 | 27 | @Configuration 28 | @EnableVaadin 29 | public static class MyConfiguration { 30 | } 31 | 32 | @Autowired 33 | SpringViewProvider viewProvider; 34 | 35 | @Override 36 | protected void init(VaadinRequest request) { 37 | // Set up access denied view 38 | // viewProvider.setAccessDeniedViewClass(MyAccessDeniedView.class); 39 | 40 | Navigator navigator = new Navigator(this, this); 41 | navigator.addProvider(viewProvider); 42 | 43 | // Navigate to start view 44 | navigator.navigateTo(MainView.NAME); 45 | } 46 | } 47 | // END-EXAMPLE: advanced.spring.navigation 48 | // EXAMPLE-REF: advanced.spring.navigation com.vaadin.book.examples.advanced.spring.LoginView advanced.spring.navigation 49 | // EXAMPLE-REF: advanced.spring.navigation com.vaadin.book.examples.advanced.spring.MainView advanced.spring.navigation 50 | -------------------------------------------------------------------------------- /src/com/vaadin/book/examples/advanced/spring/SpringBroadcaster.java: -------------------------------------------------------------------------------- 1 | package com.vaadin.book.examples.advanced.spring; 2 | 3 | import java.io.Serializable; 4 | import java.util.Collection; 5 | import java.util.HashSet; 6 | import java.util.concurrent.ExecutorService; 7 | import java.util.concurrent.Executors; 8 | 9 | import org.springframework.beans.factory.annotation.Autowired; 10 | import org.springframework.beans.factory.annotation.Qualifier; 11 | 12 | import com.vaadin.ui.UI; 13 | 14 | // BEGIN-EXAMPLE: advanced.cdi.broadcasting 15 | // TODO Spring 16 | // @ApplicationScoped 17 | public class SpringBroadcaster implements Serializable { 18 | private static final long serialVersionUID = -368230891317363146L; 19 | 20 | private Collection uis = new HashSet(); 21 | 22 | public synchronized void register(UI listener) { 23 | uis.add(listener); 24 | } 25 | 26 | public synchronized void unregister(UI listener) { 27 | uis.remove(listener); 28 | } 29 | 30 | // TODO Spring 31 | @Qualifier 32 | // @Retention(RUNTIME) 33 | // @Target({PARAMETER, FIELD}) 34 | public @interface OriginalSender {} 35 | 36 | // Inject event to be fired 37 | @Autowired 38 | private javax.enterprise.event.Event 39 | messageEvent; 40 | 41 | ExecutorService executorService = 42 | Executors.newSingleThreadExecutor(); 43 | 44 | // TODO Spring 45 | // Observe messages (only from clients) 46 | @SuppressWarnings("unused") 47 | private synchronized void observeMessage( 48 | // @Observes @OriginalSender 49 | final BroadcastMessage message) { 50 | for (final UI listener: uis) 51 | executorService.execute(() -> 52 | listener.access(()-> 53 | messageEvent.fire(message))); 54 | } 55 | } 56 | // END-EXAMPLE: advanced.cdi.broadcasting 57 | -------------------------------------------------------------------------------- /src/com/vaadin/book/examples/advanced/spring/SpringChatUI.java: -------------------------------------------------------------------------------- 1 | package com.vaadin.book.examples.advanced.spring; 2 | 3 | import org.springframework.beans.factory.annotation.Autowired; 4 | 5 | import com.vaadin.annotations.Push; 6 | import com.vaadin.annotations.Theme; 7 | import com.vaadin.server.VaadinRequest; 8 | import com.vaadin.spring.annotation.SpringUI; 9 | import com.vaadin.ui.UI; 10 | 11 | // BEGIN-EXAMPLE: advanced.cdi.broadcasting 12 | @SpringUI(path = "springchat") 13 | @Push 14 | @Theme("valo") 15 | public class SpringChatUI extends UI { 16 | private static final long serialVersionUID = 390555781627137542L; 17 | 18 | @Autowired 19 | SpringBroadcaster broadcaster; 20 | 21 | @Autowired 22 | ChatBox chatbox; 23 | 24 | @Override 25 | protected void init(VaadinRequest request) { 26 | setContent(chatbox); 27 | 28 | // Register to receive broadcasts 29 | broadcaster.register(this); 30 | } 31 | 32 | // Must also unregister when the UI expires or is closed 33 | @Override 34 | public void detach() { 35 | broadcaster.unregister(this); 36 | super.detach(); 37 | } 38 | } 39 | // END-EXAMPLE: advanced.cdi.broadcasting 40 | -------------------------------------------------------------------------------- /src/com/vaadin/book/examples/advanced/spring/SpringEventUI.java: -------------------------------------------------------------------------------- 1 | package com.vaadin.book.examples.advanced.spring; 2 | 3 | import org.springframework.beans.factory.annotation.Autowired; 4 | 5 | import com.vaadin.annotations.Theme; 6 | import com.vaadin.server.VaadinRequest; 7 | import com.vaadin.spring.annotation.SpringUI; 8 | import com.vaadin.ui.HorizontalLayout; 9 | import com.vaadin.ui.Layout; 10 | import com.vaadin.ui.UI; 11 | 12 | //EXAMPLE-REF: advanced.cdi.events com.vaadin.book.examples.advanced.cdi.MyEvent advanced.cdi.events 13 | //EXAMPLE-REF: advanced.cdi.events com.vaadin.book.examples.advanced.cdi.InputPanel advanced.cdi.events 14 | //EXAMPLE-REF: advanced.cdi.events com.vaadin.book.examples.advanced.cdi.DisplayPanel advanced.cdi.events 15 | // BEGIN-EXAMPLE: advanced.cdi.events 16 | @SpringUI(path = "springevents") 17 | @Theme("valo") 18 | public class SpringEventUI extends UI { 19 | private static final long serialVersionUID = 390555781627137542L; 20 | 21 | @Autowired 22 | InputPanel inputPanel; 23 | 24 | @Autowired 25 | DisplayPanel display; 26 | 27 | @Override 28 | protected void init(VaadinRequest request) { 29 | Layout content = 30 | new HorizontalLayout(inputPanel, display); 31 | content.setSizeFull(); 32 | setContent(content); 33 | } 34 | } 35 | // END-EXAMPLE: advanced.cdi.events 36 | -------------------------------------------------------------------------------- /src/com/vaadin/book/examples/advanced/spring/SpringNavEventsUI.java: -------------------------------------------------------------------------------- 1 | package com.vaadin.book.examples.advanced.spring; 2 | 3 | import com.vaadin.annotations.Theme; 4 | import com.vaadin.server.VaadinRequest; 5 | import com.vaadin.spring.annotation.SpringUI; 6 | import com.vaadin.ui.UI; 7 | 8 | // BEGIN-EXAMPLE: advanced.cdi.producers 9 | @SpringUI(path = "springnavevents") 10 | @Theme("valo") 11 | public class SpringNavEventsUI extends UI { 12 | private static final long serialVersionUID = 390555781627137542L; 13 | 14 | 15 | @Override 16 | protected void init(VaadinRequest request) { 17 | } 18 | } 19 | // END-EXAMPLE: advanced.cdi.producers 20 | -------------------------------------------------------------------------------- /src/com/vaadin/book/examples/advanced/spring/SpringProducerUI.java: -------------------------------------------------------------------------------- 1 | package com.vaadin.book.examples.advanced.spring; 2 | 3 | import java.util.logging.Logger; 4 | 5 | import org.springframework.beans.factory.annotation.Autowired; 6 | 7 | import com.vaadin.annotations.Theme; 8 | import com.vaadin.server.VaadinRequest; 9 | import com.vaadin.spring.annotation.SpringUI; 10 | import com.vaadin.ui.UI; 11 | 12 | // BEGIN-EXAMPLE: advanced.cdi.producers 13 | @SpringUI(path = "springproducers") 14 | @Theme("valo") 15 | public class SpringProducerUI extends UI { 16 | private static final long serialVersionUID = 390555781627137542L; 17 | 18 | @Autowired 19 | Logger logger; 20 | 21 | @Override 22 | protected void init(VaadinRequest request) { 23 | logger.info("Initializing UI"); 24 | // setContent(new MyComponent(TableExample.generateContent())); 25 | } 26 | 27 | /* 28 | // Some class without a default constructor 29 | final class MyComponent extends Table { 30 | private static final long serialVersionUID = -278058594282382429L; 31 | 32 | public MyComponent(Container container) { 33 | super(null, container); 34 | } 35 | }*/ 36 | 37 | /* 38 | @Inject 39 | MyComponent myComponent; 40 | */ 41 | 42 | /* 43 | Container container = TableExample.generateContent(); 44 | 45 | @Produces 46 | private MyComponent createMyTable() { 47 | return new MyComponent(container); 48 | }*/ 49 | } 50 | // END-EXAMPLE: advanced.cdi.producers 51 | -------------------------------------------------------------------------------- /src/com/vaadin/book/examples/advanced/spring/SpringProducers.java: -------------------------------------------------------------------------------- 1 | package com.vaadin.book.examples.advanced.spring; 2 | 3 | import java.util.logging.Logger; 4 | 5 | import javax.enterprise.inject.spi.InjectionPoint; 6 | 7 | public class SpringProducers { 8 | // TODO Spring @Produces 9 | Logger createLogger(InjectionPoint injectionPoint) { 10 | return Logger.getLogger( injectionPoint.getMember().getDeclaringClass().getName() ); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /src/com/vaadin/book/examples/advanced/spring/User.java: -------------------------------------------------------------------------------- 1 | package com.vaadin.book.examples.advanced.spring; 2 | 3 | import java.io.Serializable; 4 | 5 | import com.vaadin.spring.annotation.SpringComponent; 6 | import com.vaadin.spring.annotation.VaadinSessionScope; 7 | 8 | /** 9 | * A stateful bean. 10 | */ 11 | @SpringComponent 12 | @VaadinSessionScope 13 | public class User implements Serializable { 14 | private static final long serialVersionUID = -5560593616074492199L; 15 | 16 | private String name; 17 | 18 | public User() {} 19 | 20 | public void setName(String name) { 21 | this.name = name; 22 | } 23 | 24 | public String getName() { 25 | return name; 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/com/vaadin/book/examples/application/BuildingUIExample.java: -------------------------------------------------------------------------------- 1 | package com.vaadin.book.examples.application; 2 | 3 | import com.vaadin.book.BookExamplesUI; 4 | import com.vaadin.book.examples.BookExampleBundle; 5 | import com.vaadin.server.ExternalResource; 6 | import com.vaadin.ui.BrowserFrame; 7 | import com.vaadin.ui.CustomComponent; 8 | import com.vaadin.ui.Layout; 9 | import com.vaadin.ui.VerticalLayout; 10 | 11 | public class BuildingUIExample extends CustomComponent implements BookExampleBundle { 12 | private static final long serialVersionUID = -4292553844521293140L; 13 | 14 | public void init(String context) { 15 | VerticalLayout layout = new VerticalLayout(); 16 | 17 | if ("hierarchical".equals(context)) 18 | hierarchical(layout); 19 | 20 | setCompositionRoot(layout); 21 | } 22 | 23 | public static final String hierarchicalDescription = 24 | "

Building UIs Hierarchically

" + 25 | "

"; 26 | 27 | // EXAMPLE-REF: application.architecture.hierarchical com.vaadin.book.applications.MyHierarchicalUI application.architecture.hierarchical 28 | void hierarchical(Layout layout) { 29 | BrowserFrame frame = new BrowserFrame("Browser Frame"); 30 | frame.setSource(new ExternalResource(BookExamplesUI.APPCONTEXT + "/buildingui?restartApplication")); 31 | frame.setWidth("570px"); 32 | frame.setHeight("300px"); 33 | layout.addComponent(frame); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /src/com/vaadin/book/examples/application/calc/CalculatorModel.java: -------------------------------------------------------------------------------- 1 | package com.vaadin.book.examples.application.calc; 2 | 3 | /** Business logic object for the Calculator example application. */ 4 | public class CalculatorModel { 5 | double current; 6 | double stored; 7 | double result; 8 | 9 | 10 | } 11 | -------------------------------------------------------------------------------- /src/com/vaadin/book/examples/application/declarative/CustomComponentDesign.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 6 | 7 | 8 | 9 | Hello! - How are you? 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /src/com/vaadin/book/examples/application/declarative/DeclarativeComponents.html: -------------------------------------------------------------------------------- 1 | 2 | Hello! - How are you? 3 | 4 | 5 | 7 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | OK 18 | 19 | 20 | -------------------------------------------------------------------------------- /src/com/vaadin/book/examples/application/declarative/DesignRootUI.java: -------------------------------------------------------------------------------- 1 | package com.vaadin.book.examples.application.declarative; 2 | 3 | import javax.servlet.annotation.WebServlet; 4 | 5 | import com.vaadin.annotations.DesignRoot; 6 | import com.vaadin.annotations.Theme; 7 | import com.vaadin.annotations.VaadinServletConfiguration; 8 | import com.vaadin.book.examples.component.TreeExample; 9 | import com.vaadin.book.examples.component.table.TableExample; 10 | import com.vaadin.server.VaadinRequest; 11 | import com.vaadin.server.VaadinServlet; 12 | import com.vaadin.ui.Notification; 13 | import com.vaadin.ui.Table; 14 | import com.vaadin.ui.Tree; 15 | import com.vaadin.ui.UI; 16 | import com.vaadin.ui.VerticalLayout; 17 | import com.vaadin.ui.declarative.Design; 18 | 19 | @SuppressWarnings("serial") 20 | @Theme("valo") 21 | // BEGIN-EXAMPLE: application.declarative.designroot 22 | public class DesignRootUI extends UI { 23 | @WebServlet(value = "/designrootui/*", 24 | asyncSupported = true) 25 | @VaadinServletConfiguration( 26 | productionMode = false, 27 | ui = DesignRootUI.class) 28 | public static class Servlet extends VaadinServlet { 29 | } 30 | 31 | @DesignRoot 32 | public class MyViewDesign extends VerticalLayout { 33 | Tree mytree; 34 | Table mytable; 35 | 36 | public MyViewDesign() { 37 | Design.read("MyDeclarativeUI.html", this); 38 | 39 | // Show some (example) data 40 | mytree.setContainerDataSource( 41 | TreeExample.createTreeContent()); 42 | mytable.setContainerDataSource( 43 | TableExample.generateContent()); 44 | 45 | // Some interaction 46 | mytree.addItemClickListener(click -> // Java 8 47 | Notification.show("Selected " + 48 | click.getItemId())); 49 | } 50 | } 51 | 52 | @Override 53 | protected void init(VaadinRequest request) { 54 | setContent(new MyViewDesign()); 55 | } 56 | } 57 | // END-EXAMPLE: application.declarative.designroot 58 | -------------------------------------------------------------------------------- /src/com/vaadin/book/examples/application/declarative/ExampleComponent.java: -------------------------------------------------------------------------------- 1 | package com.vaadin.book.examples.application.declarative; 2 | 3 | import com.vaadin.ui.CustomComponent; 4 | import com.vaadin.ui.Label; 5 | 6 | public class ExampleComponent extends CustomComponent { 7 | public ExampleComponent() { 8 | setCompositionRoot(new Label("I am an example.")); 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /src/com/vaadin/book/examples/application/declarative/InlineDesign.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 6 | 7 | 8 | 9 | 10 | Hello! - How are you? 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | -------------------------------------------------------------------------------- /src/com/vaadin/book/examples/application/declarative/MyBasicDeclarativeUI.java: -------------------------------------------------------------------------------- 1 | package com.vaadin.book.examples.application.declarative; 2 | 3 | import javax.servlet.annotation.WebServlet; 4 | 5 | import com.vaadin.annotations.Theme; 6 | import com.vaadin.annotations.VaadinServletConfiguration; 7 | import com.vaadin.server.VaadinRequest; 8 | import com.vaadin.server.VaadinServlet; 9 | import com.vaadin.ui.UI; 10 | import com.vaadin.ui.declarative.Design; 11 | 12 | @SuppressWarnings("serial") 13 | @Theme("myproject") 14 | // BEGIN-EXAMPLE: application.declarative.basic 15 | public class MyBasicDeclarativeUI extends UI { 16 | @WebServlet(value = "/basicdeclarativeui/*", 17 | asyncSupported = true) 18 | @VaadinServletConfiguration( 19 | productionMode = false, 20 | ui = MyBasicDeclarativeUI.class) 21 | public static class Servlet extends VaadinServlet { 22 | } 23 | 24 | @Override 25 | protected void init(VaadinRequest request) { 26 | setContent(Design.read(getClass(). 27 | getResourceAsStream("MyDeclarativeUI.html"))); 28 | } 29 | } 30 | // END-EXAMPLE: application.declarative.basic 31 | -------------------------------------------------------------------------------- /src/com/vaadin/book/examples/application/declarative/MyDeclarativeUI.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Hello! - How are you? 6 | 7 | 8 | 10 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /src/com/vaadin/book/examples/application/declarative/MyDeclarativeUI.java: -------------------------------------------------------------------------------- 1 | package com.vaadin.book.examples.application.declarative; 2 | 3 | import javax.servlet.annotation.WebServlet; 4 | 5 | import com.vaadin.annotations.Theme; 6 | import com.vaadin.annotations.VaadinServletConfiguration; 7 | import com.vaadin.book.examples.component.TreeExample; 8 | import com.vaadin.book.examples.component.table.TableExample; 9 | import com.vaadin.server.VaadinRequest; 10 | import com.vaadin.server.VaadinServlet; 11 | import com.vaadin.ui.Table; 12 | import com.vaadin.ui.Tree; 13 | import com.vaadin.ui.UI; 14 | import com.vaadin.ui.declarative.Design; 15 | import com.vaadin.ui.declarative.DesignContext; 16 | 17 | @SuppressWarnings("serial") 18 | @Theme("valo") 19 | // BEGIN-EXAMPLE: application.declarative.context 20 | public class MyDeclarativeUI extends UI { 21 | @WebServlet(value = "/declarativeui/*", 22 | asyncSupported = true) 23 | @VaadinServletConfiguration( 24 | productionMode = false, 25 | ui = MyDeclarativeUI.class) 26 | public static class Servlet extends VaadinServlet { 27 | } 28 | 29 | Tree mytree; 30 | Table mytable; 31 | 32 | @Override 33 | protected void init(VaadinRequest request) { 34 | DesignContext design = Design.read(getClass(). 35 | getResourceAsStream("MyDeclarativeUI.html"), 36 | null); 37 | setContent(design.getRootComponent()); 38 | 39 | // Get the components from the design 40 | mytree = (Tree) design.getComponentByLocalId("mytree"); 41 | mytable = (Table) design.getComponentByLocalId("mytable"); 42 | 43 | // Bind the data display components to (example) data 44 | mytree.setContainerDataSource( 45 | TreeExample.createTreeContent()); 46 | mytable.setContainerDataSource( 47 | TableExample.generateContent()); 48 | } 49 | } 50 | // END-EXAMPLE: application.declarative.context 51 | -------------------------------------------------------------------------------- /src/com/vaadin/book/examples/application/images/image.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vaadin/book-examples/435f8b377a946ad5a8129ed266289afe0e015790/src/com/vaadin/book/examples/application/images/image.png -------------------------------------------------------------------------------- /src/com/vaadin/book/examples/client/ColorPicker.java: -------------------------------------------------------------------------------- 1 | /* 2 | @ITMillApache2LicenseForJavaFiles@ 3 | */ 4 | 5 | package com.vaadin.book.examples.client; 6 | 7 | import com.vaadin.ui.AbstractField; 8 | 9 | /** 10 | * Color picker for selecting a color from a palette. 11 | * 12 | * @author magi 13 | */ 14 | public class ColorPicker extends AbstractField { 15 | private static final long serialVersionUID = -49625621494L; 16 | 17 | public ColorPicker() { 18 | super(); 19 | setValue(new String("white")); 20 | } 21 | 22 | /** The property value of the field is a String. */ 23 | @Override 24 | public Class getType() { 25 | return String.class; 26 | } 27 | 28 | /** Set the currently selected color. */ 29 | public void setColor(String newcolor) { 30 | // Sets the color name as the property of the component. 31 | // Setting the property will automatically cause 32 | // repainting of the component with paintContent(). 33 | setValue(newcolor); 34 | } 35 | 36 | /** Retrieve the currently selected color. */ 37 | public String getColor() { 38 | return (String) getValue(); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /src/com/vaadin/book/examples/client/ColorpickerExample.java: -------------------------------------------------------------------------------- 1 | package com.vaadin.book.examples.client; 2 | 3 | import com.vaadin.book.examples.BookExampleBundle; 4 | import com.vaadin.data.Property.ValueChangeEvent; 5 | import com.vaadin.data.Property.ValueChangeListener; 6 | import com.vaadin.ui.CustomComponent; 7 | import com.vaadin.ui.Label; 8 | import com.vaadin.ui.VerticalLayout; 9 | 10 | public class ColorpickerExample extends CustomComponent implements BookExampleBundle { 11 | private static final long serialVersionUID = -6235574698344484522L; 12 | 13 | public void init (String context) { 14 | VerticalLayout layout = new VerticalLayout(); 15 | 16 | if ("basic".equals(context)) 17 | basic(layout); 18 | else 19 | layout.addComponent(new Label("Invalid context: " + context)); 20 | 21 | setCompositionRoot(layout); 22 | } 23 | 24 | public final static String basicDescription = 25 | "

Basic Widget Integration

" + 26 | "

"; 27 | 28 | void basic(VerticalLayout layout) { 29 | // BEGIN-EXAMPLE: gwt.basic 30 | final ColorPicker colorpicker = new ColorPicker(); 31 | layout.addComponent(colorpicker); 32 | 33 | final Label colorname = new Label("-"); 34 | 35 | // Listen for value change events in the custom component, 36 | // triggered when user clicks a button to select another color. 37 | colorpicker.addValueChangeListener (new ValueChangeListener() { 38 | private static final long serialVersionUID = 7844511885218471927L; 39 | 40 | public void valueChange(ValueChangeEvent event) { 41 | // Provide some server-side feedback 42 | colorname.setValue("Selected color: " + 43 | colorpicker.getColor()); 44 | } 45 | }); 46 | // END-EXAMPLE: gwt.basic 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /src/com/vaadin/book/examples/client/MyComponent.java: -------------------------------------------------------------------------------- 1 | package com.vaadin.book.examples.client; 2 | 3 | import com.vaadin.book.examples.client.widgetset.client.mycomponent.MyComponentClientRpc; 4 | import com.vaadin.book.examples.client.widgetset.client.mycomponent.MyComponentServerRpc; 5 | import com.vaadin.book.examples.client.widgetset.client.mycomponent.MyComponentState; 6 | import com.vaadin.server.Resource; 7 | 8 | public class MyComponent extends com.vaadin.ui.AbstractComponent { 9 | private static final long serialVersionUID = 7486429214661043969L; 10 | 11 | private MyComponentServerRpc rpc = new MyComponentServerRpc() { 12 | private static final long serialVersionUID = -3384499731721458101L; 13 | 14 | private int clickCount = 0; 15 | 16 | @Override 17 | public void clicked(String buttonName) { 18 | // Nag every 5:th click using RPC 19 | if (++clickCount % 5 == 0) { 20 | getRpcProxy(MyComponentClientRpc.class).alert( 21 | "Ok, that's enough!"); 22 | } 23 | 24 | // Update shared state 25 | getState().text = "You have clicked " + clickCount + 26 | " times, now " + buttonName; 27 | } 28 | }; 29 | 30 | public MyComponent() { 31 | getState().text = "This is MyComponent"; 32 | registerRpc(rpc); 33 | } 34 | 35 | @Override 36 | public MyComponentState getState() { 37 | return (MyComponentState) super.getState(); 38 | } 39 | 40 | public void setMyIcon(Resource myIcon) { 41 | setResource("myIcon", myIcon); 42 | } 43 | 44 | public Resource getMyIcon() { 45 | return getResource("myIcon"); 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /src/com/vaadin/book/examples/client/MyComponentExample.java: -------------------------------------------------------------------------------- 1 | package com.vaadin.book.examples.client; 2 | 3 | import com.vaadin.book.examples.BookExampleBundle; 4 | import com.vaadin.server.ThemeResource; 5 | import com.vaadin.ui.CustomComponent; 6 | import com.vaadin.ui.Label; 7 | import com.vaadin.ui.VerticalLayout; 8 | 9 | public class MyComponentExample extends CustomComponent implements BookExampleBundle { 10 | private static final long serialVersionUID = -6235574698344484522L; 11 | 12 | public void init (String context) { 13 | VerticalLayout layout = new VerticalLayout(); 14 | 15 | if ("basic".equals(context)) 16 | basic(layout); 17 | else if ("resource".equals(context)) 18 | resource(layout); 19 | else 20 | layout.addComponent(new Label("Invalid context: " + context)); 21 | 22 | setCompositionRoot(layout); 23 | } 24 | 25 | public final static String basicDescription = 26 | "

Custom Widget

" + 27 | "

"; 28 | 29 | void basic(VerticalLayout layout) { 30 | // BEGIN-EXAMPLE: gwt.eclipse.basic 31 | final MyComponent mycomponent = new MyComponent(); 32 | layout.addComponent(mycomponent); 33 | // END-EXAMPLE: gwt.eclipse.basic 34 | } 35 | 36 | void resource(VerticalLayout layout) { 37 | // BEGIN-EXAMPLE: gwt.integration.resource 38 | final MyComponent mycomponent = new MyComponent(); 39 | mycomponent.setMyIcon(new ThemeResource("img/reindeer-128px.png")); 40 | layout.addComponent(mycomponent); 41 | // END-EXAMPLE: gwt.integration.resource 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /src/com/vaadin/book/examples/client/clientside/MyModule.gwt.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /src/com/vaadin/book/examples/client/clientside/MyModuleWidgetset.gwt.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /src/com/vaadin/book/examples/client/clientside/client/MyEntryPoint.java: -------------------------------------------------------------------------------- 1 | package com.vaadin.book.examples.client.clientside.client; 2 | 3 | import com.google.gwt.core.client.EntryPoint; 4 | import com.google.gwt.event.dom.client.ClickEvent; 5 | import com.google.gwt.event.dom.client.ClickHandler; 6 | import com.google.gwt.user.client.ui.RootPanel; 7 | import com.vaadin.client.ui.VButton; 8 | 9 | public class MyEntryPoint implements EntryPoint { 10 | @Override 11 | public void onModuleLoad() { 12 | // Use the custom widget 13 | final MyWidget mywidget = new MyWidget(); 14 | RootPanel.get().add(mywidget); 15 | 16 | // Add a Vaadin button 17 | VButton button = new VButton(); 18 | button.setText("Click me!"); 19 | button.addClickHandler(new ClickHandler() { 20 | @Override 21 | public void onClick(ClickEvent event) { 22 | mywidget.setText("Clicked!"); 23 | } 24 | }); 25 | 26 | RootPanel.get().add(button); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/com/vaadin/book/examples/client/clientside/client/MyWidget.java: -------------------------------------------------------------------------------- 1 | package com.vaadin.book.examples.client.clientside.client; 2 | 3 | import com.google.gwt.user.client.ui.Label; 4 | 5 | public class MyWidget extends Label { 6 | public static final String CLASSNAME = "mywidget"; 7 | 8 | public MyWidget() { 9 | setStyleName(CLASSNAME); 10 | setText("This is MyWidget"); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /src/com/vaadin/book/examples/client/js/JSIntegrationExample.java: -------------------------------------------------------------------------------- 1 | package com.vaadin.book.examples.client.js; 2 | 3 | import com.vaadin.book.examples.BookExampleBundle; 4 | import com.vaadin.ui.CustomComponent; 5 | import com.vaadin.ui.Label; 6 | import com.vaadin.ui.Notification; 7 | import com.vaadin.ui.VerticalLayout; 8 | 9 | public class JSIntegrationExample extends CustomComponent implements BookExampleBundle { 10 | private static final long serialVersionUID = -6235574698344484522L; 11 | 12 | public void init (String context) { 13 | VerticalLayout layout = new VerticalLayout(); 14 | 15 | if ("basic".equals(context)) 16 | basic(layout); 17 | else 18 | layout.addComponent(new Label("Invalid context: " + context)); 19 | 20 | setCompositionRoot(layout); 21 | } 22 | 23 | public final static String basicDescription = 24 | "

Integrating a JavaScript Component

" + 25 | "

"; 26 | 27 | void basic(VerticalLayout layout) { 28 | // BEGIN-EXAMPLE: gwt.javascript.basic 29 | final MyComponent mycomponent = new MyComponent(); 30 | mycomponent.setValue("Server-side value"); 31 | mycomponent.onChange(newValue -> 32 | Notification.show("New value: " + newValue)); 33 | // END-EXAMPLE: gwt.javascript.basic 34 | // EXAMPLE-REF: gwt.javascript.basic com.vaadin.book.examples.client.js.MyComponent gwt.javascript.basic 35 | // EXAMPLE-REF: gwt.javascript.basic com.vaadin.book.examples.client.js.MyComponentState gwt.javascript.basic 36 | // EXAMPLE-FILE: gwt.javascript.basic /com/vaadin/book/examples/client/js/mylibrary.js 37 | // EXAMPLE-FILE: gwt.javascript.basic /com/vaadin/book/examples/client/js/mycomponent-connector.js 38 | layout.addComponent(mycomponent); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /src/com/vaadin/book/examples/client/js/MyComponent.java: -------------------------------------------------------------------------------- 1 | package com.vaadin.book.examples.client.js; 2 | 3 | import java.util.ArrayList; 4 | import java.util.function.Consumer; 5 | 6 | import com.vaadin.annotations.JavaScript; 7 | import com.vaadin.ui.AbstractJavaScriptComponent; 8 | import com.vaadin.ui.JavaScriptFunction; 9 | 10 | import elemental.json.JsonArray; 11 | 12 | // BEGIN-EXAMPLE: gwt.javascript.basic 13 | /** Server-side API for the JavaScript component */ 14 | @JavaScript({"mylibrary.js", "mycomponent-connector.js"}) 15 | public class MyComponent extends AbstractJavaScriptComponent { 16 | private static final long serialVersionUID = -8510122663484494839L; 17 | 18 | // Java 8 19 | ArrayList> listeners = 20 | new ArrayList>(); 21 | public void onChange(Consumer listener) { 22 | listeners.add(listener); 23 | } 24 | 25 | public void setValue(String value) { 26 | getState().setValue(value); 27 | markAsDirty(); 28 | } 29 | 30 | public String getValue() { 31 | return getState().getValue(); 32 | } 33 | 34 | @Override 35 | public MyComponentState getState() { 36 | return (MyComponentState) super.getState(); 37 | } 38 | 39 | public MyComponent() { 40 | addFunction("onClick", new JavaScriptFunction() { 41 | private static final long serialVersionUID = 1256984845028849243L; 42 | 43 | @Override 44 | public void call(JsonArray arguments) { 45 | getState().setValue(arguments.getString(0)); 46 | for (Consumer listener: listeners) 47 | listener.accept(arguments.getString(0)); 48 | } 49 | }); 50 | } 51 | } 52 | // END-EXAMPLE: gwt.javascript.basic 53 | -------------------------------------------------------------------------------- /src/com/vaadin/book/examples/client/js/MyComponentState.java: -------------------------------------------------------------------------------- 1 | package com.vaadin.book.examples.client.js; 2 | 3 | import com.vaadin.shared.ui.JavaScriptComponentState; 4 | 5 | //BEGIN-EXAMPLE: gwt.javascript.basic 6 | /** Shared state class for MyComponent */ 7 | public class MyComponentState extends JavaScriptComponentState { 8 | private static final long serialVersionUID = -1260235093446938046L; 9 | 10 | private String value; 11 | 12 | public String getValue() { 13 | return value; 14 | } 15 | 16 | public void setValue(String value) { 17 | this.value = value; 18 | } 19 | } 20 | //END-EXAMPLE: gwt.javascript.basic 21 | -------------------------------------------------------------------------------- /src/com/vaadin/book/examples/client/js/mycomponent-connector.js: -------------------------------------------------------------------------------- 1 | window.com_vaadin_book_examples_client_js_MyComponent = 2 | function() { 3 | // Create the component 4 | var mycomponent = 5 | new mylibrary.MyComponent(this.getElement()); 6 | 7 | // Handle changes from the server-side 8 | this.onStateChange = function() { 9 | mycomponent.setValue(this.getState().value); 10 | }; 11 | 12 | // Pass user interaction to the server-side 13 | var connector = this; 14 | mycomponent.click = function() { 15 | connector.onClick(mycomponent.getValue()); 16 | }; 17 | }; 18 | -------------------------------------------------------------------------------- /src/com/vaadin/book/examples/client/js/mylibrary.js: -------------------------------------------------------------------------------- 1 | // Define the namespace 2 | var mylibrary = mylibrary || {}; 3 | 4 | mylibrary.MyComponent = function (element) { 5 | element.innerHTML = 6 | "
Hello, world!
" + 7 | "
Enter a value: " + 8 | "" + 9 | "" + 10 | "
"; 11 | 12 | // Style it 13 | element.style.border = "thin solid red"; 14 | element.style.display = "inline-block"; 15 | 16 | // Getter and setter for the value property 17 | this.getValue = function () { 18 | return element. 19 | getElementsByTagName("input")[0].value; 20 | }; 21 | this.setValue = function (value) { 22 | element.getElementsByTagName("input")[0].value = 23 | value; 24 | }; 25 | 26 | // Default implementation of the click handler 27 | this.click = function () { 28 | alert("Error: Must implement click() method"); 29 | }; 30 | 31 | // Set up button click 32 | var button = element.getElementsByTagName("input")[1]; 33 | var self = this; // Can't use this inside the function 34 | button.onclick = function () { 35 | self.click(); 36 | }; 37 | }; 38 | -------------------------------------------------------------------------------- /src/com/vaadin/book/examples/client/widgetset/ColorPickerWidgetSet.gwt.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /src/com/vaadin/book/examples/client/widgetset/client/colorpicker/ColorPickerConnector.java: -------------------------------------------------------------------------------- 1 | /* 2 | @ITMillApache2LicenseForJavaFiles@ 3 | */ 4 | 5 | package com.vaadin.book.examples.client.widgetset.client.colorpicker; 6 | 7 | import com.google.gwt.core.client.GWT; 8 | import com.google.gwt.user.client.ui.Widget; 9 | import com.vaadin.book.examples.client.ColorPicker; 10 | import com.vaadin.client.ui.AbstractFieldConnector; 11 | import com.vaadin.shared.ui.Connect; 12 | 13 | @Connect(ColorPicker.class) 14 | public class ColorPickerConnector extends AbstractFieldConnector { 15 | private static final long serialVersionUID = 7157710461018167631L; 16 | 17 | public ColorPickerConnector() { 18 | } 19 | 20 | @Override 21 | protected Widget createWidget() { 22 | return GWT.create(GwtColorPicker.class); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /src/com/vaadin/book/examples/client/widgetset/client/colorpicker/ColorPickerState.java: -------------------------------------------------------------------------------- 1 | package com.vaadin.book.examples.client.widgetset.client.colorpicker; 2 | 3 | import com.vaadin.shared.AbstractFieldState; 4 | 5 | public class ColorPickerState extends AbstractFieldState { 6 | private static final long serialVersionUID = -2527367189687383833L; 7 | 8 | private String colorName; 9 | 10 | public String getColorName() { 11 | return colorName; 12 | } 13 | 14 | public void setColorName(String colorName) { 15 | this.colorName = colorName; 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /src/com/vaadin/book/examples/client/widgetset/client/mycomponent/MyComponentClientRpc.java: -------------------------------------------------------------------------------- 1 | package com.vaadin.book.examples.client.widgetset.client.mycomponent; 2 | 3 | import com.vaadin.shared.communication.ClientRpc; 4 | 5 | public interface MyComponentClientRpc extends ClientRpc { 6 | 7 | // TODO example API 8 | public void alert(String message); 9 | 10 | } -------------------------------------------------------------------------------- /src/com/vaadin/book/examples/client/widgetset/client/mycomponent/MyComponentServerRpc.java: -------------------------------------------------------------------------------- 1 | package com.vaadin.book.examples.client.widgetset.client.mycomponent; 2 | 3 | import com.vaadin.shared.communication.ServerRpc; 4 | 5 | public interface MyComponentServerRpc extends ServerRpc { 6 | 7 | // TODO example API 8 | public void clicked(String buttonName); 9 | 10 | } 11 | -------------------------------------------------------------------------------- /src/com/vaadin/book/examples/client/widgetset/client/mycomponent/MyComponentState.java: -------------------------------------------------------------------------------- 1 | package com.vaadin.book.examples.client.widgetset.client.mycomponent; 2 | 3 | import com.vaadin.shared.AbstractComponentState; 4 | 5 | public class MyComponentState extends AbstractComponentState { 6 | private static final long serialVersionUID = -5149323568169128231L; 7 | 8 | //@DelegateToWidget 9 | public String text; 10 | } -------------------------------------------------------------------------------- /src/com/vaadin/book/examples/client/widgetset/client/mycomponent/MyComponentWidget.java: -------------------------------------------------------------------------------- 1 | package com.vaadin.book.examples.client.widgetset.client.mycomponent; 2 | 3 | import com.google.gwt.user.client.DOM; 4 | import com.google.gwt.user.client.Element; 5 | import com.google.gwt.user.client.ui.Label; 6 | 7 | // TODO extend any GWT Widget 8 | public class MyComponentWidget extends Label { 9 | 10 | public static final String CLASSNAME = "mycomponent"; 11 | 12 | public MyComponentWidget() { 13 | 14 | // setText("MyComponent sets the text via MyComponentConnector using MyComponentState"); 15 | setStyleName(CLASSNAME); 16 | 17 | } 18 | 19 | Element imgElement = null; 20 | 21 | public void setMyIcon(String url) { 22 | if (imgElement == null) { 23 | imgElement = DOM.createImg(); 24 | getElement().appendChild(imgElement); 25 | } 26 | 27 | DOM.setElementAttribute(imgElement, "src", url); 28 | } 29 | } -------------------------------------------------------------------------------- /src/com/vaadin/book/examples/client/widgetset/client/renderer/CellValueChangeRpc.java: -------------------------------------------------------------------------------- 1 | package com.vaadin.book.examples.client.widgetset.client.renderer; 2 | 3 | import com.vaadin.shared.communication.ServerRpc; 4 | 5 | public interface CellValueChangeRpc extends ServerRpc { 6 | public void changed(String newValue, String rowKey, String columnKey); 7 | } 8 | -------------------------------------------------------------------------------- /src/com/vaadin/book/examples/client/widgetset/client/renderer/MyButtonRenderer.java: -------------------------------------------------------------------------------- 1 | package com.vaadin.book.examples.client.widgetset.client.renderer; 2 | 3 | import com.google.gwt.user.client.ui.Button; 4 | import com.vaadin.client.renderers.ButtonRenderer; 5 | import com.vaadin.client.widget.grid.RendererCellReference; 6 | 7 | public class MyButtonRenderer extends ButtonRenderer { 8 | @Override 9 | public void render(RendererCellReference cell, String text, Button button) { 10 | boolean enabled = true; 11 | if (text.startsWith("Disabled:")) { 12 | text = text.substring("Disabled:".length()); 13 | enabled = false; 14 | } 15 | button.setText(text); 16 | button.setEnabled(enabled); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/com/vaadin/book/examples/client/widgetset/client/renderer/MyButtonRendererConnector.java: -------------------------------------------------------------------------------- 1 | package com.vaadin.book.examples.client.widgetset.client.renderer; 2 | 3 | import com.google.web.bindery.event.shared.HandlerRegistration; 4 | import com.vaadin.client.connectors.ButtonRendererConnector; 5 | import com.vaadin.client.renderers.ButtonRenderer; 6 | import com.vaadin.client.renderers.ClickableRenderer.RendererClickHandler; 7 | import com.vaadin.shared.ui.Connect; 8 | 9 | import elemental.json.JsonObject; 10 | 11 | /** 12 | * A connector for {@link ButtonRenderer}. 13 | * 14 | * @since 7.4 15 | * @author Vaadin Ltd 16 | */ 17 | @Connect(com.vaadin.book.examples.component.grid.MyButtonRenderer.class) 18 | public class MyButtonRendererConnector extends ButtonRendererConnector { 19 | 20 | private static final long serialVersionUID = 6138259415131488971L; 21 | 22 | @Override 23 | public MyButtonRenderer getRenderer() { 24 | return (MyButtonRenderer) super.getRenderer(); 25 | } 26 | 27 | @Override 28 | protected HandlerRegistration addClickHandler( 29 | RendererClickHandler handler) { 30 | return getRenderer().addClickHandler(handler); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /src/com/vaadin/book/examples/client/widgetset/client/renderer/RendererTextBox.java: -------------------------------------------------------------------------------- 1 | package com.vaadin.book.examples.client.widgetset.client.renderer; 2 | 3 | import com.google.gwt.user.client.ui.TextBox; 4 | 5 | class RendererTextBox extends TextBox { 6 | private String rowKey; 7 | private String columnKey; 8 | 9 | public void setRowKey(String rowKey) { 10 | this.rowKey = rowKey; 11 | } 12 | public String getRowKey() { 13 | return rowKey; 14 | } 15 | 16 | public void setColumnKey(String columnKey) { 17 | this.columnKey = columnKey; 18 | } 19 | public String getColumnKey() { 20 | return columnKey; 21 | } 22 | } -------------------------------------------------------------------------------- /src/com/vaadin/book/examples/client/widgetset/client/renderer/TextFieldRenderer.java: -------------------------------------------------------------------------------- 1 | package com.vaadin.book.examples.client.widgetset.client.renderer; 2 | 3 | import com.vaadin.client.renderers.WidgetRenderer; 4 | import com.vaadin.client.widget.grid.RendererCellReference; 5 | 6 | public class TextFieldRenderer extends WidgetRenderer { 7 | 8 | @Override 9 | public RendererTextBox createWidget() { 10 | RendererTextBox box = new RendererTextBox(); 11 | return box; 12 | } 13 | 14 | @Override 15 | public void render(RendererCellReference cell, String data, 16 | RendererTextBox widget) { 17 | widget.setText(data); 18 | // widget.setRowKey(cell.getRowIndex()); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/com/vaadin/book/examples/client/widgetset/client/renderer/TextFieldRendererConnector.java: -------------------------------------------------------------------------------- 1 | package com.vaadin.book.examples.client.widgetset.client.renderer; 2 | 3 | import com.vaadin.client.connectors.AbstractRendererConnector; 4 | import com.vaadin.shared.ui.Connect; 5 | 6 | /** 7 | * A connector for {@link TextFieldRenderer}. 8 | * 9 | * @since 7.4 10 | * @author Vaadin Ltd 11 | */ 12 | @Connect(com.vaadin.book.examples.component.grid.TextFieldRenderer.class) 13 | public class TextFieldRendererConnector extends AbstractRendererConnector { 14 | 15 | private static final long serialVersionUID = 6138259415131488971L; 16 | 17 | @Override 18 | public MyButtonRenderer getRenderer() { 19 | return (MyButtonRenderer) super.getRenderer(); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/com/vaadin/book/examples/client/widgetset/public/colorpicker/styles.css: -------------------------------------------------------------------------------- 1 | /* Set style for the color picker table. 2 | This assumes that the Grid layout is rendered as a HTML .*/ 3 | table.example-colorpicker { 4 | border-collapse: collapse; 5 | border: 0px; 6 | } 7 | 8 | /* Set color picker button style. 9 | This does not make assumptions about the HTML element tree as it only uses 10 | the logical class names.*/ 11 | .example-colorpicker .gwt-Button { 12 | height: 60px; 13 | width: 60px; 14 | border: none; 15 | padding: 0px; 16 | } 17 | 18 | /* Set style for the right-hand box that shows the currently selected color. 19 | While this may work for other implementations of the HorizontalPanel as well, 20 | it somewhat assumes that the layout is rendered as a table where cells 21 | are
elements. */ 22 | .colorpicker-currentcolorbox { 23 | width: 240px; 24 | text-align: center; 25 | vertical-align: middle !important; 26 | } 27 | -------------------------------------------------------------------------------- /src/com/vaadin/book/examples/component/MyCalendarEvent.java: -------------------------------------------------------------------------------- 1 | package com.vaadin.book.examples.component; 2 | 3 | import java.util.Date; 4 | 5 | import javax.persistence.Entity; 6 | import javax.persistence.GeneratedValue; 7 | import javax.persistence.GenerationType; 8 | import javax.persistence.Id; 9 | import javax.persistence.Temporal; 10 | import javax.persistence.TemporalType; 11 | 12 | @Entity 13 | public class MyCalendarEvent { 14 | @Id 15 | @GeneratedValue(strategy=GenerationType.IDENTITY) 16 | Long id; 17 | 18 | String caption; 19 | String description; 20 | 21 | @Temporal(TemporalType.TIMESTAMP) 22 | Date startDate; 23 | 24 | @Temporal(TemporalType.TIMESTAMP) 25 | Date endDate; 26 | String styleName; 27 | 28 | public MyCalendarEvent() { 29 | } 30 | 31 | public MyCalendarEvent(String caption, String description, 32 | Date startDate, Date endDate, String styleName) { 33 | this.caption = caption; 34 | this.description = description; 35 | this.startDate = startDate; 36 | this.endDate = endDate; 37 | this.styleName = styleName; 38 | } 39 | 40 | public Long getId() { 41 | return id; 42 | } 43 | public void setId(Long id) { 44 | this.id = id; 45 | } 46 | public String getCaption() { 47 | return caption; 48 | } 49 | public void setCaption(String caption) { 50 | this.caption = caption; 51 | } 52 | public String getDescription() { 53 | return description; 54 | } 55 | public void setDescription(String description) { 56 | this.description = description; 57 | } 58 | public Date getStartDate() { 59 | return startDate; 60 | } 61 | public void setStartDate(Date startDate) { 62 | this.startDate = startDate; 63 | } 64 | public Date getEndDate() { 65 | return endDate; 66 | } 67 | public void setEndDate(Date endDate) { 68 | this.endDate = endDate; 69 | } 70 | public String getStyleName() { 71 | return styleName; 72 | } 73 | public void setStyleName(String styleName) { 74 | this.styleName = styleName; 75 | } 76 | } 77 | -------------------------------------------------------------------------------- /src/com/vaadin/book/examples/component/NativeSelectExample.java: -------------------------------------------------------------------------------- 1 | package com.vaadin.book.examples.component; 2 | 3 | import com.vaadin.book.examples.AnyBookExampleBundle; 4 | import com.vaadin.data.Container; 5 | import com.vaadin.data.util.IndexedContainer; 6 | import com.vaadin.ui.CustomComponent; 7 | import com.vaadin.ui.NativeSelect; 8 | import com.vaadin.ui.Notification; 9 | import com.vaadin.ui.VerticalLayout; 10 | 11 | public class NativeSelectExample extends CustomComponent implements AnyBookExampleBundle { 12 | private static final long serialVersionUID = -4292553844521293140L; 13 | 14 | public void basic(VerticalLayout layout) { 15 | // BEGIN-EXAMPLE: component.select.nativeselect.basic 16 | // Create the selection component with some items 17 | NativeSelect select = new NativeSelect("Native Selection"); 18 | select.addItems("Mercury", "Venus", "Earth", "Mars", 19 | "Jupiter", "Saturn", "Neptune", "Uranus"); 20 | select.setNullSelectionAllowed(false); 21 | 22 | select.addValueChangeListener( event -> // Java 8 23 | Notification.show((String) select.getValue())); 24 | select.setImmediate(true); 25 | // END-EXAMPLE: component.select.nativeselect.basic 26 | 27 | layout.setHeight("200px"); 28 | layout.addComponent(select); 29 | } 30 | 31 | Container createSelectData() { 32 | IndexedContainer container = new IndexedContainer(); 33 | container.addContainerProperty("caption", String.class, null); 34 | return container; 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /src/com/vaadin/book/examples/component/PasswordFieldExample.java: -------------------------------------------------------------------------------- 1 | package com.vaadin.book.examples.component; 2 | 3 | import com.vaadin.book.examples.BookExampleBundle; 4 | import com.vaadin.ui.Button; 5 | import com.vaadin.ui.CustomComponent; 6 | import com.vaadin.ui.Label; 7 | import com.vaadin.ui.PasswordField; 8 | import com.vaadin.ui.VerticalLayout; 9 | 10 | public class PasswordFieldExample extends CustomComponent implements BookExampleBundle { 11 | private static final long serialVersionUID = -4454143876393393750L; 12 | 13 | public void init (String context) { 14 | VerticalLayout layout = new VerticalLayout(); 15 | layout.addStyleName("passwordfieldexample"); 16 | 17 | if ("basic".equals(context)) 18 | basic(layout); 19 | else if ("css".equals(context)) 20 | css (layout); 21 | 22 | setCompositionRoot(layout); 23 | } 24 | 25 | void basic(VerticalLayout layout) { 26 | // BEGIN-EXAMPLE: component.passwordfield.basic 27 | // Create a text field 28 | PasswordField tf = new PasswordField("Keep it secret"); 29 | 30 | Button ok = new Button("OK", event -> // Java 8 31 | layout.addComponent(new Label("Secret: " + tf.getValue()))); 32 | // END-EXAMPLE: component.passwordfield.basic 33 | 34 | layout.addComponents(tf, ok); 35 | layout.setSpacing(true); 36 | } 37 | 38 | public static String cssDescription = 39 | "

Styling PasswordField with CSS

" + 40 | "

PasswordField uses the same v-textfield style as TextField.

"; 41 | 42 | void css(VerticalLayout layout) { 43 | // BEGIN-EXAMPLE: component.passwordfield.css 44 | PasswordField tf = new PasswordField("Fence around the secret field"); 45 | tf.addStyleName("dashing"); 46 | // END-EXAMPLE: component.passwordfield.css 47 | 48 | layout.addComponent(tf); 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /src/com/vaadin/book/examples/component/RichTextAreaExample.java: -------------------------------------------------------------------------------- 1 | package com.vaadin.book.examples.component; 2 | 3 | import com.vaadin.book.examples.BookExampleBundle; 4 | import com.vaadin.ui.Button; 5 | import com.vaadin.ui.CustomComponent; 6 | import com.vaadin.ui.Label; 7 | import com.vaadin.ui.RichTextArea; 8 | import com.vaadin.ui.VerticalLayout; 9 | 10 | public class RichTextAreaExample extends CustomComponent implements BookExampleBundle { 11 | private static final long serialVersionUID = -4292553844521293140L; 12 | 13 | public void init (String context) { 14 | VerticalLayout layout = new VerticalLayout(); 15 | 16 | if ("basic".equals(context)) 17 | basic(layout); 18 | else if ("localization".equals(context)) 19 | localization(layout); 20 | 21 | setCompositionRoot(layout); 22 | } 23 | 24 | void basic(VerticalLayout layout) { 25 | // BEGIN-EXAMPLE: component.richtextarea.basic 26 | RichTextArea area = new RichTextArea("My Rich Textarea"); 27 | area.setValue("

Helpful Heading

"+ 28 | "

All this is for you to edit.

"); 29 | 30 | // Handle edits 31 | Button ok = new Button("OK"); 32 | Label feedback = new Label((String) area.getValue()); 33 | ok.addClickListener(event -> // Java 8 34 | feedback.setValue(area.getValue())); 35 | // END-EXAMPLE: component.richtextarea.basic 36 | 37 | layout.addComponents(area, ok, feedback); 38 | layout.setSpacing(true); 39 | } 40 | 41 | void localization(VerticalLayout layout) { 42 | // BEGIN-EXAMPLE: component.richtextarea.localization 43 | RichTextArea area = new RichTextArea(); 44 | area.setCaption("You can edit stuff here"); 45 | area.setValue("

Helpful Heading

"+ 46 | "

All this is for you to edit.

"); 47 | 48 | // END-EXAMPLE: component.richtextarea.localization 49 | 50 | layout.addComponent(area); 51 | } 52 | 53 | } 54 | -------------------------------------------------------------------------------- /src/com/vaadin/book/examples/component/grid/MyButtonRenderer.java: -------------------------------------------------------------------------------- 1 | package com.vaadin.book.examples.component.grid; 2 | 3 | import com.vaadin.ui.renderers.ButtonRenderer; 4 | 5 | public class MyButtonRenderer extends ButtonRenderer { 6 | public MyButtonRenderer() { 7 | super(); 8 | } 9 | 10 | public MyButtonRenderer(RendererClickListener listener) { 11 | this(); 12 | addClickListener(listener); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /src/com/vaadin/book/examples/component/grid/TextFieldRenderer.java: -------------------------------------------------------------------------------- 1 | package com.vaadin.book.examples.component.grid; 2 | 3 | import com.vaadin.book.examples.client.widgetset.client.renderer.CellValueChangeRpc; 4 | import com.vaadin.data.Container; 5 | import com.vaadin.data.Property; 6 | import com.vaadin.ui.Grid; 7 | import com.vaadin.ui.Grid.AbstractRenderer; 8 | 9 | public class TextFieldRenderer extends AbstractRenderer { 10 | private static final long serialVersionUID = 1934095081875959877L; 11 | 12 | private CellValueChangeRpc rpc = new CellValueChangeRpc() { 13 | private static final long serialVersionUID = -3384499731721458101L; 14 | 15 | @Override 16 | public void changed(String newValue, String rowKey, String columnKey) { 17 | Object itemId = getItemId(rowKey); 18 | Object propertyId = getColumn(columnKey).getPropertyId(); 19 | Grid grid = getParentGrid(); 20 | Container container = grid.getContainerDataSource(); 21 | 22 | // Change the property value in the container 23 | @SuppressWarnings("unchecked") 24 | Property property = container.getContainerProperty(itemId, propertyId); 25 | property.setValue(newValue); 26 | } 27 | }; 28 | 29 | public TextFieldRenderer() { 30 | super(String.class, ""); 31 | 32 | registerRpc(rpc); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /src/com/vaadin/book/examples/component/properties/EnabledExample.java: -------------------------------------------------------------------------------- 1 | package com.vaadin.book.examples.component.properties; 2 | 3 | import com.vaadin.book.examples.BookExampleBundle; 4 | import com.vaadin.ui.Button; 5 | import com.vaadin.ui.CustomComponent; 6 | import com.vaadin.ui.HorizontalLayout; 7 | import com.vaadin.ui.TextField; 8 | 9 | public class EnabledExample extends CustomComponent implements BookExampleBundle { 10 | private static final long serialVersionUID = -4690921662019963336L; 11 | 12 | public void init (String context) { 13 | if ("simple".equals(context)) 14 | simple(); 15 | else if ("styling".equals(context)) 16 | styling(); 17 | } 18 | 19 | void simple() { 20 | HorizontalLayout layout = new HorizontalLayout(); 21 | 22 | // BEGIN-EXAMPLE: component.features.enabled.simple 23 | Button enabled = new Button("Enabled"); 24 | enabled.setEnabled(true); // The default 25 | layout.addComponent(enabled); 26 | 27 | Button disabled = new Button("Disabled"); 28 | disabled.setEnabled(false); 29 | layout.addComponent(disabled); 30 | // END-EXAMPLE: component.features.enabled.simple 31 | 32 | setCompositionRoot(layout); 33 | } 34 | 35 | void styling() { 36 | HorizontalLayout layout = new HorizontalLayout(); 37 | 38 | // BEGIN-EXAMPLE: component.features.enabled.styling 39 | TextField disabled = new TextField("Disabled"); 40 | disabled.setValue("Read-only value"); 41 | disabled.setEnabled(false); 42 | layout.addComponent(disabled); 43 | // END-EXAMPLE: component.features.enabled.styling 44 | 45 | setCompositionRoot(layout); 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /src/com/vaadin/book/examples/component/properties/IconExample.java: -------------------------------------------------------------------------------- 1 | package com.vaadin.book.examples.component.properties; 2 | 3 | import com.vaadin.book.examples.AnyBookExampleBundle; 4 | import com.vaadin.server.ThemeResource; 5 | import com.vaadin.ui.Alignment; 6 | import com.vaadin.ui.Button; 7 | import com.vaadin.ui.CustomComponent; 8 | import com.vaadin.ui.HorizontalLayout; 9 | import com.vaadin.ui.TextField; 10 | import com.vaadin.ui.VerticalLayout; 11 | 12 | public class IconExample extends CustomComponent implements AnyBookExampleBundle { 13 | private static final long serialVersionUID = -2576571397568672542L; 14 | 15 | public void basic (VerticalLayout vlayout) { 16 | HorizontalLayout layout = new HorizontalLayout(); 17 | layout.setSpacing(true); 18 | 19 | // BEGIN-EXAMPLE: component.features.icon.basic 20 | // Component with an icon from a custom theme 21 | TextField name = new TextField("Name"); 22 | name.setIcon(new ThemeResource("icons/user.png")); 23 | layout.addComponent(name); 24 | 25 | // Component with an icon from another theme ('runo') 26 | Button ok = new Button("OK"); 27 | ok.setIcon(new ThemeResource("../runo/icons/16/ok.png")); 28 | layout.addComponent(ok); 29 | // END-EXAMPLE: component.features.icon.basic 30 | 31 | layout.setComponentAlignment(ok, Alignment.BOTTOM_RIGHT); 32 | vlayout.addComponent(layout); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /src/com/vaadin/book/examples/datamodel/ContainerExample.java: -------------------------------------------------------------------------------- 1 | package com.vaadin.book.examples.datamodel; 2 | 3 | import com.vaadin.book.examples.BookExampleBundle; 4 | import com.vaadin.ui.CustomComponent; 5 | import com.vaadin.ui.VerticalLayout; 6 | 7 | public class ContainerExample extends CustomComponent implements BookExampleBundle { 8 | private static final long serialVersionUID = -6235574698344484522L; 9 | 10 | public void init (String context) { 11 | VerticalLayout layout = new VerticalLayout(); 12 | 13 | if ("basic".equals(context)) 14 | basic(layout); 15 | 16 | setCompositionRoot(layout); 17 | } 18 | 19 | void basic(final VerticalLayout layout) { 20 | // BEGIN-EXAMPLE: datamodel.items.basic 21 | // TODO 22 | // IndexedContainer container = new IndexedContainer(); 23 | // END-EXAMPLE: datamodel.items.basic 24 | 25 | // layout.addComponent(form); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/com/vaadin/book/examples/datamodel/FilesystemContainerExample.java: -------------------------------------------------------------------------------- 1 | package com.vaadin.book.examples.datamodel; 2 | 3 | import java.io.File; 4 | 5 | import com.vaadin.book.examples.BookExampleBundle; 6 | import com.vaadin.data.util.FilesystemContainer; 7 | import com.vaadin.server.VaadinService; 8 | import com.vaadin.ui.CustomComponent; 9 | import com.vaadin.ui.TreeTable; 10 | import com.vaadin.ui.VerticalLayout; 11 | 12 | public class FilesystemContainerExample extends CustomComponent implements BookExampleBundle { 13 | private static final long serialVersionUID = 6337856314788300891L; 14 | 15 | String context; 16 | 17 | public void init (String context) { 18 | this.context = context; 19 | } 20 | 21 | @Override 22 | public void attach() { 23 | VerticalLayout layout = new VerticalLayout(); 24 | 25 | if ("basic".equals(context)) 26 | basic(layout); 27 | 28 | setCompositionRoot(layout); 29 | } 30 | 31 | void basic(final VerticalLayout layout) { 32 | // BEGIN-EXAMPLE: datamodel.container.filesystemcontainer.basic 33 | // Find the root folder of the web application 34 | File folder = VaadinService.getCurrent().getBaseDirectory(); 35 | 36 | // Create the file system container 37 | FilesystemContainer container = new FilesystemContainer(folder); 38 | 39 | // Create a TreeTable bound to the container 40 | TreeTable treetable = new TreeTable("Here's my File System"); 41 | treetable.setContainerDataSource(container); 42 | 43 | // Set the row header icon by the file type 44 | treetable.setItemIconPropertyId("Icon"); 45 | 46 | // Do not show the Icon column 47 | treetable.setVisibleColumns(new Object[]{"Name", "Size", 48 | "Last Modified"}); 49 | // END-EXAMPLE: datamodel.container.filesystemcontainer.basic 50 | 51 | layout.addComponent(treetable); 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /src/com/vaadin/book/examples/editor/MyComponent2.java: -------------------------------------------------------------------------------- 1 | package com.vaadin.book.examples.editor; 2 | 3 | import com.vaadin.annotations.AutoGenerated; 4 | import com.vaadin.ui.AbsoluteLayout; 5 | import com.vaadin.ui.CustomComponent; 6 | import com.vaadin.ui.HorizontalLayout; 7 | 8 | public class MyComponent2 extends CustomComponent { 9 | 10 | /*- VaadinEditorProperties={"grid":"RegularGrid,20","showGrid":true,"snapToGrid":true,"snapToObject":true,"movingGuides":false,"snappingDistance":10} */ 11 | 12 | @AutoGenerated 13 | private AbsoluteLayout mainLayout; 14 | @AutoGenerated 15 | private HorizontalLayout horizontalLayout_1; 16 | /** 17 | * The constructor should first build the main layout, set the 18 | * composition root and then do any custom initialization. 19 | * 20 | * The constructor will not be automatically regenerated by the 21 | * visual editor. 22 | */ 23 | public MyComponent2() { 24 | buildMainLayout(); 25 | setCompositionRoot(mainLayout); 26 | 27 | // TODO add user code here 28 | } 29 | 30 | @AutoGenerated 31 | private AbsoluteLayout buildMainLayout() { 32 | // common part: create layout 33 | mainLayout = new AbsoluteLayout(); 34 | mainLayout.setImmediate(false); 35 | mainLayout.setWidth("100%"); 36 | mainLayout.setHeight("100%"); 37 | 38 | // top-level component properties 39 | setWidth("100.0%"); 40 | setHeight("100.0%"); 41 | 42 | // horizontalLayout_1 43 | horizontalLayout_1 = new HorizontalLayout(); 44 | horizontalLayout_1.setImmediate(false); 45 | horizontalLayout_1.setWidth("200px"); 46 | horizontalLayout_1.setHeight("200px"); 47 | horizontalLayout_1.setMargin(false); 48 | mainLayout.addComponent(horizontalLayout_1, "top:80.0px;left:180.0px;"); 49 | 50 | return mainLayout; 51 | } 52 | 53 | } 54 | -------------------------------------------------------------------------------- /src/com/vaadin/book/examples/gettingstarted/MyScalaUI.scala: -------------------------------------------------------------------------------- 1 | package com.vaadin.book.examples.gettingstarted 2 | 3 | // BEGIN-EXAMPLE: gettingstarted.scala 4 | import java.util.Date 5 | 6 | import com.vaadin.annotations.Theme 7 | import com.vaadin.server.VaadinRequest 8 | import com.vaadin.ui.Button 9 | import com.vaadin.ui.Button.ClickEvent 10 | import com.vaadin.ui.Button.ClickListener 11 | import com.vaadin.ui.Label 12 | import com.vaadin.ui.Notification 13 | import com.vaadin.ui.UI 14 | import com.vaadin.ui.VerticalLayout 15 | 16 | @Theme("book-examples") 17 | class MyScalaUI extends UI { 18 | // Enable implicit conversion from a lambda expression to a listener 19 | implicit def clickListener(f: ClickEvent => Unit) = 20 | new ClickListener { 21 | override def buttonClick(event: ClickEvent) { 22 | f(event) 23 | } 24 | } 25 | 26 | override def init(request: VaadinRequest) = { 27 | val content: VerticalLayout = new VerticalLayout 28 | setContent(content) 29 | 30 | val label: Label = new Label("Hello, world!") 31 | content addComponent label 32 | 33 | // Handle user interaction 34 | content addComponent new Button("Click Me!", 35 | new ClickListener { 36 | override def buttonClick(event: ClickEvent) = 37 | Notification.show("The time is " + new Date) 38 | }) 39 | } 40 | } 41 | // END-EXAMPLE: gettingstarted.scala 42 | -------------------------------------------------------------------------------- /src/com/vaadin/book/examples/gettingstarted/MyprojectUI.java: -------------------------------------------------------------------------------- 1 | package com.vaadin.book.examples.gettingstarted; 2 | 3 | // BEGIN-EXAMPLE: gettingstarted.firstproject.newproject 4 | import javax.servlet.annotation.WebServlet; 5 | 6 | import com.vaadin.annotations.Theme; 7 | import com.vaadin.annotations.VaadinServletConfiguration; 8 | import com.vaadin.server.VaadinRequest; 9 | import com.vaadin.server.VaadinServlet; 10 | import com.vaadin.ui.Button; 11 | import com.vaadin.ui.Button.ClickEvent; 12 | import com.vaadin.ui.Label; 13 | import com.vaadin.ui.UI; 14 | import com.vaadin.ui.VerticalLayout; 15 | 16 | @SuppressWarnings("serial") 17 | @Theme("myproject") 18 | public class MyprojectUI extends UI { 19 | 20 | @WebServlet(value = "/newproject/*", 21 | asyncSupported = true) 22 | @VaadinServletConfiguration( 23 | productionMode = false, 24 | ui = MyprojectUI.class) 25 | public static class Servlet extends VaadinServlet { 26 | } 27 | 28 | @Override 29 | protected void init(VaadinRequest request) { 30 | final VerticalLayout layout = new VerticalLayout(); 31 | layout.setMargin(true); 32 | setContent(layout); 33 | 34 | Button button = new Button("Click Me"); 35 | button.addClickListener(new Button.ClickListener() { 36 | public void buttonClick(ClickEvent event) { 37 | layout.addComponent(new Label("Thank you for clicking")); 38 | } 39 | }); 40 | layout.addComponent(button); 41 | } 42 | 43 | } 44 | // END-EXAMPLE: gettingstarted.firstproject.newproject 45 | 46 | -------------------------------------------------------------------------------- /src/com/vaadin/book/examples/gettingstarted/NewProjectExample.java: -------------------------------------------------------------------------------- 1 | package com.vaadin.book.examples.gettingstarted; 2 | 3 | import com.vaadin.book.BookExamplesUI; 4 | import com.vaadin.book.examples.BookExampleBundle; 5 | import com.vaadin.server.ExternalResource; 6 | import com.vaadin.ui.BrowserFrame; 7 | import com.vaadin.ui.CustomComponent; 8 | import com.vaadin.ui.Label; 9 | import com.vaadin.ui.Layout; 10 | import com.vaadin.ui.VerticalLayout; 11 | 12 | public class NewProjectExample extends CustomComponent implements BookExampleBundle { 13 | private static final long serialVersionUID = -4292553844521293140L; 14 | 15 | public void init(String context) { 16 | VerticalLayout layout = new VerticalLayout(); 17 | 18 | if ("newproject".equals(context)) 19 | newproject(layout); 20 | else if ("scala".equals(context)) 21 | scalaui(layout); 22 | else 23 | layout.addComponent(new Label("Invalid context: " + context)); 24 | 25 | setCompositionRoot(layout); 26 | } 27 | 28 | public static final String helloworldDescription = 29 | "

Hello World

" + 30 | ""; 31 | 32 | // EXAMPLE-REF: gettingstarted.firstproject.newproject com.vaadin.book.examples.gettingstarted.MyprojectUI gettingstarted.firstproject.newproject 33 | void newproject(Layout layout) { 34 | BrowserFrame embedded = new BrowserFrame(); 35 | embedded.setSource(new ExternalResource(BookExamplesUI.APPCONTEXT + "/newproject?restartApplication")); 36 | embedded.setWidth("400px"); 37 | embedded.setHeight("200px"); 38 | layout.addComponent(embedded); 39 | } 40 | 41 | // EXAMPLE-REF: gettingstarted.scala com.vaadin.book.examples.gettingstarted.MyScalaUI gettingstarted.scala 42 | void scalaui(Layout layout) { 43 | BrowserFrame embedded = new BrowserFrame(); 44 | embedded.setSource(new ExternalResource(BookExamplesUI.APPCONTEXT + "/scalaproject?restartApplication")); 45 | embedded.setWidth("400px"); 46 | embedded.setHeight("200px"); 47 | layout.addComponent(embedded); 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /src/com/vaadin/book/examples/intro/HelloWorldExample.java: -------------------------------------------------------------------------------- 1 | package com.vaadin.book.examples.intro; 2 | 3 | import com.vaadin.book.BookExamplesUI; 4 | import com.vaadin.book.examples.BookExampleBundle; 5 | import com.vaadin.server.ExternalResource; 6 | import com.vaadin.ui.CustomComponent; 7 | import com.vaadin.ui.Embedded; 8 | import com.vaadin.ui.VerticalLayout; 9 | 10 | public class HelloWorldExample extends CustomComponent implements BookExampleBundle { 11 | private static final long serialVersionUID = -4292553844521293140L; 12 | 13 | public static final String helloworldDescription = 14 | "

Hello World

" + 15 | "

You make a basic Vaadin application by extending the UI component and implementing the init() method.

" + 16 | "
    " + 17 | "
  • The caption of the root component is usually shown in title bar of the browser window or as the caption of the tab.
  • " + 18 | "
  • The user interface is built by adding components to the root component.
  • " + 19 | "
"; 20 | 21 | public void init(String context) { 22 | VerticalLayout layout = new VerticalLayout(); 23 | 24 | Embedded embedded = new Embedded(); 25 | embedded.setSource(new ExternalResource(BookExamplesUI.APPCONTEXT + "/helloworld?restartApplication")); 26 | embedded.setType(Embedded.TYPE_BROWSER); 27 | embedded.setWidth("200px"); 28 | embedded.setHeight("100px"); 29 | layout.addComponent(embedded); 30 | 31 | setCompositionRoot(layout); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /src/com/vaadin/book/examples/layout/FormLayoutExample.java: -------------------------------------------------------------------------------- 1 | package com.vaadin.book.examples.layout; 2 | 3 | import com.vaadin.book.examples.AnyBookExampleBundle; 4 | import com.vaadin.data.validator.IntegerRangeValidator; 5 | import com.vaadin.data.validator.NullValidator; 6 | import com.vaadin.server.FontAwesome; 7 | import com.vaadin.ui.CustomComponent; 8 | import com.vaadin.ui.FormLayout; 9 | import com.vaadin.ui.TextField; 10 | import com.vaadin.ui.VerticalLayout; 11 | 12 | public class FormLayoutExample extends CustomComponent implements AnyBookExampleBundle { 13 | private static final long serialVersionUID = 5602882631420102318L; 14 | 15 | public void basic(VerticalLayout layout) { 16 | // BEGIN-EXAMPLE: layout.formlayout.basic 17 | // BOOK: layout.components.orderedlayout 18 | FormLayout form = new FormLayout(); 19 | TextField tf1 = new TextField("Name"); 20 | tf1.setIcon(FontAwesome.USER); 21 | tf1.setRequired(true); 22 | tf1.addValidator(new NullValidator("Must be given", false)); 23 | form.addComponent(tf1); 24 | 25 | TextField tf2 = new TextField("Street address"); 26 | tf2.setIcon(FontAwesome.ROAD); 27 | form.addComponent(tf2); 28 | 29 | TextField tf3 = new TextField("Postal code"); 30 | tf3.setIcon(FontAwesome.ENVELOPE); 31 | tf3.addValidator(new IntegerRangeValidator("Doh!", 1, 99999)); 32 | form.addComponent(tf3); 33 | // END-EXAMPLE: layout.formlayout.basic 34 | layout.addComponent(form); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /src/com/vaadin/book/examples/layout/MarginExample.java: -------------------------------------------------------------------------------- 1 | package com.vaadin.book.examples.layout; 2 | 3 | import com.vaadin.book.examples.BookExampleBundle; 4 | import com.vaadin.shared.ui.MarginInfo; 5 | import com.vaadin.ui.CustomComponent; 6 | import com.vaadin.ui.Label; 7 | import com.vaadin.ui.VerticalLayout; 8 | 9 | public class MarginExample extends CustomComponent implements BookExampleBundle { 10 | private static final long serialVersionUID = 4598073828719119575L; 11 | 12 | public void init (String context) { 13 | // BEGIN-EXAMPLE: layout.formatting.margin 14 | // A layout with a margin 15 | VerticalLayout layout = new VerticalLayout(); 16 | layout.addStyleName("mymargins"); 17 | layout.setMargin(true); 18 | layout.setMargin(new MarginInfo(false, true, false, true)); 19 | 20 | // A component inside the layout 21 | Label label = new Label("My Label with Margins"); 22 | layout.addComponent(label); 23 | 24 | layout.setSizeUndefined(); 25 | setSizeUndefined(); 26 | setCompositionRoot(layout); 27 | // END-EXAMPLE: layout.formatting.margin 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/com/vaadin/book/examples/layout/WindowExample.java: -------------------------------------------------------------------------------- 1 | package com.vaadin.book.examples.layout; 2 | 3 | import com.vaadin.book.examples.BookExampleBundle; 4 | import com.vaadin.ui.CustomComponent; 5 | import com.vaadin.ui.FormLayout; 6 | import com.vaadin.ui.Label; 7 | import com.vaadin.ui.VerticalLayout; 8 | 9 | public class WindowExample extends CustomComponent implements BookExampleBundle { 10 | private static final long serialVersionUID = 3321998143334619838L; 11 | 12 | String context; 13 | 14 | public void init(String context) { 15 | this.context = context; 16 | } 17 | 18 | public void attach() { 19 | VerticalLayout layout = new VerticalLayout(); 20 | 21 | if ("mainwindowsize".equals(context)) 22 | mainwindowsize(layout); 23 | else 24 | setCompositionRoot(new Label("Error")); 25 | 26 | setCompositionRoot(layout); 27 | } 28 | 29 | void mainwindowsize(VerticalLayout root) { 30 | // BEGIN-EXAMPLE: layout.window.mainwindowsize 31 | FormLayout layout = new FormLayout(); 32 | 33 | Label height = new Label("" + getUI().getPage().getBrowserWindowHeight()); 34 | height.setCaption("Height:"); 35 | layout.addComponent(height); 36 | 37 | Label width = new Label("" + getUI().getPage().getBrowserWindowWidth()); 38 | width.setCaption("Width:"); 39 | layout.addComponent(width); 40 | // END-EXAMPLE: layout.window.mainwindowsize 41 | 42 | root.addComponent(layout); 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /src/com/vaadin/book/examples/portlet/Person.java: -------------------------------------------------------------------------------- 1 | package com.vaadin.book.examples.portlet; 2 | 3 | import java.io.Serializable; 4 | 5 | public class Person implements Serializable { 6 | private static final long serialVersionUID = -4100598417936367677L; 7 | 8 | String name; 9 | int age; 10 | 11 | public String getName() { 12 | return name; 13 | } 14 | public void setName(String name) { 15 | this.name = name; 16 | } 17 | public int getAge() { 18 | return age; 19 | } 20 | public void setAge(int age) { 21 | this.age = age; 22 | } 23 | } -------------------------------------------------------------------------------- /src/com/vaadin/book/examples/themes/ScssThemeExample.java: -------------------------------------------------------------------------------- 1 | package com.vaadin.book.examples.themes; 2 | 3 | import com.vaadin.book.BookExamplesUI; 4 | import com.vaadin.book.examples.BookExampleBundle; 5 | import com.vaadin.server.ExternalResource; 6 | import com.vaadin.ui.BrowserFrame; 7 | import com.vaadin.ui.CustomComponent; 8 | import com.vaadin.ui.Label; 9 | import com.vaadin.ui.VerticalLayout; 10 | 11 | public class ScssThemeExample extends CustomComponent implements 12 | BookExampleBundle { 13 | private static final long serialVersionUID = -4292553844521293140L; 14 | 15 | public static final String basicDescription = "

SCSS Themes

" + "

You can write a theme using SCSS instead of CSS simply by having a " + "styles.scss instead of styles.css file in the theme folder.

"; 16 | 17 | public void init(String context) { 18 | VerticalLayout layout = new VerticalLayout(); 19 | 20 | if ("basic".equals(context)) 21 | basic(layout); 22 | else layout.addComponent(new Label("Invalid context " + context)); 23 | 24 | setCompositionRoot(layout); 25 | } 26 | 27 | // EXAMPLE-REF: themes.scss.basic com.vaadin.book.examples.themes.ScssThemeUI themes.scss.basic 28 | // EXAMPLE-APPFILE: themes.scss.basic VAADIN/themes/mytheme/styles.scss 29 | void basic(VerticalLayout layout) { 30 | BrowserFrame browser = new BrowserFrame(); 31 | browser.setSource(new ExternalResource(BookExamplesUI.APPCONTEXT + "/scsstheme?restartApplication")); 32 | browser.setWidth("300px"); 33 | browser.setHeight("150px"); 34 | layout.addComponent(browser); 35 | 36 | setCompositionRoot(layout); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /src/com/vaadin/book/examples/themes/ScssThemeUI.java: -------------------------------------------------------------------------------- 1 | package com.vaadin.book.examples.themes; 2 | 3 | import com.vaadin.annotations.Theme; 4 | import com.vaadin.server.VaadinRequest; 5 | import com.vaadin.ui.Button; 6 | import com.vaadin.ui.Label; 7 | import com.vaadin.ui.UI; 8 | import com.vaadin.ui.VerticalLayout; 9 | 10 | //BEGIN-EXAMPLE: themes.scss.basic 11 | @Theme("mytheme") 12 | public class ScssThemeUI extends UI { 13 | private static final long serialVersionUID = 511085335415683713L; 14 | 15 | @Override 16 | protected void init(VaadinRequest request) { 17 | // Set the window or tab title 18 | getPage().setTitle("Window with My Theme"); 19 | 20 | // Create the content root layout for the UI 21 | VerticalLayout content = new VerticalLayout(); 22 | setContent(content); 23 | 24 | content.addComponent(new Label("This is my theme!")); 25 | 26 | Button button = new Button("Stylish Button"); 27 | button.addStyleName("mybutton"); 28 | content.addComponent(button); 29 | } 30 | } 31 | // END-EXAMPLE: themes.scss.basic 32 | -------------------------------------------------------------------------------- /src/com/vaadin/book/examples/themes/ThemeExample.java: -------------------------------------------------------------------------------- 1 | package com.vaadin.book.examples.themes; 2 | 3 | import com.vaadin.book.BookExamplesUI; 4 | import com.vaadin.book.examples.AnyBookExampleBundle; 5 | import com.vaadin.server.ExternalResource; 6 | import com.vaadin.ui.BrowserFrame; 7 | import com.vaadin.ui.VerticalLayout; 8 | 9 | public class ThemeExample implements AnyBookExampleBundle { 10 | private static final long serialVersionUID = -4292553844521293140L; 11 | 12 | // EXAMPLE-REF: themes.using.default.valo com.vaadin.book.examples.themes.ValoThemeUI themes.using.default.valo 13 | // EXAMPLE-APPFILE: themes.using.default.valo VAADIN/themes/myvalotheme/styles.scss 14 | // EXAMPLE-APPFILE: themes.using.default.valo VAADIN/themes/myvalotheme/myvalotheme.scss 15 | public void valo(VerticalLayout layout) { 16 | BrowserFrame browser = new BrowserFrame(); 17 | browser.setSource(new ExternalResource(BookExamplesUI.APPCONTEXT + "/myvalothemeui?restartApplication")); 18 | browser.setWidth("800px"); 19 | browser.setHeight("600px"); 20 | layout.addComponent(browser); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/com/vaadin/book/ui/TreeMenu.java: -------------------------------------------------------------------------------- 1 | package com.vaadin.book.ui; 2 | 3 | import com.vaadin.server.ThemeResource; 4 | import com.vaadin.ui.Image; 5 | import com.vaadin.ui.Label; 6 | import com.vaadin.ui.Layout; 7 | import com.vaadin.ui.Panel; 8 | import com.vaadin.ui.VerticalLayout; 9 | import com.vaadin.ui.themes.Reindeer; 10 | 11 | /** 12 | * The old plain and simple tree menu. This will be replaced later. 13 | * 14 | * @author magi 15 | */ 16 | public class TreeMenu extends AbstractExampleMenu { 17 | private static final long serialVersionUID = -5810026236836035167L; 18 | 19 | public TreeMenu(Layout viewLayout, Label exampleTitle) { 20 | super(viewLayout, exampleTitle); 21 | 22 | addStyleName("examplemenu"); 23 | setWidth("400px"); 24 | setHeight("100%"); 25 | 26 | VerticalLayout content = new VerticalLayout(); 27 | content.setSizeFull(); 28 | 29 | Image logo = new Image(null, new ThemeResource("img/vaadin-logo.png")); 30 | logo.addStyleName("vaadinlogo"); 31 | content.addComponent(logo); 32 | 33 | Panel scrollpanel = new Panel("Table of Contents"); 34 | scrollpanel.setSizeFull(); 35 | scrollpanel.addStyleName(Reindeer.PANEL_LIGHT); 36 | scrollpanel.addStyleName("menupanel"); 37 | scrollpanel.addStyleName("scrollmenu"); 38 | 39 | scrollpanel.setContent(menu); 40 | 41 | content.addComponent(scrollpanel); 42 | content.setExpandRatio(scrollpanel, 1.0f); 43 | 44 | setCompositionRoot(content); 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /src/com/vaadin/book/widgetset/BookExamplesWidgetSet.gwt.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 33 | 34 | -------------------------------------------------------------------------------- /tests/com/vaadin/book/examples/BookExampleTestcase.java: -------------------------------------------------------------------------------- 1 | package com.vaadin.book.examples; 2 | 3 | import org.junit.After; 4 | import org.junit.Before; 5 | import org.junit.Rule; 6 | import org.openqa.selenium.By; 7 | import org.openqa.selenium.WebElement; 8 | import org.openqa.selenium.firefox.FirefoxDriver; 9 | 10 | import com.vaadin.testbench.ElementQuery; 11 | import com.vaadin.testbench.ScreenshotOnFailureRule; 12 | import com.vaadin.testbench.TestBench; 13 | import com.vaadin.testbench.TestBenchTestCase; 14 | import com.vaadin.testbench.elementsbase.AbstractElement; 15 | 16 | // @RunOnHub("localhost") 17 | public class BookExampleTestcase extends TestBenchTestCase { 18 | protected String baseUrl; 19 | 20 | @Rule 21 | public ScreenshotOnFailureRule screenshotOnFailureRule = new ScreenshotOnFailureRule(this, true); 22 | 23 | @Before 24 | public void setUp() throws Exception { 25 | setDriver(TestBench.createDriver(new FirefoxDriver())); 26 | baseUrl = "http://localhost:8080/book-examples-vaadin7/book"; 27 | } 28 | 29 | public void startTest(String urifragment) { 30 | getDriver().get(concatUrl(baseUrl, "#" + urifragment)); 31 | } 32 | 33 | public ElementQuery inExample(Class clazz) { 34 | WebElement example = findElement(By.className("bookexample")); 35 | 36 | return super.$(clazz).context(example); 37 | } 38 | 39 | @After 40 | public void tearDown() throws Exception { 41 | // TODO Can't call quit anymore because it causes odd exceptions 42 | // driver.quit(); 43 | } 44 | 45 | /* 46 | @BrowserConfiguration 47 | public List getBrowserConfiguration() { 48 | List browsers = 49 | new ArrayList(); 50 | 51 | // Add all the browsers you want to test 52 | browsers.add(BrowserUtil.firefox()); 53 | browsers.add(BrowserUtil.chrome()); 54 | 55 | return browsers; 56 | } */ 57 | } 58 | -------------------------------------------------------------------------------- /tests/com/vaadin/book/examples/ForExample.java: -------------------------------------------------------------------------------- 1 | package com.vaadin.book.examples; 2 | 3 | import java.lang.annotation.ElementType; 4 | import java.lang.annotation.Retention; 5 | import java.lang.annotation.RetentionPolicy; 6 | import java.lang.annotation.Target; 7 | 8 | @Retention(RetentionPolicy.RUNTIME) 9 | @Target({ElementType.TYPE}) 10 | public @interface ForExample { 11 | Class value(); 12 | } 13 | -------------------------------------------------------------------------------- /tests/com/vaadin/book/examples/application/NotificationTest.java: -------------------------------------------------------------------------------- 1 | package com.vaadin.book.examples.application; 2 | 3 | import static org.junit.Assert.assertEquals; 4 | 5 | import org.junit.Test; 6 | 7 | import com.vaadin.book.examples.BookExampleTestcase; 8 | import com.vaadin.testbench.elements.ButtonElement; 9 | import com.vaadin.testbench.elements.NotificationElement; 10 | 11 | // @ForExample(com.vaadin.book.examples.application.NotificationExample.class) 12 | public class NotificationTest extends BookExampleTestcase { 13 | @Test 14 | public void shorthand() throws Exception { 15 | startTest("application.errors.notification.shorthand"); 16 | 17 | inExample(ButtonElement.class).caption("Be Bad").first().click(); 18 | 19 | // Verify the notification 20 | NotificationElement notification = $(NotificationElement.class).first(); 21 | assertEquals("This is the caption", notification.getCaption()); 22 | assertEquals("This is the description", notification.getDescription()); 23 | assertEquals("warning", notification.getType()); 24 | notification.close(); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /tests/com/vaadin/book/examples/component/ButtonTest.java: -------------------------------------------------------------------------------- 1 | package com.vaadin.book.examples.component; 2 | 3 | import static org.junit.Assert.assertEquals; 4 | 5 | import org.junit.Test; 6 | 7 | import com.vaadin.book.examples.BookExampleTestcase; 8 | import com.vaadin.book.examples.Description; 9 | import com.vaadin.testbench.elements.ButtonElement; 10 | import com.vaadin.testbench.elements.NotificationElement; 11 | 12 | // @ForExample(com.vaadin.book.examples.component.ButtonExample.class) 13 | public class ButtonTest extends BookExampleTestcase { 14 | @Test 15 | public void basic() throws Exception { 16 | startTest("component.button.basic"); 17 | 18 | ButtonElement button = inExample(ButtonElement.class).caption("Do not press this button").first(); 19 | button.click(); 20 | 21 | // Verify the notification 22 | NotificationElement notification = $(NotificationElement.class).first(); 23 | assertEquals("Do not press this button again", notification.getCaption()); 24 | notification.close(); 25 | } 26 | 27 | @Test 28 | public void link() throws Exception { 29 | startTest("component.button.link"); 30 | 31 | ButtonElement button = inExample(ButtonElement.class).caption("Click Me!").first(); 32 | button.click(); 33 | 34 | // Verify the notification 35 | NotificationElement notification = $(NotificationElement.class).first(); 36 | assertEquals("Thank You!", notification.getText()); 37 | notification.close(); 38 | } 39 | 40 | @Test 41 | public void small() throws Exception { 42 | startTest("component.button.small"); 43 | 44 | // Just find the button, clicking doesn't do anything 45 | ButtonElement button = inExample(ButtonElement.class).caption("Click Me!").first(); 46 | button.click(); 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /tests/com/vaadin/book/examples/component/PasswordFieldTest.java: -------------------------------------------------------------------------------- 1 | package com.vaadin.book.examples.component; 2 | 3 | import static org.junit.Assert.assertEquals; 4 | 5 | import org.junit.Test; 6 | 7 | import com.vaadin.book.examples.BookExampleTestcase; 8 | import com.vaadin.book.examples.Description; 9 | import com.vaadin.testbench.elements.ButtonElement; 10 | import com.vaadin.testbench.elements.LabelElement; 11 | import com.vaadin.testbench.elements.PasswordFieldElement; 12 | 13 | // @ForExample(com.vaadin.book.examples.component.PasswordFieldExample.class) 14 | public class PasswordFieldTest extends BookExampleTestcase { 15 | @Test 16 | public void basic() throws Exception { 17 | startTest("component.passwordfield.basic"); 18 | 19 | PasswordFieldElement pwf = inExample(PasswordFieldElement.class).caption("Keep it secret").first(); 20 | pwf.sendKeys("mypassword123"); 21 | assertEquals("mypassword123", pwf.getAttribute("value")); 22 | 23 | ButtonElement okbutton = inExample(ButtonElement.class).caption("OK").first(); 24 | okbutton.click(); 25 | 26 | // Verify the UI changes after button action finishes 27 | LabelElement output = inExample(LabelElement.class).first(); 28 | assertEquals("Secret: mypassword123", output.getText()); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /tests/com/vaadin/book/examples/component/properties/DescriptionTest.java: -------------------------------------------------------------------------------- 1 | package com.vaadin.book.examples.component.properties; 2 | 3 | import static org.junit.Assert.assertEquals; 4 | 5 | import org.junit.Test; 6 | import org.openqa.selenium.By; 7 | import org.openqa.selenium.WebElement; 8 | 9 | import com.vaadin.book.examples.BookExampleTestcase; 10 | import com.vaadin.book.examples.Description; 11 | import com.vaadin.testbench.elements.ButtonElement; 12 | 13 | // @ForExample(com.vaadin.book.examples.component.properties.DescriptionExample.class) 14 | public class DescriptionTest extends BookExampleTestcase { 15 | @Test 16 | public void plain() throws Exception { 17 | startTest("component.features.description.plain"); 18 | 19 | // This button has a tooltip 20 | ButtonElement button = $(ButtonElement.class).caption("A Button").first(); 21 | 22 | // Show it 23 | button.showTooltip(); 24 | 25 | // It's a floating element, so need to search from entire page 26 | WebElement ttip = findElement(By.className("v-tooltip")); 27 | assertEquals(ttip.getText(), "This is the tooltip"); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /tests/com/vaadin/book/examples/layout/PanelTest.java: -------------------------------------------------------------------------------- 1 | package com.vaadin.book.examples.layout; 2 | 3 | import static org.junit.Assert.assertEquals; 4 | 5 | import org.junit.Test; 6 | 7 | import com.vaadin.book.examples.BookExampleTestcase; 8 | import com.vaadin.book.examples.Description; 9 | import com.vaadin.testbench.elements.ButtonElement; 10 | import com.vaadin.testbench.elements.NotificationElement; 11 | import com.vaadin.testbench.elements.PanelElement; 12 | 13 | // @ForExample(com.vaadin.book.examples.layout.PanelExample.class) 14 | public class PanelTest extends BookExampleTestcase { 15 | @Test 16 | public void scroll() throws Exception { 17 | startTest("layout.panel.scroll"); 18 | 19 | // Scroll to some position 20 | PanelElement panel = inExample(PanelElement.class) 21 | .caption("Scrolling Panel").first(); 22 | panel.scroll(123); 23 | 24 | // Verify that scrolled to correct position 25 | inExample(ButtonElement.class).caption("Scroll Position").first().click(); 26 | NotificationElement notification = $(NotificationElement.class).first(); 27 | assertEquals("Scroll position: 123", notification.getCaption()); 28 | notification.close(); 29 | 30 | // Click the manual scroll button 31 | inExample(ButtonElement.class).caption("Scroll Down").first().click(); 32 | 33 | inExample(ButtonElement.class).caption("Scroll Position").first().click(); 34 | notification = $(NotificationElement.class).first(); 35 | assertEquals("Scroll position: 223", notification.getCaption()); 36 | notification.close(); 37 | } 38 | } 39 | --------------------------------------------------------------------------------