Skip to content

Commit

Permalink
feat: create the default url browser when starts
Browse files Browse the repository at this point in the history
  • Loading branch information
LiLittleCat committed Mar 21, 2023
1 parent 01abf5d commit b83e41b
Showing 1 changed file with 16 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import com.lilittlecat.chatgpt.action.AddTabAction;
import com.lilittlecat.chatgpt.action.RefreshAction;
import com.lilittlecat.chatgpt.action.SettingsAction;
import com.lilittlecat.chatgpt.message.ChatGPTBundle;
import com.lilittlecat.chatgpt.setting.ChatGPTSettingsState;
import org.jetbrains.annotations.NotNull;

import java.util.ArrayList;
Expand All @@ -28,19 +28,22 @@ public void createToolWindowContent(@NotNull Project project, @NotNull ToolWindo
ContentManager contentManager = toolWindow.getContentManager();
@SuppressWarnings("DialogTitleCapitalization")
Content labelContent = contentManager.getFactory().createContent(
new ChatGPTToolWindow(ChatGPTBundle.message("default.url")).getContent(), ChatGPTBundle.message("browser.tab.name"), false);
new ChatGPTToolWindow(ChatGPTSettingsState.getInstance().defaultUrl).getContent(),
ChatGPTSettingsState.getInstance().defaultUrl, false);
contentManager.addContent(labelContent);
contentManager.addContentManagerListener(new ContentManagerListener() {
@Override
public void contentRemoved(@NotNull ContentManagerEvent event) {
// when all tabs are closed, add a new tab
if (contentManager.getContentCount() == 0) {
Content labelContent = contentManager.getFactory().createContent(
new ChatGPTToolWindow(ChatGPTBundle.message("default.url")).getContent(), ChatGPTBundle.message("browser.tab.name"), false);
contentManager.addContent(labelContent);
}
}
}
contentManager.addContentManagerListener(
new ContentManagerListener() {
@Override
public void contentRemoved(@NotNull ContentManagerEvent event) {
// when all tabs are closed, add a new tab
if (contentManager.getContentCount() == 0) {
Content labelContent = contentManager.getFactory().createContent(
new ChatGPTToolWindow(ChatGPTSettingsState.getInstance().defaultUrl).getContent(),
ChatGPTSettingsState.getInstance().defaultUrl, false);
contentManager.addContent(labelContent);
}
}
}
);
// add actions to tool window
List<AnAction> anActionList = new ArrayList<>();
Expand Down

0 comments on commit b83e41b

Please sign in to comment.