コード例 #1
2
ファイル: WPart11Dialog.java プロジェクト: timburrow/ovj3
  protected void runScript(String[] cmd, JTextArea txaMsg) {
    String strg = "";

    if (cmd == null) return;

    Process prcs = null;
    try {
      Messages.postDebug("Running script: " + cmd[2]);
      Runtime rt = Runtime.getRuntime();

      prcs = rt.exec(cmd);

      if (prcs == null) return;

      InputStream istrm = prcs.getInputStream();
      if (istrm == null) return;

      BufferedReader bfr = new BufferedReader(new InputStreamReader(istrm));

      while ((strg = bfr.readLine()) != null) {
        // System.out.println(strg);
        strg = strg.trim();
        // Messages.postDebug(strg);
        strg = strg.toLowerCase();
        if (txaMsg != null) {
          txaMsg.append(strg);
          txaMsg.append("\n");
        }
      }
    } catch (Exception e) {
      // e.printStackTrace();
      Messages.writeStackTrace(e);
      Messages.postDebug(e.toString());
    } finally {
      // It is my understanding that these streams are left
      // open sometimes depending on the garbage collector.
      // So, close them.
      try {
        if (prcs != null) {
          OutputStream os = prcs.getOutputStream();
          if (os != null) os.close();
          InputStream is = prcs.getInputStream();
          if (is != null) is.close();
          is = prcs.getErrorStream();
          if (is != null) is.close();
        }
      } catch (Exception ex) {
        Messages.writeStackTrace(ex);
      }
    }
  }
コード例 #2
0
ファイル: WinSize.java プロジェクト: McNeight/GLsat
  void doExeCommand() {
    PSlider slider;
    Runtime program = Runtime.getRuntime();
    String currentCmd = new String();
    String X = new String();
    String Y = new String();

    // Kill the current executing program
    pid.destroy();

    // Setup the command parameters and run it
    slider = (PSlider) vSlider.elementAt(0);
    X = slider.getValue();
    slider = (PSlider) vSlider.elementAt(1);
    Y = slider.getValue();
    currentCmd = cmd + " " + X + " " + Y;

    try {
      pid = program.exec(currentCmd);
      if (isWindows == false) {
        Process pid2 = null;
        pid2 = program.exec("getpid WinSize");
      }
    } catch (IOException ie) {
      System.err.println("Couldn't run " + ie);
      System.exit(-1);
    }

    // Update the new value in the source code of the program
    doSourceFileUpdate();
    scrollPane.getViewport().setViewPosition(new Point(0, 20));
  }
コード例 #3
0
ファイル: WinSize.java プロジェクト: McNeight/GLsat
 private void killUNIXProcess() {
   Runtime program = Runtime.getRuntime();
   try {
     pid = program.exec("trigger WinSize");
   } catch (IOException ie) {
     System.err.println("Error in killing process " + ie);
     System.exit(-1);
   }
 }
コード例 #4
0
ファイル: TMFrame.java プロジェクト: 52Jolynn/BSMS
 /** 帮助文档 */
 private void help() {
   Runtime rt = Runtime.getRuntime();
   try {
     logger.info("打开帮助文档. - " + TMFrame.class.getName());
     rt.exec("hh.exe help.chm");
     logger.info("打开帮助文档成功. - " + TMFrame.class.getName());
   } catch (IOException e) {
     logger.error("打开帮助文档失败! - " + TMFrame.class.getName());
     JOptionPane.showMessageDialog(this, "系统无法打开帮助文档,请联系开发人员。", "提示", JOptionPane.ERROR_MESSAGE);
   }
 }
コード例 #5
0
ファイル: OrderTrans2.java プロジェクト: McNeight/GLsat
  void doExeCommand() {
    JViewport viewport = scrollPane.getViewport();
    String strContent = new String();
    PSlider slider;
    int i;
    File fp = new File(dataFile);

    RandomAccessFile access = null;
    Runtime program = Runtime.getRuntime();
    String cmdTrigger = "trigger";

    boolean delete = fp.delete();

    try {
      fp.createNewFile();
    } catch (IOException ie) {
      System.err.println("Couldn't create the new file " + ie);
      // System.exit(-1);;
    }

    try {
      access = new RandomAccessFile(fp, "rw");
    } catch (IOException ie) {
      System.err.println("Error in accessing the file " + ie);
      // System.exit(-1);;
    }

    for (i = 0; i < COMPONENTS; i++) {
      slider = (PSlider) vSlider.elementAt(i);
      /* Modified on March 20th to satisfy advisors' new request */
      if (slider.isString == true) strContent = strContent + slider.getRealStringValue() + " ";
      else strContent = strContent + slider.getValue() + " ";
    }

    // Get value of the radio button group
    if (firstBox.isSelected() == true) strContent = strContent + "1";
    else strContent = strContent + "0";

    try {
      access.writeBytes(strContent);
      access.close();
    } catch (IOException ie) {
      System.err.println("Error in writing to file " + ie);
      // System.exit(-1);;
    }
    // Trigger the OpenGL program to update with new values
    try {
      Process pid = program.exec(cmdTrigger);
    } catch (IOException ie) {
      System.err.println("Couldn't run " + ie);
      // System.exit(-1);;
    }
    doSourceFileUpdate();
  }
