You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

gwt-eclipse.asciidoc 6.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  1. ---
  2. title: Starting It Simple With Eclipse
  3. order: 2
  4. layout: page
  5. ---
  6. [[gwt.eclipse]]
  7. = Starting It Simple With Eclipse
  8. ((("Eclipse", "widget development", id="term.gwt.eclipse", range="startofrange")))
  9. Let us first take the easy way and create a simple component with Eclipse. While
  10. you can develop new widgets with any IDE or even without, you may find Eclipse
  11. and the Vaadin Plugin for it useful, as it automates all the basic routines of
  12. widget development, most importantly the creation of new widgets.
  13. [[gwt.eclipse.widget]]
  14. == Creating a Widget
  15. . Right-click the project in the Project Explorer and select "New > Other...".
  16. . In the wizard selection, select "Vaadin > Vaadin Widget" and click
  17. [guibutton]#Next#.
  18. ifdef::web[]
  19. +
  20. image::img/widget-new-select.png[]
  21. endif::web[]
  22. . In the [guilabel]#New Component Wizard#, make the following settings.
  23. +
  24. image::img/widget-new-settings.png[]
  25. [guilabel]#Source folder#:: The root folder of the entire source tree. The default value is the default
  26. source tree of your project, and you should normally leave it unchanged unless
  27. you have a different project structure.
  28. [guilabel]#Package#:: The parent package under which the new server-side component should be created.
  29. If the project does not already have a widget set, one is created under this
  30. package in the [package]#widgetset# subpackage. The subpackage will contain the
  31. [filename]#.gwt.xml# descriptor that defines the widget set and the new widget
  32. stub under the [package]#widgetset.client# subpackage.
  33. [guilabel]#Name#:: The class name of the new __server-side component__. The name of the client-side
  34. widget stub will be the same but with "- [classname]#Widget#" suffix, for
  35. example, [classname]#MyComponentWidget#. You can rename the classes afterwards.
  36. [guilabel]#Superclass#:: The superclass of the server-side component. It is
  37. [classname]#AbstractComponent# by default, but
  38. [classname]#com.vaadin.ui.AbstractField# or
  39. [classname]#com.vaadin.ui.AbstractSelect# are other commonly used superclasses.
  40. If you are extending an existing component, you should select it as the
  41. superclass. You can easily change the superclass later.
  42. [guilabel]#Template#:: Select which template to use. The default is [guilabel]#Full fledged#, which
  43. creates the server-side component, the client-side widget, the connector, a
  44. shared state object, and an RPC object. The [guilabel]#Connector only# leaves
  45. the shared state and RPC objects out.
  46. +
  47. Finally, click [guibutton]#Finish# to create the new component.
  48. The wizard will:
  49. * Create a server-side component stub in the base package
  50. * If the project does not already have a widget set, the wizard creates a GWT
  51. module descriptor file ( [filename]#.gwt.xml#) in the base package and modifies
  52. the servlet class or the [filename]#web.xml# deployment descriptor to specify
  53. the widget set class name parameter for the application
  54. * Create a client-side widget stub (along with the connector and shared state and
  55. RPC stubs) in the [filename]#client.componentname# package under the base
  56. package
  57. The structure of the server-side component and the client-side widget, and the
  58. serialization of component state between them, is explained in the subsequent
  59. sections of this chapter.
  60. To compile the widget set, click the [guibutton]#Compile widget set# button in
  61. the Eclipse toolbar. See <<gwt.eclipse.compiling>> for details. After the
  62. compilation finishes, you should be able to run your application as before, but
  63. using the new widget set. The compilation result is written under the
  64. [filename]#WebContent/VAADIN/widgetsets# folder. When you need to recompile the
  65. widget set in Eclipse, see <<gwt.eclipse.compiling>>. For detailed information
  66. on compiling widget sets, see
  67. <<../clientside/clientside-compiling#clientside.compiling,"Compiling
  68. a Client-Side Module">>.
  69. The following setting is inserted in the [filename]#web.xml# deployment
  70. descriptor to enable the widget set:
  71. [subs="normal"]
  72. ----
  73. &lt;init-param&gt;
  74. &lt;description&gt;Application widgetset&lt;/description&gt;
  75. &lt;param-name&gt;widgetset&lt;/param-name&gt;
  76. &lt;param-value&gt;__com.example.myproject.widgetset.MyprojectApplicationWidgetset__&lt;/param-value&gt;
  77. &lt;/init-param&gt;
  78. ----
  79. You can refactor the package structure if you find need for it, but GWT compiler
  80. requires that the client-side code __must__ always be stored under a package
  81. named " [filename]#client#" or a package defined with a [literal]#++source++#
  82. element in the widget set descriptor.
  83. [[gwt.eclipse.compiling]]
  84. == Compiling the Widget Set
  85. After you edit a widget, you need to compile the widget set. The Vaadin Plugin
  86. for Eclipse automatically suggests to compile the widget set in various
  87. situations, such as when you save a client-side source file. If this gets
  88. annoying, you can disable the automatic recompilation in the Vaadin category in
  89. project settings, by selecting the [guilabel]#Suspend automatic widgetset
  90. builds# option.
  91. You can compile the widget set manually by clicking the [guibutton]#Compile
  92. widgetset# button in the Eclipse toolbar, shown in
  93. <<figure.gwt.eclipse.compiling.toolbar>>, while the project is open and
  94. selected. If the project has multiple widget set definition files, you need to
  95. select the one to compile in the Project Explorer.
  96. [[figure.gwt.eclipse.compiling.toolbar]]
  97. .The [guibutton]#Compile Widgetset# Button in Eclipse Toolbar
  98. image::img/widgetset-compiling-toolbar-hi.png[]
  99. The compilation progress is shown in the [guilabel]#Console# panel in Eclipse,
  100. illustrated in <<figure.gwt.eclipse.compiling>>. You should note especially the
  101. list of widget sets found in the class path.
  102. [[figure.gwt.eclipse.compiling]]
  103. .Compiling a Widget Set
  104. image::img/widgetset-compiling.png[]
  105. The compilation output is written under the
  106. [filename]#WebContent/VAADIN/widgetsets# folder, in a widget set specific
  107. folder.
  108. You can speed up the compilation significantly by compiling the widget set only
  109. for your browser during development. The generated [filename]#.gwt.xml#
  110. descriptor stub includes a disabled element that specifies the target browser.
  111. See
  112. <<../clientside/clientside-module#gwt.module.compilation-limiting,"Limiting
  113. Compilation Targets">> for more details on setting the [literal]#++user-agent++#
  114. property.
  115. For more information on compiling widget sets, see
  116. <<../clientside/clientside-compiling#clientside.compiling,"Compiling
  117. a Client-Side Module">>. Should you compile a widget set outside Eclipse, you
  118. need to refresh the project by selecting it in [guilabel]#Project Explorer# and
  119. pressing F5.
  120. (((range="endofrange", startref="term.gwt.eclipse")))