You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jmeter-dev@jakarta.apache.org by se...@apache.org on 2009/12/01 02:51:29 UTC

svn commit: r885648 [1/2] - in /jakarta/jmeter/trunk/src: components/org/apache/jmeter/visualizers/ core/org/apache/jmeter/resources/ jorphan/org/apache/jorphan/gui/

Author: sebb
Date: Tue Dec  1 01:51:15 2009
New Revision: 885648

URL: http://svn.apache.org/viewvc?rev=885648&view=rev
Log:
Bug 47474 - View Results Tree support for plugin renderers

Added:
    jakarta/jmeter/trunk/src/components/org/apache/jmeter/visualizers/RenderAsHTML.java   (with props)
    jakarta/jmeter/trunk/src/components/org/apache/jmeter/visualizers/RenderAsHTMLWithEmbedded.java   (with props)
    jakarta/jmeter/trunk/src/components/org/apache/jmeter/visualizers/RenderAsJSON.java   (with props)
    jakarta/jmeter/trunk/src/components/org/apache/jmeter/visualizers/RenderAsRegexp.java   (with props)
    jakarta/jmeter/trunk/src/components/org/apache/jmeter/visualizers/RenderAsText.java   (with props)
    jakarta/jmeter/trunk/src/components/org/apache/jmeter/visualizers/RenderAsXML.java   (with props)
    jakarta/jmeter/trunk/src/components/org/apache/jmeter/visualizers/ResultRenderer.java   (with props)
    jakarta/jmeter/trunk/src/components/org/apache/jmeter/visualizers/SamplerResultTab.java   (with props)
    jakarta/jmeter/trunk/src/jorphan/org/apache/jorphan/gui/GuiUtils.java   (with props)
Modified:
    jakarta/jmeter/trunk/src/components/org/apache/jmeter/visualizers/SearchTextExtension.java
    jakarta/jmeter/trunk/src/components/org/apache/jmeter/visualizers/ViewResultsFullVisualizer.java
    jakarta/jmeter/trunk/src/core/org/apache/jmeter/resources/messages.properties
    jakarta/jmeter/trunk/src/core/org/apache/jmeter/resources/messages_fr.properties

Added: jakarta/jmeter/trunk/src/components/org/apache/jmeter/visualizers/RenderAsHTML.java
URL: http://svn.apache.org/viewvc/jakarta/jmeter/trunk/src/components/org/apache/jmeter/visualizers/RenderAsHTML.java?rev=885648&view=auto
==============================================================================
--- jakarta/jmeter/trunk/src/components/org/apache/jmeter/visualizers/RenderAsHTML.java (added)
+++ jakarta/jmeter/trunk/src/components/org/apache/jmeter/visualizers/RenderAsHTML.java Tue Dec  1 01:51:15 2009
@@ -0,0 +1,150 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed  under the  License is distributed on an "AS IS" BASIS,
+ * WITHOUT  WARRANTIES OR CONDITIONS  OF ANY KIND, either  express  or
+ * implied.
+ *
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.jmeter.visualizers;
+
+import javax.swing.JEditorPane;
+import javax.swing.text.ComponentView;
+import javax.swing.text.Document;
+import javax.swing.text.EditorKit;
+import javax.swing.text.Element;
+import javax.swing.text.StyleConstants;
+import javax.swing.text.View;
+import javax.swing.text.ViewFactory;
+import javax.swing.text.html.HTML;
+import javax.swing.text.html.HTMLEditorKit;
+
+import org.apache.jmeter.samplers.SampleResult;
+import org.apache.jmeter.util.JMeterUtils;
+import org.apache.jorphan.logging.LoggingManager;
+import org.apache.log.Logger;
+
+public class RenderAsHTML extends SamplerResultTab implements ResultRenderer {
+
+    private static final Logger log = LoggingManager.getLoggerForClass();
+
+    private static final String TEXT_HTML = "text/html"; // $NON-NLS-1$
+
+    // Keep copies of the two editors needed
+    private static final EditorKit customisedEditor = new LocalHTMLEditorKit();
+
+    private static final EditorKit defaultHtmlEditor = JEditorPane.createEditorKitForContentType(TEXT_HTML);
+
+    /** {@inheritDoc} */
+    public void renderResult(SampleResult sampleResult) {
+        // get the text response and image icon
+        // to determine which is NOT null
+        String response = ViewResultsFullVisualizer.getResponseAsString(sampleResult);
+        showRenderedResponse(response, sampleResult);
+    }
+
+    protected void showRenderedResponse(String response, SampleResult res) {
+        showRenderedResponse(response, res, false);
+    }
+
+    protected void showRenderedResponse(String response, SampleResult res, boolean embedded) {
+        if (response == null) {
+            results.setText("");
+            return;
+        }
+
+        int htmlIndex = response.indexOf("<HTML"); // could be <HTML lang=""> // $NON-NLS-1$
+
+        // Look for a case variation
+        if (htmlIndex < 0) {
+            htmlIndex = response.indexOf("<html"); // ditto // $NON-NLS-1$
+        }
+
+        // If we still can't find it, just try using all of the text
+        if (htmlIndex < 0) {
+            htmlIndex = 0;
+        }
+
+        String html = response.substring(htmlIndex);
+
+        /*
+         * To disable downloading and rendering of images and frames, enable the
+         * editor-kit. The Stream property can then be
+         */
+        log.debug("html embedded=" + embedded);
+        // Must be done before setContentType
+        results.setEditorKitForContentType(TEXT_HTML, embedded ? defaultHtmlEditor : customisedEditor);
+
+        results.setContentType(TEXT_HTML);
+
+        if (embedded) {
+            // Allow JMeter to render frames (and relative images)
+            // Must be done after setContentType [Why?]
+            results.getDocument().putProperty(Document.StreamDescriptionProperty, res.getURL());
+        }
+        /*
+         * Get round problems parsing <META http-equiv='content-type'
+         * content='text/html; charset=utf-8'> See
+         * http://issues.apache.org/bugzilla/show_bug.cgi?id=23315
+         *
+         * Is this due to a bug in Java?
+         */
+        results.getDocument().putProperty("IgnoreCharsetDirective", Boolean.TRUE); // $NON-NLS-1$
+
+        results.setText(html);
+        results.setCaretPosition(0);
+        resultsScrollPane.setViewportView(results);
+
+    }
+
+    private static class LocalHTMLEditorKit extends HTMLEditorKit {
+
+        private static final long serialVersionUID = -3399554318202905392L;
+
+        private static final ViewFactory defaultFactory = new LocalHTMLFactory();
+
+        @Override
+        public ViewFactory getViewFactory() {
+            return defaultFactory;
+        }
+
+        private static class LocalHTMLFactory extends javax.swing.text.html.HTMLEditorKit.HTMLFactory {
+            /*
+             * Provide dummy implementations to suppress download and display of
+             * related resources: - FRAMEs - IMAGEs TODO create better dummy
+             * displays TODO suppress LINK somehow
+             */
+            @Override
+            public View create(Element elem) {
+                Object o = elem.getAttributes().getAttribute(StyleConstants.NameAttribute);
+                if (o instanceof HTML.Tag) {
+                    HTML.Tag kind = (HTML.Tag) o;
+                    if (kind == HTML.Tag.FRAME) {
+                        return new ComponentView(elem);
+                    } else if (kind == HTML.Tag.IMG) {
+                        return new ComponentView(elem);
+                    }
+                }
+                return super.create(elem);
+            }
+        }
+    }
+
+    /** {@inheritDoc} */
+    @Override
+    public String toString() {
+        return JMeterUtils.getResString("view_results_render_html"); // $NON-NLS-1$
+    }
+
+}

