mirror of
https://github.com/carlrobertoh/ProxyAI.git
synced 2026-05-13 07:02:34 +00:00
Remove Quartz Scheduler, You.com model change topic, theme utils, and include other basic refactoring
This commit is contained in:
parent
73870cca40
commit
53bdbcd4f5
57 changed files with 385 additions and 507 deletions
|
|
@ -1,7 +1,7 @@
|
|||
package ee.carlrobert.codegpt.toolwindow.chat;
|
||||
|
||||
import static ee.carlrobert.codegpt.util.SwingUtils.createScrollPaneWithSmartScroller;
|
||||
import static ee.carlrobert.codegpt.util.ThemeUtils.getPanelBackgroundColor;
|
||||
import static ee.carlrobert.codegpt.util.UIUtil.createScrollPaneWithSmartScroller;
|
||||
import static ee.carlrobert.codegpt.util.UIUtil.getPanelBackgroundColor;
|
||||
import static java.lang.String.format;
|
||||
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
|
|
@ -24,8 +24,8 @@ import ee.carlrobert.codegpt.toolwindow.chat.components.TotalTokensPanel;
|
|||
import ee.carlrobert.codegpt.toolwindow.chat.components.UserMessagePanel;
|
||||
import ee.carlrobert.codegpt.toolwindow.chat.components.UserPromptTextArea;
|
||||
import ee.carlrobert.codegpt.toolwindow.chat.components.UserPromptTextAreaHeader;
|
||||
import ee.carlrobert.codegpt.util.EditorUtils;
|
||||
import ee.carlrobert.codegpt.util.file.FileUtils;
|
||||
import ee.carlrobert.codegpt.util.EditorUtil;
|
||||
import ee.carlrobert.codegpt.util.file.FileUtil;
|
||||
import java.awt.BorderLayout;
|
||||
import java.awt.GridBagConstraints;
|
||||
import java.awt.GridBagLayout;
|
||||
|
|
@ -62,7 +62,7 @@ public abstract class BaseChatToolWindowTabPanel implements ChatToolWindowTabPan
|
|||
toolWindowScrollablePanel = new ChatToolWindowScrollablePanel(settings);
|
||||
totalTokensPanel = new TotalTokensPanel(
|
||||
conversation,
|
||||
EditorUtils.getSelectedEditorSelectedText(project),
|
||||
EditorUtil.getSelectedEditorSelectedText(project),
|
||||
this);
|
||||
userPromptTextArea = new UserPromptTextArea(this::handleSubmit, totalTokensPanel);
|
||||
rootPanel = createRootPanel(settings);
|
||||
|
|
@ -185,12 +185,12 @@ public abstract class BaseChatToolWindowTabPanel implements ChatToolWindowTabPan
|
|||
|
||||
private void handleSubmit(String text) {
|
||||
var message = new Message(text);
|
||||
var editor = EditorUtils.getSelectedEditor(project);
|
||||
var editor = EditorUtil.getSelectedEditor(project);
|
||||
if (editor != null) {
|
||||
var selectionModel = editor.getSelectionModel();
|
||||
var selectedText = selectionModel.getSelectedText();
|
||||
if (selectedText != null && !selectedText.isEmpty()) {
|
||||
var fileExtension = FileUtils.getFileExtension(
|
||||
var fileExtension = FileUtil.getFileExtension(
|
||||
((EditorImpl) editor).getVirtualFile().getName());
|
||||
message = new Message(text + format("\n```%s\n%s\n```", fileExtension, selectedText));
|
||||
message.setUserMessage(text);
|
||||
|
|
@ -207,9 +207,7 @@ public abstract class BaseChatToolWindowTabPanel implements ChatToolWindowTabPan
|
|||
JBUI.Borders.customLine(JBColor.border(), 1, 0, 0, 0),
|
||||
JBUI.Borders.empty(8)));
|
||||
panel.setBackground(getPanelBackgroundColor());
|
||||
panel.add(
|
||||
new UserPromptTextAreaHeader(project, settings, totalTokensPanel),
|
||||
BorderLayout.NORTH);
|
||||
panel.add(new UserPromptTextAreaHeader(settings, totalTokensPanel), BorderLayout.NORTH);
|
||||
panel.add(userPromptTextArea, BorderLayout.SOUTH);
|
||||
return panel;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
package ee.carlrobert.codegpt.toolwindow.chat;
|
||||
|
||||
import static ee.carlrobert.codegpt.util.ThemeUtils.getPanelBackgroundColor;
|
||||
import static ee.carlrobert.codegpt.util.UIUtil.getPanelBackgroundColor;
|
||||
|
||||
import com.intellij.openapi.roots.ui.componentsList.components.ScrollablePanel;
|
||||
import com.intellij.openapi.roots.ui.componentsList.layout.VerticalStackLayout;
|
||||
|
|
@ -8,7 +8,7 @@ import ee.carlrobert.codegpt.completions.you.YouUserManager;
|
|||
import ee.carlrobert.codegpt.settings.service.ServiceType;
|
||||
import ee.carlrobert.codegpt.settings.state.SettingsState;
|
||||
import ee.carlrobert.codegpt.toolwindow.chat.components.ResponsePanel;
|
||||
import ee.carlrobert.codegpt.util.SwingUtils;
|
||||
import ee.carlrobert.codegpt.util.UIUtil;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
|
@ -73,7 +73,7 @@ public class ChatToolWindowScrollablePanel extends ScrollablePanel {
|
|||
|
||||
// TODO: Move
|
||||
private JTextPane createYouCouponTextPane() {
|
||||
var textPane = SwingUtils.createTextPane(
|
||||
var textPane = UIUtil.createTextPane(
|
||||
"<html>\n"
|
||||
+ "<body>\n"
|
||||
+ " <p style=\"margin: 4px 0;\">Use CodeGPT coupon for free month of GPT-4.</p>\n"
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
package ee.carlrobert.codegpt.toolwindow.chat;
|
||||
|
||||
import com.intellij.ui.ColorUtil;
|
||||
import com.intellij.ui.JBColor;
|
||||
import com.vladsch.flexmark.ast.BulletListItem;
|
||||
import com.vladsch.flexmark.ast.Code;
|
||||
|
|
@ -11,7 +12,6 @@ import com.vladsch.flexmark.html.renderer.NodeRendererContext;
|
|||
import com.vladsch.flexmark.html.renderer.NodeRendererFactory;
|
||||
import com.vladsch.flexmark.html.renderer.NodeRenderingHandler;
|
||||
import com.vladsch.flexmark.util.data.DataHolder;
|
||||
import ee.carlrobert.codegpt.util.ThemeUtils;
|
||||
import java.util.Set;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
|
|
@ -26,7 +26,7 @@ public class ResponseNodeRenderer implements NodeRenderer {
|
|||
}
|
||||
|
||||
private void renderCode(Code node, NodeRendererContext context, HtmlWriter html) {
|
||||
html.attr("style", "color: " + ThemeUtils.getRGB(new JBColor(0x00627A, 0xCC7832)));
|
||||
html.attr("style", "color: " + ColorUtil.toHex(new JBColor(0x00627A, 0xCC7832)));
|
||||
context.delegateRender();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ import ee.carlrobert.codegpt.toolwindow.chat.components.ChatMessageResponseBody;
|
|||
import ee.carlrobert.codegpt.toolwindow.chat.components.ResponsePanel;
|
||||
import ee.carlrobert.codegpt.toolwindow.chat.components.TotalTokensPanel;
|
||||
import ee.carlrobert.codegpt.toolwindow.chat.components.UserPromptTextArea;
|
||||
import ee.carlrobert.codegpt.util.OverlayUtils;
|
||||
import ee.carlrobert.codegpt.util.OverlayUtil;
|
||||
import ee.carlrobert.llm.client.openai.completion.ErrorDetails;
|
||||
import ee.carlrobert.llm.client.you.completion.YouSerpResult;
|
||||
import java.util.HashMap;
|
||||
|
|
@ -98,7 +98,7 @@ abstract class ToolWindowCompletionResponseEventListener implements
|
|||
|
||||
@Override
|
||||
public void handleTokensExceeded(Conversation conversation, Message message) {
|
||||
var answer = OverlayUtils.showTokenLimitExceededDialog();
|
||||
var answer = OverlayUtil.showTokenLimitExceededDialog();
|
||||
if (answer == OK) {
|
||||
TelemetryAction.IDE_ACTION.createActionMessage()
|
||||
.property("action", "DISCARD_TOKEN_LIMIT")
|
||||
|
|
|
|||
|
|
@ -1,11 +0,0 @@
|
|||
package ee.carlrobert.codegpt.toolwindow.chat;
|
||||
|
||||
import com.intellij.util.messages.Topic;
|
||||
|
||||
public interface YouModelChangeNotifier {
|
||||
|
||||
Topic<YouModelChangeNotifier> YOU_MODEL_CHANGE_NOTIFIER_TOPIC =
|
||||
Topic.create("youModelChangeTopic", YouModelChangeNotifier.class);
|
||||
|
||||
void modelChanged(boolean selected);
|
||||
}
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
package ee.carlrobert.codegpt.toolwindow.chat.components;
|
||||
|
||||
import static ee.carlrobert.codegpt.util.ThemeUtils.getPanelBackgroundColor;
|
||||
import static ee.carlrobert.codegpt.util.UIUtil.getPanelBackgroundColor;
|
||||
import static java.lang.String.format;
|
||||
import static javax.swing.event.HyperlinkEvent.EventType.ACTIVATED;
|
||||
|
||||
|
|
@ -26,8 +26,8 @@ import ee.carlrobert.codegpt.toolwindow.chat.ResponseNodeRenderer;
|
|||
import ee.carlrobert.codegpt.toolwindow.chat.StreamParser;
|
||||
import ee.carlrobert.codegpt.toolwindow.chat.StreamResponseType;
|
||||
import ee.carlrobert.codegpt.toolwindow.chat.editor.ResponseEditor;
|
||||
import ee.carlrobert.codegpt.util.MarkdownUtils;
|
||||
import ee.carlrobert.codegpt.util.SwingUtils;
|
||||
import ee.carlrobert.codegpt.util.MarkdownUtil;
|
||||
import ee.carlrobert.codegpt.util.UIUtil;
|
||||
import ee.carlrobert.llm.client.you.completion.YouSerpResult;
|
||||
import java.awt.BorderLayout;
|
||||
import java.awt.Color;
|
||||
|
|
@ -93,7 +93,7 @@ public class ChatMessageResponseBody extends JPanel {
|
|||
}
|
||||
|
||||
public ChatMessageResponseBody withResponse(String response) {
|
||||
for (var message : MarkdownUtils.splitCodeBlocks(response)) {
|
||||
for (var message : MarkdownUtil.splitCodeBlocks(response)) {
|
||||
boolean isCodeResponse = message.startsWith("```");
|
||||
if (isCodeResponse) {
|
||||
currentlyProcessedEditor = null;
|
||||
|
|
@ -281,14 +281,14 @@ public class ChatMessageResponseBody extends JPanel {
|
|||
}
|
||||
|
||||
private JTextPane createTextPane(String text) {
|
||||
var textPane = SwingUtils.createTextPane(text, event -> {
|
||||
var textPane = UIUtil.createTextPane(text, event -> {
|
||||
if (FileUtil.exists(event.getDescription()) && ACTIVATED.equals(event.getEventType())) {
|
||||
VirtualFile file = LocalFileSystem.getInstance().findFileByPath(event.getDescription());
|
||||
FileEditorManager.getInstance(project).openFile(Objects.requireNonNull(file), true);
|
||||
return;
|
||||
}
|
||||
|
||||
SwingUtils.handleHyperlinkClicked(event);
|
||||
UIUtil.handleHyperlinkClicked(event);
|
||||
});
|
||||
textPane.getCaret().setVisible(true);
|
||||
textPane.setCaretPosition(textPane.getDocument().getLength());
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
package ee.carlrobert.codegpt.toolwindow.chat.components;
|
||||
|
||||
import static ee.carlrobert.codegpt.util.ThemeUtils.getPanelBackgroundColor;
|
||||
import static ee.carlrobert.codegpt.util.UIUtil.getPanelBackgroundColor;
|
||||
|
||||
import com.intellij.icons.AllIcons.Actions;
|
||||
import com.intellij.openapi.actionSystem.AnAction;
|
||||
|
|
|
|||
|
|
@ -8,11 +8,10 @@ import com.intellij.ui.DocumentAdapter;
|
|||
import com.intellij.ui.JBColor;
|
||||
import com.intellij.ui.components.JBTextArea;
|
||||
import com.intellij.util.ui.JBUI;
|
||||
import com.intellij.util.ui.UIUtil;
|
||||
import ee.carlrobert.codegpt.CodeGPTBundle;
|
||||
import ee.carlrobert.codegpt.Icons;
|
||||
import ee.carlrobert.codegpt.completions.CompletionRequestHandler;
|
||||
import ee.carlrobert.codegpt.util.SwingUtils;
|
||||
import ee.carlrobert.codegpt.util.UIUtil;
|
||||
import java.awt.BasicStroke;
|
||||
import java.awt.BorderLayout;
|
||||
import java.awt.Cursor;
|
||||
|
|
@ -29,7 +28,6 @@ import javax.swing.AbstractAction;
|
|||
import javax.swing.Icon;
|
||||
import javax.swing.JButton;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.KeyStroke;
|
||||
import javax.swing.UIManager;
|
||||
import javax.swing.event.DocumentEvent;
|
||||
import javax.swing.text.BadLocationException;
|
||||
|
|
@ -40,10 +38,8 @@ public class UserPromptTextArea extends JPanel {
|
|||
|
||||
private static final Logger LOG = Logger.getInstance(UserPromptTextArea.class);
|
||||
|
||||
private static final String TEXT_SUBMIT = "text-submit";
|
||||
private static final String INSERT_BREAK = "insert-break";
|
||||
private static final JBColor BACKGROUND_COLOR = JBColor.namedColor(
|
||||
"Editor.SearchField.background", UIUtil.getTextFieldBackground());
|
||||
"Editor.SearchField.background", com.intellij.util.ui.UIUtil.getTextFieldBackground());
|
||||
|
||||
private final JBTextArea textArea;
|
||||
|
||||
|
|
@ -64,10 +60,7 @@ public class UserPromptTextArea extends JPanel {
|
|||
textArea.setWrapStyleWord(true);
|
||||
textArea.getEmptyText().setText(CodeGPTBundle.get("toolwindow.chat.textArea.emptyText"));
|
||||
textArea.setBorder(JBUI.Borders.empty(8, 4));
|
||||
var input = textArea.getInputMap();
|
||||
input.put(KeyStroke.getKeyStroke("ENTER"), TEXT_SUBMIT);
|
||||
input.put(KeyStroke.getKeyStroke("shift ENTER"), INSERT_BREAK);
|
||||
textArea.getActionMap().put(TEXT_SUBMIT, new AbstractAction() {
|
||||
UIUtil.addShiftEnterInputMap(textArea, new AbstractAction() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
try {
|
||||
|
|
@ -190,7 +183,7 @@ public class UserPromptTextArea extends JPanel {
|
|||
|
||||
// TODO: IconActionButton?
|
||||
private JButton createIconButton(Icon icon, @Nullable Runnable submitListener) {
|
||||
var button = SwingUtils.createIconButton(icon);
|
||||
var button = UIUtil.createIconButton(icon);
|
||||
if (submitListener != null) {
|
||||
button.addActionListener((e) -> handleSubmit());
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,9 +1,8 @@
|
|||
package ee.carlrobert.codegpt.toolwindow.chat.components;
|
||||
|
||||
import static ee.carlrobert.codegpt.util.ThemeUtils.getPanelBackgroundColor;
|
||||
import static ee.carlrobert.codegpt.util.UIUtil.getPanelBackgroundColor;
|
||||
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.ui.components.JBCheckBox;
|
||||
import com.intellij.util.messages.MessageBusConnection;
|
||||
import com.intellij.util.ui.JBUI;
|
||||
|
|
@ -12,16 +11,12 @@ import ee.carlrobert.codegpt.completions.you.YouSubscriptionNotifier;
|
|||
import ee.carlrobert.codegpt.completions.you.auth.SignedOutNotifier;
|
||||
import ee.carlrobert.codegpt.settings.state.SettingsState;
|
||||
import ee.carlrobert.codegpt.toolwindow.ModelIconLabel;
|
||||
import ee.carlrobert.codegpt.toolwindow.chat.YouModelChangeNotifier;
|
||||
import java.awt.BorderLayout;
|
||||
import javax.swing.JPanel;
|
||||
|
||||
public class UserPromptTextAreaHeader extends JPanel {
|
||||
|
||||
public UserPromptTextAreaHeader(
|
||||
Project project,
|
||||
SettingsState settings,
|
||||
TotalTokensPanel totalTokensPanel) {
|
||||
public UserPromptTextAreaHeader(SettingsState settings, TotalTokensPanel totalTokensPanel) {
|
||||
super(new BorderLayout());
|
||||
setBackground(getPanelBackgroundColor());
|
||||
setBorder(JBUI.Borders.emptyBottom(8));
|
||||
|
|
@ -31,8 +26,8 @@ public class UserPromptTextAreaHeader extends JPanel {
|
|||
add(totalTokensPanel, BorderLayout.LINE_START);
|
||||
break;
|
||||
case YOU:
|
||||
JBCheckBox gpt4CheckBox = new YouProCheckbox(project);
|
||||
subscribeToYouTopics(project, gpt4CheckBox);
|
||||
JBCheckBox gpt4CheckBox = new YouProCheckbox();
|
||||
subscribeToYouTopics(gpt4CheckBox);
|
||||
add(gpt4CheckBox, BorderLayout.LINE_START);
|
||||
break;
|
||||
default:
|
||||
|
|
@ -45,21 +40,12 @@ public class UserPromptTextAreaHeader extends JPanel {
|
|||
.withBackground(getPanelBackgroundColor()), BorderLayout.LINE_END);
|
||||
}
|
||||
|
||||
private void subscribeToYouTopics(Project project, JBCheckBox gpt4CheckBox) {
|
||||
private void subscribeToYouTopics(JBCheckBox gpt4CheckBox) {
|
||||
var messageBusConnection = ApplicationManager.getApplication().getMessageBus().connect();
|
||||
subscribeToYouModelChangeTopic(project, gpt4CheckBox);
|
||||
subscribeToYouSubscriptionTopic(messageBusConnection, gpt4CheckBox);
|
||||
subscribeToSignedOutTopic(messageBusConnection, gpt4CheckBox);
|
||||
}
|
||||
|
||||
private void subscribeToYouModelChangeTopic(Project project, JBCheckBox gpt4CheckBox) {
|
||||
project.getMessageBus()
|
||||
.connect()
|
||||
.subscribe(
|
||||
YouModelChangeNotifier.YOU_MODEL_CHANGE_NOTIFIER_TOPIC,
|
||||
(YouModelChangeNotifier) gpt4CheckBox::setSelected);
|
||||
}
|
||||
|
||||
private void subscribeToSignedOutTopic(
|
||||
MessageBusConnection messageBusConnection,
|
||||
JBCheckBox gpt4CheckBox) {
|
||||
|
|
|
|||
|
|
@ -1,16 +1,13 @@
|
|||
package ee.carlrobert.codegpt.toolwindow.chat.components;
|
||||
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.ui.components.JBCheckBox;
|
||||
import ee.carlrobert.codegpt.CodeGPTBundle;
|
||||
import ee.carlrobert.codegpt.completions.you.YouUserManager;
|
||||
import ee.carlrobert.codegpt.settings.state.YouSettingsState;
|
||||
import ee.carlrobert.codegpt.toolwindow.chat.YouModelChangeNotifier;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class YouProCheckbox extends JBCheckBox {
|
||||
|
||||
public YouProCheckbox(@NotNull Project project) {
|
||||
public YouProCheckbox() {
|
||||
super(CodeGPTBundle.get("toolwindow.chat.youProCheckBox.text"));
|
||||
var youSettings = YouSettingsState.getInstance();
|
||||
var youUserManager = YouUserManager.getInstance();
|
||||
|
|
@ -21,10 +18,6 @@ public class YouProCheckbox extends JBCheckBox {
|
|||
addChangeListener(e -> {
|
||||
var selected = ((JBCheckBox) e.getSource()).isSelected();
|
||||
setToolTipText(getTooltipText(youUserManager, selected));
|
||||
// TODO: Remove
|
||||
project.getMessageBus()
|
||||
.syncPublisher(YouModelChangeNotifier.YOU_MODEL_CHANGE_NOTIFIER_TOPIC)
|
||||
.modelChanged(selected);
|
||||
youSettings.setUseGPT4Model(selected);
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
package ee.carlrobert.codegpt.toolwindow.chat.contextual;
|
||||
|
||||
import static com.intellij.openapi.ui.DialogWrapper.OK_EXIT_CODE;
|
||||
import static ee.carlrobert.codegpt.util.ThemeUtils.getPanelBackgroundColor;
|
||||
import static ee.carlrobert.codegpt.util.UIUtil.getPanelBackgroundColor;
|
||||
import static javax.swing.event.HyperlinkEvent.EventType.ACTIVATED;
|
||||
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
|
|
@ -13,8 +13,8 @@ import ee.carlrobert.codegpt.indexes.CodebaseIndexingTask;
|
|||
import ee.carlrobert.codegpt.indexes.FolderStructureTreePanel;
|
||||
import ee.carlrobert.codegpt.settings.SettingsConfigurable;
|
||||
import ee.carlrobert.codegpt.toolwindow.chat.components.ResponsePanel;
|
||||
import ee.carlrobert.codegpt.util.OverlayUtils;
|
||||
import ee.carlrobert.codegpt.util.SwingUtils;
|
||||
import ee.carlrobert.codegpt.util.OverlayUtil;
|
||||
import ee.carlrobert.codegpt.util.UIUtil;
|
||||
import ee.carlrobert.vector.VectorStore;
|
||||
import javax.swing.JTextPane;
|
||||
import javax.swing.event.HyperlinkEvent;
|
||||
|
|
@ -77,7 +77,7 @@ class ContextualChatToolWindowLandingPanel extends ResponsePanel {
|
|||
}
|
||||
|
||||
private JTextPane createTextPane() {
|
||||
var textPane = SwingUtils.createTextPane("", this::handleHyperlinkClicked);
|
||||
var textPane = UIUtil.createTextPane("", this::handleHyperlinkClicked);
|
||||
textPane.setBackground(getPanelBackgroundColor());
|
||||
return textPane;
|
||||
}
|
||||
|
|
@ -102,7 +102,7 @@ class ContextualChatToolWindowLandingPanel extends ResponsePanel {
|
|||
break;
|
||||
case "START_INDEXING":
|
||||
var folderStructureTreePanel = new FolderStructureTreePanel(project);
|
||||
var show = OverlayUtils.showFileStructureDialog(project, folderStructureTreePanel);
|
||||
var show = OverlayUtil.showFileStructureDialog(project, folderStructureTreePanel);
|
||||
if (show == OK_EXIT_CODE) {
|
||||
new CodebaseIndexingTask(project, folderStructureTreePanel.getCheckedFiles()).run();
|
||||
}
|
||||
|
|
@ -111,7 +111,7 @@ class ContextualChatToolWindowLandingPanel extends ResponsePanel {
|
|||
LOG.error("Could not trigger action {}", event.getDescription());
|
||||
}
|
||||
} else {
|
||||
SwingUtils.handleHyperlinkClicked(event);
|
||||
UIUtil.handleHyperlinkClicked(event);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
package ee.carlrobert.codegpt.toolwindow.chat.editor;
|
||||
|
||||
import static ee.carlrobert.codegpt.util.file.FileUtils.findLanguageExtensionMapping;
|
||||
import static ee.carlrobert.codegpt.util.file.FileUtil.findLanguageExtensionMapping;
|
||||
import static java.lang.String.format;
|
||||
|
||||
import com.intellij.icons.AllIcons.General;
|
||||
|
|
@ -28,7 +28,7 @@ import ee.carlrobert.codegpt.toolwindow.chat.editor.actions.DiffAction;
|
|||
import ee.carlrobert.codegpt.toolwindow.chat.editor.actions.EditAction;
|
||||
import ee.carlrobert.codegpt.toolwindow.chat.editor.actions.NewFileAction;
|
||||
import ee.carlrobert.codegpt.toolwindow.chat.editor.actions.ReplaceSelectionAction;
|
||||
import ee.carlrobert.codegpt.util.EditorUtils;
|
||||
import ee.carlrobert.codegpt.util.EditorUtil;
|
||||
import java.awt.BorderLayout;
|
||||
import java.awt.Color;
|
||||
import java.awt.FlowLayout;
|
||||
|
|
@ -53,7 +53,7 @@ public class ResponseEditor extends JPanel implements Disposable {
|
|||
var extensionMapping = findLanguageExtensionMapping(markdownLanguage);
|
||||
language = extensionMapping.getKey();
|
||||
extension = extensionMapping.getValue();
|
||||
editor = EditorUtils.createEditor(project, extension, code);
|
||||
editor = EditorUtil.createEditor(project, extension, code);
|
||||
|
||||
DefaultActionGroup group = new DefaultActionGroup();
|
||||
group.add(new ReplaceCodeInMainEditorAction());
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ import com.intellij.openapi.editor.Editor;
|
|||
import ee.carlrobert.codegpt.CodeGPTBundle;
|
||||
import ee.carlrobert.codegpt.actions.ActionType;
|
||||
import ee.carlrobert.codegpt.actions.TrackableAction;
|
||||
import ee.carlrobert.codegpt.util.OverlayUtils;
|
||||
import ee.carlrobert.codegpt.util.OverlayUtil;
|
||||
import java.awt.Toolkit;
|
||||
import java.awt.datatransfer.Clipboard;
|
||||
import java.awt.datatransfer.StringSelection;
|
||||
|
|
@ -33,7 +33,7 @@ public class CopyAction extends TrackableAction {
|
|||
var locationOnScreen = ((MouseEvent) event.getInputEvent()).getLocationOnScreen();
|
||||
locationOnScreen.y = locationOnScreen.y - 16;
|
||||
|
||||
OverlayUtils.showInfoBalloon(
|
||||
OverlayUtil.showInfoBalloon(
|
||||
CodeGPTBundle.get("toolwindow.chat.editor.action.copy.success"),
|
||||
locationOnScreen);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,9 +17,9 @@ import com.intellij.openapi.util.Pair;
|
|||
import ee.carlrobert.codegpt.CodeGPTBundle;
|
||||
import ee.carlrobert.codegpt.actions.ActionType;
|
||||
import ee.carlrobert.codegpt.actions.TrackableAction;
|
||||
import ee.carlrobert.codegpt.util.EditorUtils;
|
||||
import ee.carlrobert.codegpt.util.OverlayUtils;
|
||||
import ee.carlrobert.codegpt.util.file.FileUtils;
|
||||
import ee.carlrobert.codegpt.util.EditorUtil;
|
||||
import ee.carlrobert.codegpt.util.OverlayUtil;
|
||||
import ee.carlrobert.codegpt.util.file.FileUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class DiffAction extends TrackableAction {
|
||||
|
|
@ -37,16 +37,16 @@ public class DiffAction extends TrackableAction {
|
|||
public void handleAction(@NotNull AnActionEvent event) {
|
||||
var project = requireNonNull(event.getProject());
|
||||
var selectedTextEditor = FileEditorManager.getInstance(project).getSelectedTextEditor();
|
||||
if (!EditorUtils.hasSelection(selectedTextEditor)) {
|
||||
OverlayUtils.showSelectedEditorSelectionWarning(event);
|
||||
if (!EditorUtil.hasSelection(selectedTextEditor)) {
|
||||
OverlayUtil.showSelectedEditorSelectionWarning(event);
|
||||
return;
|
||||
}
|
||||
|
||||
var resultEditorFile = FileUtils.getEditorFile(selectedTextEditor);
|
||||
var resultEditorFile = FileUtil.getEditorFile(selectedTextEditor);
|
||||
var diffContentFactory = DiffContentFactory.getInstance();
|
||||
var request = new SimpleDiffRequest(
|
||||
CodeGPTBundle.get("editor.diff.title"),
|
||||
diffContentFactory.create(project, FileUtils.getEditorFile(editor)),
|
||||
diffContentFactory.create(project, FileUtil.getEditorFile(editor)),
|
||||
diffContentFactory.create(project, resultEditorFile),
|
||||
CodeGPTBundle.get("editor.diff.local.content.title"),
|
||||
resultEditorFile.getName());
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ import com.intellij.util.ui.FormBuilder;
|
|||
import ee.carlrobert.codegpt.CodeGPTBundle;
|
||||
import ee.carlrobert.codegpt.actions.ActionType;
|
||||
import ee.carlrobert.codegpt.actions.TrackableAction;
|
||||
import ee.carlrobert.codegpt.util.file.FileUtils;
|
||||
import ee.carlrobert.codegpt.util.file.FileUtil;
|
||||
import java.util.Objects;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
|
|
@ -49,7 +49,7 @@ public class NewFileAction extends TrackableAction {
|
|||
fileNameTextField.setColumns(30);
|
||||
|
||||
if (showDialog(project, textFieldWithBrowseButton, fileNameTextField) == OK_EXIT_CODE) {
|
||||
var file = FileUtils.createFile(
|
||||
var file = FileUtil.createFile(
|
||||
textFieldWithBrowseButton.getText(),
|
||||
fileNameTextField.getText(),
|
||||
editor.getDocument().getText());
|
||||
|
|
|
|||
|
|
@ -8,8 +8,8 @@ import com.intellij.openapi.editor.Editor;
|
|||
import ee.carlrobert.codegpt.CodeGPTBundle;
|
||||
import ee.carlrobert.codegpt.actions.ActionType;
|
||||
import ee.carlrobert.codegpt.actions.TrackableAction;
|
||||
import ee.carlrobert.codegpt.util.EditorUtils;
|
||||
import ee.carlrobert.codegpt.util.OverlayUtils;
|
||||
import ee.carlrobert.codegpt.util.EditorUtil;
|
||||
import ee.carlrobert.codegpt.util.OverlayUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class ReplaceSelectionAction extends TrackableAction {
|
||||
|
|
@ -26,10 +26,10 @@ public class ReplaceSelectionAction extends TrackableAction {
|
|||
@Override
|
||||
public void handleAction(@NotNull AnActionEvent event) {
|
||||
var project = requireNonNull(event.getProject());
|
||||
if (EditorUtils.isMainEditorTextSelected(project)) {
|
||||
EditorUtils.replaceMainEditorSelection(project, editor.getDocument().getText());
|
||||
if (EditorUtil.isMainEditorTextSelected(project)) {
|
||||
EditorUtil.replaceMainEditorSelection(project, editor.getDocument().getText());
|
||||
} else {
|
||||
OverlayUtils.showSelectedEditorSelectionWarning(event);
|
||||
OverlayUtil.showSelectedEditorSelectionWarning(event);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,13 +1,13 @@
|
|||
package ee.carlrobert.codegpt.toolwindow.chat.standard;
|
||||
|
||||
import static ee.carlrobert.codegpt.util.ThemeUtils.getPanelBackgroundColor;
|
||||
import static ee.carlrobert.codegpt.util.UIUtil.getPanelBackgroundColor;
|
||||
import static java.lang.String.format;
|
||||
import static javax.swing.event.HyperlinkEvent.EventType.ACTIVATED;
|
||||
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import ee.carlrobert.codegpt.settings.state.SettingsState;
|
||||
import ee.carlrobert.codegpt.toolwindow.chat.components.ResponsePanel;
|
||||
import ee.carlrobert.codegpt.util.SwingUtils;
|
||||
import ee.carlrobert.codegpt.util.UIUtil;
|
||||
import java.awt.event.MouseEvent;
|
||||
import javax.swing.JTextPane;
|
||||
import javax.swing.event.HyperlinkEvent;
|
||||
|
|
@ -24,7 +24,7 @@ class StandardChatToolWindowLandingPanel extends ResponsePanel {
|
|||
}
|
||||
|
||||
private JTextPane createContent() {
|
||||
var textPane = SwingUtils.createTextPane(
|
||||
var textPane = UIUtil.createTextPane(
|
||||
"<html>"
|
||||
+ format(
|
||||
"<p style=\"margin-top: 4px; margin-bottom: 4px;\">"
|
||||
|
|
@ -79,7 +79,7 @@ class StandardChatToolWindowLandingPanel extends ResponsePanel {
|
|||
LOG.error("Could not trigger action {}", event.getDescription());
|
||||
}
|
||||
} else {
|
||||
SwingUtils.handleHyperlinkClicked(event);
|
||||
UIUtil.handleHyperlinkClicked(event);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,9 +11,9 @@ import ee.carlrobert.codegpt.toolwindow.chat.BaseChatToolWindowTabPanel;
|
|||
import ee.carlrobert.codegpt.toolwindow.chat.components.ChatMessageResponseBody;
|
||||
import ee.carlrobert.codegpt.toolwindow.chat.components.ResponsePanel;
|
||||
import ee.carlrobert.codegpt.toolwindow.chat.components.UserMessagePanel;
|
||||
import ee.carlrobert.codegpt.util.EditorUtils;
|
||||
import ee.carlrobert.codegpt.util.OverlayUtils;
|
||||
import ee.carlrobert.codegpt.util.file.FileUtils;
|
||||
import ee.carlrobert.codegpt.util.EditorUtil;
|
||||
import ee.carlrobert.codegpt.util.OverlayUtil;
|
||||
import ee.carlrobert.codegpt.util.file.FileUtil;
|
||||
import javax.swing.JComponent;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
|
|
@ -34,16 +34,16 @@ public class StandardChatToolWindowTabPanel extends BaseChatToolWindowTabPanel {
|
|||
@Override
|
||||
protected JComponent getLandingView() {
|
||||
return new StandardChatToolWindowLandingPanel((action, locationOnScreen) -> {
|
||||
var editor = EditorUtils.getSelectedEditor(project);
|
||||
var editor = EditorUtil.getSelectedEditor(project);
|
||||
if (editor == null || !editor.getSelectionModel().hasSelection()) {
|
||||
OverlayUtils.showWarningBalloon(
|
||||
OverlayUtil.showWarningBalloon(
|
||||
editor == null ? "Unable to locate a selected editor"
|
||||
: "Please select a target code before proceeding",
|
||||
locationOnScreen);
|
||||
return;
|
||||
}
|
||||
|
||||
var fileExtension = FileUtils.getFileExtension(
|
||||
var fileExtension = FileUtil.getFileExtension(
|
||||
((EditorImpl) editor).getVirtualFile().getName());
|
||||
var message = new Message(action.getPrompt().replace(
|
||||
"{{selectedCode}}",
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
package ee.carlrobert.codegpt.toolwindow.conversations;
|
||||
|
||||
import static ee.carlrobert.codegpt.util.ThemeUtils.getPanelBackgroundColor;
|
||||
import static ee.carlrobert.codegpt.util.UIUtil.getPanelBackgroundColor;
|
||||
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.ui.JBColor;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue