-
Notifications
You must be signed in to change notification settings - Fork 376
Expand file tree
/
Copy pathDeleteConversationAction.java
More file actions
53 lines (46 loc) · 1.77 KB
/
DeleteConversationAction.java
File metadata and controls
53 lines (46 loc) · 1.77 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
package ee.carlrobert.codegpt.actions.toolwindow;
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.project.Project;
import com.intellij.openapi.ui.Messages;
import ee.carlrobert.codegpt.actions.ActionType;
import ee.carlrobert.codegpt.actions.editor.EditorActionsUtil;
import ee.carlrobert.codegpt.conversations.ConversationsState;
import ee.carlrobert.codegpt.telemetry.TelemetryAction;
import ee.carlrobert.codegpt.ui.OverlayUtil;
import org.jetbrains.annotations.NotNull;
public class DeleteConversationAction extends AnAction {
private final Runnable onDelete;
public DeleteConversationAction(Runnable onDelete) {
super("Delete Conversation", "Delete single conversation", AllIcons.Actions.GC);
this.onDelete = onDelete;
EditorActionsUtil.registerAction(this);
}
@Override
public void update(@NotNull AnActionEvent event) {
Project project = event.getProject();
if (project == null) {
event.getPresentation().setEnabled(false);
return;
}
event.getPresentation().setEnabled(ConversationsState.getInstance(project).getCurrentConversation() != null);
}
@Override
public void actionPerformed(@NotNull AnActionEvent event) {
if (OverlayUtil.showDeleteConversationDialog() == Messages.YES) {
var project = event.getProject();
if (project != null) {
TelemetryAction.IDE_ACTION.createActionMessage()
.property("action", ActionType.DELETE_CONVERSATION.name())
.send();
onDelete.run();
}
}
}
@Override
public @NotNull ActionUpdateThread getActionUpdateThread() {
return ActionUpdateThread.EDT;
}
}