Propchange: jakarta/jmeter/trunk/src/components/org/apache/jmeter/visualizers/RenderAsHTML.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: jakarta/jmeter/trunk/src/components/org/apache/jmeter/visualizers/RenderAsHTML.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Added: jakarta/jmeter/trunk/src/components/org/apache/jmeter/visualizers/RenderAsHTMLWithEmbedded.java
URL: http://svn.apache.org/viewvc/jakarta/jmeter/trunk/src/components/org/apache/jmeter/visualizers/RenderAsHTMLWithEmbedded.java?rev=885648&view=auto
==============================================================================
--- jakarta/jmeter/trunk/src/components/org/apache/jmeter/visualizers/RenderAsHTMLWithEmbedded.java (added)
+++ jakarta/jmeter/trunk/src/components/org/apache/jmeter/visualizers/RenderAsHTMLWithEmbedded.java Tue Dec  1 01:51:15 2009
@@ -0,0 +1,41 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed  under the  License is distributed on an "AS IS" BASIS,
+ * WITHOUT  WARRANTIES OR CONDITIONS  OF ANY KIND, either  express  or
+ * implied.
+ *
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.jmeter.visualizers;
+
+import org.apache.jmeter.samplers.SampleResult;
+import org.apache.jmeter.util.JMeterUtils;
+
+public class RenderAsHTMLWithEmbedded extends RenderAsHTML
+    implements ResultRenderer {
+
+    /** {@inheritDoc} */
+    @Override
+    protected void showRenderedResponse(String response, SampleResult res) {
+        // enable embedded html resources
+        showRenderedResponse(response, res, true);
+    }
+
+    /** {@inheritDoc} */
+    @Override
+    public String toString() {
+        return JMeterUtils.getResString("view_results_render_html_embedded"); // $NON-NLS-1$
+    }
+
+}

Propchange: jakarta/jmeter/trunk/src/components/org/apache/jmeter/visualizers/RenderAsHTMLWithEmbedded.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: jakarta/jmeter/trunk/src/components/org/apache/jmeter/visualizers/RenderAsHTMLWithEmbedded.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Added: jakarta/jmeter/trunk/src/components/org/apache/jmeter/visualizers/RenderAsJSON.java
URL: http://svn.apache.org/viewvc/jakarta/jmeter/trunk/src/components/org/apache/jmeter/visualizers/RenderAsJSON.java?rev=885648&view=auto
==============================================================================
--- jakarta/jmeter/trunk/src/components/org/apache/jmeter/visualizers/RenderAsJSON.java (added)
+++ jakarta/jmeter/trunk/src/components/org/apache/jmeter/visualizers/RenderAsJSON.java Tue Dec  1 01:51:15 2009
@@ -0,0 +1,117 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed  under the  License is distributed on an "AS IS" BASIS,
+ * WITHOUT  WARRANTIES OR CONDITIONS  OF ANY KIND, either  express  or
+ * implied.
+ *
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.jmeter.visualizers;
+
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import org.apache.jmeter.samplers.SampleResult;
+import org.apache.jmeter.util.JMeterUtils;
+
+public class RenderAsJSON extends SamplerResultTab implements ResultRenderer {
+
+    private static final String ESC_CHAR_REGEX = "\\\\[\"\\\\/bfnrt]|\\\\u[0-9A-Fa-f]{4}"; // $NON-NLS-1$
+
+    private static final String NORMAL_CHARACTER_REGEX = "[^\"\\\\]";  // $NON-NLS-1$
+
+    private static final String STRING_REGEX = "\"(" + ESC_CHAR_REGEX + "|" + NORMAL_CHARACTER_REGEX + ")*\""; // $NON-NLS-1$
+
+    // This 'other value' regex is deliberately weak, even accepting an empty string, to be useful when reporting malformed data.
+    private static final String OTHER_VALUE_REGEX = "[^\\{\\[\\]\\}\\,]*"; // $NON-NLS-1$
+
+    private static final String VALUE_OR_PAIR_REGEX = "((" + STRING_REGEX + "\\s*:)?\\s*(" + STRING_REGEX + "|" + OTHER_VALUE_REGEX + ")\\s*,?\\s*)"; // $NON-NLS-1$
+
+    private static final Pattern VALUE_OR_PAIR_PATTERN = Pattern.compile(VALUE_OR_PAIR_REGEX);
+
+    /** {@inheritDoc} */
+    public void renderResult(SampleResult sampleResult) {
+        String response = ViewResultsFullVisualizer.getResponseAsString(sampleResult);
+        showRenderJSONResponse(response);
+    }
+
+    private void showRenderJSONResponse(String response) {
+        results.setContentType("text/plain"); // $NON-NLS-1$
+        results.setText(response == null ? "" : prettyJSON(response));
+        results.setCaretPosition(0);
+        resultsScrollPane.setViewportView(results);
+    }
+
+    // It might be useful also to make this available in the 'Request' tab, for
+    // when posting JSON.
+    private static String prettyJSON(String json) {
+        StringBuffer pretty = new StringBuffer(json.length() * 2); // Educated guess
+
+        final String tab = ":   "; // $NON-NLS-1$
+        StringBuffer index = new StringBuffer();
+        String nl = ""; // $NON-NLS-1$
+
+        Matcher valueOrPair = VALUE_OR_PAIR_PATTERN.matcher(json);
+
+        boolean misparse = false;
+
+        for (int i = 0; i < json.length(); ) {
+            final char currentChar = json.charAt(i);
+            if ((currentChar == '{') || (currentChar == '[')) {
+                pretty.append(nl).append(index).append(currentChar);
+                i++;
+                index.append(tab);
+                misparse = false;
+            }
+            else if ((currentChar == '}') || (currentChar == ']')) {
+                if (index.length() > 0) {
+                    index.delete(0, tab.length());
+                }
+                pretty.append(nl).append(index).append(currentChar);
+                i++;
+                int j = i;
+                while ((j < json.length()) && Character.isWhitespace(json.charAt(j))) {
+                    j++;
+                }
+                if ((j < json.length()) && (json.charAt(j) == ',')) {
+                    pretty.append(","); // $NON-NLS-1$
+                    i=j+1;
+                }
+                misparse = false;
+            }
+            else if (valueOrPair.find(i) && valueOrPair.group().length() > 0) {
+                pretty.append(nl).append(index).append(valueOrPair.group());
+                i=valueOrPair.end();
+                misparse = false;
+            }
+            else {
+                if (!misparse) {
+                    pretty.append(nl).append("- Parse failed from:");
+                }
+                pretty.append(currentChar);
+                i++;
+                misparse = true;
+            }
+            nl = "\n"; // $NON-NLS-1$
+        }
+        return pretty.toString();
+    }
+
+    /** {@inheritDoc} */
+    @Override
+    public String toString() {
+        return JMeterUtils.getResString("view_results_render_json"); // $NON-NLS-1$
+    }
+
+}

