mirror of
https://github.com/carlrobertoh/ProxyAI.git
synced 2026-05-19 16:28:46 +00:00
Change project's name, heavy refactoring
This commit is contained in:
parent
c0cea7cc43
commit
483abe146b
80 changed files with 969 additions and 968 deletions
|
|
@ -0,0 +1,72 @@
|
|||
package ee.carlrobert.codegpt.ide.action;
|
||||
|
||||
import static ee.carlrobert.codegpt.ide.toolwindow.components.SwingUtils.addShiftEnterInputMap;
|
||||
|
||||
import com.intellij.openapi.ui.DialogWrapper;
|
||||
import com.intellij.ui.components.JBScrollPane;
|
||||
import com.intellij.util.ui.FormBuilder;
|
||||
import com.intellij.util.ui.JBUI;
|
||||
import com.intellij.util.ui.UI;
|
||||
import ee.carlrobert.codegpt.ide.toolwindow.components.SyntaxTextArea;
|
||||
import javax.annotation.Nullable;
|
||||
import javax.swing.JComponent;
|
||||
import javax.swing.JTextArea;
|
||||
import org.fife.ui.rsyntaxtextarea.SyntaxConstants;
|
||||
|
||||
public class CustomPromptDialog extends DialogWrapper {
|
||||
|
||||
private final String selectedText;
|
||||
private final String fileExtension;
|
||||
private final JTextArea userPromptTextArea;
|
||||
private final SyntaxTextArea syntaxTextArea =
|
||||
new SyntaxTextArea(false, false, SyntaxConstants.SYNTAX_STYLE_MARKDOWN);
|
||||
|
||||
public CustomPromptDialog(String selectedText, String fileExtension, String previousUserPrompt) {
|
||||
super(true);
|
||||
this.selectedText = selectedText;
|
||||
this.fileExtension = fileExtension;
|
||||
this.userPromptTextArea = new JTextArea(previousUserPrompt);
|
||||
this.userPromptTextArea.setCaretPosition(previousUserPrompt.length());
|
||||
setTitle("Custom Prompt");
|
||||
setSize(460, 320);
|
||||
init();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public JComponent getPreferredFocusedComponent() {
|
||||
return userPromptTextArea;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
protected JComponent createCenterPanel() {
|
||||
userPromptTextArea.setLineWrap(true);
|
||||
userPromptTextArea.setWrapStyleWord(true);
|
||||
userPromptTextArea.setMargin(JBUI.insets(5));
|
||||
addShiftEnterInputMap(userPromptTextArea, this::clickDefaultButton);
|
||||
|
||||
syntaxTextArea.setText(selectedText.trim());
|
||||
// syntaxTextArea.setSyntaxEditingStyle(getSyntaxForFileExtension(fileExtension));
|
||||
syntaxTextArea.setSyntaxEditingStyle(SyntaxConstants.SYNTAX_STYLE_JAVA);
|
||||
|
||||
return FormBuilder.createFormBuilder()
|
||||
.addComponent(UI.PanelFactory.panel(userPromptTextArea)
|
||||
.withLabel("Prefix:")
|
||||
.moveLabelOnTop()
|
||||
.withComment(
|
||||
"Example: Find bugs in the following code")
|
||||
.createPanel())
|
||||
.addVerticalGap(16)
|
||||
.addComponent(new JBScrollPane(syntaxTextArea))
|
||||
.getPanel();
|
||||
}
|
||||
|
||||
public String getFullPrompt() {
|
||||
return userPromptTextArea.getText() + "\n\n" + syntaxTextArea.getText();
|
||||
}
|
||||
|
||||
public String getUserPrompt() {
|
||||
return userPromptTextArea.getText();
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue