Source actions



Source menu commands
Name
Function
Keyboard Shortcut
Comment
Comments out all lines containing the current selection.
Ctrl + /
Uncomment
Uncomments all lines containing the current selection.
Ctrl + \
Shift Right
Increments the level of indentation of the currently select lines. Only activated when the selection covers multiple lines or a single whole line.
Tab
Shift Left
Decrements the level of indentation of the currently select lines. Only activated when the selection covers multiple lines or a single whole line.
Shift + Tab
Format
Uses the code formatter to format the current text selection. The formatting options are configured on the Code Formatter preference page (Window > Preferences > Java > Code Formatter)
Ctrl + Shift + F
Organize Imports Organizes the import declarations in the compilation unit currently open or selected. Unnecessary import declarations are removed, and required import declarations are ordered as specified in the Organize Import preference page (Window > Preferences > Java > Organize Import). Organize import can be executed on incomplete source and will prompt you when a referenced type name can not be mapped uniquely to a type in the current project.
You can also organize multiple compilation units by invoking the action on a package or selecting a set of compilation units.
Ctrl + Shift + O
Add Import Creates an import declaration for a type reference currently selected. If the type reference if qualified, the qualification will be removed if possible. If the referenced type name can not be mapped uniquely to a type of the current project you will be prompted to specify the correct type. Add Import tries to follow the import order as specified in the Organize Import preference page Ctrl + Shift + M
Override Methods Opens the Override Method dialog that allows you to override or implement a method in the current type. Available on types or on a text selection inside a type.  
Generate Getter and Setter Opens the Generate Getter and Setter dialog that allows you to create Getter and Setters for field in the current type. Available on fields and types or on a text selection inside a type.  
Add Constructor from Superclass For the currently selected type adds constructors as defined in the super class. Available on types or on a text selection inside a type.  
Surround with try/catch For the selected statements all exception that have to be caught are evaluated. A try catch block is created around these expressions. You can use Expand Selection to from the Edit menu to get a valid selection range.  
Externalize Strings Opens the Externalize strings wizard. This wizards allows you to replace all strings in the code by statements accessing a property file.  
Find Strings to Externalize Shows a dialog presenting a summary of number of strings not externalized. Available on projects, source folders and packages.  
Convert Line Delimiters Changes all line delimiter in the currently open editor to use line delimiters as used in the following operating systems :
  • Windows (\r\n)
  • Unix (\n)
  • MacOS (\r)
\n is the ASCII code 10 (0x0A), \r code 13 (0x0D).
The Java editor is tolerant for a mixed usage of line delimiters. However, many other tools require an OS conform usage of line delimiters or at least line delimiter consistency. 
 


Related concepts

Java editor
String externalization
Java development tools (JDT)


Related tasks

Using the Java editor

Externalizing Strings

Related reference

Java editor
Java editor preferences
Outline view for Java
Views and editors


 Copyright IBM Corporation 2000, 2002. All Rights Reserved.