Finger Macros in Java EE Development (part 1)
By vbkraemer on May 23, 2007
As folks can probably tell, my main responsibility around here is to help maintain and extend the integration modules for GlassFish and Sun's application server offerings. I am also very interested in the development experience for Java EE that NetBeans provides.
I recently started looking at how to structure a couple simple elements of IDE to reduce the number of keystrokes that I use when working on a web or enterprise project. My goal is to find the edge cases and propose some enhancements.
The two elements of the IDE are the editor and the 'Main Project'. The editor is obvious, since almost every change that you want to test will be made there. The 'Main Project' is special, since a number of actions and keybindings trigger actions associated with this project, instead of the project which "owns" the code that you have focused in the editor.
I started off looking at a various scenarios to see what the current situation is. Since I was writing it down, I figured I might as well share what I found.
In the first set of experiments I have two projects open. I have a web app as the Main Project and an additional class library project that the web app depends on.
|File in the Editor||From Main Project||Action (Keybinding)||Result|
|A jsp file||yes||Save (Command-S)||File saved to source and deployment directory. The user can switch applications to the browser (Command-Tab), possibly need to switch application windows (Command-`) and finally reload the page (Command-R) to see their updated content.|
|a jsp file||yes||Run File (Shift-F6)||The jsp file is saved (if it was edited). The web application is redeployed (in place). The browser is told to load the page automatically.|
|a servlet||yes||Run File (Shift-F6)||The changed file is saved and recompiled. The web app is redeployed. A dialog may open to confirm the value of the URL to open in the browser, relative to the context root of the web app. The IDE tells the browser to open using the context root and the relative URL.|
|A java file that isn't a servlet||yes||Run File (Shift-R6)||The java file is saved. If the class has a public static main(String), it gets run (just like a regular Java project). If the class doesn't have a main(), an error message is displayed.|
|any file||yes||Run Project (not bound by default)||Changes are saved. Any necessary compilations are done. The web app is directory deployed. The browser is opened and told to load the URL constructed from the values of the context root and the relative URL.|
|any file||no||Run Main Project (F6)||Changes are saved. Any necessary compilations are done. The web app is directory deployed. The browser is opened and told to load the URL constructed from the values of the context root and the relative URL.|
I did notice one thing while working on some larger sample applications, that was a bit embarassing for me. In the past I have touted the joy of the save and reload development workflow. Once a project got beyond JSP development or I had multiple projects that I was integrating and testing, Run Main Project (F6), judicious management of the Main Project and its Relative Url were the things that helped keep me productive.