< Day Day Up > |
Recipe 1.6 Managing Perspectives, Views, and Editors1.6.1 ProblemHow do you work with Eclipse views, editors, and perspectives? 1.6.2 SolutionTo use Eclipse, you need to know what view, editor, and perspective mean:
1.6.3 DiscussionViews display data but don't let you edit it; editors both display data and make it editable. Because screen space is always at a premium in GUIs, views are often stacked one on top of another. You select the one you want to see using tabs that appear on the edge of the stacked views.
When you open code or other resources, their data will appear in an editor so that you can work on it. Eclipse automatically selects the right editor for the resource you're opening, based on the resource's file extension: the JDT's Java code editor for Java code (.java files), an XML editor if you have one installed for XML files (.xml files), and so on. You even can open Microsoft Word documents (.doc files) in an editor; Eclipse displays a Microsoft Word window in the editor space using Windows Object Linking and Embedding (OLE).
Editors are where you do most of your work, developing code and working with other resources. For instance, you can develop a GUI in an editor by dragging and dropping controls when using a plug-in that provides that functionality (for more information on using a plug-in that enables you to design GUIs in this way, see Chapter 9). You can have a number of editors open at the same time, and they'll appear stacked in the center of the workbench. You select the editor you want to work with by clicking the corresponding tab at the top of the stacked editors (or by selecting Window Switch to Editor, which displays a list of editors you can switch to). You close an editor simply by clicking the X in its associated tab (or by selecting Window Hide Editors, which toggles to Window Show Editors after hiding an editor). As noted earlier, a perspective is a collection of views and editors that open and close as a group. For example, the Java perspective displays a set of views and editors appropriate to Java development. These include the Package Explorer view, which displays a clickable hierarchical class structure of the Java files in the project, and the JDT editor, which supports Java syntax checking, quick fixes for syntax errors, and so on. The Debug perspective, on the other hand, displays views and editors appropriate to debugging, including watch windows, the output console, a watch window for variables, and so on. Perspectives usually appear by themselves, following your lead (the Java perspective opens automatically when you create a Java project, for example), but you also can open Eclipse perspectives explicitly by selecting Window Open Perspective, and then choosing a perspective from the submenu that appears. To close a perspective, select Window Close Perspective.
Perspectives have a predefined set of views and editors built in. When you select a perspective, that set of views and editors appears automatically. By defining a set of perspectives, Eclipse makes your job easier because you don't have to open the specific views you want every time you want to write or debug code. You also can create (as well as delete) your own perspectives. To get a handle on these concepts by way of an example, take a look at the next recipe, in which we dissect the Java perspective. 1.6.4 See AlsoRecipe 1.3 on understanding the Eclipse workspace. |
< Day Day Up > |