Propchange: jakarta/jmeter/trunk/src/components/org/apache/jmeter/visualizers/RenderAsJSON.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: jakarta/jmeter/trunk/src/components/org/apache/jmeter/visualizers/RenderAsJSON.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Added: jakarta/jmeter/trunk/src/components/org/apache/jmeter/visualizers/RenderAsRegexp.java
URL: http://svn.apache.org/viewvc/jakarta/jmeter/trunk/src/components/org/apache/jmeter/visualizers/RenderAsRegexp.java?rev=885648&view=auto
==============================================================================
--- jakarta/jmeter/trunk/src/components/org/apache/jmeter/visualizers/RenderAsRegexp.java (added)
+++ jakarta/jmeter/trunk/src/components/org/apache/jmeter/visualizers/RenderAsRegexp.java Tue Dec  1 01:51:15 2009
@@ -0,0 +1,253 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed  under the  License is distributed on an "AS IS" BASIS,
+ * WITHOUT  WARRANTIES OR CONDITIONS  OF ANY KIND, either  express  or
+ * implied.
+ *
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ *
+ */
+package org.apache.jmeter.visualizers;
+
+import java.awt.BorderLayout;
+import java.awt.Color;
+import java.awt.Dimension;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.util.LinkedList;
+import java.util.List;
+
+import javax.swing.JButton;
+import javax.swing.JPanel;
+import javax.swing.JScrollPane;
+import javax.swing.JSplitPane;
+import javax.swing.JTabbedPane;
+import javax.swing.JTextArea;
+
+import org.apache.jmeter.samplers.SampleResult;
+import org.apache.jmeter.util.JMeterUtils;
+import org.apache.jorphan.gui.GuiUtils;
+import org.apache.jorphan.gui.JLabeledTextField;
+import org.apache.jorphan.logging.LoggingManager;
+import org.apache.log.Logger;
+import org.apache.oro.text.PatternCacheLRU;
+import org.apache.oro.text.regex.MatchResult;
+import org.apache.oro.text.regex.Pattern;
+import org.apache.oro.text.regex.PatternMatcherInput;
+import org.apache.oro.text.regex.Perl5Compiler;
+import org.apache.oro.text.regex.Perl5Matcher;
+
+/**
+ * Implement ResultsRender for Regexp tester
+ */
+public class RenderAsRegexp implements ResultRenderer, ActionListener {
+
+    private static final Logger log = LoggingManager.getLoggerForClass();
+
+    private static final String REGEXP_TESTER_COMMAND = "regexp_tester"; // $NON-NLS-1$
+
+    private JPanel regexpPane;
+
+    private JTextArea regexpDataField;
+
+    private JLabeledTextField regexpField;
+
+    private JTextArea regexpResultField;
+
+    private JTabbedPane rightSide;
+
+    private SampleResult sampleResult = null;
+
+    /** {@inheritDoc} */
+    public void clearData() {
+        this.clearFields();
+    }
+
+    /** {@inheritDoc} */
+    public void init() {
+        // Create the panels for the regexp tab
+        regexpPane = createRegexpPanel();
+    }
+
+    /**
+     * Display the response as text or as rendered HTML. Change the text on the
+     * button appropriate to the current display.
+     *
+     * @param e the ActionEvent being processed
+     */
+    public void actionPerformed(ActionEvent e) {
+        String command = e.getActionCommand();
+        if ((sampleResult != null) && (REGEXP_TESTER_COMMAND.equals(command))) {
+            String response = ViewResultsFullVisualizer.getResponseAsString(sampleResult);
+            executeAndShowRegexpTester(response);
+        }
+    }
+
+    /**
+     * Launch regexp engine to parse a input text
+     * @param textToParse
+     */
+    private void executeAndShowRegexpTester(String textToParse) {
+        if (textToParse != null && textToParse.length() > 0
+                && this.regexpField.getText().length() > 0) {
+            log.debug("regexpField = " + this.regexpField.getText());
+            this.regexpResultField.setText(process(textToParse));
+        }
+    }
+
+    private String process(String textToParse) {
+
+        Perl5Matcher matcher = new Perl5Matcher();
+        PatternMatcherInput input = new PatternMatcherInput(textToParse);
+
+        PatternCacheLRU pcLRU = new PatternCacheLRU();
+        Pattern pattern = pcLRU.getPattern(regexpField.getText(), Perl5Compiler.READ_ONLY_MASK);
+        List<MatchResult> matches = new LinkedList<MatchResult>();
+        int x = 0;
+        boolean done = false;
+        do {
+            if (matcher.contains(input, pattern)) {
+                //log.debug("RegexExtractor: Match found!");
+                matches.add(matcher.getMatch());
+            } else {
+                done = true;
+            }
+            x++;
+        } while (!done);
+
+        // Construct a multi-line string with all matches
+        StringBuffer sb = new StringBuffer();
+        for (int j = 0; j < matches.size(); j++) {
+            MatchResult mr = matches.get(j);
+            final int groups = mr.groups();
+            for (int i = 0; i < groups; i++) {
+                sb.append(" group[" + j + "][" + i + "]=" + mr.group(i) + "\n");
+
+            }
+        }
+        return sb.toString();
+
+    }
+    /** {@inheritDoc} */
+   public void renderResult(SampleResult sampleResult) {
+        this.clearFields();
+
+        if ((SampleResult.TEXT).equals(sampleResult.getDataType())) {
+            String response = ViewResultsFullVisualizer.getResponseAsString(sampleResult);
+            regexpDataField.setText(response);
+            regexpDataField.setCaretPosition(0);
+        } else {
+            regexpDataField.setText(JMeterUtils.getResString("regexp_render_no_text"));
+        }
+    }
+
+    /** {@inheritDoc} */
+    public void setupTabPane() {
+         // Add regexp tester pane
+        if (rightSide.indexOfTab(JMeterUtils.getResString("regexp_tester_title")) < 0) { // $NON-NLS-1$
+            rightSide.addTab(JMeterUtils.getResString("regexp_tester_title"), regexpPane); // $NON-NLS-1$
+        }
+        clearData();
+    }
+
+    /**
+     * @return RegExp Tester panel
+     */
+    private JPanel createRegexpPanel() {
+        regexpDataField = new JTextArea();
+        regexpDataField.setEditable(false);
+        regexpDataField.setLineWrap(true);
+        regexpDataField.setWrapStyleWord(true);
+
+        JScrollPane regexpDataPane = GuiUtils.makeScrollPane(regexpDataField);
+        regexpDataPane.setMinimumSize(new Dimension(0, 200));
+
+        JPanel pane = new JPanel(new BorderLayout(0, 5));
+
+        JSplitPane mainSplit = new JSplitPane(JSplitPane.VERTICAL_SPLIT,
+                regexpDataPane, createRegexpTasksPanel());
+        mainSplit.setDividerLocation(300);
+        pane.add(mainSplit, BorderLayout.CENTER);
+        return pane;
+    }
+
+    /**
+     * Create the Regexp task pane
+     *
+     * @return Regexp task pane
+     */
+    private JPanel createRegexpTasksPanel() {
+        JPanel regexpActionPanel = new JPanel();
+        regexpField = new JLabeledTextField(JMeterUtils.getResString("regexp_tester_field"), 30); // $NON-NLS-1$
+        regexpActionPanel.add(regexpField, BorderLayout.WEST);
+
+        JButton regexpTester = new JButton(JMeterUtils.getResString("regexp_tester_button_test"));
+        regexpTester.setActionCommand(REGEXP_TESTER_COMMAND);
+        regexpTester.addActionListener(this);
+        regexpActionPanel.add(regexpTester, BorderLayout.EAST);
+
+        regexpResultField = new JTextArea();
+        regexpResultField.setEditable(false);
+        regexpResultField.setLineWrap(true);
+        regexpResultField.setWrapStyleWord(true);
+
+        JPanel regexpTasksPanel = new JPanel(new BorderLayout(0, 5));
+        regexpTasksPanel.add(regexpActionPanel, BorderLayout.NORTH);
+        regexpTasksPanel.add(GuiUtils.makeScrollPane(regexpResultField), BorderLayout.CENTER);
+
+        return regexpTasksPanel;
+    }
+
+    private void clearFields() {
+        regexpDataField.setText(""); // $NON-NLS-1$
+        // don't set empty to keep regexp
+        // regexpField.setText(""); // $NON-NLS-1$
+        regexpResultField.setText(""); // $NON-NLS-1$
+    }
+
+    /** {@inheritDoc} */
+    public synchronized void setRightSide(JTabbedPane side) {
+        rightSide = side;
+    }
+
+    /** {@inheritDoc} */
+    public synchronized void setSamplerResult(Object userObject) {
+        if (userObject instanceof SampleResult) {
+            sampleResult = (SampleResult) userObject;
+        }
+    }
+
+    /** {@inheritDoc} */
+    public void setLastSelectedTab(int index) {
+        // nothing to do
+    }
+
+    /** {@inheritDoc} */
+    @Override
+    public String toString() {
+        return JMeterUtils.getResString("regexp_tester_title");
+    }
+
+    /** {@inheritDoc} */
+    public void renderImage(SampleResult sampleResult) {
+        clearData();
+    }
+
+    /** {@inheritDoc} */
+    public void setBackgroundColor(Color backGround) {
+    }
+
+}

