Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added alphabetical order in menu showing Ingo categories - #2582

Merged
merged 2 commits into from
Sep 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -678,6 +678,7 @@ You should also get your employer (if you work as a programmer) or school,
import com.jdimension.jlawyer.persistence.AssistantPrompt;
import java.awt.event.ActionEvent;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
Expand Down Expand Up @@ -814,6 +815,12 @@ public Map<AssistantConfig, List<AiCapability>> filterCapabilities(String reques
filtered.get(config).add(clone);
}
}

// Sort the list of AiCapabilities by name for each AssistantConfig
List<AiCapability> capabilities = filtered.get(config);
if (capabilities != null) {
capabilities.sort(Comparator.comparing(AiCapability::getName));
}
}
}
return filtered;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1056,6 +1056,7 @@ public Component getTableCellRendererComponent(JTable table, Object value, boole
try {
Map<AssistantConfig, List<AiCapability>> capabilities2 = ingo.filterCapabilities(AiCapability.REQUESTTYPE_SUMMARIZE, AiCapability.INPUTTYPE_STRING);
ingo.populateMenu(this.mnuAssistant, capabilities2, (AssistantInputAdapter)this, this.dto);
this.mnuAssistant.add(new JSeparator());
Map<AssistantConfig, List<AiCapability>> capabilities3 = ingo.filterCapabilities(AiCapability.REQUESTTYPE_CHAT, AiCapability.INPUTTYPE_NONE);
ingo.populateMenu(this.mnuAssistant, capabilities3, (AssistantInputAdapter)this, this.dto);
} catch (Exception ex) {
Expand Down Expand Up @@ -6981,11 +6982,12 @@ private void cmdAssistantGenerateMouseReleased(java.awt.event.MouseEvent evt) {/
dlg.setVisible(true);
});
this.popAssistantNoContext.add(mi);
this.popAssistantNoContext.add(new JSeparator());

AssistantAccess ingo = AssistantAccess.getInstance();
Map<AssistantConfig, List<AiCapability>> capabilities3 = ingo.filterCapabilities(AiCapability.REQUESTTYPE_CHAT, AiCapability.INPUTTYPE_NONE);
ingo.populateMenu(this.popAssistantNoContext, capabilities3, (AssistantInputAdapter)this, this.dto);

this.popAssistantNoContext.show(this.cmdAssistantGenerate, evt.getX(), evt.getY());

} catch (Exception ex) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2018,19 +2018,48 @@ private void cmdAssistantMouseReleased(java.awt.event.MouseEvent evt) {//GEN-FIR

AssistantAccess ingo = AssistantAccess.getInstance();
try {
this.popAssistant.removeAll();
this.popAssistant.removeAll();

// Erste Kategorie
Map<AssistantConfig, List<AiCapability>> capabilitiesGenerate = ingo.filterCapabilities(AiCapability.REQUESTTYPE_GENERATE, AiCapability.INPUTTYPE_STRING);
ingo.populateMenu(this.popAssistant, capabilitiesGenerate, (AssistantInputAdapter) this, this.caseContext);
if (!capabilitiesGenerate.isEmpty()) {
this.popAssistant.add(new JSeparator());
}

// Zweite Kategorie
Map<AssistantConfig, List<AiCapability>> capabilitiesGenerate2 = ingo.filterCapabilities(AiCapability.REQUESTTYPE_GENERATE, AiCapability.INPUTTYPE_NONE);
ingo.populateMenu(this.popAssistant, capabilitiesGenerate2, (AssistantInputAdapter) this, this.caseContext);
if (!capabilitiesGenerate2.isEmpty()) {
this.popAssistant.add(new JSeparator());
}

// Dritte Kategorie
Map<AssistantConfig, List<AiCapability>> capabilities = ingo.filterCapabilities(AiCapability.REQUESTTYPE_EXPLAIN, AiCapability.INPUTTYPE_STRING);
ingo.populateMenu(this.popAssistant, capabilities, (AssistantInputAdapter) this, this.caseContext);
if (!capabilities.isEmpty()) {
this.popAssistant.add(new JSeparator());
}

// Vierte Kategorie
Map<AssistantConfig, List<AiCapability>> capabilities2 = ingo.filterCapabilities(AiCapability.REQUESTTYPE_SUMMARIZE, AiCapability.INPUTTYPE_STRING);
ingo.populateMenu(this.popAssistant, capabilities2, (AssistantInputAdapter) this, this.caseContext);
if (!capabilities2.isEmpty()) {
this.popAssistant.add(new JSeparator());
}

// Fünfte Kategorie
Map<AssistantConfig, List<AiCapability>> capabilities3 = ingo.filterCapabilities(AiCapability.REQUESTTYPE_TRANSLATE, AiCapability.INPUTTYPE_STRING);
ingo.populateMenu(this.popAssistant, capabilities3, (AssistantInputAdapter) this, this.caseContext);
if (!capabilities3.isEmpty()) {
this.popAssistant.add(new JSeparator());
}

// Sechste Kategorie
Map<AssistantConfig, List<AiCapability>> capabilities4 = ingo.filterCapabilities(AiCapability.REQUESTTYPE_CHAT, AiCapability.INPUTTYPE_NONE);
ingo.populateMenu(this.popAssistant, capabilities4, (AssistantInputAdapter) this, this.caseContext);


this.popAssistant.show(this.cmdAssistant, evt.getX(), evt.getY());
} catch (Exception ex) {
log.error(ex);
Expand Down