【发布时间】:2015-01-28 06:01:37
【问题描述】:
有没有办法通过插件以编程方式刷新/同步 IntelliJ IDEA 项目?
我正在开发一个在活动项目中创建文件的 IntelliJ IDEA 插件。我想通过插件自动刷新/同步项目,以便用户可以立即看到更改。这在 IntelliJ IDEA 中可行吗?
【问题讨论】:
标签: java intellij-idea intellij-plugin intellij-14
有没有办法通过插件以编程方式刷新/同步 IntelliJ IDEA 项目?
我正在开发一个在活动项目中创建文件的 IntelliJ IDEA 插件。我想通过插件自动刷新/同步项目,以便用户可以立即看到更改。这在 IntelliJ IDEA 中可行吗?
【问题讨论】:
标签: java intellij-idea intellij-plugin intellij-14
在深入挖掘之后,我通过了以下解决方案,并且成功了。
public void actionPerformed(AnActionEvent e) {
// Create/Modify files
// Get the project from the ActionEvent
Project project = e.getData(PlatformDataKeys.PROJECT);
// Get the Base Dir and refresh with the following parameters
// 'asynchronous' set to false and 'recursive' set to true
project.getBaseDir().refresh(false,true);
}
【讨论】:
您可以为此使用 SyncAction
SyncProjectAction().actionPerformed(actionEvent)
【讨论】: