2011-03-29 46 views
18

我是eclipse插件開發新手。我想刷新我的工作空間或以編程方式完成Eclipse。那麼是否有任何以編程方式刷新eclipse?如何以編程方式刷新eclipse工作區?

+2

[This](http://blog.pengoworks.com/index.cfm/2008/6/30/Refreshing-Eclipse-Workspace-using-ANT)可以幫助你。 – 2011-03-29 04:38:09

+0

@Harry Joy:感謝這正是我需要的,在ant腳本中刷新eclipse。 – 2013-01-23 08:46:30

+0

[用Ant刷新Eclipse項目](https://stackoverflow.com/questions/985976/refresh-an-eclipse-project-with-ant) – 2017-10-31 06:10:51

回答

17

使用IResource.refreshLocal() API。您可以在項目根目錄,特定文件夾或單個文件中執行此操作。要刷新工作區中的所有項目,只需使用ResourcesPlugin.getWorkspace().getRoot().getProjects() API枚舉所有項目並依次刷新。

+0

我得到工作區關閉的IllegalStateException。如何解決這個問題呢? – 2016-11-30 05:22:54

3

下面是一個用於刷新Eclipse工作區中每個項目的快速片段。

for(IProject project : ResourcesPlugin.getWorkspace().getRoot().getProjects()){ 
    project.refreshLocal(IResource.DEPTH_INFINITE, new NullProgressMonitor()); 
} 
+0

我得到工作區關閉的IllegalStateException。如何解決這個問題呢? – 2016-11-30 05:22:25

+0

可能是一些事情。你是否偶然地以無頭的方式運行Eclipse?如果是這樣,確保你實際上已經建立了一個工作區。另外檢查你的插件清單設置,請閱讀這篇文章:https://stackoverflow.com/questions/962364/workspace-is-closed-exception-when-trying-to-get-the-workspace-through-resourc – 2016-12-03 21:27:03

相關問題