Chapter 3. Managing Your Projects
; Create multiple workspaces for independent work
; Navigate and filter Java project views窗口
; Link project folders to directories目录 outside the workspace
; Plan the structure of your workspace and projects
3.1. Your Project Workspace
Each instance of 实体Eclipse is associated with 联系exactly one workspace, but you can select the workspace that will be used for the current session.会话，学期
You will see a child folder named .metadata 元数据don't mess with 混在一起this unless
you know what you are doing! Also be certain to back this up 坚持along with your other workspace project folders because it contains important data about your workbench state and preferences.
You can rename or move your workspace folder at any time without ill effect, as long as
you always keep the child folders, including the .metadata folder, intact 完整的within a
3.1.1. Using Multiple Workspaces
Some common reasons for multiple workspaces include the following:
; Independent work topics主题, possibly managed in different version control
; You are a consultant 顾客顾问and need to maintain clear separation between client
; Two or more workspaces are used to distinguish concurrent并发 work on
maintenance维护 branch versions in CVS计算机并发并行版本系统.
To create a new workspace, simply start Eclipse and enter a new location in the Workspace
3.2. Eclipse Resources
The resources are contained in a hierarchical 分布式structure with a singleton 一个，名词
workspace as its root. The primary主要的 resource types are shown in Figure 3-1.
Figure 3-1. Eclipse platform resource types.
You can modify a resource on the file system directly or from within在内部 Eclipse. If
you create, delete, or modify a file system resource within a folder that is managed by Eclipse,
then the Eclipse workspace must be refreshed 刷新to synchronize同步 its state with that of the actual实际的 files.
Resources may be refreshed manually or automatically in Eclipse. If you are working on
处理very large projects with thousands of files, automatic refreshing can become an
excessive巨大的 processing burden; otherwise it's very helpful. You can enable激活
automatic refresh by checking the option for Refresh workspace automatically in the
preferences dialog opened via the menu Window > Preferences > General> Workspace.
Manual refresh is invoked for projects, folders, or individual files via the context环境
menu in the Java Package Explorer view, as shown in Figure 3-2.
Figure 3-2. Synchronize Eclipse resources with the file system. 3.2.1. Projects
Projects are special entities 选项in your workspace. They carry 携带metadata about
project characteristics and contribute automatic behavior when their resources are modified. A
project is a container that groups 组织resources into buildable,可构造 reusable units.
Features of projects include the following:
; A project collects together a set of files and folders.
; A project's location controls where the project's resources are stored in the local file
; A project's build spec 规约controls how its resources are built.
; A project can carry session 临时and persistent properties属性.
; A project can be open or closed; a closed project is passive 被动的and has a minimal
; A project can refer to 引用other projects.
; A project can have one or more project natures类.
If you have created a new Java project, you will see a J on top of the project folder icon in the Package Explorer views.
If you are working with a large number of projects or a large number of folders within a
project, you can narrow your current scope to a subset of workspace content. In the Package Explorer view, pick any project or package folder and select the Go Into context menu item,
环境菜单as shown in Figure 3-3. You can then use the Back, Forward, or Up toolbar icons on that view to move between a series of sub-folder focus areas.集中区域
Figure 3-3. Drill into workspace focus areas using Go Into. Alternatively,两者择一 in the Package Explorer view, right-click on a project folder and select Close Project. Then filter your view as shown in Figure 3-4 to hide all closed projects.
This approach has an additional benefit of reducing Eclipse resource consumption for closed
Figure 3-4. Filter content of the Package Explorer view 3.2.2. Linked Resource Locations
Some reasons for doing this are as follows:
; Including configuration or class file directories that are stored outside of the project,
e.g., in a Tomcat or JBoss server installation
; Accommodating满足 inflexible file location requirements of other tools used in
combination with和——结合 Eclipse
; Referencing shared network drive 驱动器locations containing source or library files
; Referencing other product installations on your file system Right-click on the project where you want to create a linked resource and select New >
Folder or New > File. As shown in Figure 3-5, specify the name of the folder as it will appear in the workbench and browse找到 to the linked folder. The Eclipse folder name can be different from the name of the folder in the file system.
Figure 3-5. Create a linked folder for an external product library. 3.3. Planning Projects and Dependencies依赖性
The planned scope of our order management application includes a product catalog, order
processing, and a Web-based 基于网络user interface. Our initial 最初的design calls for
five modular projects with dependencies as shown in Figure 3-8.
Figure 3-8. Order processing application package dependencies.
The projects are summarized 总结as follows:
catalog. Domain 专用model for product catalogs产品目录.
orders. Domain model for order management订货管理; depends on product catalog domain model.
ubl. The OASIS 结构化信息标准促进组织Universal Business Language (UBL) reusable
components for electronic commerce. These components are used within both the catalog and orders domain models.
orders.webapp. A J2EE Web application interface for order processing; depends on the orders domain model.
orders.webapp.test. A separate project for unit and integration testing 单元和集成测试of the
Your first Java project for the product catalog was created in Chapter 2, "Hello Eclipse."
Following the same approach, open the Java perspective and use the New Java Project wizard to create the remaining four projects. You should now have the Eclipse workspace projects as shown in Figure 3-9.
Figure 3-9. Projects in the Package Explorer view.
When creating new Java projects using the wizard, be sure to select the project layout 布局
option to Create separate source and output folders. You should click the button to
Configure Defaults… and set this choice as the default folder configuration from this point
Project dependencies affect the visibility 可视性of imported classes in Java projects. It is
possible to develop this entire application using a single Eclipse project, but the use of multiple projects provides additional benefits when reusing independent modules. Creating separate projects makes you think clearly about the dependencies between logical subsystems. 3.4. Distilled
; A workspace provides a complete view of all resources required by a set of related
; Eclipse resources provide a platform-independent, logical view of files and folders,
but they must be synchronized with the file system if changes are made outside of the
Eclipse workbench. 【2】
; A Java project contains source and output folders (preferably separate locations). 【3】
; You can map parts of the Eclipse workspace hierarchy onto disjoint locations in the
file system by using linked resource locations. This is especially helpful when using
Eclipse in combination with other products and development tools that require specific
file locations. 【4】
; Configuring an application using multiple projects contributes long-term benefits that
improve reuse of independent modules.【5】
New Words and Phrases
; New words
navigate 定位 filter 过滤
folder 文件夹 director 目录
instance 实例 multiple 多个
concurrent 并发的 refresh 刷新
synchronize ，使！同步 spec 规约
cache 缓存 subsystem 子系统
child folde 子文件夹
hierarchical structure 分层结构/层次结构
session and persistent properties 临时属性和永久属性
Domain model 专用模型
reusable components 可重用组件
electronic commerce 电子商务
【1】A workspace provides a complete view of all resources required by a set of related
【2】Eclipse resources provide a platform-independent, logical view of files and folders,
but they must be synchronized with the file system if changes are made outside of the
【3】A Java project contains source and output folders (preferably separate locations). 一个Java项目包括源文件夹和输出文件夹。
【4】You can map parts of the Eclipse workspace hierarchy onto disjoint locations in the file system by using linked resource locations. This is especially helpful when using Eclipse in combination with other products and development tools that require specific file locations.
【5】Configuring an application using multiple projects contributes long-term benefits that improve reuse of independent modules.