Skip to content

Commit

Permalink
Merge pull request #103 from devoxx/issue-102
Browse files Browse the repository at this point in the history
Issue 102
  • Loading branch information
stephanj authored Jun 20, 2024
2 parents b96a0d5 + cc8092b commit 2f68163
Show file tree
Hide file tree
Showing 8 changed files with 28 additions and 17 deletions.
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ plugins {
}

group = "com.devoxx.genie"
version = "0.1.16"
version = "0.1.17"

repositories {
mavenCentral()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,11 @@ private void webSearchPrompt(@NotNull ChatMessageContext chatMessageContext,
* @param chatMessageContext the chat message context
* @param promptOutputPanel the prompt output panel
*/
public void updatePromptWithCommandIfPresent(@NotNull ChatMessageContext chatMessageContext,
PromptOutputPanel promptOutputPanel) {
public Optional<String> updatePromptWithCommandIfPresent(@NotNull ChatMessageContext chatMessageContext,
PromptOutputPanel promptOutputPanel) {
Optional<String> commandFromPrompt = getCommandFromPrompt(chatMessageContext.getUserPrompt(), promptOutputPanel);
chatMessageContext.setUserPrompt(commandFromPrompt.orElse(chatMessageContext.getUserPrompt()));
return commandFromPrompt;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ public FileEntryComponent(Project project,

setLayout(new FlowLayout(FlowLayout.LEFT, 0, 0));

Icon fileTypeIcon = FileTypeIconUtil.getFileTypeIcon(project, virtualFile);
JButton fileNameButton = new JButton(virtualFile.getName(), fileTypeIcon);
// Icon fileTypeIcon = FileTypeIconUtil.getFileTypeIcon(project, virtualFile);
JButton fileNameButton = new JButton(virtualFile.getName());

JButton fileNameBtn = createButton(fileNameButton);
fileNameBtn.addActionListener(e -> openFileWithSelectedCode(project, virtualFile));
Expand Down
16 changes: 10 additions & 6 deletions src/main/java/com/devoxx/genie/ui/panel/ActionButtonsPanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import java.awt.*;
import java.awt.event.ActionEvent;
import java.util.List;
import java.util.Optional;

import static com.devoxx.genie.model.Constant.*;
import static com.devoxx.genie.model.Constant.ADD_FILE_S_TO_PROMPT_CONTEXT;
Expand Down Expand Up @@ -150,18 +151,21 @@ private void onSubmitPrompt(ActionEvent actionEvent) {

disableButtons();

chatPromptExecutor.updatePromptWithCommandIfPresent(chatMessageContext, promptOutputPanel);
chatPromptExecutor.executePrompt(chatMessageContext, promptOutputPanel, this::enableButtons);
chatPromptExecutor.updatePromptWithCommandIfPresent(chatMessageContext, promptOutputPanel)
.ifPresentOrElse(command -> chatPromptExecutor.executePrompt(chatMessageContext, promptOutputPanel, this::enableButtons),
this::enableButtons);
}

/**
* Enable the prompt input component and reset the Submit button icon.
*/
public void enableButtons() {
submitBtn.setIcon(SubmitIcon);
submitBtn.setEnabled(true);
submitBtn.setToolTipText(SUBMIT_THE_PROMPT);
promptInputComponent.setEnabled(true);
SwingUtilities.invokeLater(() -> {
submitBtn.setIcon(SubmitIcon);
submitBtn.setEnabled(true);
submitBtn.setToolTipText(SUBMIT_THE_PROMPT);
promptInputComponent.setEnabled(true);
});
}

/**
Expand Down
1 change: 1 addition & 0 deletions src/main/java/com/devoxx/genie/ui/panel/HelpPanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ public HelpPanel(String helpMsg) {
super("helpPanel");
setLayout(new BorderLayout());
withPreferredHeight(80);
withPreferredHeight(175);
add(new JBLabel(helpMsg), BorderLayout.CENTER);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public Component getListCellRendererComponent(JList<?> list,
JLabel label = (JLabel) super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);

if (value instanceof VirtualFile file) {
label.setIcon(FileTypeIconUtil.getFileTypeIcon(project, file));
// label.setIcon(FileTypeIconUtil.getFileTypeIcon(project, file));
label.setText(file.getName());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,29 +33,29 @@ public JPanel createSettingsPanel() {
.addComponent(new JXTitledSeparator("Prompts"))
.addVerticalGap(5)
.addLabeledComponentFillVertically(
"System Prompt",
"System prompt",
systemPromptField
)
.addLabeledComponent(
new JBLabel("Test Prompt"),
new JBLabel("Test prompt"),
testPromptField,
10,
true
)
.addLabeledComponent(
new JBLabel("Explain Prompt"),
new JBLabel("Explain prompt"),
explainPromptField,
10,
true
)
.addLabeledComponent(
new JBLabel("Review Prompt"),
new JBLabel("Review prompt"),
reviewPromptField,
10,
true
)
.addLabeledComponent(
new JBLabel("Custom Prompt"),
new JBLabel("Custom prompt"),
customPromptField,
10,
true
Expand Down
5 changes: 5 additions & 0 deletions src/main/resources/META-INF/plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,11 @@
]]></description>

<change-notes><![CDATA[
<h2>v0.1.17</h2>
<UL>
<LI>Feat: Split settings into different panels underneath Tools menu</LI>
<LI>Fix #102: /help also runs the actual prompt</LI>
</UL>
<h2>v0.1.16</h2>
<UL>
<LI>Feat #90: Include System Prompt in Settings page</LI>
Expand Down

0 comments on commit 2f68163

Please sign in to comment.