]> SALOME platform Git repositories - tools/siman.git/commitdiff
Salome HOME
Run Salome with separated parameters. Read output and error streams.
authorrkv <rkv@opencascade.com>
Mon, 10 Dec 2012 07:20:10 +0000 (07:20 +0000)
committerrkv <rkv@opencascade.com>
Mon, 10 Dec 2012 07:20:10 +0000 (07:20 +0000)
Workspace/Siman/src/org/splat/launcher/ToolbarApplet.java

index 89f500f97d24b84add06ef3a4c4151ce6c61e2dd..d5f2a757ab32cff2d39897d5f160f61a6f357f47 100644 (file)
@@ -15,6 +15,9 @@ import java.net.MalformedURLException;
 import java.net.URL;
 import java.net.URLConnection;
 import java.net.URLEncoder;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
 
 /**
  * Applet providing a set of buttons. Each button is defined by three parameters:<BR>
@@ -178,7 +181,7 @@ public class ToolbarApplet extends java.applet.Applet implements ActionListener
                                }
                        }
                } catch (Exception error) {
-                       error.printStackTrace(); // RKV: NOPMD: TODO: try to use logger
+                       error.printStackTrace(); // RKV: NOPMD: Applet output
                }
        }
 
@@ -243,12 +246,31 @@ public class ToolbarApplet extends java.applet.Applet implements ActionListener
                        if (isOk) {
                                // Execute the runSalome script.
                                // filename here indeed a string containing parameters for runSalome.
-                               Runtime.getRuntime().exec(
-                                               new String[] { script.getAbsolutePath(), params },
-                                               null, new File(SALOME_HOME));
+                               List<String> cmd = new ArrayList<String>(Arrays.asList(params
+                                               .split("\\s")));
+                               cmd.add(0, script.getAbsolutePath());
+                               Process proc = Runtime.getRuntime().exec(
+                                               cmd.toArray(new String[] {}), null,
+                                               new File(SALOME_HOME));
                                // Refresh the current scenario view
                                getAppletContext().showDocument(
                                                new URL(this.getParameter("refresh")));
+                               BufferedReader bri = new BufferedReader(new InputStreamReader(
+                                               proc.getInputStream()));
+                               BufferedReader bre = new BufferedReader(new InputStreamReader(
+                                               proc.getErrorStream()));
+                               String line = bri.readLine();
+                               while (line != null) {
+                                       System.out.println(line); // RKV: NOPMD: Applet output
+                                       line = bri.readLine();
+                               }
+                               bri.close();
+                               line = bre.readLine();
+                               while (line != null) {
+                                       System.out.println(line); // RKV: NOPMD: Applet output
+                                       line = bre.readLine();
+                               }
+                               bre.close();
                        } else {
                                // Checkout of the scenario is failed at the beginning.
                                if (response != null) {