コード例 #6
0
 private void printCurrent() {
   if (tableModel instanceof TransportTableModel) {
     Transport o = (Transport) tableModel.getRowData(objectTable.getSelectedRow());
     String filename = TransportHelper.createHTMLFileFromTransport(o);
     try {
       Runtime runtime = Runtime.getRuntime();
       runtime.exec("explorer " + filename);
     } catch (IOException ioe) {
       System.out.println(ioe);
     }
   }
 }
コード例 #7
0
ファイル: Installer.java プロジェクト: suever/CTP
 private boolean startLauncher(File dir) {
   try {
     Runtime rt = Runtime.getRuntime();
     ArrayList<String> command = new ArrayList<String>();
     command.add("java");
     command.add("-jar");
     command.add("Launcher.jar");
     String[] cmdarray = command.toArray(new String[command.size()]);
     Process proc = rt.exec(cmdarray, null, dir);
     return true;
   } catch (Exception ex) {
     System.err.println("Unable to start the Launcher program.\n" + ex.getMessage());
     return false;
   }
 }
コード例 #8
0
ファイル: OrderTrans2.java プロジェクト: McNeight/GLsat
  public OrderTrans2() {
    super(windowTitle);
    int i;
    int currentPanel; // Value to specify which is the current panel in the vector
    JPanel subPanel = new JPanel(); // value used when adding sliders to the frame
    Runtime program = Runtime.getRuntime();
    Container content = getContentPane();

    createSliderVector();
    createPanelVector();
    getCodeSwapString();
    /** Set code-swap strings' value. */

    /** Get current OS of the system. */
    if (System.getProperty("os.name").startsWith("Windows")) isWindows = true;
    else isWindows = false;

    /** Add the radio buttons to the group */
    radioGrp.add(firstBox);
    radioGrp.add(secondBox);
    /** Set interactive buttons for the user interface */
    JButton exeButton = new JButton("Execute");
    exeButton.setToolTipText("Re-execute the program");
    JButton resetButton = new JButton("Reset");
    resetButton.setToolTipText("Reset Value");
    JButton exitButton = new JButton("Exit");
    exitButton.setToolTipText("Exit the Program");

    // Create the main panel that contains everything.
    JPanel mainPanel = new JPanel();
    // Create the panel that contains the sliders
    JPanel subPanel1 = new JPanel();
    // Create the panel that contains the checkboxes
    JPanel subPanel2 = new JPanel();
    // Create the panel that contains the buttons
    JPanel subPanel3 = new JPanel();

    // JScrollPane scrollPane = new JScrollPane(); // main text pane with scroll bars
    content.add(mainPanel, BorderLayout.SOUTH);
    mainPanel.setLayout(new BoxLayout(mainPanel, BoxLayout.Y_AXIS));
    mainPanel.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));

    content.add(scrollPane, BorderLayout.CENTER);
    scrollPane.setBorder(BorderFactory.createLoweredBevelBorder());
    scrollPane.getViewport().add(textPane);

    mainPanel.add(subPanel1);
    mainPanel.add(subPanel2);
    mainPanel.add(subPanel3);
    subPanel1.setLayout(new GridLayout(0, 1));
    /** Add subPanel elements to the subPanel1, each would be a row of sliders */
    for (i = 0; i < ROWS; i++) subPanel1.add((JPanel) vSubPanel.elementAt(i));
    /** Set the first element in the Panel Vector as the current subPanel. */
    currentPanel = 0;
    subPanel = (JPanel) vSubPanel.elementAt(currentPanel);
    /** Allocate sliders to the sub-panels. */
    for (i = 0; i < COMPONENTS; i++) {
      PSlider slider = (PSlider) vSlider.elementAt(i);
      if (slider.getResideValue() == 'n') {
        currentPanel += 1;
        subPanel = (JPanel) vSubPanel.elementAt(currentPanel);
      }
      subPanel.add((PSlider) vSlider.elementAt(i));
    }

    /** Set and view the source code on the frame */
    textPane.setEditable(false);
    textPane.setContentType("text/html; charset=EUC-JP");

    subPanel2.setLayout(new GridLayout(0, 2));
    subPanel2.add(firstBox);
    subPanel2.add(secondBox);
    subPanel3.setLayout(new GridLayout(0, 3));
    subPanel3.add(exeButton);
    exeButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            doExeCommand();
          }
        });
    subPanel3.add(resetButton);
    resetButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            doResetCommand();
          }
        });
    subPanel3.add(exitButton);
    exitButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            doExitCommand();
          }
        });

    /** Run the illustrated program */
    try {
      pid = program.exec(cmd);
      if (isWindows == false) {
        Process pid2 = null;
        pid2 = program.exec("getpid " + cmd.substring(4));
      }
    } catch (IOException ie) {
      System.err.println("Couldn't run " + ie);
      // System.exit(-1);;
    }
    /** Set the initial status for the window */
    addWindowListener(
        new WindowAdapter() {
          public void windowClosing(WindowEvent e) {
            File fp = new File(dataFile);
            doResetCommand();
            boolean delete = fp.delete();
            pid.destroy();
          }
        });

    doExeCommand();
    setSize(WIDTH, HEIGHT);
    setLocation(500, 0);
    setVisible(true);
  }
