From f22998dc2b7e45f0a1c47f7ad97495a1da94dfcb Mon Sep 17 00:00:00 2001
From: apvrille <ludovic.apvrille@eurecom.fr>
Date: Fri, 18 Jan 2019 10:01:42 +0100
Subject: [PATCH] Update on variable modif avatar simu

---
 .../JFrameAvatarInteractiveSimulation.java    | 25 ++++++++++++++++---
 1 file changed, 21 insertions(+), 4 deletions(-)

diff --git a/src/main/java/ui/avatarinteractivesimulation/JFrameAvatarInteractiveSimulation.java b/src/main/java/ui/avatarinteractivesimulation/JFrameAvatarInteractiveSimulation.java
index 2a0e872e0a..08b1adc069 100755
--- a/src/main/java/ui/avatarinteractivesimulation/JFrameAvatarInteractiveSimulation.java
+++ b/src/main/java/ui/avatarinteractivesimulation/JFrameAvatarInteractiveSimulation.java
@@ -127,6 +127,10 @@ public class JFrameAvatarInteractiveSimulation extends JFrame implements AvatarS
 
     private int totalNbOfElements = -1;
 
+    // Edition of variable value
+    protected JMenuItem edit;
+    protected int selectedRow;
+
 
     //private String[] cpuIDs, busIDs, memIDs, taskIDs, chanIDs;
 
@@ -807,13 +811,14 @@ public class JFrameAvatarInteractiveSimulation extends JFrame implements AvatarS
                     JTablejtablePIV.clearSelection();
                 }
 
-                int rowindex = JTablejtablePIV.getSelectedRow();
-                if (rowindex < 0)
+                int selectedRow = JTablejtablePIV.getSelectedRow();
+                if (selectedRow < 0)
                     return;
+
                 if (e.getComponent() instanceof JTable) {
                     TraceManager.addDev("Popup at x=" + e.getX() + " y=" + e.getY());
-                    //JPopupMenu popup = createYourPopUp();
-                    //popup.show(e.getComponent(), e.getX(), e.getY());
+                    JPopupMenu popup = createVariablePopup();
+                    popup.show(e.getComponent(), e.getX(), e.getY());
                 }
             }
         });
@@ -2157,6 +2162,8 @@ public class JFrameAvatarInteractiveSimulation extends JFrame implements AvatarS
         } else if (evt.getSource() == down) {
             TraceManager.addDev("Source = up");
             downAsyncMsg();
+        } else if (evt.getSource() == edit) {
+            TraceManager.addDev("Edit variable at index: " + selectedRow);
         }
 
         // Check for source of jcheckbox
@@ -2271,6 +2278,16 @@ public class JFrameAvatarInteractiveSimulation extends JFrame implements AvatarS
 
     }
 
+
+    private JPopupMenu createVariablePopup() {
+        JPopupMenu menu = new JPopupMenu("Change variable value");
+        edit = new JMenuItem("Edit variable value");
+        edit.setActionCommand("edit");
+        edit.addActionListener(this);
+        menu.add(edit);
+        return menu;
+    }
+
     public void windowClosing(WindowEvent e) {
         TraceManager.addDev("Windows closed!");
         close();
-- 
GitLab