View | Details | Raw Unified | Return to bug 51876
Collapse All | Expand All

(-)src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPSamplerBase.java (-1 / +26 lines)
Lines 45-50 Link Here
45
import org.apache.jmeter.config.Argument;
45
import org.apache.jmeter.config.Argument;
46
import org.apache.jmeter.config.Arguments;
46
import org.apache.jmeter.config.Arguments;
47
import org.apache.jmeter.engine.event.LoopIterationEvent;
47
import org.apache.jmeter.engine.event.LoopIterationEvent;
48
import org.apache.jmeter.gui.Searchable;
48
import org.apache.jmeter.protocol.http.control.AuthManager;
49
import org.apache.jmeter.protocol.http.control.AuthManager;
49
import org.apache.jmeter.protocol.http.control.CacheManager;
50
import org.apache.jmeter.protocol.http.control.CacheManager;
50
import org.apache.jmeter.protocol.http.control.CookieManager;
51
import org.apache.jmeter.protocol.http.control.CookieManager;
Lines 84-90 Link Here
84
 *
85
 *
85
 */
86
 */
86
public abstract class HTTPSamplerBase extends AbstractSampler
87
public abstract class HTTPSamplerBase extends AbstractSampler
87
    implements TestListener, ThreadListener, HTTPConstantsInterface {
88
    implements TestListener, ThreadListener, HTTPConstantsInterface, Searchable {
88
89
89
    private static final long serialVersionUID = 240L;
90
    private static final long serialVersionUID = 240L;
90
91
Lines 1708-1712 Link Here
1708
            return sample(url, method, areFollowingRedirect, depth);
1709
            return sample(url, method, areFollowingRedirect, depth);
1709
        }
1710
        }
1710
    }
1711
    }
1712
    
1713
    /**
1714
     * We search in URL and arguments
1715
     * TODO Can be enhanced
1716
     * {@inheritDoc}
1717
     */
1718
    public boolean searchContent(String textToSearch) throws Exception {
1719
        if(getUrl() != null && getUrl().toString().indexOf(textToSearch)>=0){
1720
            return true;
1721
        }
1722
        Arguments arguments = getArguments();
1723
        if(arguments != null) {
1724
            for (int i = 0; i < arguments.getArgumentCount(); i++) {
1725
                Argument argument = arguments.getArgument(i);
1726
                if(argument.getName().indexOf(textToSearch)>=0) {
1727
                    return true;
1728
                }
1729
                if(argument.getValue().indexOf(textToSearch)>=0) {
1730
                    return true;
1731
                }
1732
            }
1733
        }
1734
        return false;
1735
    }
1711
}
1736
}
1712
1737
(-)src/core/org/apache/jmeter/gui/action/ActionNames.java (+1 lines)
Lines 83-88 Link Here
83
    public static final String SUB_TREE_SAVED   = "sub_tree_saved"; // $NON-NLS-1$
83
    public static final String SUB_TREE_SAVED   = "sub_tree_saved"; // $NON-NLS-1$
84
    public static final String TOGGLE           = "toggle"; // $NON-NLS-1$ enable/disable
84
    public static final String TOGGLE           = "toggle"; // $NON-NLS-1$ enable/disable
85
    public static final String WHAT_CLASS       = "what_class"; // $NON-NLS-1$
85
    public static final String WHAT_CLASS       = "what_class"; // $NON-NLS-1$
86
    public static final String SEARCH_TREE      = "search_tree"; // $NON-NLS-1$
86
87
87
    // Prevent instantiation
88
    // Prevent instantiation