Propchange: jakarta/jmeter/trunk/src/components/org/apache/jmeter/visualizers/RenderAsRegexp.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: jakarta/jmeter/trunk/src/components/org/apache/jmeter/visualizers/RenderAsRegexp.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Added: jakarta/jmeter/trunk/src/components/org/apache/jmeter/visualizers/RenderAsText.java
URL: http://svn.apache.org/viewvc/jakarta/jmeter/trunk/src/components/org/apache/jmeter/visualizers/RenderAsText.java?rev=885648&view=auto
==============================================================================
--- jakarta/jmeter/trunk/src/components/org/apache/jmeter/visualizers/RenderAsText.java (added)
+++ jakarta/jmeter/trunk/src/components/org/apache/jmeter/visualizers/RenderAsText.java Tue Dec  1 01:51:15 2009
@@ -0,0 +1,46 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed  under the  License is distributed on an "AS IS" BASIS,
+ * WITHOUT  WARRANTIES OR CONDITIONS  OF ANY KIND, either  express  or
+ * implied.
+ *
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.jmeter.visualizers;
+
+import org.apache.jmeter.samplers.SampleResult;
+import org.apache.jmeter.util.JMeterUtils;
+
+public class RenderAsText extends SamplerResultTab implements ResultRenderer {
+
+    /** {@inheritDoc} */
+    public void renderResult(SampleResult sampleResult) {
+        String response = ViewResultsFullVisualizer.getResponseAsString(sampleResult);
+        showTextResponse(response);
+    }
+
+    private void showTextResponse(String response) {
+        results.setContentType("text/plain"); // $NON-NLS-1$
+        results.setText(response == null ? "" : response); // $NON-NLS-1$
+        results.setCaretPosition(0);
+        resultsScrollPane.setViewportView(results);
+    }
+
+    /** {@inheritDoc} */
+    @Override
+    public String toString() {
+        return JMeterUtils.getResString("view_results_render_text");
+    }
+
+}

Propchange: jakarta/jmeter/trunk/src/components/org/apache/jmeter/visualizers/RenderAsText.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: jakarta/jmeter/trunk/src/components/org/apache/jmeter/visualizers/RenderAsText.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Added: jakarta/jmeter/trunk/src/components/org/apache/jmeter/visualizers/RenderAsXML.java
URL: http://svn.apache.org/viewvc/jakarta/jmeter/trunk/src/components/org/apache/jmeter/visualizers/RenderAsXML.java?rev=885648&view=auto
==============================================================================
--- jakarta/jmeter/trunk/src/components/org/apache/jmeter/visualizers/RenderAsXML.java (added)
+++ jakarta/jmeter/trunk/src/components/org/apache/jmeter/visualizers/RenderAsXML.java Tue Dec  1 01:51:15 2009
@@ -0,0 +1,222 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed  under the  License is distributed on an "AS IS" BASIS,
+ * WITHOUT  WARRANTIES OR CONDITIONS  OF ANY KIND, either  express  or
+ * implied.
+ *
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.jmeter.visualizers;
+
+import java.awt.Component;
+import java.awt.GridLayout;
+import java.io.ByteArrayInputStream;
+import java.io.StringWriter;
+
+import javax.swing.JOptionPane;
+import javax.swing.JPanel;
+import javax.swing.JScrollPane;
+import javax.swing.JTree;
+import javax.swing.ToolTipManager;
+import javax.swing.tree.DefaultMutableTreeNode;
+import javax.swing.tree.DefaultTreeCellRenderer;
+import javax.swing.tree.TreeSelectionModel;
+
+import org.apache.jmeter.samplers.SampleResult;
+import org.apache.jmeter.util.JMeterUtils;
+import org.apache.jmeter.util.XPathUtil;
+import org.apache.jorphan.logging.LoggingManager;
+import org.apache.jorphan.util.JOrphanUtils;
+import org.apache.log.Logger;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+import org.w3c.tidy.Tidy;
+import org.xml.sax.SAXException;
+
+public class RenderAsXML extends SamplerResultTab
+    implements ResultRenderer {
+
+    private static final Logger log = LoggingManager.getLoggerForClass();
+
+    private static final byte[] XML_PFX = "<?xml ".getBytes(); // $NON-NLS-1$
+
+    public RenderAsXML(){
+        activateSearchExtension = false; // TODO work out how to search the XML pane
+    }
+
+    /** {@inheritDoc} */
+    public void renderResult(SampleResult sampleResult) {
+        showRenderXMLResponse(sampleResult);
+    }
+
+    private void showRenderXMLResponse(SampleResult res) {
+        results.setContentType("text/xml"); // $NON-NLS-1$
+        results.setCaretPosition(0);
+        byte[] source = res.getResponseData();
+        final ByteArrayInputStream baIS = new ByteArrayInputStream(source);
+        for(int i=0; i<source.length-XML_PFX.length; i++){
+            if (JOrphanUtils.startsWith(source, XML_PFX, i)){
+                baIS.skip(i);// Skip the leading bytes (if any)
+                break;
+            }
+        }
+
+        // there is also a javax.swing.text.Document class.
+        org.w3c.dom.Document document = null;
+
+        StringWriter sw = new StringWriter();
+        Tidy tidy = XPathUtil.makeTidyParser(true, true, true, sw);
+        document = tidy.parseDOM(baIS, null);
+        document.normalize();
+        if (tidy.getParseErrors() > 0) {
+            showErrorMessageDialog(sw.toString(),
+                    "Tidy: " + tidy.getParseErrors() + " errors, " + tidy.getParseWarnings() + " warnings",
+                    JOptionPane.WARNING_MESSAGE);
+        }
+
+        JPanel domTreePanel = new DOMTreePanel(document);
+        resultsScrollPane.setViewportView(domTreePanel);
+    }
+
+    /**
+     *
+     * A Dom tree panel for to display response as tree view author <a
+     * href="mailto:d.maung@mdl.com">Dave Maung</a> TODO implement to find any
+     * nodes in the tree using TreePath.
+     *
+     */
+    private static class DOMTreePanel extends JPanel {
+
+        private static final long serialVersionUID = 6871690021183779153L;
+
+        private JTree domJTree;
+
+        public DOMTreePanel(org.w3c.dom.Document document) {
+            super(new GridLayout(1, 0));
+            try {
+                Node firstElement = getFirstElement(document);
+                DefaultMutableTreeNode top = new XMLDefaultMutableTreeNode(firstElement);
+                domJTree = new JTree(top);
+
+                domJTree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
+                domJTree.setShowsRootHandles(true);
+                JScrollPane domJScrollPane = new JScrollPane(domJTree);
+                domJTree.setAutoscrolls(true);
+                this.add(domJScrollPane);
+                ToolTipManager.sharedInstance().registerComponent(domJTree);
+                domJTree.setCellRenderer(new DomTreeRenderer());
+            } catch (SAXException e) {
+                log.warn("", e);
+            }
+
+        }
+
+        /**
+         * Skip all DTD nodes, all prolog nodes. They dont support in tree view
+         * We let user to insert them however in DOMTreeView, we dont display it
+         *
+         * @param root
+         * @return
+         */
+        private Node getFirstElement(Node parent) {
+            NodeList childNodes = parent.getChildNodes();
+            Node toReturn = parent; // Must return a valid node, or may generate an NPE
+            for (int i = 0; i < childNodes.getLength(); i++) {
+                Node childNode = childNodes.item(i);
+                toReturn = childNode;
+                if (childNode.getNodeType() == Node.ELEMENT_NODE){
+                    break;
+                }
+
+            }
+            return toReturn;
+        }
+
+        /**
+         * This class is to view as tooltext. This is very useful, when the
+         * contents has long string and does not fit in the view. it will also
+         * automatically wrap line for each 100 characters since tool tip
+         * support html. author <a href="mailto:d.maung@mdl.com">Dave Maung</a>
+         */
+        private static class DomTreeRenderer extends DefaultTreeCellRenderer {
+
+            private static final long serialVersionUID = 240210061375790195L;
+
+            @Override
+            public Component getTreeCellRendererComponent(JTree tree, Object value, boolean sel, boolean expanded,
+                    boolean leaf, int row, boolean phasFocus) {
+                super.getTreeCellRendererComponent(tree, value, sel, expanded, leaf, row, phasFocus);
+
+                DefaultMutableTreeNode valueTreeNode = (DefaultMutableTreeNode) value;
+                setToolTipText(getHTML(valueTreeNode.toString(), "<br>", 100)); // $NON-NLS-1$
+                return this;
+            }
+
+            /**
+             * get the html
+             *
+             * @param str
+             * @param separator
+             * @param maxChar
+             * @return
+             */
+            private String getHTML(String str, String separator, int maxChar) {
+                StringBuffer strBuf = new StringBuffer("<html><body bgcolor=\"yellow\"><b>"); // $NON-NLS-1$
+                char[] chars = str.toCharArray();
+                for (int i = 0; i < chars.length; i++) {
+
+                    if (i % maxChar == 0 && i != 0) {
+                        strBuf.append(separator);
+                    }
+                    strBuf.append(encode(chars[i]));
+
+                }
+                strBuf.append("</b></body></html>"); // $NON-NLS-1$
+                return strBuf.toString();
+
+            }
+
+            private String encode(char c) {
+                String toReturn = String.valueOf(c);
+                switch (c) {
+                case '<': // $NON-NLS-1$
+                    toReturn = "&lt;"; // $NON-NLS-1$
+                    break;
+                case '>': // $NON-NLS-1$
+                    toReturn = "&gt;"; // $NON-NLS-1$
+                    break;
+                case '\'': // $NON-NLS-1$
+                    toReturn = "&apos;"; // $NON-NLS-1$
+                    break;
+                case '\"': // $NON-NLS-1$
+                    toReturn = "&quot;"; // $NON-NLS-1$
+                    break;
+
+                }
+                return toReturn;
+            }
+        }
+    }
+
+    private static void showErrorMessageDialog(String message, String title, int messageType) {
+        JOptionPane.showMessageDialog(null, message, title, messageType);
+    }
+
+    /** {@inheritDoc} */
+    @Override
+    public String toString() {
+        return JMeterUtils.getResString("view_results_render_xml");
+    }
+
+}

