jmeter-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From s...@apache.org
Subject svn commit: r1209914 - /jmeter/trunk/src/jorphan/org/apache/jorphan/gui/JLabeledTextArea.java
Date Sat, 03 Dec 2011 14:19:18 GMT
Author: sebb
Date: Sat Dec  3 14:19:18 2011
New Revision: 1209914

URL: http://svn.apache.org/viewvc?rev=1209914&view=rev
Log:
Add getTextLines() method; needed for Bug 51861

Modified:
    jmeter/trunk/src/jorphan/org/apache/jorphan/gui/JLabeledTextArea.java

Modified: jmeter/trunk/src/jorphan/org/apache/jorphan/gui/JLabeledTextArea.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/jorphan/org/apache/jorphan/gui/JLabeledTextArea.java?rev=1209914&r1=1209913&r2=1209914&view=diff
==============================================================================
--- jmeter/trunk/src/jorphan/org/apache/jorphan/gui/JLabeledTextArea.java (original)
+++ jmeter/trunk/src/jorphan/org/apache/jorphan/gui/JLabeledTextArea.java Sat Dec  3 14:19:18
2011
@@ -32,6 +32,7 @@ import javax.swing.JScrollPane;
 import javax.swing.JTextArea;
 import javax.swing.event.ChangeEvent;
 import javax.swing.event.ChangeListener;
+import javax.swing.text.BadLocationException;
 import javax.swing.text.Document;
 
 /**
@@ -239,4 +240,22 @@ public class JLabeledTextArea extends JP
             mChangeListeners.get(index).stateChanged(ce);
         }
     }
+    
+    public String[] getTextLines() {
+        int numLines = mTextArea.getLineCount();
+        String[] lines = new String[numLines];
+        for(int i = 0; i < numLines; i++) {
+            try {
+                int start = mTextArea.getLineStartOffset(i);
+                int end = mTextArea.getLineEndOffset(i); // treats last line specially
+                if (i == numLines-1) { // Last line
+                    end++; // Allow for missing terminator
+                }
+                lines[i]=mTextArea.getText(start, end-start-1);
+            } catch (BadLocationException e) { // should not happen
+                throw new IllegalStateException("Could not read line "+i,e);
+            }
+        }
+        return lines;
+    }
 }
\ No newline at end of file



Mime
View raw message