88
    private ActionNames(){
89
    private ActionNames(){
(-)src/core/org/apache/jmeter/gui/action/SearchTreeCommand.java (+88 lines)
Line 0 Link Here
1
/*
2
 * Licensed to the Apache Software Foundation (ASF) under one or more
3
 * contributor license agreements.  See the NOTICE file distributed with
4
 * this work for additional information regarding copyright ownership.
5
 * The ASF licenses this file to You under the Apache License, Version 2.0
6
 * (the "License"); you may not use this file except in compliance with
7
 * the License.  You may obtain a copy of the License at
8
 *
9
 *   http://www.apache.org/licenses/LICENSE-2.0
10
 *
11
 * Unless required by applicable law or agreed to in writing, software
12
 * distributed under the License is distributed on an "AS IS" BASIS,
13
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
 * See the License for the specific language governing permissions and
15
 * limitations under the License.
16
 *
17
 */
18
19
package org.apache.jmeter.gui.action;
20
21
import java.awt.event.ActionEvent;
22
import java.util.HashSet;
23
import java.util.Iterator;
24
import java.util.Set;
25
26
import javax.swing.JOptionPane;
27
28
import org.apache.jmeter.gui.GuiPackage;
29
import org.apache.jmeter.gui.Searchable;
30
import org.apache.jmeter.gui.tree.JMeterTreeModel;
31
import org.apache.jmeter.gui.tree.JMeterTreeNode;
32
import org.apache.jmeter.util.JMeterUtils;
33
34
/**
35
 * Search nodes for a text
36
 * TODO Enhance search dialog to select kind of nodes ....
37
 */
38
public class SearchTreeCommand extends AbstractAction {
39
    private static final Set<String> commands = new HashSet<String>();
40
41
    static {
42
        commands.add(ActionNames.SEARCH_TREE);
43
    }
44
45
    /**
46
     * @see Command#doAction(ActionEvent)
47
     */
48
    @Override
49
    public void doAction(ActionEvent e) {
50
        String wordToSearch = JOptionPane.showInputDialog(
51
                GuiPackage.getInstance().getMainFrame(),
52
                JMeterUtils.getResString("search_word"),  // $NON-NLS-1$
53
                JMeterUtils.getResString("search_tree_title"),  // $NON-NLS-1$
54
                JOptionPane.QUESTION_MESSAGE);
55
        GuiPackage guiPackage = GuiPackage.getInstance();
56
        JMeterTreeModel jMeterTreeModel = guiPackage.getTreeModel();
57
        Iterator<?> iter = jMeterTreeModel.getNodesOfType(Searchable.class).iterator();
58
        while (iter.hasNext()) {
59
            try {
60
                JMeterTreeNode jMeterTreeNode = (JMeterTreeNode) iter.next();
61
                if (jMeterTreeNode.getUserObject() instanceof Searchable){
62
                    Searchable searchable = (Searchable) jMeterTreeNode.getUserObject();
63
                    
64
                    boolean result = searchable.searchContent(wordToSearch);
65
                    if(result) {
66
                        jMeterTreeNode.setMarkedBySearch(true);
67
                    }
68
                    else {
69
                        jMeterTreeNode.setMarkedBySearch(false);   
70
                    }
71
                }
72
            } catch (Exception ex) {
73
                // FIXME Improve this
74
                ex.printStackTrace();
75
            }
76
        }
77
        GuiPackage.getInstance().getMainFrame().repaint();
78
    }
79
80
81
    /**
82
     * @see Command#getActionNames()
83
     */
84
    @Override
85
    public Set<String> getActionNames() {
86
        return commands;
87
    }
88
}
(-)src/core/org/apache/jmeter/gui/tree/JMeterCellRenderer.java (-4 / +15 lines)
Lines 18-25 Link Here
18
18
19
package org.apache.jmeter.gui.tree;
19
package org.apache.jmeter.gui.tree;
20
20
21
import java.awt.Color;
21
import java.awt.Component;
22
import java.awt.Component;
22
23
24
import javax.swing.BorderFactory;
23
import javax.swing.ImageIcon;
25
import javax.swing.ImageIcon;
24
import javax.swing.JTree;
26
import javax.swing.JTree;
25
import javax.swing.tree.DefaultTreeCellRenderer;
27
import javax.swing.tree.DefaultTreeCellRenderer;
Lines 36-45 Link Here
36
    @Override
38
    @Override
37
    public Component getTreeCellRendererComponent(JTree tree, Object value, boolean sel, boolean expanded,
39
    public Component getTreeCellRendererComponent(JTree tree, Object value, boolean sel, boolean expanded,
38
            boolean leaf, int row, boolean p_hasFocus) {
40
            boolean leaf, int row, boolean p_hasFocus) {
39
        super.getTreeCellRendererComponent(tree, ((JMeterTreeNode) value).getName(), sel, expanded, leaf, row,
41
        JMeterTreeNode node = (JMeterTreeNode) value;
42
        super.getTreeCellRendererComponent(tree, (node).getName(), sel, expanded, leaf, row,
40
                p_hasFocus);
43
                p_hasFocus);
41
        boolean enabled = ((JMeterTreeNode) value).isEnabled();
44
        boolean enabled = (node).isEnabled();
42
        ImageIcon ic = ((JMeterTreeNode) value).getIcon(enabled);
45
        ImageIcon ic = (node).getIcon(enabled);
43
        if (ic != null) {
46
        if (ic != null) {
44
            if (enabled) {
47
            if (enabled) {
45
                setIcon(ic);
48
                setIcon(ic);
Lines 51-63 Link Here
51
            {
54
            {
52
                // Must therefore set the enabled icon so there is at least some
55
                // Must therefore set the enabled icon so there is at least some
53
                // icon
56
                // icon
54
                ic = ((JMeterTreeNode) value).getIcon();
57
                ic = (node).getIcon();
55
                if (ic != null) {
58
                if (ic != null) {
56
                    setIcon(ic);
59
                    setIcon(ic);
57
                }
60
                }
58
            }
61
            }
59
        }
62
        }
60
        this.setEnabled(enabled);
63
        this.setEnabled(enabled);
64
        if(node.isMarkedBySearch())
65
        {
66
            setBorder(BorderFactory.createLineBorder(Color.red));
67
        }
68
        else
69
        {
70
            setBorder(null);
71
        }
61
        return this;
72
        return this;
62
    }
73
    }
63
}
74
}
(-)src/core/org/apache/jmeter/gui/Searchable.java (+19 lines)
Line 0 Link Here
1
/**
2
 * 
3
 */
4
package org.apache.jmeter.gui;
5
6
/**
7
 * Interface for nodes that are searchable
8
 */
9
public interface Searchable {
10
11
    /**
12
     * 
13
     * @param textToSearch
14
     * @return true if search was successful
15
     */
16
    boolean searchContent(String textToSearch)
17
        throws Exception ;
18
19
}
(-)src/core/org/apache/jmeter/gui/util/JMeterMenuBar.java (+3 lines)
Lines 309-314 Link Here
309
309
310
        JMenuItem expand = makeMenuItemRes("menu_expand_all", ActionNames.EXPAND_ALL, KeyStrokes.EXPAND_ALL); //$NON-NLS-1$
310
        JMenuItem expand = makeMenuItemRes("menu_expand_all", ActionNames.EXPAND_ALL, KeyStrokes.EXPAND_ALL); //$NON-NLS-1$
311
        optionsMenu.add(expand);
311
        optionsMenu.add(expand);
312
        
313
        JMenuItem search = makeMenuItemRes("menu_search", ActionNames.SEARCH_TREE); //$NON-NLS-1$
314
        optionsMenu.add(search);
312
    }
315
    }
