Changeset 4081
- Timestamp:
- Dec 17, 2010, 9:32:28 AM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/plugin/src/org/proteios/plugins/RunMsInspectPlugin.java
r4080 r4081 77 77 OutputStream os; 78 78 String content = null; 79 ProgressReporter myProgress = null; 79 80 80 81 … … 90 91 this.type = type; 91 92 this.os = redirect; 93 } 94 95 96 StreamGobbler(InputStream is, String type, OutputStream redirect, ProgressReporter progress) 97 { 98 this.is = is; 99 this.type = type; 100 this.os = redirect; 101 this.myProgress = progress; 92 102 } 93 103 … … 133 143 content = content + "\n" + line; 134 144 } 145 // Parse output for progress report 146 updateProgressInformation(myProgress, line); 135 147 } 136 148 if (pw != null) … … 455 467 Runtime rt = Runtime.getRuntime(); 456 468 Process proc = rt.exec(cmd); 469 /* 457 470 // any error message? 458 471 StreamGobbler errorGobbler = new StreamGobbler(proc 459 472 .getErrorStream(), "ERR"); 473 */ 474 // Parse error stream for progress info 475 // any error message? 476 StreamGobbler errorGobbler = new StreamGobbler(proc 477 .getErrorStream(), "ERR", null, progress); 460 478 // any output? 461 479 StreamGobbler outputGobbler = new StreamGobbler(proc … … 713 731 714 732 /** 733 * Updates progress reporter information. 734 * 735 * @param progress ProgressReporter The progress reporter instance to use. 736 * @param line String The information string to parse for progress information 737 */ 738 private void updateProgressInformation(ProgressReporter progress, String line) 739 { 740 // Parse output for progress report 741 if (progress != null) 742 { 743 if (line.contains("complete")) 744 { 745 // msInspect typically outputs a line like "16 Dec 2010 11:02:02,965 INFO ApplicationContext: 12.043658% complete." 746 String testStr = new String("ApplicationContext: "); 747 int index = line.indexOf(testStr); 748 if (index >= 0) 749 { 750 // Cut off start of string including testStr 751 String percentStr = line.substring(index + testStr.length()); 752 /* 753 System.out 754 .println(this.getClass().getSimpleName() + ": percentStr (1) = \"" + percentStr + "\""); 755 */ 756 testStr = new String("."); 757 index = percentStr.indexOf(testStr); 758 if (index >= 0) 759 { 760 // Cut off end of string starting with testStr 761 percentStr = percentStr.substring(0, index); 762 /* 763 System.out 764 .println(this.getClass().getSimpleName() + ": percentStr (2) = \"" + percentStr + "\""); 765 */ 766 // Convert percent string to int 767 int percentCompleted = 0; 768 try 769 { 770 percentCompleted = Integer.parseInt(percentStr); 771 } 772 catch (NumberFormatException e) 773 {} 774 // Total progress includes more than msInspect analysis 775 if (percentCompleted > 99) 776 { 777 percentCompleted = 99; 778 } 779 progress.display(percentCompleted, "% completed"); 780 } 781 } 782 } 783 } 784 } 785 786 787 /** 715 788 * Update command line with new option and value, 716 789 * provided that the value differs from null and
Note: See TracChangeset
for help on using the changeset viewer.