Chapter 2. Working With Projects

When you use JStyle to review a set of Java source files, first you have to create a project and then add the relevant source files to the project. When JStyle is launched, the main screen looks like this:

Fig.  2.1

Creating a New Project

Select Project->New. It brings up a file dialog. Navigate to the desired directory and type a name for the project file. JStyle project files have .jst extension. After this a file chooser dialog will appear. See figure below.

Fig.  2.2

Select the files to be added to the project and click OK. The project will now contain the added source files. Files can be added and removed at any time through this file chooser dialog. Once you add files to the project, the project window lists them. See figure

Fig.  2.3

You may open any of the project files in the editor window by double clicking on the file name in the project view. Another way is by selecting Open from the context sensitive menu that appears when you right click the mouse on the file name in the project window. The next step is to ensure that classes required for building the current project are included in the settings. To do this, select Settings->Project. This will display the following dialog

Fig. 2.4

Each class path specification needs to be separated from the next by a semicolon. Ensure that the correct JDK class jar is included as otherwise unresolved references are likely to generate errors.

The next step is to save the project-related information. Choose Project->Save. The options and the files included in the project will be saved. At this point you are ready to generate comments. Select Tools->Generate Comments (or CTRL+G). This will cause JStyle to parse all the source files and generate comment reports. The screen at this point might look like this:

Fig. 2.5

You will notice some trace messages displayed in the bottom message window and ProjectSummary tab created on the top right pane with a list of files. Files displayed in the Report pane have some concerns from JStyle’s point of view. If you double click on any file in the Report pane, JStyle displays detailed comments pertaining to that file. See the following figure.

Fig. 2.6

The comment view is made up of three panes. The top pane displays the comment text. More information about this comment is available by clicking the More Info button. The bottom left pane lists the comment IDs applicable to this file, with one ID highlighted. The corresponding source line is highlighted on the bottom right pane. If you click on a particular ID on the left pane, the focus will move to that context on the right pane.

Comment vs. Report Generation

For certain practical reasons, JStyle has separated comment generation and report generation phases. During the comment generation phase, a parse tree is built after analyzing the source files and comments specified in the Comment Generation Settings (see next chapter) are applied. During the report generation phase, the input is not reparsed, but comments specified in the Report Generation Settings are applied. This can be convenient if you have several hundred source files to analyze and would like to experiment with various comment options. In this case, you would generate comments only once (possibly with all comments included), but generate reports many times, each time with a different set of comment settings.

Closing a Project

To close a project, select Project->Close.

Using an Existing Project

If you want to open an existing project file, choose Project->Open (or select from the recent project files list). A file dialog will appear asking you to select from the list. See figure.

Fig. 2.7

Navigate to the desired directory and select the project file. This will update the project view with the files that belong to the project and will cause JStyle to use the project settings as defined in that file. 

Generating comments will involve the same procedure as before.

Contents     Top    Previous    Next


Copyright © Man Machine Systems 1997-2003.
All Rights Reserved.
We acknowledge all trademarks.