313
316
314
    private static class LangMenuHelper{
317
    private static class LangMenuHelper{
(-)src/core/org/apache/jmeter/resources/messages.properties (+12 lines)
Lines 29-34 Link Here
29
add_user=Add User
29
add_user=Add User
30
add_value=Add Value
30
add_value=Add Value
31
addtest=Add test
31
addtest=Add test
32
menu_search=Search in Tree
33
search_tree=Search Tree
34
search_word=Word to search
35
search_tree_title=Search Tree
32
aggregate_graph=Statistical Graphs
36
aggregate_graph=Statistical Graphs
33
aggregate_graph_column=Column
37
aggregate_graph_column=Column
34
aggregate_graph_display=Display Graph
38
aggregate_graph_display=Display Graph
Lines 1030-1035 Link Here
1030
web_server_client=Client implementation:
1034
web_server_client=Client implementation:
1031
web_server_domain=Server Name or IP\:
1035
web_server_domain=Server Name or IP\:
1032
web_server_port=Port Number\:
1036
web_server_port=Port Number\:
1037
web_parameters_lost_message=Switching to RAW Post body will convert parameters\nto raw body and loose parameters table when you select \nanother node or save test plan, do you confirm ?
1038
web_cannot_convert_parameters_to_raw=Cannot convert parameters to RAW Post body \nbecause one of the parameters has a name
1039
web_cannot_switch_tab=You cannot switch because data cannot be converted\n to target Tab data, empty data to switch
1040
confirm=Confirm
1041
post_as_parameters=Parameters
1042
post_as_rawbody=RAW Body
1043
post_body_raw=Raw Post Body
1044
post_body=Post Body
1033
web_testing2_source_ip=Source IP address:
1045
web_testing2_source_ip=Source IP address:
1034
web_testing2_title=HTTP Request HTTPClient
1046
web_testing2_title=HTTP Request HTTPClient
1035
web_testing_concurrent_download=Use concurrent pool. Size:
1047
web_testing_concurrent_download=Use concurrent pool. Size:
(-)src/core/org/apache/jmeter/gui/tree/JMeterTreeNode.java (+21 lines)
Lines 45-50 Link Here
45
45
46
    private final JMeterTreeModel treeModel;
46
    private final JMeterTreeModel treeModel;
47
47
48
    private boolean markedBySearch;
49
48
    public JMeterTreeNode() {// Allow serializable test to work
50
    public JMeterTreeNode() {// Allow serializable test to work
49
        // TODO: is the serializable test necessary now that JMeterTreeNode is
51
        // TODO: is the serializable test necessary now that JMeterTreeNode is
50
        // no longer a GUI component?
52
        // no longer a GUI component?
Lines 64-69 Link Here
64
        getTestElement().setProperty(new BooleanProperty(TestElement.ENABLED, enabled));
66
        getTestElement().setProperty(new BooleanProperty(TestElement.ENABLED, enabled));
65
        treeModel.nodeChanged(this);
67
        treeModel.nodeChanged(this);
66
    }
68
    }
69
    
70
    /**
71
     * Tag Node as result of a search
72
     * @return
73
     */
74
    public void setMarkedBySearch(boolean tagged) {
75
        this.markedBySearch = tagged;
76
        treeModel.nodeChanged(this);
77
    }
78
    
79
    /**
80
     * Node is markedBySearch by a search
81
     * @return
82
     */
83
    public boolean isMarkedBySearch() {
84
        return this.markedBySearch;
85
    }
67
86
68
    public ImageIcon getIcon() {
87
    public ImageIcon getIcon() {
69
        return getIcon(true);
88
        return getIcon(true);
Lines 153-156 Link Here
153
    public Enumeration<JMeterTreeNode> children() {
172
    public Enumeration<JMeterTreeNode> children() {
154
        return super.children();
173
        return super.children();
155
    }
174
    }
175
176
156
}
177
}

Return to bug 51876