Intellij 项目视图:不在同一个文件中显示多个类

我在 Intellij 的项目视图中发现的一件令人沮丧的事情是,它显示了一个文件中的所有类,而不仅仅是为该文件命名的类.

One frustrating thing I find in Intellij's project view is that it shows all the classes in a file instead of just the class for which the file is named.

这样做的问题是,要打开一个文件,我必须双击两次:一次展开文件并显示文件中的类,然后第二次实际打开文件.

The problem with this is that to open a file I have to double click twice: once to expand the file and show the classes in the file, and then a second time to actually open the file.

在大多数情况下,我不想看到文件中的类.我只想在项目视图中查看该文件,当我双击该文件时,我想打开该文件,而不是深入了解其结构.

In most cases I don't want to see the classes inside of a file. I just want to see the file in the project view and when I double click on the file I want to open the file, not drill down into its structure.

可以这样配置我的用户界面吗?

Is it possible to configure my UI this way?

更新:进一步解释

显然人们在理解这个问题时遇到了问题.请参见 Intellij Project 导航窗格的上图.请注意,某些类(蓝色圆圈)带有 + 号,而其他类则没有.带有加号的文件是其中包含多个类的文件.

Apparently people are having problems understanding this question. See the above picture of the Intellij Project navigation pane. Notice that some classes (the blue circles) have a + sign and others do not. The ones with a plus sign are files that have multiple classes inside of them.

问题是,如果你双击一个只有一个类(没有加号)的文件,它会打开(好),但是如果你双击一个有多个类的文件(有加号)然后文件不会打开,它只是扩展加号以将文件中的各个类显示为 BoxArray.java,例如 (BAD).

The problem is that if you double click on a file with only one class (no plus sign) it opens (GOOD), but if you double click on a file with multiple classes in it (has plus sign) then the file does NOT open, it just expands the plus sign to show you the individual classes in the file as BoxArray.java, for example (BAD).

例如,如果我在上面的视图中双击文件 Coastline.java,它不会打开文件,它会展开加号.当我双击 Coastline.java 时,我希望它打开 Coastline.java,而不是展开它.我不在乎查看类文件中的类,我只想双击打开它.

For example, if I double click on the file Coastline.java in the view above it will NOT open the file, it will expand the plus sign. I want it to open Coastline.java when I double click on Coastline.java, not expand it. I do not care about seeing the classes inside of a class file, I just want to open it in one double click.

我知道我可以使用热键 F4 来执行此操作.我不想按 F4 键.我想双击文件并打开它.

I know that I can use the hotkey F4 to do this. I do not want to reach for the F4 key. I want to double click on the file and have it open.

推荐答案

当你在你的项目工具窗口(视图>工具窗口>项目)的小菜单中启用Autoscroll to Source时,单击一个集合(关闭和打开)直接进入代码以及折叠/展开它.

When you enable Autoscroll to Source in the little menu of your Project tool window (View > Tool Windows > Project), single clicking a collection (closed and opened) goes straight to the code as well as folding / unfolding it.

这适用于 IntelliJ 13.1 和 14(在 OSX 和 Linux 中)

This works in IntelliJ 13.1 and 14 (in OSX and Linux)

相关文章