From 55ece03b98786d4644c7304526f7ba55625c1932 Mon Sep 17 00:00:00 2001
From: Ludovic Apvrille <ludovic.apvrille@telecom-paris.fr>
Date: Tue, 13 Jun 2023 18:33:51 +0200
Subject: [PATCH] Update on JFrameAI: multichat now reworks

---
 modeling/AVATAR/CoffeeMachine_Avatar.xml |  2 +-
 src/main/java/ai/AIChatData.java         |  2 +-
 src/main/java/ui/window/JFrameAI.java    | 27 ++++++++++++++++++++----
 3 files changed, 25 insertions(+), 6 deletions(-)

diff --git a/modeling/AVATAR/CoffeeMachine_Avatar.xml b/modeling/AVATAR/CoffeeMachine_Avatar.xml
index c84292d8b9..9dc6a280f2 100644
--- a/modeling/AVATAR/CoffeeMachine_Avatar.xml
+++ b/modeling/AVATAR/CoffeeMachine_Avatar.xml
@@ -1459,7 +1459,7 @@
 <MainCode value="}"/>
 <Optimized value="true" />
 <considerTimingOperators value="true" />
-<Validated value="Wallet;CoffeeMachine;CoffeeButton;TeaButton;" />
+<Validated value="" />
 <Ignored value="" />
 
 <CONNECTOR type="5002" id="771" index="0" uid="f480e606-bbb6-4ab7-8f89-8abb37ff40bb" >
diff --git a/src/main/java/ai/AIChatData.java b/src/main/java/ai/AIChatData.java
index 7cb22e32df..38570c34ab 100644
--- a/src/main/java/ai/AIChatData.java
+++ b/src/main/java/ai/AIChatData.java
@@ -59,8 +59,8 @@ import javax.swing.*;
 
 public class AIChatData  {
 
-
     public AIInterface aiinterface;
+
     public boolean knowledgeOnProperties = false;
     public int knowledgeOnBlockJSON = -1;
     public boolean knowledgeOnAMULET = false;
diff --git a/src/main/java/ui/window/JFrameAI.java b/src/main/java/ui/window/JFrameAI.java
index 658f9711b6..b8716b111d 100644
--- a/src/main/java/ui/window/JFrameAI.java
+++ b/src/main/java/ui/window/JFrameAI.java
@@ -46,6 +46,7 @@ import ai.AISysMLV2DiagramContent;
 import avatartranslator.AvatarSpecification;
 import help.HelpEntry;
 import help.HelpManager;
+import myutil.AIInterface;
 import myutil.GraphicLib;
 import myutil.TraceManager;
 import ui.*;
@@ -78,15 +79,21 @@ public class JFrameAI extends JFrame implements ActionListener {
     private static String[] POSSIBLE_ACTIONS = {"Chat - Chat on any topic you like, or help the AI give a better answer on a previous question",
             "Identify requirements - Provide a system specification", "Classify requirements - select a" +
             " requirement diagram first",
+            "Identify use cases",
             "Identify properties - Select a block diagram first. You can also provide a system specification",
             "Identify system blocks - Provide a system specification", "Identify software blocks - Provide a system specification", "Identify state" +
-            " machines - Select a block diagram. Additionally, you can provide a system specification", "A(I)MULET - Select a block diagram first"};
+            " machines - Select a block diagram. Additionally, you can provide a system specification",
+            "A(I)MULET - Select a block diagram first"};
 
-    private static String[] AIInteractClass = {"AIChat", "AIReqIdent", "AIReqClassification", "AIDesignPropertyIdentification", "AIBlock",
+    private static String[] AIInteractClass = {"AIChat", "AIReqIdent", "AIReqClassification", "AIChat", "AIDesignPropertyIdentification", "AIBlock",
             "AISoftwareBlock", "AIStateMachine", "AIAmulet"};
 
     private static String[] INFOS = {"Chat on any topic you like", "Identify requirements from the specification of a system", "Classify " +
-            "requirements from a requirement diagram", "Identify the typical properties to be proven from a block diagram", "Identify the system " +
+            "requirements from a requirement diagram", "Identify use cases and actors from a system specification",
+            "Identify the typical properties" +
+            " to be proven " +
+            "from a block" +
+            " diagram", "Identify the system " +
             "blocks from a specification", "Identify the software blocks from a specification", "Identify the state machines from a system " +
             "specification and a block diagram", "Formalize mutations to be performed on a block diagram"};
 
@@ -303,10 +310,17 @@ public class JFrameAI extends JFrame implements ActionListener {
         currentChatIndex = answerPane.getSelectedIndex();
         ChatData selected = selectedChat();
 
-        if (selected.makeAIChatData()) {
+        boolean chatDataMade = selected.aiChatData != null;
+
+        if (!chatDataMade) {
+            chatDataMade = selected.makeAIChatData();
+        }
+
+        if (chatDataMade) {
             String selectedClass = AIInteractClass[listOfPossibleActions.getSelectedIndex()];
             selected.aiInteract = ai.AIInteract.getInstance("ai." + selectedClass, selected.aiChatData);
 
+
             if (selected.aiInteract == null) {
                 error("Unknow selected type");
                 return;
@@ -358,6 +372,8 @@ public class JFrameAI extends JFrame implements ActionListener {
             applyRequirementClassification();
         } else if (selectedChat.aiInteract instanceof ai.AIDesignPropertyIdentification) {
             // nothing up to now :-)
+        } else if (selectedChat.aiInteract instanceof ai.AIStateMachine) {
+            // nothing up to now :-)
         } else if (selectedChat.aiInteract instanceof ai.AIAmulet) {
             applyMutations();
         }
@@ -482,7 +498,10 @@ public class JFrameAI extends JFrame implements ActionListener {
 
     private void printInfos() {
         int index = listOfPossibleActions.getSelectedIndex();
+        Font tmpFont = console.getFont();
+        console.setFont(tmpFont.deriveFont(Font.BOLD));
         GraphicLib.appendToPane(console, "Your selection: " + INFOS[index] + "\n", Color.darkGray);
+        console.setFont(tmpFont);
     }
 
     private void setOptionsJTextPane(JTextPane jta, boolean _isEditable) {
-- 
GitLab