• Aucun résultat trouvé

Using a working set

Dans le document DUMmIES Eclipse (Page 68-72)

When I first discovered Eclipse, I created a simple Hello Worldproject.

Then I wanted to experiment further, so I created MySecondProjectand MyThirdProject. Within a few hours, I had created 17 projects, all fun (but all useless).

When I create real code in Eclipse, I do the same thing. I build small experi-mental projects to test concepts and try out new ideas. In addition, I normally have several projects going at once. One way or another, my Package Explorer becomes cluttered.

To remove the clutter I create working sets.A working set is just a bunch of things that you want to be visible. Any item that’s not in the working set is out of your face and temporarily invisible.

Working sets aren’t only for Java projects. Eclipse supports several different kinds of working sets. Here are three kinds:

Java:A Java working setcontains items that you see in the Package Explorer — projects, source folders, source files, packages, libraries, and other things.

Resource:A resource working setcontains items that you see in the Navigator view — files, folders, and projects.

Help:A help working setcontains sections from Eclipse’s Help screens.

Use a help working set to narrow the collection of hits when you search for a particular topic.

To find out more about help working sets, see Chapter 15.

For a better understanding of working sets, try this experiment:

1. Start with a few projects in the Package Explorer.

This experiment works well if you have at least three projects, and if at least two of those projects contain Java source code. You don’t need any fancy code — just a class or two. So if you don’t already have at least three projects, I suggest creating some new ones.

Of course, if you’re impatient, lazy, or both, you can still get something out of this experiment. You can try this experiment with only one pro-ject, even if that project contains no code.

To find out how to create a Java project, see Chapter 2.

2. Click the menu button on the Package Explorer’s toolbar. In the result-ing context menu, choose Select Workresult-ing Set. (See Figure 3-15.)

The Select Working Set dialog appears.

3. In the Select Working Set dialog, click New.

The New Working Set Wizard appears. In the wizard’s Working Set Type list you see three entries — Java, Help, and Resource, as shown in Figure 3-16.

Figure 3-15:

Clicking the Package Explorer’s menu button.

4. Select a working set type, and then click Next.

In this experiment, select the Java working set. When you click Next, the Java Working Set page appears, as shown in Figure 3-17.

Figure 3-17:

The Java Working Set page.

Figure 3-16:

The Select page of the New Working Set Wizard.

5. Type something informative in the Working Set Name field.

How about typing My first working set? For now, that’s informative enough.

6. In the Working Set Content tree, put check marks next to the items that you want to appear in your view.

In Figure 3-17, I select the entire HelloProjectand portions of MySecondProject. I leave everything else unselected.

7. Click Finish to dismiss the New Working Set Wizard.

The Select Working Set dialog reappears, with the new working set you just created automatically selected.

8. In the Select Working Set dialog, click OK.

You get plopped back into the Eclipse workbench. Figure 3-18 shows a new Package Explorer tree with some of its branches expanded.

Figures 3-17 and 3-18 go hand in hand. When I check the boxes that I check in Figure 3-17, I get the Package Explorer shown in Figure 3-18. Comparing Figures 3-17 and 3-18, you find some expected things and some surprising things.

The Package Explorer contains only two projects — HelloProject and MySecondProject.

That’s not surprising given the check marks in Figure 3-17.

Figure 3-18:

The working set of Figure 3-17.

In the Package Explorer, the MySecondProjectbranch doesn’t con-tain SecondToNone.java.

Again, that’s not surprising given the absence of a SecondToNone.java check mark in Figure 3-17.

The Package Explorer displays rt.jarin both the HelloProjectand MySecondProjectbranches.

That’s surprising because, in Figure 3-17, the rt.jarbox is unchecked.

But wait! Figure 3-17 has a nice, dark check mark next to HelloProject. (Compare the dark HelloProjectcheck mark with the hesitant gray MySecondProjectcheck mark. You may not be able to see the differ-ence in Figure 3-17, but you can see the differdiffer-ence on your computer screen.)

That dark HelloProjectcheck mark indicates that everything in the HelloProjectis part of this working set. By “everything” I mean

“everything including rt.jar.” And because at least one copy of rt.jar is in the working set, the Package Explorer displays all the rt.jar branches.

No file named .classpathappears in the Package Explorer.

That’s certainly surprising. Figure 3-17 has a check mark in the .classpathbranch. So what gives?

Like many other views, you can filter the Package Explorer. By default, the Package Explorer’s filter masks files with names like .classpath and .project. For more information, see the section on “Using filters.”

Each view has its own active working set. For instance, your Games working set can be active in the Package Explorer while your SmallBusiness working set is active in the Hierarchy view. Later, you can do the old switcheroo. You can make the SmallBusiness set active in the Package Explorer view while the Games set is active in the Hierarchy view.

Dans le document DUMmIES Eclipse (Page 68-72)

Documents relatifs