generated from JetBrains/intellij-platform-plugin-template
-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4 from LiLittleCat/2-add-a-refresh-or-a-reload-bu…
…tton fix #2, remove session token check
- Loading branch information
Showing
7 changed files
with
85 additions
and
31 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
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
45 changes: 45 additions & 0 deletions
45
src/main/java/com/lilittlecat/chatgpt/action/RefreshAction.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,45 @@ | ||
package com.lilittlecat.chatgpt.action; | ||
|
||
import com.intellij.icons.AllIcons; | ||
import com.intellij.openapi.actionSystem.AnActionEvent; | ||
import com.intellij.openapi.project.DumbAwareAction; | ||
import com.intellij.openapi.wm.ToolWindow; | ||
import com.intellij.openapi.wm.ToolWindowManager; | ||
import com.intellij.ui.content.Content; | ||
import com.intellij.ui.content.ContentFactory; | ||
import com.intellij.ui.content.ContentManager; | ||
import com.lilittlecat.chatgpt.message.ChatGPTBundle; | ||
import com.lilittlecat.chatgpt.window.ChatGPTToolWindow; | ||
import org.jetbrains.annotations.Nls; | ||
import org.jetbrains.annotations.NotNull; | ||
|
||
import java.util.Objects; | ||
|
||
/** | ||
* @author LiLittleCat | ||
* @link <a href="https://github.com/LiLittleCat">https://github.com/LiLittleCat</a> | ||
* @since 2022/12/15 | ||
*/ | ||
public class RefreshAction extends DumbAwareAction { | ||
public RefreshAction(@NotNull @Nls String text) { | ||
super(() -> text, AllIcons.Actions.Refresh); | ||
} | ||
|
||
@Override | ||
public void actionPerformed(@NotNull AnActionEvent e) { | ||
ToolWindowManager instance = ToolWindowManager.getInstance(Objects.requireNonNull(e.getProject())); | ||
ToolWindow toolWindow = instance.getToolWindow("ChatGPT"); | ||
if (toolWindow != null) { | ||
ContentManager contentManager = toolWindow.getContentManager(); | ||
Content browserContent = contentManager.findContent(ChatGPTBundle.message("browser.tab.name")); | ||
if (browserContent != null) { | ||
contentManager.removeContent(browserContent, false); | ||
} | ||
ContentFactory contentFactory = ContentFactory.SERVICE.getInstance(); | ||
Content browser = contentFactory.createContent(new ChatGPTToolWindow().getContent(), | ||
ChatGPTBundle.message("browser.tab.name"), false); | ||
contentManager.addContent(browser); | ||
contentManager.setSelectedContent(browser); | ||
} | ||
} | ||
} |
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
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 |
---|---|---|
@@ -1,4 +1,5 @@ | ||
name=ChatGPT | ||
|
||
setting.session.token.label=Session token: | ||
setting.menu.text=ChatGPT | ||
setting.menu.text=ChatGPT | ||
browser.tab.name=chat.openai.com |