Eclipse 中的 Java 工作集或资源工作集

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/13824141/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 19:35:40  来源:igfitidea点击:

Java working set or Resource working set in Eclipse

javaeclipse

提问by sheidaei

I have never specifically found the answer to "What is the difference between Java working set and Resource working set in Eclipse?" The Resource working set is more general and it can include not only the Java applications / projects, but let me put it this way. Let's assume a daily life of a Java developer. Do you suggest him/her to use Resource working set over Java working set? Is there any specific situation in which you prefer one over the other?

我从来没有专门找到“Eclipse 中的 Java 工作集和资源工作集有什么区别?”的答案。Resource 工作集更通用,它不仅可以包括 Java 应用程序/项目,而且让我这样说。让我们假设 Java 开发人员的日常生活。您是否建议他/她使用 Resource 工作集而不是 Java 工作集?在任何特定情况下,您更喜欢其中一种吗?

回答by paulsm4

It sounds like this should have answered the question:

听起来这应该回答了这个问题:

A Working Set is a subset of your Eclipse projects. You can create different Working Sets and then select which Working Set to display in the Navigator view.

工作集是 Eclipse 项目的一个子集。您可以创建不同的工作集,然后选择要在导航器视图中显示的工作集。

Specifically:

具体来说:

1) "Working set" (in this particular context), is an "Eclipse thing"

1)“工作集”(在这个特定的上下文中),是一个“Eclipse事物”

2) The purpose of Eclipse working sets is to help organize your projects

2) Eclipse 工作集的目的是帮助组织你的项目

3) A project consists of "stuff": source code, bitmap graphics files, WSDL's, CSS style sheets - just about anything imagineable.

3) 一个项目由“东西”组成:源代码、位图图形文件、WSDL、CSS 样式表——几乎任何可以想象的东西。

4) Consequently, Eclipse projects are organized (glancing at my J2EE perspective, for example) into subsections like "src", "WebContent", "Services" and so on. A project itself can be one of many different types: a "Java project", a "Java Swing Design project", and "Dynamic Web Project" and so on.

4) 因此,Eclipse 项目被组织成诸如“src”、“WebContent”、“Services”等子部分(例如,看看我的 J2EE 透视图)。项目本身可以是许多不同类型中的一种:“Java 项目”、“Java Swing 设计项目”和“动态 Web 项目”等等。

5) Similarly, an Eclipse Working set can be one of several different types: a "Java working set", a "Breakpoint working set ... and a "Resource working set".

5) 同样,Eclipse 工作集可以是以下几种不同类型之一:“Java 工作集”、“断点工作集……和“资源工作集”。

6) As with Eclipse "Views" and Perspectives", you can usually access any project resource you need any time you need it. Selecting one or another perspective simply makes the object (e.g. "Problems pane" or "Build list") easier to get to.

6) 与 Eclipse 的“视图”和“透视”一样,您通常可以随时访问任何需要的项目资源。选择一个或另一个透视只会使对象(例如“问题窗格”或“构建列表”)更容易到达。

7) Which kind of "Working Set" you choose - or whether or not you use working sets at all - is largely just a matter of personal preference and convenience.

7) 你选择哪种“工作集”——或者你是否完全使用工作集——很大程度上只是个人喜好和方便的问题。

Please let us know if you still have any further questions.

如果您还有其他问题,请告诉我们。

PS: Additional links:

PS:附加链接:

https://www.ibm.com/developerworks/library/os-eclipse-visualstudio/

As mentioned, many developers load all their projects into a single Eclipse workspace. It's convenient, but it can sometimes create too much clutter. In addition to closing unnecessary projects, you can define working sets: groups of elements (projects, folders, classes, etc.). Eclipse can use working sets in different views (such as Package Explorer) and operations (like searching).

https://www.ibm.com/developerworks/library/os-eclipse-visualstudio/

如前所述,许多开发人员将他们所有的项目加载到一个 Eclipse 工作区中。这很方便,但有时会造成太多混乱。除了关闭不必要的项目,您还可以定义工作集:元素组(项目、文件夹、类等)。Eclipse 可以在不同的视图(例如 Package Explorer)和操作(例如搜索)中使用工作集。

... and ...

... 和 ...

help.eclipse.org: Working Sets

help.eclipse.org:工作集

回答by Neel

A working set in the context of eclipse is a logical grouping of related projects to ease search and organize views within the IDE.

Eclipse 上下文中的工作集是相关项目的逻辑分组,以简化 IDE 中的搜索和组织视图。

A resource working set can capture all types of resources - maybe java source, html, xml, javascript, images - anything that exists within the scope of the projects included into the working set.

资源工作集可以捕获所有类型的资源——可能是 java 源代码、html、xml、javascript、图像——存在于包含在工作集中的项目范围内的任何东西。

