I would like to have Eclipse (3.5, if that matters) close any open projects I have before I exit my workspace. Is this possible?
我想让Eclipse(3.5,如果这很重要)关闭我退出工作区之前的任何打开的项目。这可能吗?
EDIT I forgot to mention that these projects are remotely stored and it would be nice for that reason as well.
编辑我忘了提到这些项目是远程存储的,这也是很好的理由。
3 个解决方案
#1
9
Update 2011:
To actually close all projects on exit, you need a plugin similar to the one mentioned in this thread:
要在退出时实际关闭所有项目,您需要一个类似于此线程中提到的插件:
I have implemented
shutdown()
of my plugin to close all the project and save the workspace.我已经实现了我的插件的shutdown()来关闭所有项目并保存工作区。
Note: today, you would implement the stop()
method of an AbstractUIPlugin
, since shutdown()
has been deprecated in Eclipse3.0+.
In it, you would call IProject.close()
.
注意:今天,您将实现AbstractUIPlugin的stop()方法,因为在Eclipse3.0 +中不推荐使用shutdown()。在其中,您将调用IProject.close()。
But you also need to set the org.eclipse.ui.IWorkbenchPreferenceConstants.CLOSE_EDITORS_ON_EXIT preference (the one I originally referenced below) for Eclipse to not try to restore those editors when you restart Eclipse again.
If you don't, you will get some exceptions like:
但是,您还需要设置org.eclipse.ui.IWorkbenchPreferenceConstants.CLOSE_EDITORS_ON_EXIT首选项(我最初在下面引用的首选项),以便Eclipse在再次重新启动Eclipse时不尝试还原这些编辑器。如果你不这样做,你会得到一些例外:
Could not restore workbench layout
Unable to restore editor -
createElement returned null for input element factory:
org.eclipse.ui.part.FileEditorInputFactory.
Original answer back in 2010 ;)
原答案回到2010年;)
This preference is close you need (from this JavaTips) -- it does not close projects, but at least clean your workspace:
这个首选项是你需要的(从这个JavaTips开始) - 它不关闭项目,但至少清理你的工作区:
> General > Editors > Close editors automatically
When any workspace of the eclipse is closed without closing all its editors and again opens the same workspace, it opens all the editors again which were opened at the time of closing.
This might cause slow down the starting of the eclipse.
So it is better to close all the opened editors before closing the workspace.当关闭eclipse的任何工作空间而不关闭所有编辑器并再次打开相同的工作空间时,它会再次打开所有编辑器,这些编辑器在关闭时打开。这可能会导致日食开始减慢。因此,最好在关闭工作区之前关闭所有打开的编辑器。
All open editors can be closed automatically with the closing of the eclipse workspace.
关闭Eclipse工作区后,可以自动关闭所有打开的编辑器。
#2
1
I guess you can write a plugin to do it but since you're the first person who seems to need this, nothing like this exists.
我想你可以写一个插件去做,但因为你是第一个似乎需要这个的人,所以不存在这样的东西。
#3
0
Is it Ok to add an answer several years later ... just discovered if you right click on the project and click close all unrelated projects, all the projects unrelated close anyway which is a quicker way of closing all your projects.
几年后添加答案是否可以...刚刚发现如果您右键单击项目并单击关闭所有不相关的项目,所有项目无关紧密关闭,这是关闭所有项目的更快捷方式。
If thats helpful to anyone in future ? :-)
如果那将来对任何人都有帮助? :-)
#1
9
Update 2011:
To actually close all projects on exit, you need a plugin similar to the one mentioned in this thread:
要在退出时实际关闭所有项目,您需要一个类似于此线程中提到的插件:
I have implemented
shutdown()
of my plugin to close all the project and save the workspace.我已经实现了我的插件的shutdown()来关闭所有项目并保存工作区。
Note: today, you would implement the stop()
method of an AbstractUIPlugin
, since shutdown()
has been deprecated in Eclipse3.0+.
In it, you would call IProject.close()
.
注意:今天,您将实现AbstractUIPlugin的stop()方法,因为在Eclipse3.0 +中不推荐使用shutdown()。在其中,您将调用IProject.close()。
But you also need to set the org.eclipse.ui.IWorkbenchPreferenceConstants.CLOSE_EDITORS_ON_EXIT preference (the one I originally referenced below) for Eclipse to not try to restore those editors when you restart Eclipse again.
If you don't, you will get some exceptions like:
但是,您还需要设置org.eclipse.ui.IWorkbenchPreferenceConstants.CLOSE_EDITORS_ON_EXIT首选项(我最初在下面引用的首选项),以便Eclipse在再次重新启动Eclipse时不尝试还原这些编辑器。如果你不这样做,你会得到一些例外:
Could not restore workbench layout
Unable to restore editor -
createElement returned null for input element factory:
org.eclipse.ui.part.FileEditorInputFactory.
Original answer back in 2010 ;)
原答案回到2010年;)
This preference is close you need (from this JavaTips) -- it does not close projects, but at least clean your workspace:
这个首选项是你需要的(从这个JavaTips开始) - 它不关闭项目,但至少清理你的工作区:
> General > Editors > Close editors automatically
When any workspace of the eclipse is closed without closing all its editors and again opens the same workspace, it opens all the editors again which were opened at the time of closing.
This might cause slow down the starting of the eclipse.
So it is better to close all the opened editors before closing the workspace.当关闭eclipse的任何工作空间而不关闭所有编辑器并再次打开相同的工作空间时,它会再次打开所有编辑器,这些编辑器在关闭时打开。这可能会导致日食开始减慢。因此,最好在关闭工作区之前关闭所有打开的编辑器。
All open editors can be closed automatically with the closing of the eclipse workspace.
关闭Eclipse工作区后,可以自动关闭所有打开的编辑器。
#2
1
I guess you can write a plugin to do it but since you're the first person who seems to need this, nothing like this exists.
我想你可以写一个插件去做,但因为你是第一个似乎需要这个的人,所以不存在这样的东西。
#3
0
Is it Ok to add an answer several years later ... just discovered if you right click on the project and click close all unrelated projects, all the projects unrelated close anyway which is a quicker way of closing all your projects.
几年后添加答案是否可以...刚刚发现如果您右键单击项目并单击关闭所有不相关的项目,所有项目无关紧密关闭,这是关闭所有项目的更快捷方式。
If thats helpful to anyone in future ? :-)
如果那将来对任何人都有帮助? :-)