From d667888242f65ac6cf5e193f0a3c7c7d43acf502 Mon Sep 17 00:00:00 2001
From: dblouin <dominique.blouin@telecom-paristech.fr>
Date: Thu, 2 Feb 2017 17:26:27 +0100
Subject: [PATCH] Issue #18: RSH client API refactoring

---
 .../JDialogAvatarExecutableCodeGeneration.java | 11 ++++++++---
 ...DialogAvatarddExecutableCodeGeneration.java |  9 ++++++---
 src/ui/window/JDialogBisimulation.java         |  4 ++--
 .../window/JDialogBisimulationBisimulator.java |  4 ++--
 src/ui/window/JDialogCCodeGeneration.java      |  2 +-
 src/ui/window/JDialogDSE.java                  |  2 +-
 src/ui/window/JDialogFormalValidation.java     |  6 +++---
 src/ui/window/JDialogGenAUT.java               |  4 ++--
 src/ui/window/JDialogGenAUTS.java              |  4 ++--
 src/ui/window/JDialogGraphModification.java    |  4 ++--
 src/ui/window/JDialogLOTOSAnalysis.java        |  4 ++--
 src/ui/window/JDialogLOTOSValidation.java      |  4 ++--
 src/ui/window/JDialogProVerifGeneration.java   |  4 ++--
 src/ui/window/JDialogProjection.java           |  4 ++--
 src/ui/window/JDialogSimulation.java           |  4 ++--
 src/ui/window/JDialogTMatrixManagement.java    | 18 +++++++++---------
 src/ui/window/JDialogTPNValidation.java        |  4 ++--
 src/ui/window/JDialogTextProcess.java          | 11 +++++++----
 src/ui/window/JDialogUPPAALValidation.java     |  4 ++--
 19 files changed, 59 insertions(+), 48 deletions(-)

diff --git a/src/ui/window/JDialogAvatarExecutableCodeGeneration.java b/src/ui/window/JDialogAvatarExecutableCodeGeneration.java
index 04680e6c81..9beb87fd71 100644
--- a/src/ui/window/JDialogAvatarExecutableCodeGeneration.java
+++ b/src/ui/window/JDialogAvatarExecutableCodeGeneration.java
@@ -85,6 +85,7 @@ import myutil.ScrolledJTextArea;
 import myutil.TraceManager;
 import ui.AvatarDeploymentPanelTranslator;
 import ui.IconManager;
+import ui.JTextAreaWriter;
 import ui.MainGUI;
 import ui.avatardd.ADDDiagramPanel;
 import ui.interactivesimulation.JFrameSimulationSDPanel;
@@ -137,6 +138,7 @@ public class JDialogAvatarExecutableCodeGeneration extends javax.swing.JFrame im
 
     //components
     protected JTextArea jta;
+    private JTextAreaWriter textAreaWriter;
     protected JButton start;
     protected JButton stop;
     protected JButton close;
@@ -441,6 +443,8 @@ public class JDialogAvatarExecutableCodeGeneration extends javax.swing.JFrame im
         jta.append("Select options and then, click on 'start' to launch code generation / compilation / execution\n");
         Font f = new Font("Courrier", Font.BOLD, 12);
         jta.setFont(f);
