mirror of
https://github.com/carlrobertoh/ProxyAI.git
synced 2026-04-28 19:52:17 +00:00
Reopen plugin's source code (1.10.8 → 2.0.5)
This commit is contained in:
parent
faf02a5c0a
commit
26a3e07360
231 changed files with 88014 additions and 4271 deletions
106
src/main/java/ee/carlrobert/codegpt/util/OverlayUtils.java
Normal file
106
src/main/java/ee/carlrobert/codegpt/util/OverlayUtils.java
Normal file
|
|
@ -0,0 +1,106 @@
|
|||
package ee.carlrobert.codegpt.util;
|
||||
|
||||
import static com.intellij.openapi.ui.Messages.CANCEL;
|
||||
import static com.intellij.openapi.ui.Messages.OK;
|
||||
import static ee.carlrobert.codegpt.Icons.DefaultImageIcon;
|
||||
|
||||
import com.intellij.execution.ExecutionBundle;
|
||||
import com.intellij.notification.Notification;
|
||||
import com.intellij.notification.NotificationType;
|
||||
import com.intellij.notification.Notifications;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.ui.DialogBuilder;
|
||||
import com.intellij.openapi.ui.DoNotAskOption;
|
||||
import com.intellij.openapi.ui.MessageDialogBuilder;
|
||||
import com.intellij.openapi.ui.MessageType;
|
||||
import com.intellij.openapi.ui.Messages;
|
||||
import com.intellij.openapi.ui.popup.Balloon;
|
||||
import com.intellij.openapi.ui.popup.JBPopupFactory;
|
||||
import com.intellij.ui.awt.RelativePoint;
|
||||
import com.intellij.ui.components.JBLabel;
|
||||
import com.intellij.util.ui.JBFont;
|
||||
import com.intellij.util.ui.JBUI;
|
||||
import ee.carlrobert.codegpt.CodeGPTBundle;
|
||||
import ee.carlrobert.codegpt.conversations.ConversationsState;
|
||||
import ee.carlrobert.codegpt.embeddings.FolderStructureTreePanel;
|
||||
import java.awt.Point;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class OverlayUtils {
|
||||
|
||||
public static void showNotification(String content, NotificationType type) {
|
||||
Notifications.Bus.notify(new Notification("CodeGPT Notification Group", "CodeGPT", content, type));
|
||||
}
|
||||
|
||||
public static int showFileStructureDialog(Project project, FolderStructureTreePanel folderStructureTreePanel) {
|
||||
var dialogBuilder = new DialogBuilder(project);
|
||||
dialogBuilder.setNorthPanel(JBUI.Panels.simplePanel(new JBLabel(
|
||||
"<html>" +
|
||||
"<p>Indexing files enables direct queries related to your codebase.</p>" +
|
||||
"<br/>" +
|
||||
"<p>File indexing occurs locally on your computer; no files are sent to any 3rd party services.</p>" +
|
||||
"<p>For additional information, refer to the <a href=\"https://google.com\">CodeGPT documentation</a>.</p>" +
|
||||
"</html>")
|
||||
.setCopyable(true)
|
||||
.setAllowAutoWrapping(true)
|
||||
.withFont(JBFont.medium()))
|
||||
.withBorder(JBUI.Borders.emptyBottom(12)));
|
||||
dialogBuilder.setCenterPanel(folderStructureTreePanel.getPanel());
|
||||
dialogBuilder.addOkAction().setText("Start Indexing");
|
||||
dialogBuilder.addCancelAction();
|
||||
dialogBuilder.setTitle("Choose Files for Indexing");
|
||||
return dialogBuilder.show();
|
||||
}
|
||||
|
||||
public static int showDeleteConversationDialog() {
|
||||
return Messages.showYesNoDialog(
|
||||
CodeGPTBundle.get("dialog.deleteConversation.description"),
|
||||
CodeGPTBundle.get("dialog.deleteConversation.title"),
|
||||
DefaultImageIcon);
|
||||
}
|
||||
|
||||
public static int showTokenLimitExceededDialog() {
|
||||
return MessageDialogBuilder.okCancel(
|
||||
CodeGPTBundle.get("dialog.tokenLimitExceeded.title"),
|
||||
CodeGPTBundle.get("dialog.tokenLimitExceeded.description"))
|
||||
.yesText(CodeGPTBundle.get("dialog.tokenLimitExceeded.continue"))
|
||||
.noText(CodeGPTBundle.get("dialog.tokenLimitExceeded.cancel"))
|
||||
.icon(DefaultImageIcon)
|
||||
.doNotAsk(new DoNotAskOption.Adapter() {
|
||||
@Override
|
||||
public void rememberChoice(boolean isSelected, int exitCode) {
|
||||
if (isSelected) {
|
||||
ConversationsState.getInstance().discardAllTokenLimits();
|
||||
}
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public String getDoNotShowMessage() {
|
||||
return ExecutionBundle.message("don.t.ask.again");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldSaveOptionsOnCancel() {
|
||||
return true;
|
||||
}
|
||||
})
|
||||
.guessWindowAndAsk() ? OK : CANCEL;
|
||||
}
|
||||
|
||||
public static void showWarningBalloon(String content, Point locationOnScreen) {
|
||||
showBalloon(content, MessageType.WARNING, locationOnScreen);
|
||||
}
|
||||
|
||||
public static void showInfoBalloon(String content, Point locationOnScreen) {
|
||||
showBalloon(content, MessageType.INFO, locationOnScreen);
|
||||
}
|
||||
|
||||
private static void showBalloon(String content, MessageType messageType, Point locationOnScreen) {
|
||||
JBPopupFactory.getInstance()
|
||||
.createHtmlTextBalloonBuilder(content, messageType, null)
|
||||
.setFadeoutTime(2500)
|
||||
.createBalloon()
|
||||
.show(RelativePoint.fromScreen(locationOnScreen), Balloon.Position.above);
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue