
STAGE 1.0 USER MANUAL Overview ChangeStyle is a style formatter extension for the BlueJ Java IDE. Oftentimes a programmer has difficulty conforming to different style rules at the expense of development time. ChangeStyle provides a way for any programmer working with BlueJ to convert their code to any coding style in seconds, thus increasing efficiency. This extension reduces the time spent manually reformatting code. ChangeStyle formats code depending on the options the user specifies. It formats the specified file on demand by using the Style Conventions, that can be modified. Some key features include setting the format settings to preset Style Conventions such as K&R Style and Sun Style, formatting braces, whitespace, and indentation. For more features look in 5.0 Features. 1.0 Requirements The following requirements should be met to ensure proper working conditions: J2SE 1.5.0 (Java 2 SDK version 1.5.0) or newer must be installed. BlueJ 2.2 or newer must be installed Must Run: Minimum: 64Mb main memory, Pentium II processor or equivalent Recommended: 128Mb main memory, 400MHz Pentium III processor or above Extensions are installed by placing the extension jar file into an extension directory. BlueJ has three separate locations for extensions, each giving the extension a different scope. The locations are: Verify Extension Installed To verify extension installed go to Help > Installed Extensions. Click on the ? to find more information about ChangeStyle . If ChangeStyle is not there, for more information go to. [BlueJ Extension Installation Help] 3.0 Usage 3.1 Format the Code 3.1.1 Format one Class. Start BlueJ. Open a project. Optionally open editor. Right click the Class of choice. Click on ChangeStyle > Format to format the selected class using the current style conventions.(If editor window is open the changes will be immediately visible. Otherwise you must open the editor to see the changes.) The editor window, if open shows the 'formatted' code. 3.1.2 Format All Files Start BlueJ. Open a project. Optionally open editor. Click on Tools > ChangeStyle > Format to format all the classes in the current package using the current style conventions.(If editor window is open for any class, the changes will be immediately visible for that class. Otherwise you must open the editor to see the changes.) The editor window, if open shows the 'formatted' code. When not all of the classes in the package are compiled an error window will pop-up and ChangeStyle will not format the classes. 3.2 Undo Formatting NOTE: Only works immediately after formatting code (the code cannot be altered since the last format). Right click on the class and click on ChangeStyle > Undo. The original code appears in the editor window. 4.0 Edit Style Conventions To edit the Style Conventions used to format your code or to Export / Import those Style Conventions the ChangeStyle Editor is used. To access the Editor go to Tools > Preferences. In the window that pops up go to the Extensions tab and if necessary scroll down to the ChangeStyle section. To open up the Setting Dialog click Edit Style Conventions. This opens up the Settings Dialog panel which is where the Style Convention Configuration Files can be edited and customized.
4.1 Predefined Conventions To import predefined Style Conventions click on the drop down box and click the one you want. Once a Style Convention is selected you may change the conventions but they will not be saved over the predefined one. 4.1.1 ANSI C Braces are opened and closed at the beginning of a new line for functions or right under the keyword for commands A closing brace is always on a line of its own Function names are never indented TABs are 4 spaces wide In an if-else statement the if and else should be vertically aligned Null statements should be placed on their own line and commented Spaces should be placed around all assignment and binary operators, and no spaces should follow unary operators Only one statement should appear on each line Line length should be limited to 80 characters 4.1.2 Kernighan and Ritchie (K & R) Braces are always opening attached to the pre-block code, and closing right under the keyword Fucntion names are never indented TABs are two spaces wide An else is attached to the closing brace Unrelated declarations, even of the same type, should be on separate lines. Lines may be broken: After a comma Before an operator Align the new line with the beginning of the expression at the same level in the previous line Just indent 8 spaces. For a more in depth explanation of K & R look at [The C Programming Language, Second Edition] 4.1.3 Sun Convention 4.1.4 Dalbey Style Dalbey Style is Sun Conventions with five different rules.
Open-close braces are aligned vertically One character varaibles are not allowed No ternary expressions There are no Beginning Comments In an if-else statement the if and else should be vertically aligned. [More detailed Dalbey Style Rules] 4.2 Printer The most important part of the Custom Settings is the Printer section. Here is where the specific Style Rules are defined. As each Style Rule is defined, the window to the right shows the original and formatted sample source code. Click Ok or Apply if you want to approve this Convention and move on or Cancel to exit the Editor without saving these changes. 4.3 Help For more information about what each Style Convention does click on Help. The objective of ChangeStyle is to properly format code to a specified format.ChangeStyle provides many features which can be specified by the user. ChangeStyle allows the formatting preferences to be specified by the graphical interface. ChangeStyle checks and formats the following style: [Brace] [Wrapping] [Comments] [Import] [Header] [Footer] [Sorting] 6.0 Credits
2.0 Installation
Location
Extensions installed here are available:
<BLUEJ_HOME>/lib/extensions (Unix), or <BLUEJ_HOME>\lib\extensions (Windows), or <BLUEJ_HOME>/BlueJ.app/Contents/Resources/Java/extensions (Mac, Control-click BlueJ.app and choose Show Package Contents)
For all users of this system in all projects.
<USER_HOME>/.bluej/extensions (Unix), or <USER_HOME>\bluej\extensions (Windows), or <USER_HOME>/Library/Preferences/org.bluej/extensions (Mac)
For a single user for all projects.
<BLUEJ_PROJECT>/extensions
5. 0 Specific Style Conventions
Section
Author
Overview
Stephanie
Features
Stephanie
Credit Page
Stephanie
Usage: Formatting
Tracy
Usage: Editing
Mark
Requirements
Paul
Installation
Paul
<compiling the parts>
Mark
<Took overcompiling the parts>
Tracy
Final Revisions (QA)
Paul
Stage 0.1 Pictures;
Mark
Stage 0.1 Rework
Tracy
Stage 1.0 Pictures;
Mark
Stage 1.0 Rework
Tracy