+        textAreaWriter = new JTextAreaWriter( jta );
+
         jsp = new JScrollPane(jta, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
 
         c.add(jsp, BorderLayout.CENTER);
@@ -548,7 +552,7 @@ public class JDialogAvatarExecutableCodeGeneration extends javax.swing.JFrame im
 
     public void stopProcess() {
         try {
-            rshc.stopFillJTA();
+            rshc.stopCommand();
         } catch (LauncherException le) {
 
         }
@@ -882,8 +886,9 @@ list = FileUtils.deleteFiles(code1.getText() +  TasksAndMainGenerator.getGenerat
 
     protected void processCmd(String cmd, JTextArea _jta) throws LauncherException {
         rshc.setCmd(cmd);
-        rshc.sendProcessRequest();
-        rshc.fillJTA(_jta);
+        rshc.sendExecuteCommandRequest();
+        rshc.writeCommandMessages( textAreaWriter );
+        
         return;
     }
 
diff --git a/src/ui/window/JDialogAvatarddExecutableCodeGeneration.java b/src/ui/window/JDialogAvatarddExecutableCodeGeneration.java
index 894cf5a5ec..c620e22dd2 100755
--- a/src/ui/window/JDialogAvatarddExecutableCodeGeneration.java
+++ b/src/ui/window/JDialogAvatarddExecutableCodeGeneration.java
@@ -478,7 +478,7 @@ public class JDialogAvatarddExecutableCodeGeneration extends javax.swing.JFrame
 
     public void stopProcess() {
         try {
-            rshc.stopFillJTA();
+            rshc.stopCommand();
         } catch (LauncherException le) {
 
         }
@@ -710,8 +710,11 @@ public class JDialogAvatarddExecutableCodeGeneration extends javax.swing.JFrame
 
     protected void processCmd(String cmd, JTextArea _jta) throws LauncherException {
         rshc.setCmd(cmd);
-        rshc.sendProcessRequest();
-        rshc.fillJTA(_jta);
+        rshc.sendExecuteCommandRequest();
+        final Writer output = new StringWriter();
+        rshc.writeCommandMessages( output );
+        _jta.append( output.toString() );
+
         return;
     }
 
diff --git a/src/ui/window/JDialogBisimulation.java b/src/ui/window/JDialogBisimulation.java
index 03e1129bca..fdd23b3288 100755
--- a/src/ui/window/JDialogBisimulation.java
+++ b/src/ui/window/JDialogBisimulation.java
@@ -299,7 +299,7 @@ public class JDialogBisimulation extends javax.swing.JDialog implements ActionLi
     public void stopProcess() {
         if (rshc != null) {
             try {
-                rshc.stopFillJTA();
+                rshc.stopCommand();
             } catch (LauncherException le) {
                 
             }
@@ -378,7 +378,7 @@ public class JDialogBisimulation extends javax.swing.JDialog implements ActionLi
     protected String processCmd(String cmd) throws LauncherException {
         rshc.setCmd(cmd);
         String s = null;
-        rshc.sendProcessRequest();
+        rshc.sendExecuteCommandRequest();
         s = rshc.getDataFromProcess();
         return s;
     }
diff --git a/src/ui/window/JDialogBisimulationBisimulator.java b/src/ui/window/JDialogBisimulationBisimulator.java
index 57fb73e79b..2d60e96d5b 100755
--- a/src/ui/window/JDialogBisimulationBisimulator.java
+++ b/src/ui/window/JDialogBisimulationBisimulator.java
@@ -348,7 +348,7 @@ public class JDialogBisimulationBisimulator extends javax.swing.JDialog implemen
     public void stopProcess() {
         if (rshc != null) {
             try {
-                rshc.stopFillJTA();
+                rshc.stopCommand();
             } catch (LauncherException le) {
                 
             }
@@ -467,7 +467,7 @@ public class JDialogBisimulationBisimulator extends javax.swing.JDialog implemen
     protected String processCmd(String cmd) throws LauncherException {
         rshc.setCmd(cmd);
         String s = null;
-        rshc.sendProcessRequest();
+        rshc.sendExecuteCommandRequest();
         s = rshc.getDataFromProcess();
         return s;
     }
diff --git a/src/ui/window/JDialogCCodeGeneration.java b/src/ui/window/JDialogCCodeGeneration.java
index 157fd92b90..e99422a1b0 100755
--- a/src/ui/window/JDialogCCodeGeneration.java
+++ b/src/ui/window/JDialogCCodeGeneration.java
@@ -421,7 +421,7 @@ public class JDialogCCodeGeneration extends javax.swing.JDialog implements Actio
 
     public void stopProcess() {
         try {
-            rshc.stopFillJTA();
+            rshc.stopCommand();
         } catch (LauncherException le) {
 
         }
diff --git a/src/ui/window/JDialogDSE.java b/src/ui/window/JDialogDSE.java
index 7632b2eddc..2db7003e80 100644
--- a/src/ui/window/JDialogDSE.java
+++ b/src/ui/window/JDialogDSE.java
@@ -586,7 +586,7 @@ public class JDialogDSE extends javax.swing.JDialog implements ActionListener, R
     public void stopProcess() {
         if (rshc != null ){
             try {
-                rshc.stopFillJTA();
+                rshc.stopCommand();
             } catch (LauncherException le) {
             }
         }
diff --git a/src/ui/window/JDialogFormalValidation.java b/src/ui/window/JDialogFormalValidation.java
index 29abbc46d1..1cba38a02d 100755
--- a/src/ui/window/JDialogFormalValidation.java
+++ b/src/ui/window/JDialogFormalValidation.java
@@ -357,7 +357,7 @@ public class JDialogFormalValidation extends javax.swing.JDialog implements Acti
     
     public void stopProcess() {
         try {
-            rshc.stopFillJTA();
+            rshc.stopCommand();
         } catch (LauncherException le) {
             
         }
@@ -597,14 +597,14 @@ public class JDialogFormalValidation extends javax.swing.JDialog implements Acti
     protected String processCmd(String cmd) throws LauncherException {
         rshc.setCmd(cmd);
         String s = null;
-        rshc.sendProcessRequest();
+        rshc.sendExecuteCommandRequest();
         s = rshc.getDataFromProcess();
         return s;
     }
     
     protected String processPipedCmd(String cmd1, String cmd2) throws LauncherException {
         String s = null;
-        rshc.sendProcessRequest(cmd1, cmd2);
+        rshc.sendExecutePipedCommandsRequest(cmd1, cmd2);
         s = rshc.getDataFromProcess();
         return s;
     }
diff --git a/src/ui/window/JDialogGenAUT.java b/src/ui/window/JDialogGenAUT.java
index 93408b74a4..9a85e1fecf 100755
--- a/src/ui/window/JDialogGenAUT.java
+++ b/src/ui/window/JDialogGenAUT.java
@@ -203,7 +203,7 @@ public class JDialogGenAUT extends javax.swing.JDialog implements ActionListener
     
     public void stopProcess() {
         try {
-            rshc.stopFillJTA();
+            rshc.stopCommand();
         } catch (LauncherException le) {
         }
         rshc = null;
@@ -289,7 +289,7 @@ public class JDialogGenAUT extends javax.swing.JDialog implements ActionListener
     protected String processCmd(String cmd) throws LauncherException {
         rshc.setCmd(cmd);
         String s = null;
-        rshc.sendProcessRequest();
+        rshc.sendExecuteCommandRequest();
         s = rshc.getDataFromProcess();
         return s;
     }
diff --git a/src/ui/window/JDialogGenAUTS.java b/src/ui/window/JDialogGenAUTS.java
index 5f564b7b75..1aef51c5c4 100755
--- a/src/ui/window/JDialogGenAUTS.java
+++ b/src/ui/window/JDialogGenAUTS.java
@@ -216,7 +216,7 @@ public class JDialogGenAUTS extends javax.swing.JDialog implements ActionListene
     
     public void stopProcess() {
         try {
-            rshc.stopFillJTA();
+            rshc.stopCommand();
         } catch (LauncherException le) {
         }
         rshc = null;
@@ -344,7 +344,7 @@ public class JDialogGenAUTS extends javax.swing.JDialog implements ActionListene
     protected String processCmd(String cmd) throws LauncherException {
         rshc.setCmd(cmd);
         String s = null;
-        rshc.sendProcessRequest();
+        rshc.sendExecuteCommandRequest();
         s = rshc.getDataFromProcess();
         return s;
     }
diff --git a/src/ui/window/JDialogGraphModification.java b/src/ui/window/JDialogGraphModification.java
index 634d2b63cc..392b76864c 100755
--- a/src/ui/window/JDialogGraphModification.java
+++ b/src/ui/window/JDialogGraphModification.java
@@ -348,7 +348,7 @@ public class JDialogGraphModification extends javax.swing.JDialog implements Act
     public void stopProcess() {
         if (rshc != null) {
             try {
-                rshc.stopFillJTA();
+                rshc.stopCommand();
             } catch (LauncherException le) {
 
             }
@@ -527,7 +527,7 @@ public class JDialogGraphModification extends javax.swing.JDialog implements Act
     protected String processCmd(String cmd) throws LauncherException {
         rshc.setCmd(cmd);
         String s = null;
-        rshc.sendProcessRequest();
+        rshc.sendExecuteCommandRequest();
         s = rshc.getDataFromProcess();
         return s;
     }
diff --git a/src/ui/window/JDialogLOTOSAnalysis.java b/src/ui/window/JDialogLOTOSAnalysis.java
index da7e908c33..dcfc4080ab 100755
--- a/src/ui/window/JDialogLOTOSAnalysis.java
+++ b/src/ui/window/JDialogLOTOSAnalysis.java
@@ -193,7 +193,7 @@
       
       public void stopProcess() {
           try {
-              rshc.stopFillJTA();
+              rshc.stopCommand();
           } catch (LauncherException le) {
           }
           rshc = null;
@@ -280,7 +280,7 @@
       protected String processCmd(String cmd) throws LauncherException {
           rshc.setCmd(cmd);
           String s = null;
-          rshc.sendProcessRequest();
+          rshc.sendExecuteCommandRequest();
           s = rshc.getDataFromProcess();
           return s;
       }
diff --git a/src/ui/window/JDialogLOTOSValidation.java b/src/ui/window/JDialogLOTOSValidation.java
index 0bfcee299e..0abd1ba619 100755
--- a/src/ui/window/JDialogLOTOSValidation.java
+++ b/src/ui/window/JDialogLOTOSValidation.java
@@ -271,7 +271,7 @@ public class JDialogLOTOSValidation extends javax.swing.JDialog implements Actio
 	
 	public void stopProcess() {
 		try {
-			rshc.stopFillJTA();
+			rshc.stopCommand();
 		} catch (LauncherException le) {
 		}
 		rshc = null;
@@ -517,7 +517,7 @@ public class JDialogLOTOSValidation extends javax.swing.JDialog implements Actio
 	protected String processCmd(String cmd) throws LauncherException {
 		rshc.setCmd(cmd);
 		String s = null;
-		rshc.sendProcessRequest();
+		rshc.sendExecuteCommandRequest();
 		s = rshc.getDataFromProcess();
 		return s;
 	}
diff --git a/src/ui/window/JDialogProVerifGeneration.java b/src/ui/window/JDialogProVerifGeneration.java
index e0a5f9b46b..d507aa886b 100644
--- a/src/ui/window/JDialogProVerifGeneration.java
+++ b/src/ui/window/JDialogProVerifGeneration.java
@@ -318,7 +318,7 @@ public class JDialogProVerifGeneration extends javax.swing.JDialog implements Ac
     public void stopProcess() {
         if (rshc != null ){
             try {
-                rshc.stopFillJTA();
+                rshc.stopCommand();
             } catch (LauncherException le) {
             }
         }
@@ -501,7 +501,7 @@ public class JDialogProVerifGeneration extends javax.swing.JDialog implements Ac
     protected String processCmd(String cmd) throws LauncherException {
         rshc.setCmd(cmd);
         String s = null;
-        rshc.sendProcessRequest();
+        rshc.sendExecuteCommandRequest();
         s = rshc.getDataFromProcess();
         return s;
     }
diff --git a/src/ui/window/JDialogProjection.java b/src/ui/window/JDialogProjection.java
index cacd3793b8..6022472f93 100755
--- a/src/ui/window/JDialogProjection.java
+++ b/src/ui/window/JDialogProjection.java
@@ -584,7 +584,7 @@ public class JDialogProjection extends javax.swing.JDialog implements ActionList
     public void stopProcess() {
         if (rshc != null) {
             try {
-                rshc.stopFillJTA();
+                rshc.stopCommand();
             } catch (LauncherException le) {
                 
             }
@@ -784,7 +784,7 @@ public class JDialogProjection extends javax.swing.JDialog implements ActionList
     protected String processCmd(String cmd) throws LauncherException {
         rshc.setCmd(cmd);
         String s = null;
-        rshc.sendProcessRequest();
+        rshc.sendExecuteCommandRequest();
         s = rshc.getDataFromProcess();
         return s;
     }
diff --git a/src/ui/window/JDialogSimulation.java b/src/ui/window/JDialogSimulation.java
index 3dfe583f3c..b8edd11e45 100755
--- a/src/ui/window/JDialogSimulation.java
+++ b/src/ui/window/JDialogSimulation.java
@@ -212,7 +212,7 @@ public class JDialogSimulation extends javax.swing.JDialog implements ActionList
     
     public void stopProcess() {
         try {
-            rshc.stopFillJTA();
+            rshc.stopCommand();
         } catch (LauncherException le) {
         }
         rshc = null;
@@ -325,7 +325,7 @@ public class JDialogSimulation extends javax.swing.JDialog implements ActionList
     protected String processCmd(String cmd) throws LauncherException {
         rshc.setCmd(cmd);
         String s = null;
-        rshc.sendProcessRequest();
+        rshc.sendExecuteCommandRequest();
         s = rshc.getDataFromProcess();
         return s;
     }
diff --git a/src/ui/window/JDialogTMatrixManagement.java b/src/ui/window/JDialogTMatrixManagement.java
index 2b77604fe0..32d3da8fdf 100755
--- a/src/ui/window/JDialogTMatrixManagement.java
+++ b/src/ui/window/JDialogTMatrixManagement.java
@@ -241,7 +241,7 @@ public class JDialogTMatrixManagement extends JFrame implements ActionListener,
     
     public void stopProcess() {
         try {
-            rshc.stopFillJTA();
+            rshc.stopCommand();
         } catch (LauncherException le) {
             
         }
@@ -380,17 +380,17 @@ public class JDialogTMatrixManagement extends JFrame implements ActionListener,
     protected String processCmd(String cmd) throws LauncherException {
         rshc.setCmd(cmd);
         String s = null;
-        rshc.sendProcessRequest();
-        s = rshc.getDataFromProcess();
-        return s;
-    }
-    
-    protected String processPipedCmd(String cmd1, String cmd2) throws LauncherException {
-        String s = null;
-        rshc.sendProcessRequest(cmd1, cmd2);
+        rshc.sendExecuteCommandRequest();
         s = rshc.getDataFromProcess();
         return s;
     }
+//    DB: Issue #18: This method is not used
+//    protected String processPipedCmd(String cmd1, String cmd2) throws LauncherException {
+//        String s = null;
+//        rshc.sendExecutePipedCommandsRequest(cmd1, cmd2);
+//        s = rshc.getDataFromProcess();
+//        return s;
+//    }
     
     protected void checkMode() {
         
diff --git a/src/ui/window/JDialogTPNValidation.java b/src/ui/window/JDialogTPNValidation.java
index 0bbf64c4aa..eec86b8555 100755
--- a/src/ui/window/JDialogTPNValidation.java
+++ b/src/ui/window/JDialogTPNValidation.java
@@ -199,7 +199,7 @@ public class JDialogTPNValidation extends javax.swing.JDialog implements ActionL
 
 	public void stopProcess() {
 		try {
-			rshc.stopFillJTA();
+			rshc.stopCommand();
 		} catch (LauncherException le) {
 		}
 		rshc = null;
@@ -301,7 +301,7 @@ public class JDialogTPNValidation extends javax.swing.JDialog implements ActionL
 	protected String processCmd(String cmd) throws LauncherException {
 		rshc.setCmd(cmd);
 		String s = null;
-		rshc.sendProcessRequest();
+		rshc.sendExecuteCommandRequest();
 		s = rshc.getDataFromProcess();
 		return s;
 	}
diff --git a/src/ui/window/JDialogTextProcess.java b/src/ui/window/JDialogTextProcess.java
index 04291246be..1adbc9e600 100755
--- a/src/ui/window/JDialogTextProcess.java
+++ b/src/ui/window/JDialogTextProcess.java
@@ -48,6 +48,7 @@ package ui.window;
 
 import java.awt.*;
 import java.awt.event.*;
+
 import javax.swing.*;
 import launcher.*;
 import myutil.*;
@@ -70,6 +71,7 @@ public class JDialogTextProcess extends javax.swing.JDialog implements ActionLis
 	
 	//components
 	protected JTextArea jta; 
+    private JTextAreaWriter textAreaWriter;
 	protected JButton start;
 	protected JButton stop;
 	protected JButton close;
@@ -110,7 +112,8 @@ public class JDialogTextProcess extends javax.swing.JDialog implements ActionLis
 		Font f = new Font("Courrier", Font.BOLD, 12); 
 		jta.setFont(f);
 		JScrollPane jsp = new JScrollPane(jta, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
-		
+        textAreaWriter = new JTextAreaWriter( jta );
+	
 		c.add(jsp, BorderLayout.CENTER);
 		
 		start = new JButton("Start", IconManager.imgic53);
@@ -155,7 +158,7 @@ public class JDialogTextProcess extends javax.swing.JDialog implements ActionLis
 	
 	public void stopProcess() {
                 try {
-                    rshc.stopFillJTA();
+                    rshc.stopCommand();
                 } catch (LauncherException le) {
                     
                 }
@@ -184,7 +187,7 @@ public class JDialogTextProcess extends javax.swing.JDialog implements ActionLis
 			rshc.sendFileData(fileName, spec);
 			jta.append("Sending process request\n");
 			rshc.setCmd(Conversion.replaceAllString(cmd, "__FILENAME", fileName));
-			rshc.sendProcessRequest();
+			rshc.sendExecuteCommandRequest();
 
 		} catch (LauncherException le) {
 			jta.append(le.getMessage() + "\n");
@@ -199,7 +202,7 @@ public class JDialogTextProcess extends javax.swing.JDialog implements ActionLis
 			
 		try {
 			jta.append("\nRTL Process:\n------------------\n");
-			rshc.fillJTA(jta);
+	        rshc.writeCommandMessages( textAreaWriter );
 
 			rshc.deleteFile(fileName);
 			rshc.deleteFile(fileName+".sim");
diff --git a/src/ui/window/JDialogUPPAALValidation.java b/src/ui/window/JDialogUPPAALValidation.java
index b90cfe86a1..339febba5c 100755
--- a/src/ui/window/JDialogUPPAALValidation.java
+++ b/src/ui/window/JDialogUPPAALValidation.java
@@ -300,7 +300,7 @@ public class JDialogUPPAALValidation extends javax.swing.JDialog implements Acti
 
     public void stopProcess() {
         try {
-            rshc.stopFillJTA();
+            rshc.stopCommand();
         } catch (LauncherException le) {
         }
         rshc = null;
@@ -651,7 +651,7 @@ public class JDialogUPPAALValidation extends javax.swing.JDialog implements Acti
     protected String processCmd(String cmd) throws LauncherException {
         rshc.setCmd(cmd);
         String s = null;
-        rshc.sendProcessRequest();
+        rshc.sendExecuteCommandRequest();
         s = rshc.getDataFromProcess();
         return s;
     }
-- 
GitLab