Skip to content

Commit

Permalink
feat: add GitHubAction and MorePluginAction
Browse files Browse the repository at this point in the history
  • Loading branch information
LiLittleCat committed Mar 21, 2023
1 parent 622ddc9 commit 8839339
Show file tree
Hide file tree
Showing 4 changed files with 66 additions and 9 deletions.
25 changes: 25 additions & 0 deletions src/main/java/com/lilittlecat/chatgpt/action/GitHubAction.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package com.lilittlecat.chatgpt.action;

import com.intellij.icons.AllIcons;
import com.intellij.ide.BrowserUtil;
import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.project.DumbAwareAction;
import com.lilittlecat.chatgpt.message.ChatGPTBundle;
import org.jetbrains.annotations.Nls;
import org.jetbrains.annotations.NotNull;

/**
* @author <a href="https://github.com/LiLittleCat">LiLittleCat</a>
* @since 2023/3/21
*/
public class GitHubAction extends DumbAwareAction {

public GitHubAction(@NotNull @Nls String text) {
super(() -> text, AllIcons.Vcs.Vendors.Github);
}

@Override
public void actionPerformed(@NotNull AnActionEvent e) {
BrowserUtil.browse(ChatGPTBundle.message("github.url"));
}
}
24 changes: 24 additions & 0 deletions src/main/java/com/lilittlecat/chatgpt/action/MorePluginAction.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package com.lilittlecat.chatgpt.action;

import com.intellij.icons.AllIcons;
import com.intellij.ide.BrowserUtil;
import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.project.DumbAwareAction;
import com.lilittlecat.chatgpt.message.ChatGPTBundle;
import org.jetbrains.annotations.Nls;
import org.jetbrains.annotations.NotNull;

/**
* @author <a href="https://github.com/LiLittleCat">LiLittleCat</a>
* @since 2023/3/21
*/
public class MorePluginAction extends DumbAwareAction {
public MorePluginAction(@NotNull @Nls String text) {
super(() -> text, AllIcons.Nodes.Plugin);
}

@Override
public void actionPerformed(@NotNull AnActionEvent e) {
BrowserUtil.browse(ChatGPTBundle.message("more.plugins.url"));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,8 @@
import com.intellij.ui.content.ContentManager;
import com.intellij.ui.content.ContentManagerEvent;
import com.intellij.ui.content.ContentManagerListener;
import com.lilittlecat.chatgpt.action.AddTabAction;
import com.lilittlecat.chatgpt.action.RefreshAction;
import com.lilittlecat.chatgpt.action.SettingsAction;
import com.lilittlecat.chatgpt.action.*;
import com.lilittlecat.chatgpt.message.ChatGPTBundle;
import com.lilittlecat.chatgpt.setting.ChatGPTSettingsState;
import org.jetbrains.annotations.NotNull;

Expand All @@ -26,7 +25,6 @@ public class ChatGPTToolWindowFactory implements ToolWindowFactory {
@Override
public void createToolWindowContent(@NotNull Project project, @NotNull ToolWindow toolWindow) {
ContentManager contentManager = toolWindow.getContentManager();
@SuppressWarnings("DialogTitleCapitalization")
Content labelContent = contentManager.getFactory().createContent(
new ChatGPTToolWindow(ChatGPTSettingsState.getInstance().defaultUrl).getContent(),
ChatGPTSettingsState.getInstance().defaultUrl, false);
Expand All @@ -47,9 +45,11 @@ public void contentRemoved(@NotNull ContentManagerEvent event) {
);
// add actions to tool window
List<AnAction> anActionList = new ArrayList<>();
anActionList.add(new SettingsAction("Settings"));
anActionList.add(new RefreshAction("Refresh"));
anActionList.add(new AddTabAction("Add Tab"));
anActionList.add(new SettingsAction(ChatGPTBundle.message("settings.action")));
anActionList.add(new RefreshAction(ChatGPTBundle.message("refresh.action")));
anActionList.add(new AddTabAction(ChatGPTBundle.message("add.tab.action")));
anActionList.add(new GitHubAction(ChatGPTBundle.message("github.action")));
anActionList.add(new MorePluginAction(ChatGPTBundle.message("more.plugins.action")));
toolWindow.setTitleActions(anActionList);
}
}
12 changes: 10 additions & 2 deletions src/main/resources/messages/ChatGPTBundle.properties
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name=ChatGPT Tool

setting.session.token.label=Session token:
setting.menu.text=ChatGPT Tool
default.url.message=Default URL:
url.list.message=URL list:
original.url=https://chat.openai.com
default.url=https://chat.openai.com
Expand All @@ -17,10 +17,18 @@ jBCefApp.not.supported=<html><body style='text-align: center; display: flex; jus
chatgpt.settings.defaultUrlCanNotBeRemoved=Default URL can not be removed.
chatgpt.settings.originalUrlCanNotBeRemoved=Original URL can not be removed.
chatgpt.settings.fetch.url.list.from.github=Fetch URL list from GitHub
default.url.message=Default URL:

free.chatgpt.file.url.original=https://raw.githubusercontent.com/LiLittleCat/awesome-free-chatgpt/main/urls.json
free.chatgpt.file.url.fallback=https://cdn.jsdelivr.net/gh/LiLittleCat/awesome-free-chatgpt/urls.json
cannot.fetch.message=Can not fetch from remote, please check your network
success.fetch.message=Successfully fetched from remote


settings.action=Settings
refresh.action=Refresh
add.tab.action=Add Tab
github.action=Author's GitHub
github.url=https://github.com/LiLittleCat
more.plugins.action=More plugins from Author
more.plugins.url=https://plugins.jetbrains.com/organizations/LiLittleCat

0 comments on commit 8839339

Please sign in to comment.