Propchange: jakarta/jmeter/trunk/src/components/org/apache/jmeter/visualizers/RenderAsXML.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: jakarta/jmeter/trunk/src/components/org/apache/jmeter/visualizers/RenderAsXML.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Added: jakarta/jmeter/trunk/src/components/org/apache/jmeter/visualizers/ResultRenderer.java
URL: http://svn.apache.org/viewvc/jakarta/jmeter/trunk/src/components/org/apache/jmeter/visualizers/ResultRenderer.java?rev=885648&view=auto
==============================================================================
--- jakarta/jmeter/trunk/src/components/org/apache/jmeter/visualizers/ResultRenderer.java (added)
+++ jakarta/jmeter/trunk/src/components/org/apache/jmeter/visualizers/ResultRenderer.java Tue Dec  1 01:51:15 2009
@@ -0,0 +1,61 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed  under the  License is distributed on an "AS IS" BASIS,
+ * WITHOUT  WARRANTIES OR CONDITIONS  OF ANY KIND, either  express  or
+ * implied.
+ *
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ *
+ */
+package org.apache.jmeter.visualizers;
+
+import java.awt.Color;
+
+import javax.swing.JTabbedPane;
+
+import org.apache.jmeter.samplers.SampleResult;
+
+
+/**
+ * Interface to results render
+ */
+public interface ResultRenderer {
+
+    public void clearData();
+
+    public void init();
+
+    public void setupTabPane();
+
+    public void setLastSelectedTab(int index);
+
+    public void setRightSide(JTabbedPane rightSide);
+
+    public void setSamplerResult(Object userObject);
+
+    public void renderResult(SampleResult sampleResult);
+
+    public void renderImage(SampleResult sampleResult);
+
+    /**
+     *
+     * @return the string to be displayed by the ComboBox
+     */
+    public String toString();
+
+    public void setBackgroundColor(Color backGround);
+
+}