The Java working set is a different working set (it is NOT a subset of a resource working set!) which captures only those java files which belong to a source folder and are being compiled into the classpath, or those java files which belong to a module (library) in the build path. Hence, it lets you lookup java "classes" which are in the classpath. Note that all java file in your project may not necessarily be built into the classpath (for example when you exclude a java source file, it does not get built any more). But a java source file which is not included in your classpath can still be detected by a resource working set (you will notice that the icon for an included java source file is a solid J, while for an excluded java source, it is a hollow J).

Java 工作集是一个不同的工作集(它不是资源工作集的子集!)它只捕获那些属于源文件夹并被编译到类路径中的 java 文件,或者那些属于模块(库)在构建路径中。因此,它允许您查找类路径中的 java“类”。请注意,您项目中的所有 java 文件不一定都构建到类路径中(例如,当您排除一个 java 源文件时,它不会再被构建)。但是一个没有包含在你的类路径中的 java 源文件仍然可以被一个资源工作集检测到(你会注意到一个包含的 java 源文件的图标是一个实心的 J,而对于一个排除的 java 源,它是一个空心的J)。

Example: Say you have two projects p1 and p2 of which p1 belongs to the working set but p2 does not. So:

示例:假设您有两个项目 p1 和 p2,其中 p1 属于工作集,但 p2 不属于。所以:

MyClass.java (belongs to p1 and included in build path) - Shows up in java type search (Ctrl + T) and also in resource search (Ctrl + R).

MyClass.java(属于 p1 并包含在构建路径中)- 显示在 java 类型搜索 (Ctrl + T) 和资源搜索 (Ctrl + R) 中。

MyOtherClass.java (belongs to p2 and included in build path) - Does not show up in java type search nor in resource search.

MyOtherClass.java(属于 p2 并包含在构建路径中)- 不显示在 Java 类型搜索和资源搜索中。

MyExcludedClass.java (belongs to p1 and excluded from build path) - Does not show up in java type search but shows up in resource search.

MyExcludedClass.java(属于 p1 并从构建路径中排除)- 不显示在 java 类型搜索中,但显示在资源搜索中。

MyExcludedClass.class (belongs to a dependency jar in the build path of p1) - Shows up in java type search but does not show up in resource search.

MyExcludedClass.class(属于 p1 的构建路径中的依赖 jar) - 在 java 类型搜索中显示,但在资源搜索中不显示。

MyWebPage.html (belongs to p1) - Does not show up in java working set but in resource working set.

MyWebPage.html(属于 p1) - 不出现在 java 工作集中,而是出现在资源工作集中。

MyOtherWebPage.html (belongs to p2) - Does not show up in java type search nor in resource search.

MyOtherWebPage.html(属于 p2) - 不显示在 Java 类型搜索和资源搜索中。

MyConfig.xml (belongs to p1) - Does not show up in java type search but shows up in resource search.

MyConfig.xml(属于 p1) - 不会出现在 java 类型搜索中,但会出现在资源搜​​索中。

So, in the context of a Java developer's use: I use Java working sets to look up types / classes defined in Java, whereas the resources working set to lookup all different types.

因此,在 Java 开发人员使用的上下文中:我使用 Java 工作集来查找在 Java 中定义的类型/类,而使用资源工作集来查找所有不同的类型。

回答by K Erlandsson

