1.5. QuickStart with Eclipse

Just want to have a quick try with IT Mill Toolkit? This section presents a QuickStart into running and debugging IT Mill Toolkit demos under Eclipse. The QuickStart includes a web server, so you do not need to install a full-weight web container such as Apache Tomcat.

1.5.1. Importing IT Mill Toolkit as a Project

The installation directory of IT Mill Toolkit contains all the necessary files to allow importing it as a ready-to-run Eclipse project. Do the following steps.

  1. Start Eclipse. If necessary, switch to Java Perspective from menu WindowOpen PerspectiveJava.

  2. Select FileImport... and the dialog for importing opens.

  3. In the Import dialog, select GeneralExisting Project Into Workspace and click Next.

  4. In the Select root directory option, click on the Browse button, and select the folder where you unpacked IT Mill Toolkit, such as itmill-toolkit-5.x.x. Click OK in the selection window. Click Finish in the Import window to finish importing the project.

    The newly imported project will look as follows.

    Figure 1.5. IT Mill Toolkit Imported as a Project in Eclipse

    IT Mill Toolkit Imported as a Project in Eclipse

    You can browse the source code of the demo application, and run the demo in a web browser by following the instructions given in the next section.

1.5.2. How to Run the Demo Applications in Eclipse?

Once the project is imported, as described above, you can run the Content Browser, including the demo applications, as follows. Either:

  1. From the main menu, select RunOpen Run Dialog....
  2. From the list on the left, select Java ApplicationIT Mill Toolkit Web Mode.
  3. Click Run.

Notice that after the application is launched once, it appears on the Favourites list. You can then either:

  • Click on the small dropdown arrow on the right side of the Run button on Eclipse toolbar and select IT Mill Toolkit Web Mode.

  • or... Select RunRun HistoryIT Mill Toolkit Web Mode.

Running the application in Web Mode will open a browser window with the Content Browser. The default system web browser is opened; make sure that the browser is compatible with IT Mill Toolkit. The Console view in the lower pane of Eclipse will display text printed to standard output by the application. Clicking on the red Terminate button will stop the server.

Figure 1.6. IT Mill Toolkit Content Browser Started Under Eclipse

IT Mill Toolkit Content Browser Started Under Eclipse

Notice that executing the web application locally may provide a security warning from your firewall software. This is caused by the Web Service which is started to run the Content Browser. You have to ignore the warnings or temporarily accept connections to port 8888 on your firewall software. Also, if the web service fails to start, make sure that no other service is using port 8888.

Launching the Hosted Mode Browser

The Hosted Mode Browser of Google Web Toolkit is a special web browser that runs the client-side GWT Java code as Java runtime instead of JavaScript, thereby allowing you to debug the client-side components in an IDE such as Eclipse.

Note

Hosted Mode Browser of Google Web Toolkit 1.4.62 does not work with Linux/Mozilla (Issue #1636 in IT Mill Toolkit version 5.2.0). As a workaround, you have to use a hand-made loader page as explained in http://dev.itmill.com/ticket/1636.

To run the demo applications in the Hosted Mode Browser of Google Web Toolkit, follow the following steps:

  1. If not already started, start the demo application in Web Mode as described above. This launches the web server, which is used also when using the hosted mode.
  2. From the main menu, select RunOpen Debug Dialog....
  3. From the list select Java ApplicationIT Mill Toolkit Hosted Mode.
  4. Click Debug.

Starting demo applications under the Hosted Mode Browser can take considerable time! This is especially true for the Reservation and Color Picker applications, which require compilation of custom widget sets. During this time, the Hosted Mode Browser is unresponsive and does not update its window. Compiling widgets can take 5-30 seconds, depending on the hardware.

As with the Web Mode launcher, after you have run the launch once, you can select RunDebug HistoryIT Mill Toolkit Hosted Mode, or click the dropdown marker on right of the Debug button in the toolbar and select IT Mill Toolkit Hosted Mode.

To use the Hosted Mode Browser in your own projects, you need to create a launch configuration in Eclipse. See Section 8.7.6, “Hosted Mode Browser” for more detailed information about the Hosted Mode Browser and how to create the launch configuration.

How to Stop the Run

To stop the launched Jetty web container that serves the Content Browser web application, select the Console tab and click on the Terminate button.

Figure 1.7. Terminating a Launch

Terminating a Launch

To clean up all terminated launches from the Console window, click on the Remove All Terminated Launches button.

Figure 1.8. Removing Terminated Launches

Removing Terminated Launches

1.5.3. How to Debug the Demo Applications in Eclipse?

You can inspect and experiment with the imported project as you like. When you develop an application, you may want to debug it. Running a web application in debug mode is easy in Eclipse. Next, we will show you how to debug the demo applications by inserting a breakpoint in the Calc example.

  1. Make sure to stop any previous Run command as instructed above at the end of Section 1.3.4, “Running the Demo Applications”.
  2. Select from menu RunDebug... and the Debug configuration window will open.

  3. Select Java ApplicationIT Mill Toolkit Web Mode and click Debug. The server will start and the web browser will open.

  4. Open the Calc application by selecting on the start page Additional demosCalculator.

  5. Open the source code for the Calc program. It is located in WebContent/WEB-INF/src/com.itmill.toolkit.demo.Calc. Doubleclick the class to open the source code in the editor.

  6. Insert a breakpoint in the init() (line 57) by clicking on the gray bar on the left of the editor window to open the context menu, and select Toggle Breakpoint.

  7. Switch to the browser window and click on the Calc link to open it.

  8. Eclipse encouters the breakpoint and asks to switch to the Debug perspective. Click Yes. The debug window will show the current line where the execution stopped as follows:

    Figure 1.9. Execution Stopped at Breakpoint in Debug Perspective in Eclipse

    Execution Stopped at Breakpoint in Debug Perspective in Eclipse

1.5.4. Using QuickStart as a Project Skeleton

If you like, you can also use the imported Toolkit as a skeleton for your project. Just remove any unnecessary files or files related to the demo applications from the project. You may also want to rename the IT Mill Toolkit installation directory with a name more proper for your project.

If you want to go the long way, which is probably preferred for a real project, especially a large one, you should follow the instructions in Section 1.6, “Your First Project with IT Mill Toolkit”.