Top
Interstage Studio User's Guide
FUJITSU Software

10.1.3 Coding Support

Adding a Try/Catch Block

In Java, if exceptions must be processed, a try/catch block can be added easily, as follows:

  1. In the Java editor, select the range in which you want to process exceptions.

  2. From the menu, select [Source] > [Surround With] > [Try/catch Block].

Generating a Getter and Setter

When using an editor to edit a Java class, you can specify a field and generate the Getter and Setter by selecting [Source] > [Generate Getters and Setters] from the context menu.

Adding Import Statements

In Java, when coding using only the class name without specifying the package name, the editor displays an error indicating an unresolvable type until an import statement is added.
In this situation, the required import statement can be added automatically by selecting [Source] > [Organize Imports] from the context menu.

Templates

Code fragments that are used numerous times can be saved as templates. These can be inserted when you are using Contents Assist to edit a file, or when you are using the New wizard to create a file.

Templates can be edited from the preference pages shown below.

File type

Preference Page

Ant script

[Ant] > [Editor] > [Templates]

Java

[Java] > [Editor] > [Templates]

SQL file

[SQL Development] > [SQL Editor] > [Templates]

CSS

[Web] > [CSS Files] > [Editor] > [Templates]

DTD

[XML] > [DTD Files] > [Templates]

HTML

[Web] > [HTML Files] > [Editor] > [Templates]

JSP

[Web] > [JSP Files] > [Editor] > [Templates]

XML file

[XML] > [XML Files] > [Editor] > [Templates]

Variables (user, date, selection resource, and so on) previously prepared in the workbench can be used in templates.

Snippets

Fragments used in coding can be registered in advance as snippets, as shown below. They can then be inserted easily by using the mouse to drag and drop.

  1. Display the Snippets view.

  2. Select [Customize] from the context menu.

  3. Enter the name, variables, and template pattern in the [Customize Palette] dialog box.

If a template that uses variables is inserted, variable values can be specified during template insertion.
Note that templates cannot be added, deleted, or changed for category JSP that is already defined.

File Comments and Type Comments

File comments and type comments can be set from the preference page using [Java] > [Code Style] > [Code Templates]. This enables comments to be unified when creating a Java class.

Variable Name Suggestions

When declaring a field or local variable, enter the type name and a blank space, then enter the [Ctrl+Space] keys. This displays field name or variable name suggestions.

Variable and Return Highlighting

When a field or local variable name is selected, the places where that field or local variable is used are highlighted.
In addition, when a return value type is selected in a method, the return location is highlighted.

TODO Comments

If things that must be done later are coded in the source using a TODO comment, that information is collected during build and listed in the Tasks view. The user can jump from the Tasks view to the place where the comment is coded.

This function can be used with Java, XML, HTML, JSP, and so on. Task tags other than TODO can be added in the preference pages shown below for a variety of purposes.

File type

Preference Page

Java

[Java] > [Compiler] > [Task Tags]

XML,HTML,JSP and so on

[General] > [Editors] > [Structured Text Editors] > [Task Tags]

String Externalization

Character string constants that have been coded directly in a Java source can be extracted, gathered together and managed in a property file, as shown below.

  1. Select the package, source folder, or similar from the view.

  2. From the menu, select [Source] > [Externalize Strings].

  3. Select the source to be targeted in the [Externalize Strings] dialog box, then click the [Externalize] button.

  4. The String Externalization wizard is displayed. Specify the property file to be used when externalizing strings, the key, the accessor class, and so on, and execute the string externalization.