Propchange: jakarta/jmeter/trunk/src/components/org/apache/jmeter/visualizers/ResultRenderer.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: jakarta/jmeter/trunk/src/components/org/apache/jmeter/visualizers/ResultRenderer.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Added: jakarta/jmeter/trunk/src/components/org/apache/jmeter/visualizers/SamplerResultTab.java
URL: http://svn.apache.org/viewvc/jakarta/jmeter/trunk/src/components/org/apache/jmeter/visualizers/SamplerResultTab.java?rev=885648&view=auto
==============================================================================
--- jakarta/jmeter/trunk/src/components/org/apache/jmeter/visualizers/SamplerResultTab.java (added)
+++ jakarta/jmeter/trunk/src/components/org/apache/jmeter/visualizers/SamplerResultTab.java Tue Dec  1 01:51:15 2009
@@ -0,0 +1,345 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed  under the  License is distributed on an "AS IS" BASIS,
+ * WITHOUT  WARRANTIES OR CONDITIONS  OF ANY KIND, either  express  or
+ * implied.
+ *
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.jmeter.visualizers;
+
+import java.awt.BorderLayout;
+import java.awt.Color;
+import java.awt.Component;
+import java.text.DateFormat;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+
+import javax.swing.BorderFactory;
+import javax.swing.Icon;
+import javax.swing.ImageIcon;
+import javax.swing.JEditorPane;
+import javax.swing.JLabel;
+import javax.swing.JPanel;
+import javax.swing.JScrollPane;
+import javax.swing.JTabbedPane;
+import javax.swing.JTextArea;
+import javax.swing.JTextPane;
+import javax.swing.text.BadLocationException;
+import javax.swing.text.Style;
+import javax.swing.text.StyleConstants;
+import javax.swing.text.StyledDocument;
+
+import org.apache.jmeter.assertions.AssertionResult;
+import org.apache.jmeter.samplers.SampleResult;
+import org.apache.jmeter.util.JMeterUtils;
+import org.apache.jorphan.gui.GuiUtils;
+import org.apache.jorphan.logging.LoggingManager;
+import org.apache.log.Logger;
+
+public abstract class SamplerResultTab implements ResultRenderer {
+
+    private static final Logger log = LoggingManager.getLoggerForClass();
+
+    // N.B. these are not multi-threaded, so don't make it static
+    private final DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss z"); // ISO format $NON-NLS-1$
+
+    private static final String NL = "\n"; // $NON-NLS-1$
+
+    public static final Color SERVER_ERROR_COLOR = Color.red;
+
+    public static final Color CLIENT_ERROR_COLOR = Color.blue;
+
+    public static final Color REDIRECT_COLOR = Color.green;
+
+    protected static final String TEXT_COMMAND = "text"; // $NON-NLS-1$
+
+    private static final String STYLE_SERVER_ERROR = "ServerError"; // $NON-NLS-1$
+
+    private static final String STYLE_CLIENT_ERROR = "ClientError"; // $NON-NLS-1$
+
+    private static final String STYLE_REDIRECT = "Redirect"; // $NON-NLS-1$
+
+    protected JEditorPane results;
+
+    private JTextPane stats;
+
+    protected JScrollPane resultsScrollPane;
+
+    private JPanel resultsPane;
+
+    private JLabel imageLabel;
+
+    private JPanel requestPane;
+
+    private JTextArea sampleDataField;
+
+    protected JTabbedPane rightSide;
+
+    private int lastSelectedTab;
+
+    private Object userObject = null; // Could be SampleResult or AssertionResult
+
+    private SampleResult sampleResult = null;
+
+    private AssertionResult assertionResult = null;
+
+    protected SearchTextExtension searchTextExtension;
+
+    private JPanel searchPanel = null;
+
+    protected boolean activateSearchExtension = true; // most current subclasses can process text
+
+    private Color backGround;
+
+    public void clearData() {
+        results.setText("");// Response Data // $NON-NLS-1$
+        sampleDataField.setText("");// Request Data // $NON-NLS-1$
+    }
+
+    public void init() {
+        rightSide.addTab(JMeterUtils.getResString("view_results_tab_sampler"), createResponseMetadataPanel()); // $NON-NLS-1$
+        // Create the panels for the other tabs
+        requestPane = createRequestPanel();
+        resultsPane = createResponseDataPanel();
+    }
+
+    public void setupTabPane() {
+        StyledDocument statsDoc = stats.getStyledDocument();
+        try {
+            statsDoc.remove(0, statsDoc.getLength());
+            sampleDataField.setText(""); // $NON-NLS-1$
+            results.setText(""); // $NON-NLS-1$
+            if (userObject instanceof SampleResult) {
+                sampleResult = (SampleResult) userObject;
+                // We are displaying a SampleResult
+                setupTabPaneForSampleResult();
+
+                // load time label
+                log.debug("valueChanged1 : load time - " + sampleResult.getTime());
+                String sd = sampleResult.getSamplerData();
+                if (sd != null) {
+                    String rh = sampleResult.getRequestHeaders();
+                    if (rh != null) {
+                        StringBuffer sb = new StringBuffer(sd.length() + rh.length() + 20);
+                        sb.append(sd);
+                        sb.append("\n"); //$NON-NLS-1$
+                        sb.append(JMeterUtils.getResString("view_results_request_headers")); //$NON-NLS-1$
+                        sb.append("\n"); //$NON-NLS-1$
+                        sb.append(rh);
+                        sd = sb.toString();
+                    }
+                    sampleDataField.setText(sd);
+                }
+
+                StringBuffer statsBuff = new StringBuffer(200);
+                statsBuff.append(JMeterUtils.getResString("view_results_thread_name")).append(sampleResult.getThreadName()).append(NL); //$NON-NLS-1$
+                String startTime = dateFormat.format(new Date(sampleResult.getStartTime()));
+                statsBuff.append(JMeterUtils.getResString("view_results_sample_start")).append(startTime).append(NL); //$NON-NLS-1$
+                statsBuff.append(JMeterUtils.getResString("view_results_load_time")).append(sampleResult.getTime()).append(NL); //$NON-NLS-1$
+                statsBuff.append(JMeterUtils.getResString("view_results_latency")).append(sampleResult.getLatency()).append(NL); //$NON-NLS-1$
+                statsBuff.append(JMeterUtils.getResString("view_results_size_in_bytes")).append(sampleResult.getBytes()).append(NL); //$NON-NLS-1$
+                statsBuff.append(JMeterUtils.getResString("view_results_sample_count")).append(sampleResult.getSampleCount()).append(NL); //$NON-NLS-1$
+                statsBuff.append(JMeterUtils.getResString("view_results_error_count")).append(sampleResult.getErrorCount()).append(NL); //$NON-NLS-1$
+                statsDoc.insertString(statsDoc.getLength(), statsBuff.toString(), null);
+                statsBuff = new StringBuffer(); // reset for reuse
+
+                String responseCode = sampleResult.getResponseCode();
+                log.debug("valueChanged1 : response code - " + responseCode);
+
+                int responseLevel = 0;
+                if (responseCode != null) {
+                    try {
+                        responseLevel = Integer.parseInt(responseCode) / 100;
+                    } catch (NumberFormatException numberFormatException) {
+                        // no need to change the foreground color
+                    }
+                }
+
+                Style style = null;
+                switch (responseLevel) {
+                case 3:
+                    style = statsDoc.getStyle(STYLE_REDIRECT);
+                    break;
+                case 4:
+                    style = statsDoc.getStyle(STYLE_CLIENT_ERROR);
+                    break;
+                case 5:
+                    style = statsDoc.getStyle(STYLE_SERVER_ERROR);
+                    break;
+                }
+
+                statsBuff.append(JMeterUtils.getResString("view_results_response_code")).append(responseCode).append(NL); //$NON-NLS-1$
+                statsDoc.insertString(statsDoc.getLength(), statsBuff.toString(), style);
+                statsBuff = new StringBuffer(100); // reset for reuse
+
+                // response message label
+                String responseMsgStr = sampleResult.getResponseMessage();
+
+                log.debug("valueChanged1 : response message - " + responseMsgStr);
+                statsBuff.append(JMeterUtils.getResString("view_results_response_message")).append(responseMsgStr).append(NL); //$NON-NLS-1$
+
+                statsBuff.append(NL);
+                statsBuff.append(JMeterUtils.getResString("view_results_response_headers")).append(NL); //$NON-NLS-1$
+                statsBuff.append(sampleResult.getResponseHeaders()).append(NL);
+                statsBuff.append(NL);
+                final String samplerClass = sampleResult.getClass().getName();
+                statsBuff.append(samplerClass.substring(1 + samplerClass.lastIndexOf('.'))).append(" "+ JMeterUtils.getResString("view_results_fields")).append(NL); //$NON-NLS-1$
+                statsBuff.append("ContentType: ").append(sampleResult.getContentType()).append(NL);
+                statsBuff.append("DataEncoding: ").append(sampleResult.getDataEncodingNoDefault()).append(NL);
+                statsDoc.insertString(statsDoc.getLength(), statsBuff.toString(), null);
+                statsBuff = null; // Done
+
+                // Reset search
+                if (activateSearchExtension) {
+                    searchTextExtension.resetTextToFind();
+                }
+
+            } else if (userObject instanceof AssertionResult) {
+                assertionResult = (AssertionResult) userObject;
+
+                // We are displaying an AssertionResult
+                setupTabPaneForAssertionResult();
+
+                if (log.isDebugEnabled()) {
+                    log.debug("valueChanged1 : sample result - " + assertionResult);
+                }
+
+                StringBuffer statsBuff = new StringBuffer(100);
+                statsBuff.append(JMeterUtils.getResString("view_results_assertion_error")).append(assertionResult.isError()).append(NL); //$NON-NLS-1$
+                statsBuff.append(JMeterUtils.getResString("view_results_assertion_failure")).append(assertionResult.isFailure()).append(NL); //$NON-NLS-1$
+                statsBuff.append(JMeterUtils.getResString("view_results_assertion_failure_message")).append(assertionResult.getFailureMessage()).append(NL); //$NON-NLS-1$
+                statsDoc.insertString(statsDoc.getLength(), statsBuff.toString(), null);
+                statsBuff = null;
+            }
+        } catch (BadLocationException exc) {
+            log.error("Error setting statistics text", exc);
+            stats.setText("");
+        }
+    }
+
+    private void setupTabPaneForSampleResult() {
+        // Set the title for the first tab
+        rightSide.setTitleAt(0, JMeterUtils.getResString("view_results_tab_sampler")); //$NON-NLS-1$
+        // Add the other tabs if not present
+        if(rightSide.indexOfTab(JMeterUtils.getResString("view_results_tab_request")) < 0) { // $NON-NLS-1$
+            rightSide.addTab(JMeterUtils.getResString("view_results_tab_request"), requestPane); // $NON-NLS-1$
+        }
+        if(rightSide.indexOfTab(JMeterUtils.getResString("view_results_tab_response")) < 0) { // $NON-NLS-1$
+            rightSide.addTab(JMeterUtils.getResString("view_results_tab_response"), resultsPane); // $NON-NLS-1$
+        }
+        // restore last selected tab
+        if (lastSelectedTab < rightSide.getTabCount()) {
+            rightSide.setSelectedIndex(lastSelectedTab);
+        }
+    }
+
+    private void setupTabPaneForAssertionResult() {
+        // Set the title for the first tab
+        rightSide.setTitleAt(0, JMeterUtils.getResString("view_results_tab_assertion")); //$NON-NLS-1$
+        // Remove the other tabs if present
+        int requestTabIndex = rightSide.indexOfTab(JMeterUtils.getResString("view_results_tab_request")); // $NON-NLS-1$
+        if(requestTabIndex >= 0) {
+            rightSide.removeTabAt(requestTabIndex);
+        }
+        int responseTabIndex = rightSide.indexOfTab(JMeterUtils.getResString("view_results_tab_response")); // $NON-NLS-1$
+        if(responseTabIndex >= 0) {
+            rightSide.removeTabAt(responseTabIndex);
+        }
+    }
+
+    private Component createResponseMetadataPanel() {
+        stats = new JTextPane();
+        stats.setEditable(false);
+        stats.setBackground(backGround);
+
+        // Add styles to use for different types of status messages
+        StyledDocument doc = (StyledDocument) stats.getDocument();
+
+        Style style = doc.addStyle(STYLE_REDIRECT, null);
+        StyleConstants.setForeground(style, REDIRECT_COLOR);
+
+        style = doc.addStyle(STYLE_CLIENT_ERROR, null);
+        StyleConstants.setForeground(style, CLIENT_ERROR_COLOR);
+
+        style = doc.addStyle(STYLE_SERVER_ERROR, null);
+        StyleConstants.setForeground(style, SERVER_ERROR_COLOR);
+
+        JScrollPane pane = GuiUtils.makeScrollPane(stats);
+        pane.setBorder(BorderFactory.createEmptyBorder(2, 2, 2, 2));
+        return pane;
+    }
+
+    private JPanel createRequestPanel() {
+        sampleDataField = new JTextArea();
+        sampleDataField.setEditable(false);
+        sampleDataField.setLineWrap(true);
+        sampleDataField.setWrapStyleWord(true);
+
+        JPanel pane = new JPanel(new BorderLayout(0, 5));
+        pane.add(GuiUtils.makeScrollPane(sampleDataField));
+        return pane;
+    }
+
+    private JPanel createResponseDataPanel() {
+        results = new JEditorPane();
+        results.setEditable(false);
+
+        resultsScrollPane = GuiUtils.makeScrollPane(results);
+        imageLabel = new JLabel();
+
+        JPanel panel = new JPanel(new BorderLayout());
+        panel.add(resultsScrollPane, BorderLayout.CENTER);
+
+        if (activateSearchExtension) {
+            // Add search text extension
+            searchTextExtension = new SearchTextExtension();
+            searchTextExtension.init(panel);
+            searchPanel = searchTextExtension.createSearchTextExtensionPane();
+            searchTextExtension.setResults(results);
+            searchPanel.setVisible(true);
+            panel.add(searchPanel, BorderLayout.PAGE_END);
+        }
+
+        return panel;
+    }
+
+    private void showImage(Icon image) {
+        imageLabel.setIcon(image);
+        resultsScrollPane.setViewportView(imageLabel);
+    }
+
+    public synchronized void setSamplerResult(Object sample) {
+        userObject = sample;
+    }
+
+    public synchronized void setRightSide(JTabbedPane side) {
+        rightSide = side;
+    }
+
+    public void setLastSelectedTab(int index) {
+        lastSelectedTab = index;
+    }
+
+    public void renderImage(SampleResult sampleResult) {
+        byte[] responseBytes = sampleResult.getResponseData();
+        if (responseBytes != null) {
+            showImage(new ImageIcon(responseBytes)); //TODO implement other non-text types
+        }
+    }
+
+    public void setBackgroundColor(Color backGround){
+        this.backGround = backGround;
+    }
+}
\ No newline at end of file

