Page tree
Skip to end of metadata
Go to start of metadata

We make available code formatting templates for NetBeans and Eclipse, two IDEs the CONNECT development team uses. Community members are welcome to contribute templates for other IDEs.

NetBeans:

Download CONNECT-NetBeans-formatter.zip and import by going to Tools -> Options -> Import: make sure "All" is selected.  You can find the "Import" button at the bottom-left of the Options window.

Eclipse:

Download CONNECT-Eclipse-formatter.epf and import by going to File -> Import -> General -> Preferences: make sure "Import all" is selected.  Then open the global preferences window via Windows -> Preferences and perform the following steps:

  1. Under General -> Editors -> Text Editors:
    1. Check "Show print margin"
    2. Set "Print margin column" to 120
    3. Check "Insert spaces for tabs".
  2. Under General -> Workspace:
    1. Set "New text file line delimiter" to Other: Unix.
  3. Under Java -> Editor -> Save Actions:
    1. Check "Perform the selected actions on save"
    2. Check "Format source code" and choose "Format edited lines"
    3. Check "Additional Actions"
    4. Click "Configure" and check the following options:
      1. Code Organizing:
        1. Remove trailing whitespace
        2. Correct indentation
      2. Code Style:
        1. Use blocks in if/while/for/do statements (Always)
        2. Convert 'for' loops to enhanced
        3. Use parentheses in expressions (Only if necessary)
      3. Member Accesses:
        1. Use 'this' qualifier for field accesses (Only if necessary)
        2. Use 'this' qualifier for method accesses (Only if necessary)
      4. Unnecessary Code:
        1. Remove unused imports
        2. Remove unused private members (Fields, Methods)
          1. Note: Uncheck 'Types' and 'Constructors'
  4. Under Web -> HTML Files -> Editor:
    1. Set "Line width" to 120
    2. Select "Indent using spaces"
    3. Set "Indentation size" to 4.
  5. Under XML -> XML Files -> Editor:
    1. Set "Line width" to 120
    2. Select "Indent using spaces"
    3. Set "Indentation size" to 4.
  6. Under Ant -> Editor -> Formatter:
    1. Set "Maximum line width" to 120
    2. Deselect "Use tab characters instead of spaces".
  7. Optional: To prevent Eclipse from auto-suggest from listing obscure packages for common classes (e.g., suggesting java.awt.List over java.util.List), you can add the unused classes/packages to the list at Java -> Appearance -> Type Filters.
  • No labels