From 86cd94808b94fb04e30fdb2bf4d2dcdca0046e80 Mon Sep 17 00:00:00 2001 From: iradraconis <71747937+iradraconis@users.noreply.github.com> Date: Thu, 26 Sep 2024 10:02:21 +0200 Subject: [PATCH 1/2] added alphabetical order in menu showing Ingo categories added seperatorin menus between categories --- .../jlawyer/client/assistant/AssistantAccess.java | 7 +++++++ .../client/editors/files/ArchiveFilePanel.java | 4 +++- .../jlawyer/client/mail/MailContentUI.java | 13 +++++++++++++ 3 files changed, 23 insertions(+), 1 deletion(-) diff --git a/j-lawyer-client/src/com/jdimension/jlawyer/client/assistant/AssistantAccess.java b/j-lawyer-client/src/com/jdimension/jlawyer/client/assistant/AssistantAccess.java index 24493c5e6..cd5ec8f49 100644 --- a/j-lawyer-client/src/com/jdimension/jlawyer/client/assistant/AssistantAccess.java +++ b/j-lawyer-client/src/com/jdimension/jlawyer/client/assistant/AssistantAccess.java @@ -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; @@ -814,6 +815,12 @@ public Map> filterCapabilities(String reques filtered.get(config).add(clone); } } + + // Sort the list of AiCapabilities by name for each AssistantConfig + List capabilities = filtered.get(config); + if (capabilities != null) { + capabilities.sort(Comparator.comparing(AiCapability::getName)); + } } } return filtered; diff --git a/j-lawyer-client/src/com/jdimension/jlawyer/client/editors/files/ArchiveFilePanel.java b/j-lawyer-client/src/com/jdimension/jlawyer/client/editors/files/ArchiveFilePanel.java index 8db9c641f..8126cfff9 100755 --- a/j-lawyer-client/src/com/jdimension/jlawyer/client/editors/files/ArchiveFilePanel.java +++ b/j-lawyer-client/src/com/jdimension/jlawyer/client/editors/files/ArchiveFilePanel.java @@ -1056,6 +1056,7 @@ public Component getTableCellRendererComponent(JTable table, Object value, boole try { Map> capabilities2 = ingo.filterCapabilities(AiCapability.REQUESTTYPE_SUMMARIZE, AiCapability.INPUTTYPE_STRING); ingo.populateMenu(this.mnuAssistant, capabilities2, (AssistantInputAdapter)this, this.dto); + this.mnuAssistant.add(new JSeparator()); Map> capabilities3 = ingo.filterCapabilities(AiCapability.REQUESTTYPE_CHAT, AiCapability.INPUTTYPE_NONE); ingo.populateMenu(this.mnuAssistant, capabilities3, (AssistantInputAdapter)this, this.dto); } catch (Exception ex) { @@ -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> 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) { diff --git a/j-lawyer-client/src/com/jdimension/jlawyer/client/mail/MailContentUI.java b/j-lawyer-client/src/com/jdimension/jlawyer/client/mail/MailContentUI.java index d65962aac..53dc6e5b8 100755 --- a/j-lawyer-client/src/com/jdimension/jlawyer/client/mail/MailContentUI.java +++ b/j-lawyer-client/src/com/jdimension/jlawyer/client/mail/MailContentUI.java @@ -2021,16 +2021,29 @@ private void cmdAssistantMouseReleased(java.awt.event.MouseEvent evt) {//GEN-FIR this.popAssistant.removeAll(); Map> capabilitiesGenerate = ingo.filterCapabilities(AiCapability.REQUESTTYPE_GENERATE, AiCapability.INPUTTYPE_STRING); ingo.populateMenu(this.popAssistant, capabilitiesGenerate, (AssistantInputAdapter) this, this.caseContext); + this.popAssistant.add(new JSeparator()); + Map> capabilitiesGenerate2 = ingo.filterCapabilities(AiCapability.REQUESTTYPE_GENERATE, AiCapability.INPUTTYPE_NONE); ingo.populateMenu(this.popAssistant, capabilitiesGenerate2, (AssistantInputAdapter) this, this.caseContext); + this.popAssistant.add(new JSeparator()); + Map> capabilities = ingo.filterCapabilities(AiCapability.REQUESTTYPE_EXPLAIN, AiCapability.INPUTTYPE_STRING); ingo.populateMenu(this.popAssistant, capabilities, (AssistantInputAdapter) this, this.caseContext); + this.popAssistant.add(new JSeparator()); + Map> capabilities2 = ingo.filterCapabilities(AiCapability.REQUESTTYPE_SUMMARIZE, AiCapability.INPUTTYPE_STRING); ingo.populateMenu(this.popAssistant, capabilities2, (AssistantInputAdapter) this, this.caseContext); + this.popAssistant.add(new JSeparator()); + + // Fünfte Kategorie Map> capabilities3 = ingo.filterCapabilities(AiCapability.REQUESTTYPE_TRANSLATE, AiCapability.INPUTTYPE_STRING); ingo.populateMenu(this.popAssistant, capabilities3, (AssistantInputAdapter) this, this.caseContext); + this.popAssistant.add(new JSeparator()); + + // Sechste Kategorie Map> 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); From 6580bf46ebef8bfee41d79ea2913f0037ae4196e Mon Sep 17 00:00:00 2001 From: iradraconis <71747937+iradraconis@users.noreply.github.com> Date: Sat, 28 Sep 2024 13:20:22 +0200 Subject: [PATCH 2/2] added condition for empty capabilities --- .../jlawyer/client/mail/MailContentUI.java | 28 +++++++++++++++---- 1 file changed, 22 insertions(+), 6 deletions(-) diff --git a/j-lawyer-client/src/com/jdimension/jlawyer/client/mail/MailContentUI.java b/j-lawyer-client/src/com/jdimension/jlawyer/client/mail/MailContentUI.java index 53dc6e5b8..39432e8a8 100755 --- a/j-lawyer-client/src/com/jdimension/jlawyer/client/mail/MailContentUI.java +++ b/j-lawyer-client/src/com/jdimension/jlawyer/client/mail/MailContentUI.java @@ -2018,31 +2018,47 @@ private void cmdAssistantMouseReleased(java.awt.event.MouseEvent evt) {//GEN-FIR AssistantAccess ingo = AssistantAccess.getInstance(); try { - this.popAssistant.removeAll(); + this.popAssistant.removeAll(); + + // Erste Kategorie Map> capabilitiesGenerate = ingo.filterCapabilities(AiCapability.REQUESTTYPE_GENERATE, AiCapability.INPUTTYPE_STRING); ingo.populateMenu(this.popAssistant, capabilitiesGenerate, (AssistantInputAdapter) this, this.caseContext); - this.popAssistant.add(new JSeparator()); + if (!capabilitiesGenerate.isEmpty()) { + this.popAssistant.add(new JSeparator()); + } + // Zweite Kategorie Map> capabilitiesGenerate2 = ingo.filterCapabilities(AiCapability.REQUESTTYPE_GENERATE, AiCapability.INPUTTYPE_NONE); ingo.populateMenu(this.popAssistant, capabilitiesGenerate2, (AssistantInputAdapter) this, this.caseContext); - this.popAssistant.add(new JSeparator()); + if (!capabilitiesGenerate2.isEmpty()) { + this.popAssistant.add(new JSeparator()); + } + // Dritte Kategorie Map> capabilities = ingo.filterCapabilities(AiCapability.REQUESTTYPE_EXPLAIN, AiCapability.INPUTTYPE_STRING); ingo.populateMenu(this.popAssistant, capabilities, (AssistantInputAdapter) this, this.caseContext); - this.popAssistant.add(new JSeparator()); + if (!capabilities.isEmpty()) { + this.popAssistant.add(new JSeparator()); + } + // Vierte Kategorie Map> capabilities2 = ingo.filterCapabilities(AiCapability.REQUESTTYPE_SUMMARIZE, AiCapability.INPUTTYPE_STRING); ingo.populateMenu(this.popAssistant, capabilities2, (AssistantInputAdapter) this, this.caseContext); - this.popAssistant.add(new JSeparator()); + if (!capabilities2.isEmpty()) { + this.popAssistant.add(new JSeparator()); + } // Fünfte Kategorie Map> capabilities3 = ingo.filterCapabilities(AiCapability.REQUESTTYPE_TRANSLATE, AiCapability.INPUTTYPE_STRING); ingo.populateMenu(this.popAssistant, capabilities3, (AssistantInputAdapter) this, this.caseContext); - this.popAssistant.add(new JSeparator()); + if (!capabilities3.isEmpty()) { + this.popAssistant.add(new JSeparator()); + } // Sechste Kategorie Map> 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) {