我可以在 Eclipse Java 编辑器中保存/恢复分割窗口布局吗?

发布于 2024-12-24 21:23:20 字数 628 浏览 6 评论 0原文

我喜欢使用 Eclipse 的 Java 编辑器功能,它允许我将编辑器窗口分成几个窗格,这样我就可以同时查看多个文件。

示例分割窗口布局

分割的布局通常取决于上下文。理想情况下,我希望能够保存布局本身并保留打开的文件。 IntelliJ IDEA 支持保存完整上下文,包括拆分窗口布局。

我已经熟悉并使用 Mylyn 任务上下文保存/恢复。事实上,Mylyn 任务恢复实际上会在任务切换时破坏并清除分割窗口排列。对于此缺陷,有一个五年前的 Mylyn 错误报告

保存透视功能似乎也不保存窗格布局。有没有办法在有或没有插件的情况下做到这一点?

I like to use Eclipse's Java editor feature that allows the me to split the editor window into several panes so I can look at multiple files at once.

Sample split window layout

Often the layout of the splits is context dependent. Ideally I'd like to be able to save the layout itself as well preserve which files were open. IntelliJ IDEA supports saving the complete context including split window layouts.

I am already familiar with and use the Mylyn task context save/restore. In fact, the Mylyn task restore actually destroys and clears the split-window arrangement upon task switch. There's a five-year-old Mylyn bug report for this defect.

It seems that the save perspective feature also doesn't save the pane layout. Is there a way to do this with or without a plugin?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

千鲤 2024-12-31 21:23:20

一般答案:可能有可能。

打开的编辑器和 UI 设置大部分保存在 /.metadata/.plugins/org.eclipse.ui.workbench/workbench.xml 路径中。正如您所看到的,它保存在独立于已安装插件的位置,因此您甚至可以在没有负责打开编辑器的插件时恢复布局(这种情况经常发生在我身上,因为我在许多 Eclipse 配置之间共享一个工作区)。

浏览 Eclipse 源代码,我发现该文件是从 org.eclipse.ui.internal.WorkbenchrestoreState()(阅读)和 recordWorkbenchState 中访问的()+saveMementoToFile()(写入)。因此,在单独的插件中复制此功能并读取/写入不同的(配置文件)文件应该足以满足基本使用。

General answer: probably it's possible.

Open editors and UI settings are kept in <WS>/.metadata/.plugins/org.eclipse.ui.workbench/workbench.xml path, in great part. As you can see it's kept in a place independent of the installed plugins, so you can even restore the layout when there are no plugins responsible for opened editors (it happens to me often, as I share one workspace between many Eclipse configuration).

Skimming through the Eclipse sources, I see this file being accessed from org.eclipse.ui.internal.Workbench, in restoreState() (reading) and in recordWorkbenchState()+saveMementoToFile() (writing). So reproducing this functionality in a separate plugin and reading/writing to a different (profile) file should be enough for basic usage.

腹黑女流氓 2024-12-31 21:23:20

据我所知,如果不使用某种插件,这是不可能的。我经常处理多个文件并像您一样分割它们,但据我了解它是如何工作的,只要该窗格中存在文件,布局就会保持不变。

当您打开一个新编辑器并“拆分”编辑器区域(将编辑器的选项卡拖动到编辑器区域的边缘)时,Eclipse 将在新的“编辑器窗格”中打开该编辑器。您可以多次执行此操作,如图所示。

我认为你的想法的问题是当所有编辑器都关闭时,然后尝试打开一个新项目,它应该在哪个编辑器窗格中打开?目前,您有一个分割窗格视图,其中文件已打开,并尝试打开一个新文件,它会在最后一个具有焦点的窗格中打开。

这听起来是一个非常好的主意,我建议在 Eclipse 上制作增强票< /a> 添加此功能。

As far as I know, this isn't possible without using some sort of plugin. I frequently work with multiple files and split them like you do, but as I understand how it works, the layout remains so long as there is a file in that pane.

When you open a new editor and "split" the editor area (drag the tab for the editor to an edge of the editor area), Eclipse opens the editor in a new "editor pane". You can do this a number of times, as you've shown in your picture.

I think the problem with your idea is when all the editors are closed, then try to open a new item, which editor pane should it open in? Currently, you have a split pane view with files already open and try to open a new file, it opens in the last pane that had focus.

It sounds like a really good idea and I would suggest making a enhancement ticket on Eclipse to add this functionality.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文