One difference between the working sets is that they provide different editing wizards (as stated here: http://help.eclipse.org/helios/index.jsp?topic=%2Forg.eclipse.platform.doc.user%2Fconcepts%2Fcworkset.htm). If you edit a resource working set and a java working set respectively you will see they use different screens for selecting which resources/projects are included.

工作集之间的一个区别是它们提供不同的编辑向导(如下所述:http: //help.eclipse.org/helios/index.jsp?topic=%2Forg.eclipse.platform.doc.user%2Fconcepts%2Fcworkset .htm)。如果您分别编辑资源工作集和 Java 工作集,您将看到它们使用不同的屏幕来选择包含哪些资源/项目。

Apart from this I haven't found any other difference. It also does not seem to differ which resources you can choose in any way. So to answer your question which one would be recommended I would answer "it doesn't matter" since they behave the same way.

除此之外,我还没有发现任何其他区别。您可以以任何方式选择哪些资源似乎也没有区别。因此,要回答您推荐的问题,我会回答“没关系”,因为它们的行为方式相同。

回答by jens-na

A working set is a subset of your workspace and is a way to organise all your projects. With the different types of working sets you have also different types of editing wizards as described here.

工作集是工作区的子集,是组织所有项目的一种方式。对于不同类型的工作集,您还有不同类型的编辑向导,如此处所述

Editing wizards

编辑向导

For java projects the Java working set is a more comfortable way to work. Let's assume you have a bunch of java projects in a java working set and you have just opend the editing wizard of the Java Working set:

对于 Java 项目,Java 工作集是一种更舒适的工作方式。假设您在一个 Java 工作集中有一堆 Java 项目,并且您刚刚打开了 Java 工作集的编辑向导:

First of all you can see everything what is in the working set at the moment in the right table. If you now want to include another project you can simply select the project(s) and press CTRL+a. To remove a project you can press CTRL+r

首先,您可以在右表中看到当前工作集中的所有内容。如果您现在想要包含另一个项目,您只需选择项目并按CTRL+ 即可a。要删除项目,您可以按CTRL+r

In the Properties of a Resources Working set you don't know what is in the working set until you have scrolled to the bottom of the tree view. This is impossible for people who have 300+ projects in their workspace.

在资源工作集中的属性中,您不知道工作集中有什么,直到您滚动到树视图的底部。这对于工作区中有 300 多个项目的人来说是不可能的。

Structure

结构

A benefit from having two types of working sets is structure. There are situations in a daily workflow where it is useful to have different types of working sets, because they have different icons. If you have resources like config files you can create a Resource working set namend 'config files' and put all the files in there.

拥有两种类型的工作集的一个好处是结构。在日常工作流程中,有些情况下使用不同类型的工作集很有用,因为它们具有不同的图标。如果您有配置文件之类的资源,您可以创建一个名为“配置文件”的资源工作集,并将所有文件放在那里。

Afterwards you can open your File Search and search in your config files. This is possible because you can define a working set as a scope for a search.

之后,您可以打开文件搜索并在配置文件中进行搜索。这是可能的,因为您可以将工作集定义为搜索范围。

enter image description here

在此处输入图片说明

There are several parts in Eclipse where you can select your working set with the Select working set dialog.

Eclipse 中有几个部分,您可以在其中使用“选择工作集”对话框来选择您的工作集。

回答by kapex

I'll try answering from the perspective as a plugin developer. From the API:

我将尝试从插件开发人员的角度进行回答。从API

A working set is intended to group elements for presentation to the user or for operations on a set of elements.

工作集旨在将元素分组以呈现给用户或对一组元素进行操作。

This can be any kind of element and does not have to be a project. Working sets are provided by plugins, which can decide what kind of elements can be added and which provide wizards for adding elements as well as operations that can be performed.

这可以是任何类型的元素,不必是一个项目。工作集由插件提供,插件可以决定可以添加什么类型的元素,哪些提供添加元素的向导以及可以执行的操作。

It doesn't really matter for a project in which working set(s) it is in. A Java project is still a Java project if it in a resource working set. It only affects some views, dialogs and operations that filter for certain types of working sets.

对于它所在的工作集的项目来说并不重要。如果 Java 项目在资源工作集中,它仍然是一个 Java 项目。它只影响过滤某些类型工作集的一些视图、对话框和操作。

Besides Javaand Resourceworking sets, there are also Breakpoint, Task, Pluginand C/C++working sets (depending on your Eclipse setup of course). Some views only show certain types of working sets while other views don't seem to filter them. For example the "Open Type" and "Open Resource" dialogs seem to display all types of working sets. The "Open task" dialog only shows task working sets.

除了JavaResource工作集,还有BreakpointTaskPluginC/C++工作集(当然取决于你的 Eclipse 设置)。一些视图只显示某些类型的工作集,而其他视图似乎没有过滤它们。例如,“打开类型”和“打开资源”对话框似乎显示了所有类型的工作集。“打开任务”对话框仅显示任务工作集。

So what is the actual difference between Java and Resource working sets? I haven't seen any functional differences yet. All standard views and dialogs either seem to handle both or none of these two working set types. Most plugins don't seem to care about the distinction at all - but that doesn't mean some plugin couldhandle both types differently.

那么 Java 和 Resource 工作集之间的实际区别是什么?我还没有看到任何功能差异。所有标准视图和对话框似乎都处理或不处理这两种工作集类型。大多数插件似乎根本不关心区别 - 但这并不意味着某些插件可以以不同的方式处理这两种类型。

On the other hand resource working sets seem to be a catch-all for any type of project, so it makes sense that most plugins don't make a distinction here. For example if I were to create a plugin that provides an option to analyze Java projects, I would add that operation to the context menu of Java working sets but certainly not to C/C++ working sets. But some people might use resource working sets because they have both Java and C projects in the same working set. So I have to add the Java-specific operation to the context menu of resource working sets too.

另一方面,资源工作集对于任何类型的项目来说似乎都是一个包罗万象的东西,因此大多数插件在这里不做区分是有道理的。例如,如果我要创建一个提供分析 Java 项目选项的插件,我会将该操作添加到 Java 工作集的上下文菜单中,但肯定不会添加到 C/C++ 工作集。但是有些人可能会使用资源工作集,因为他们在同一个工作集中同时拥有 Java 和 C 项目。所以我也必须将特定于 Java 的操作添加到资源工作集的上下文菜单中。