The Drag-and-Drop Module
The drag-and-drop application and its associated files and directories are shown in Figure 6.4.
Figure 6.4 The drag-and-drop application's files and directories
The application is made up primarily of five things: Java source files; images; a CSS file; a configuration file; and an HTML page. In Solution 1, we showed you how to use custom widgets that were packaged in a module. For the drag-and-drop application, we employ the same technique—a two-step process—to use the drag-and-drop module:
- Inherit the module with an inherits element in the configuration file.
- Include the module's JAR file in our application's classpath.
We showed you how to include GWT Solutions Components module in your application's classpath in "Custom Widget Use" (page 40), so we don't cover that ground again, but we do show you how we inherit the drag-and-drop module in the application's configuration file.
Inheriting the Drag-and-Drop Module in an Application's Configuration File
The XML configuration file for our application is shown in Listing 6.1.
Listing 6.1. com/gwtsolutions/DragAndDrop.gwt.xml
1.<module> 2. 3. <!-- Inherit the core Web Toolkit stuff. --> 4. <inherits name='com.google.gwt.user.User'/> 5. 6. <!-- Inherit the I18N stuff. --> 7. <inherits name="com.google.gwt.i18n.I18N"/> 8. 9. <!-- Inherit the drag and drop stuff. --> 10. <inherits name='com.gwtsolutions.components.Components'/> 11. <inherits name='com.gwtsolutions.components.client.ui.Dnd'/> 12. 13. <!-- Include CSS stylesheet. --> 14. <stylesheet src="styles.css"/> 15. 16. <!-- Specify the app entry point class. --> 17. <entry-point class='com.gwtsolutions.client.DragAndDrop'/> 18. 19.</module>
The drag-and-drop application uses GWT internationalization, so we inherit GWT's I18N module in addition to the User module.
The drag-and-drop module resides in the GWT Solutions Components module, so we inherit both of those modules in our application's configuration file.
The configuration file also includes its CSS stylesheet in the configuration file. We could have included the stylesheet with a standard link element in the application's HTML page, but including stylesheets in GWT configuration files is a more reusable solution because users can reuse your stylesheet along with your module. No one's ever going to reuse our application's module, but just the same, we prefer including stylesheets in configuration files to HTML pages in general.
Finally, we specify the entry point class for our application, com.gwtsolutions.client.DragAndDrop.
Now that we've seen how the drag-and-drop application uses the drag-and-drop module, let's look at the code for the application. We revisit the drag-and-drop module in "Drag and Drop Implementation in a GWT Module" on page 182, where we look at the module's implementation.