コード例 #9
0
ファイル: CaptureReplay.java プロジェクト: easilyBaffled/435
  // Run selected test cases.
  private void runTests() {

    for (int i = 0; i < tests.size(); i++) {
      // If box for test is checked, run it.
      if (tests.get(i).isSelected()) {

        // Get the URLs of all of the required files.
        String folderURL = tests.get(i).getText();
        String testURL = folderURL.concat(folderURL.substring(folderURL.lastIndexOf('/')));
        String efgFile = testURL + ".EFG";
        String guiFile = testURL + ".GUI";
        String tstFile = testURL + ".TST";
        String prgFile = testURL + ".PRG";

        // attempt to read in file with program's parameters
        try {
          FileInputStream fstream = new FileInputStream(prgFile);
          DataInputStream in = new DataInputStream(fstream);
          BufferedReader br = new BufferedReader(new InputStreamReader(in));
          HashMap<String, String> prgParams = new HashMap<String, String>();
          String strLine;
          while ((strLine = br.readLine()) != null) {
            // add found parameters into prgParams as <key, value>
            String[] matches = strLine.split("=");
            prgParams.put(matches[0], matches[1]);
          }

          if (prgParams.containsKey("path") && prgParams.containsKey("main")) {
            programPath = prgParams.get("path");
            mainClass = prgParams.get("main");
          }

          in.close();
        } catch (Exception e) {
          System.err.println(e.getMessage());
        }

        System.out.println("We hit Run");

        // Run the replayer using the three test files.
        System.out.println(
            "../../../dist/guitar/jfc-replayer.sh -cp "
                + programPath
                + " -c "
                + mainClass
                + " -g "
                + guiFile
                + " -e "
                + efgFile
                + " -t "
                + tstFile);
        try {
          Runtime rt = Runtime.getRuntime();
          Process proc =
              rt.exec(
                  "../../../dist/guitar/jfc-replayer.sh -cp "
                      + programPath
                      + " -c "
                      + mainClass
                      + " -g "
                      + guiFile
                      + " -e "
                      + efgFile
                      + " -t "
                      + tstFile);

          // InputStream ips = proc.getInputStream();
          BufferedReader in = new BufferedReader(new InputStreamReader(proc.getInputStream()));
          String inputLine;
          while ((inputLine = in.readLine()) != null) System.out.println(inputLine);
          in.close();

        } catch (Exception e) {
          e.printStackTrace();
        }
      }
    }
  }
コード例 #10
0
ファイル: BoxOnTable.java プロジェクト: McNeight/GLsat
  public BoxOnTable() {
    super(windowTitle);
    int i;

    Runtime program = Runtime.getRuntime();
    Container content = getContentPane();

    /** Get current OS of the system. */
    if (System.getProperty("os.name").startsWith("Windows")) isWindows = true;
    else isWindows = false;
    /** Set interactive buttons for the user interface */
    JButton exitButton = new JButton("Exit");
    exitButton.setToolTipText("Exit the Program");

    JPanel mainPanel = new JPanel();

    content.add(mainPanel, BorderLayout.SOUTH);
    mainPanel.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));

    content.add(scrollPane, BorderLayout.CENTER);
    scrollPane.setBorder(BorderFactory.createLoweredBevelBorder());
    scrollPane.getViewport().add(textPane);

    mainPanel.add(exitButton, BorderLayout.CENTER);

    /** Set and view the source code on the frame */
    textPane.setEditable(false);
    textPane.setContentType("text/html; charset=EUC-JP");
    try {
      URL url = new URL("file:" + exampleSource);
      textPane.setPage(url);
    } catch (IOException ie) {
      System.err.println("Error in opening html source file " + ie);
      System.exit(-1);
    }

    exitButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            doExitCommand();
          }
        });

    /** Run the illustrated program */
    try {
      pid = program.exec(cmd);
    } catch (IOException ie) {
      System.err.println("Couldn't run " + ie);
      System.exit(-1);
    }
    /** Set the initial status for the window */
    addWindowListener(
        new WindowAdapter() {
          public void windowClosing(WindowEvent e) {
            pid.destroy();
          }
        });
    setSize(WIDTH, HEIGHT);
    setLocation(500, 0);
    setVisible(true);
  }