Wiki source code of Run or Debug a WO Application

Version 5.1 by Mike Schrag on 2005/11/19 11:44

Hide last authors
Mike Schrag 3.1 1 You'll now run your WO Application and get a glimpse at one of the coolest features of Eclipse.
2
Mike Schrag 5.1 3 ~1. If you want to run your WO Application, you can right-click/ctrl-click on the project name, "Run As" => "WOApplication". But Run doesn't give you some of the cool features that you really want. What you'd really like to be able to do is make changes to your source code WHILE you're running and see them reflected in the running app, so don't click Run :)
Mike Schrag 3.1 4
Mike Schrag 5.1 5 [[image:Picture 15.png]]
6
Mike Schrag 3.1 7 ----
8
Mike Schrag 5.1 9 2. Instead, select "Debug As" => "WOApplication" (Note from Mike: the picture has "WOApplication (profiled)" selected ~-~- that's a mistake and I don't have to energy to go and retake the photo at the moment :) ).
Mike Schrag 3.1 10
Mike Schrag 5.1 11 [[image:Picture 17.png]]
Mike Schrag 3.1 12
13 ----
14
Mike Schrag 5.1 15 3. Eclipse will now look through all the known types for classes that are launchable.
Mike Schrag 3.1 16
Mike Schrag 5.1 17 [[image:Picture 16.png]]
Mike Schrag 3.1 18
19 ----
20
Mike Schrag 5.1 21 4. In our case, we want to run our principal class "Application", so you can type Application in the search field, or scroll down to it in the list and click "OK".
Mike Schrag 3.1 22
Mike Schrag 5.1 23 Once you go through this process once, though, you will have a Run/Debug Configuration that you can just reuse every time without having to pick the class.
Mike Schrag 3.1 24
Mike Schrag 5.1 25 For reference, a slightly faster way of getting to past this step is to select Run As => WOApplication on the Application class itself in Package Explorer rather than selecting it on the project.
26
27 [[image:Picture 18.png]]
28
Mike Schrag 3.1 29 ----
30
Mike Schrag 5.1 31 6. Eclipse will now execute the WOApplication, opening a Console view at the bottom to show you stdout and stderr (stderr is red, stdout is blue). Additionally, Eclipse by default opens an internal browser that contains your Main.WO. So, hey, that's cool ~-~- it works, but that embedded browser has got to go :)
Mike Schrag 3.1 32
Mike Schrag 5.1 33 [[image:Picture 19.png]]
Mike Schrag 3.1 34
35 ----
36
Mike Schrag 5.1 37 7. Select "Window" => "Preferences..."
Mike Schrag 3.1 38
Mike Schrag 5.1 39 [[image:Picture 21.png]]
Mike Schrag 3.1 40
41 ----
42
Mike Schrag 5.1 43 8. Open "General", select "Web Browser", and change "Use internal Web browser" to "Use external Web Browser", click "Apply" and then "OK".
Mike Schrag 3.1 44
Mike Schrag 5.1 45 [[image:Picture 20.png]]
Mike Schrag 3.1 46
47 ----
48
Mike Schrag 5.1 49 9. Go ahead and stop your WO Application. In the console view, there is a red square on the right side. If you click that, it will terminate your app (it will say "<terminated>" on the title bar of the Console view when it's done, and the red stop square will turn gray). If you want to clear the console output, you can the icon of the paper with the X on it.
Mike Schrag 3.1 50
Mike Schrag 5.1 51 10. You want to Debug again, but you can now save yourself some time. On the icon bar of Eclipse, in the second set of icons, there is an icon of a Bug with an arrow next to it and a Play button with an arrow next to it. These are your Debug and Run buttons. If you click the down arrow next to the Debug icon, you will see a list of recent run configurations to choose from. If you want to rerun the last configuration, you can just click the debug icon itself. Run works the same way.
Mike Schrag 3.1 52
Mike Schrag 5.1 53 If you want to change any of the configuration options like WO parameters, commandline parameters, VM options, etc, you can click the down arrow and then select "Debug ..." or "Run ..." and then you can edit a plethora of options for the configurations.
54
55 ~11. In our case, we want to just Debug again, so click the Debug icon. You will see Eclipse open the Console view again, but this time your default web browser will launch and you will see the output of your Main.wo component.
56
57 [[image:Picture 22.png]]
58
Mike Schrag 3.1 59 ----
60
Mike Schrag 5.1 61 12. Let's check out Hot Code Replacement. Switch back to Eclipse and leave the app running. Go to the Java tab of Main.wo and change the definition of now() to return a specific date and save. The Eclipse incremental compiler will now compile the changed method and replace it on-the-fly into the running application.
Mike Schrag 3.1 62
Mike Schrag 5.1 63 [[image:Picture 23.png]]
Mike Schrag 3.1 64
65 ----
66
Mike Schrag 5.1 67 13. Reload Safari and you'll see the change. There ARE limitations to Hot Code Replacement. It is not able to replace structural changes to your code ~-~- added methods, removed methods, added fields, or removed fields. But most any change INSIDE of method works fine. You will find this to be an enormous productivity boost over the usual run, navigate, stop, fix, run, navigate, stop, fix cycle. Now it's run, navigate, fix, reload.
Mike Schrag 3.1 68
Mike Schrag 5.1 69 [[image:Picture 24.png]]
Mike Schrag 3.1 70
71 ----
72
Mike Schrag 5.1 73 14. Let's go ahead and [[Create a new WO Component]].