Propchange: jakarta/jmeter/trunk/src/components/org/apache/jmeter/visualizers/SamplerResultTab.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: jakarta/jmeter/trunk/src/components/org/apache/jmeter/visualizers/SamplerResultTab.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Modified: jakarta/jmeter/trunk/src/components/org/apache/jmeter/visualizers/SearchTextExtension.java
URL: http://svn.apache.org/viewvc/jakarta/jmeter/trunk/src/components/org/apache/jmeter/visualizers/SearchTextExtension.java?rev=885648&r1=885647&r2=885648&view=diff
==============================================================================
--- jakarta/jmeter/trunk/src/components/org/apache/jmeter/visualizers/SearchTextExtension.java (original)
+++ jakarta/jmeter/trunk/src/components/org/apache/jmeter/visualizers/SearchTextExtension.java Tue Dec  1 01:51:15 2009
@@ -1,18 +1,18 @@
-/* 
+/*
  * Licensed to the Apache Software Foundation (ASF) under one or more
  * contributor license agreements.  See the NOTICE file distributed with
  * this work for additional information regarding copyright ownership.
  * The ASF licenses this file to You under the Apache License, Version 2.0
  * (the "License"); you may not use this file except in compliance with
  * the License.  You may obtain a copy of the License at
- * 
+ *
  *   http://www.apache.org/licenses/LICENSE-2.0
- * 
+ *
  * Unless required by applicable law or agreed to in writing, software
  * distributed  under the  License is distributed on an "AS IS" BASIS,
  * WITHOUT  WARRANTIES OR CONDITIONS  OF ANY KIND, either  express  or
  * implied.
- * 
+ *
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
@@ -24,8 +24,6 @@
 import java.awt.Font;
 import java.awt.event.ActionEvent;
 import java.awt.event.ActionListener;
-import java.awt.event.InputEvent;
-import java.awt.event.KeyEvent;
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
 
@@ -56,30 +54,21 @@
 import org.apache.log.Logger;
 
 public class SearchTextExtension implements ActionListener, DocumentListener {
-    
+
     private static final Logger log = LoggingManager.getLoggerForClass();
-    
-    public static final String SEARCH_TEXT_COMMAND = "search_text"; // $NON-NLS-1$
-    
-    public static final String DIALOG_SEARCH_SHOW_COMMAND = "show_search_dialog"; // $NON-NLS-1$
-    
-    public static final String DIALOG_SEARCH_HIDE_COMMAND = "close_search_dialog"; // $NON-NLS-1$
-
-    private static final String SEARCH_SHOW_COMMAND = "show_search_text"; // $NON-NLS-1$
-
-    // set default command to Text
-    private String command = DIALOG_SEARCH_SHOW_COMMAND;
-    
+
+    private static final String SEARCH_TEXT_COMMAND = "search_text"; // $NON-NLS-1$
+
     private static int LAST_POSITION_DEFAULT = 0;
 
     private int lastPosition = LAST_POSITION_DEFAULT;
-    
+
     private final static Color HILIT_COLOR = Color.LIGHT_GRAY;
-    
+
     private Highlighter selection;
-    
+
     private Highlighter.HighlightPainter painter;
-    
+
     private JLabel label;
 
     private JButton findButton;
@@ -93,26 +82,15 @@
     private String lastTextTofind;
 
     private boolean newSearch = false;
-    
+
     private JEditorPane results;
-    
+
     private JPanel searchPanel;
 
-    private boolean enabled = true;
-    
-    private JCheckBox showSearch;
 
-    
     public void init(JPanel resultsPane) {
-        // when CTRL-T is pressed, (un-)show search dialog box (only in results pane)
-        InputMap im = resultsPane
-                .getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW);
-        im.put(KeyStroke.getKeyStroke(KeyEvent.VK_T, 
-                InputEvent.CTRL_MASK), SEARCH_SHOW_COMMAND);
-        ActionMap am = resultsPane.getActionMap();
-        am.put(SEARCH_SHOW_COMMAND, new DisplaySearchAction());
     }
-    
+
     public void setResults(JEditorPane results) {
         if (this.results != null) {
             newSearch = true;
@@ -128,10 +106,10 @@
     /**
      * Launch find text engine on response text
      */
-    public void executeAndShowTextFind() {
+    private void executeAndShowTextFind() {
+        String textToFind = textToFindField.getText();
         if (results != null && results.getText().length() > 0
-                && this.textToFindField.getText().length() > 0) {
-            String textToFind = textToFindField.getText();
+                && textToFind.length() > 0) {
 
             // new search?
             if (lastTextTofind != null && !lastTextTofind.equals(textToFind)) {
@@ -153,7 +131,7 @@
                     selection.removeAllHighlights();
                     selection.addHighlight(lastPosition + matcher.start(),
                             lastPosition + matcher.end(), painter);
-                    results.setCaretPosition(lastPosition + matcher.end());                    
+                    results.setCaretPosition(lastPosition + matcher.end());
 
                     // save search position
                     lastPosition = lastPosition + matcher.end();
@@ -180,12 +158,12 @@
 
     /**
      * Create the text find task pane
-     * 
+     *
      * @return Text find task pane
      */
-    public JPanel createSearchTextPanel() {
+    private JPanel createSearchTextPanel() {
         Font font = new Font("SansSerif", Font.PLAIN, 10);
-        
+
         // Search field
         searchPanel = new JPanel();
         searchPanel.setLayout(new BoxLayout(searchPanel, BoxLayout.X_AXIS));
@@ -224,34 +202,18 @@
         im.put(KeyStroke.getKeyStroke("ENTER"), SEARCH_TEXT_COMMAND);
         ActionMap am = textToFindField.getActionMap();
         am.put(SEARCH_TEXT_COMMAND, new EnterAction());
-        
+
+        // default not visible
+        searchPanel.setVisible(true);
         return searchPanel;
     }
-    
-    public JPanel createSearchTextExtensionPane() {
+
+    JPanel createSearchTextExtensionPane() {
         JPanel pane = new JPanel();
         pane.setLayout(new BoxLayout(pane, BoxLayout.X_AXIS));
-        pane.add(createShowSearchPanel());
         pane.add(createSearchTextPanel());
         return pane;
     }
-    
-    public JPanel createShowSearchPanel() {
-        Font fontBold = new Font("SansSerif", Font.BOLD, 10);
-
-        showSearch = new JCheckBox();
-        showSearch.setFont(fontBold);
-        showSearch.setAction(new DisplaySearchAction());
-        showSearch.setText(JMeterUtils
-                .getResString("view_results_search_pane")); // $NON-NLS-1$
-        
-        JPanel pane = new JPanel();
-        pane.setLayout(new BoxLayout(pane, BoxLayout.X_AXIS));
-        pane.add(showSearch);
-        
-        return pane;
-    }
-
 
     /**
      * Display the response as text or as rendered HTML. Change the text on the
@@ -261,18 +223,12 @@
      *            the ActionEvent being processed
      */
     public void actionPerformed(ActionEvent e) {
-        command = e.getActionCommand();
+        String command = e.getActionCommand();
 
         // Search text in response data
-        if (command != null 
-                && (command.equals(SearchTextExtension.SEARCH_TEXT_COMMAND))) {
+        if (SEARCH_TEXT_COMMAND.equals(command)) {
             executeAndShowTextFind();
         }
-        // hide search dialog box
-        else if (command != null && command.equals(
-                SearchTextExtension.DIALOG_SEARCH_HIDE_COMMAND)) {
-            hideSearchBox();
-        }
     }
 
     private class EnterAction extends AbstractAction {
@@ -282,22 +238,6 @@
         }
     }
 
-    private class DisplaySearchAction extends AbstractAction {
-        private static final long serialVersionUID = 1L;
-        public void actionPerformed(ActionEvent ev) {
-            if (searchPanel != null) {
-                resetTextToFind();
-                if (searchPanel.isVisible()) {
-                    searchPanel.setVisible(false);
-                    showSearch.setSelected(false);
-                } else {
-                    searchPanel.setVisible(true);
-                    showSearch.setSelected(true);
-                }
-            }
-        }
-    }
-    
     // DocumentListener method
     public void changedUpdate(DocumentEvent e) {
         // do nothing
@@ -313,11 +253,7 @@
         resetTextToFind();
     }
 
-    public void hideSearchBox() {
-        searchPanel.setVisible(false);
-    }
-    
-    public void resetTextToFind() {
+    void resetTextToFind() {
         if (newSearch) {
             log.debug("reset pass");
             // Reset search
@@ -330,22 +266,9 @@
             newSearch = false;
         }
     }
-    
-    public boolean isEnabled() {
-        return enabled ;
-    }
-    
-    public void setEnabled(boolean b) {
-        this.enabled = b;
-        label.setEnabled(b);
-        textToFindField.setEnabled(b);
-        findButton.setEnabled(b);
-        caseChkBox.setEnabled(b);
-        regexpChkBox.setEnabled(b);
-    }
-    
+
     private Pattern createPattern(String textToFind) {
-        // desactivate or not specials regexp char 
+        // desactivate or not specials regexp char
         String textToFindQ = Pattern.quote(textToFind);
         if (regexpChkBox.isSelected()) {
             textToFindQ = textToFind;



---------------------------------------------------------------------
To unsubscribe, e-mail: jmeter-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: jmeter-dev-help@jakarta.apache.org