Step 5.3: Look under the hood with the Resource perspective


Step 5.3: Look under the hood with the Resource perspective

I've already mentioned that the Resource perspective has no "specialized" knowledge of the various projects and resources, such as by more sophisticated plug-ins might provide. Because of this very limitation, however, the Resource perspective can be used to get a different view of things ” sort of an "under the hood" look. You don't need to know how to do this for day-to-day operations, so this step is purely optional. If you're not interested in how the IDE works internally, you may want to skip ahead to Step 5.3. Otherwise, let me show you a few cool things about Eclipse.

First, switch back to the Resource perspective.

q 5.3(a) Click on the Resource perspective icon in the perspective bar.

click to expand
Figure 5.12: Use the perspective bar to change to the Resource perspective.

You'll notice that the Hello project has been collapsed . I want you to expand the Hello project. But before you do, I'd like you to try and predict what you're going to find in the project. You might want to flip back to Steps 4.2(g) and 4.2(h).

q 5.3(b) Expand the Hello project.

click to expand
Figure 5.13: Left-click on the plus sign to expand the Hello project.

Interesting! There's a .project file, as you might have guessed after looking back at Step 4.2, as I suggested. However, I would have thought that we would see a JAR file in the project, but instead there's another document, called .classpath.

Well, we'll leave that little riddle alone for now; instead, we'll compare the .project file for this project with the one for Simple Project. To compare the two files, I'll walk you through opening each one up and then viewing them side by side.

First, open the .project file in Hello by double-clicking on it.

q 5.3(c) Open the .project file in project Hello.

click to expand
Figure 5.14: Double-click on the .project file in project Hello to open it.

The .project file will be opened up in the editor pane as shown in Figure 5.15.

click to expand
Figure 5.15: The contents of the .project file for Hello.

Next , expand Simple Project.

q 5.3(d) Expand Simple Project.

click to expand
Figure 5.16: Left-click on the plus sign to expand Simple Project.

Open the .project file (remember, one way to open a file is to double-click on it).

q 5.3(e) Open the .project file for Simple Project.

click to expand
Figure 5.17: Double-click on the .project file in Simple Project.

Double-clicking the .project file will cause the .project file from Simple Project to open up in the same editor pane, overlaying the .project file from Hello. However, you can't see them side by side this way, so the next thing is to split the pane. This is done by docking (you may want to review Step 4.5 for a reminder of how docking works).

Click on the tab for .project of the Hello project, drag it down and to the left until the black arrow appears, and then drop it. This will dock the file and split the pane.

q 5.3(f) Drag the left file to the left border and drop it.

click to expand
Figure 5.18: Dock Hello's .project file by dragging and dropping it on the left edge of the pane.

You'll see a display like the one in Figure 5.19.

click to expand
Figure 5.19: The two .project files side by side.

You might note that the Java project has a buildCommand entry in the buildSpace keyword as well as a nature entry in the natures keyword. What these particular values do is beyond the scope of this document, and in fact it's not easy to find even by looking through the Eclipse documentation. You'll need to do some research on your own to see how some of these things work.

Before we close up shop on this step, I'd like you to take a look at the other file generated for this project: the .classpath file.

First, close the .project file for Simple Project. Remember, you do this by rolling over the tab and then clicking on the X that appears. Since that's the only file in the right pane, the split will disappear.

q 5.3(g) Close the .project file for Simple Project.

click to expand
Figure 5.20: Close the .project file by clicking on the X.

q 5.3(h) Open the .classpath file.

click to expand
Figure 5.21: Double-click on the .classpath file to open it.

Since we're at a somewhat limited resolution, you can't actually see the contents of the file. This happens sometimes, and the easiest way around it is to maximize the view or editor by double-clicking on the appropriate tab.

In this case, double-click on the .classpath tab.

q 5.3(i) Maximize the .classpath pane.

click to expand
Figure 5.22: Double-click on the .classpath tab in the editor to maximize it.

What you'll see is a display like the one in Figure 5.23:

click to expand
Figure 5.23: The .classpath editor pane maximized.

You'll note that there are actually several entries in this file. Not only can you see a couple of entries for "src" and "output", but there is also a "con" entry, which seems to define the runtime JAR file but has an odd syntax to it that looks like a cross between a package name and a substitution variable. While we don't have time to delve into this in detail, some experimenting on your part (perhaps with changing values when you add a Java project) may give you more insight.

I know this step hasn't provided a lot of detailed information; it wasn't meant to. What I wanted to do was to show you this technique so that you can at least see how to peek under the covers of Eclipse. There's nothing more frustrating than a black box that doesn't work. While this step won't explain everything, it will at least start you on the path of demystifying the IDE. Remember, it's not magic ”it's just code.

Okay, play time is over. Let's clean up and move on.

Restore the editor pane for .classpath. This is the reverse of maximizing it ”simply double-click on it again.

q 5.3(j) Restore the .classpath.

click to expand
Figure 5.24: Restore the .classpath editor pane by double-clicking on it.

q 5.3(k) Close the .classpath editor pane.

click to expand
Figure 5.25: Close the .classpath editor pane.

q 5.3(I) Close the .project editor pane.

click to expand
Figure 5.26: Close the .project editor pane.

Finally return to the Java perspective to get some work done. Switching perspectives is most easily accomplished by using the perspective bar on the left of the workbench.

q 5.3(m) Switch to the Java perspective.

click to expand
Figure 5.27: Switch to the Java perspective.



Eclipse
Eclipse: Step by Step (Step-by-Step series)
ISBN: 1583470441
EAN: 2147483647
Year: 2003
Pages: 90
Authors: Joe Pluta

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net