generated from JetBrains/intellij-platform-plugin-template
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added project action to clear the cache.
Ensure that the project gets refreshed each time a build action is ran.
- Loading branch information
Showing
4 changed files
with
71 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
53 changes: 53 additions & 0 deletions
53
src/main/java/rife/bld/idea/project/BldProjectClearCacheAction.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
package rife.bld.idea.project; | ||
|
||
import com.intellij.icons.AllIcons; | ||
import com.intellij.openapi.actionSystem.ActionUpdateThread; | ||
import com.intellij.openapi.actionSystem.AnAction; | ||
import com.intellij.openapi.actionSystem.AnActionEvent; | ||
import com.intellij.openapi.application.ApplicationManager; | ||
import com.intellij.openapi.project.DumbAware; | ||
import com.intellij.openapi.project.Project; | ||
import org.jetbrains.annotations.NotNull; | ||
import rife.bld.idea.execution.BldExecution; | ||
import rife.bld.idea.utils.BldBundle; | ||
|
||
import java.io.IOException; | ||
|
||
final class BldProjectClearCacheAction extends AnAction implements DumbAware { | ||
private final Project project_; | ||
|
||
public BldProjectClearCacheAction(Project project) { | ||
super(BldBundle.messagePointer("bld.action.clearCache.name"), | ||
BldBundle.messagePointer("bld.action.clearCache.description"), AllIcons.Actions.GC); | ||
|
||
project_ = project; | ||
} | ||
|
||
@Override | ||
public void actionPerformed(@NotNull AnActionEvent e) { | ||
var cache = BldExecution.getInstance(project_).getBldCache(); | ||
if (cache != null) { | ||
ApplicationManager.getApplication().runWriteAction( | ||
() -> { | ||
try { | ||
cache.delete(null); | ||
} catch (IOException ex) { | ||
throw new RuntimeException(ex); | ||
} | ||
} | ||
); | ||
} | ||
} | ||
|
||
@Override | ||
public void update(@NotNull AnActionEvent event) { | ||
final var presentation = event.getPresentation(); | ||
presentation.setText(BldBundle.messagePointer("bld.action.clearCache.name")); | ||
presentation.setEnabled(BldExecution.getInstance(project_).hasBldCache()); | ||
} | ||
|
||
@Override | ||
public @NotNull ActionUpdateThread getActionUpdateThread() { | ||
return ActionUpdateThread.EDT; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters