ONJava.com -- The Independent Source for Enterprise Java
oreilly.comSafari Books Online.Conferences.


AddThis Social Bookmark Button O'Reilly Book Excerpts: Eclipse Cookbook

Cooking with Eclipse

by Steve Holzner

Editor's note: In the Eclipse Cookbook, Steve Holzner, who also authored O'Reilly's Eclipse, offers practical recipes for more than 800 situations you may encounter while working with Eclipse. Today we sample two recipes from the cookbook, with two more (on connecting Eclipse to a CVS repository and on using Swing and AWT inside SWT for Eclipse 3.0) to follow next week.

Related Reading

Eclipse Cookbook
By Steve Holzner

Recipe 2.21: Creating a New Perspective


None of the built-in perspectives is quite right for you. You want to mix and match to create your own custom perspective.


No problem. Just open a perspective that's close to the one you want to create, add new views and close the ones you don't want, and save the new perspective by selecting Window→ Save Perspective As.


The Save Perspective As dialog is shown in Figure 2-20. This new perspective, named Debug2, adds the Navigator view to the Debug perspective.

Figure 2-20
Figure 2-20. Creating a new perspective

Now you're free to open your new perspective whenever you want, as shown in Figure 2-21. Very cool.

Figure 2-21
Figure 2-21. Opening a new perspective

TIP: To delete a custom perspective, select Window→ Preferences→ Workbench→ Perspectives, choose the perspective you want to get rid of, and click Delete.

Being able to create your own perspectives is very cool, and is something virtually no other IDE offers. You've got the opportunity here to mix and match views and create something totally new. Get creative!

Recipe 3.1: Speeding Up the JDT Editor


As you enter code in the JDT editor, windows flash, wavy red lines appear under text, and red boxes appear in rulers, among other annoying distractions.


You can turn off many automatic syntax and problem-checking features to speed code entry.


Although Eclipse provides a host of automatic syntax and problem-checking features, sometimes those features can be annoying. Fortunately, Eclipse is almost endlessly customizable. Here are some of the more common auto-checking features people find distracting, along with tips for dealing with them:

Problem indicators that appear while you're typing

Turn off by selecting Window→ Preferences→ Java→ Editor→ Annotations, and then uncheck all checkboxes.

The overview ruler

Hide by selecting Window→ Preferences→ Java→ Editor→ Appearance→ Show Overview Ruler, and then uncheck the appropriate checkbox.

Outline synchronization

Turn off by selecting Window→ Preferences→ Java→ Editor→ Appearance→ Synchronize Outline Selection on Cursor Move, and then uncheck the appropriate checkbox.

Eclipse 3.0

Smart insert mode is another automatic feature, new in Eclipse 3.0, which you can turn on and off. This is the mode in which Eclipse does things for you automatically as you type, such as adding a closing quote to strings, adding closing braces, and so on. You can toggle smart insert mode on and off in Eclipse 3.0 by pressing the Insert key, which cycles you through the overwrite and insert modes (which Eclipse 3.0 shares with Eclipse 2.x) as well as the Eclipse 3.0 smart insert mode. You can see the smart insert mode cursor, which looks like a left bracket, in the JDT editor in Figure 3-1.

Figure 3-1
Figure 3-1. Smart insert in Eclipse 3.0

TIP: To configure whether the JDT editor closes strings for you, adds braces, and so on, as well as to configure smart insert mode in Eclipse 3.0, select Window→ Preferences→ Java→ Editor→ Typing.

Steve Holzner is the author of O'Reilly's upcoming Eclipse: A Java Developer's Guide.

Return to ONJava.com.