Skip to content

Commit

Permalink
Merge pull request #2582 from jlawyerorg/feature/sort-ingo-categories
Browse files Browse the repository at this point in the history
added alphabetical order in menu showing Ingo categories -
  • Loading branch information
j-dimension authored Sep 28, 2024
2 parents 8a0f98e + 6580bf4 commit 3a41d3a
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 2 deletions.
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

0 comments on commit 3a41d3a

Please sign in to comment.