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

(-)src/components/org/apache/jmeter/control/IncludeController.java (+31 lines)
Lines 26-31 Link Here
26
import java.util.Iterator;
26
import java.util.Iterator;
27
import java.util.LinkedList;
27
import java.util.LinkedList;
28
28
29
import org.apache.jmeter.testelement.TestPlan;
30
import org.apache.jmeter.control.TestFragmentController;
31
29
import org.apache.jmeter.gui.tree.JMeterTreeNode;
32
import org.apache.jmeter.gui.tree.JMeterTreeNode;
30
import org.apache.jmeter.save.SaveService;
33
import org.apache.jmeter.save.SaveService;
31
import org.apache.jmeter.services.FileServer;
34
import org.apache.jmeter.services.FileServer;
Lines 105-110 Link Here
105
        return SUBTREE;
108
        return SUBTREE;
106
    }
109
    }
107
110
111
    public TestElement getReplacementElement() {
112
        return SUB;
113
    }
114
108
    public void resolveReplacementSubTree(JMeterTreeNode context) {
115
    public void resolveReplacementSubTree(JMeterTreeNode context) {
109
        this.SUBTREE = this.loadIncludedElements();
116
        this.SUBTREE = this.loadIncludedElements();
110
    }
117
    }
Lines 135-140 Link Here
135
                
142
                
136
                reader = new FileInputStream(file);
143
                reader = new FileInputStream(file);
137
                tree = SaveService.loadTree(reader);
144
                tree = SaveService.loadTree(reader);
145
                // filter the tree for a TestFragment.
146
                tree = getProperBranch(tree);
138
                removeDisabledItems(tree);
147
                removeDisabledItems(tree);
139
                return tree;
148
                return tree;
140
            } catch (NoClassDefFoundError ex) // Allow for missing optional jars
149
            } catch (NoClassDefFoundError ex) // Allow for missing optional jars
Lines 164-169 Link Here
164
        return tree;
173
        return tree;
165
    }
174
    }
166
175
176
    private HashTree getProperBranch(HashTree tree) {
177
        Iterator<Object> iter = new LinkedList<Object>(tree.list()).iterator();
178
        while (iter.hasNext()) {
179
            TestElement item = (TestElement) iter.next();
180
181
            //if we found a TestPlan, then we are on our way to the TestFragment
182
            if (item instanceof TestPlan)
183
            {
184
                return getProperBranch(tree.getTree(item));
185
            }
186
187
            if (item instanceof TestFragmentController)
188
            {
189
                return tree.getTree(item);
190
            }
191
        }
192
        //return the tree since we didn't find a TestFragment.  This will mimic the 
193
        //old behavior to import an exact node.
194
        return tree;
195
    }
196
197
167
    private void removeDisabledItems(HashTree tree) {
198
    private void removeDisabledItems(HashTree tree) {
168
        Iterator<Object> iter = new LinkedList<Object>(tree.list()).iterator();
199
        Iterator<Object> iter = new LinkedList<Object>(tree.list()).iterator();
169
        while (iter.hasNext()) {
200
        while (iter.hasNext()) {
(-)src/core/org/apache/jmeter/control/gui/TestPlanGui.java (+1 lines)
Lines 87-92 Link Here
87
        JPopupMenu pop = new JPopupMenu();
87
        JPopupMenu pop = new JPopupMenu();
88
        JMenu addMenu = new JMenu(JMeterUtils.getResString("add")); // $NON-NLS-1$
88
        JMenu addMenu = new JMenu(JMeterUtils.getResString("add")); // $NON-NLS-1$
89
        addMenu.add(MenuFactory.makeMenu(MenuFactory.THREADS, ActionNames.ADD));
89
        addMenu.add(MenuFactory.makeMenu(MenuFactory.THREADS, ActionNames.ADD));
90
        addMenu.add(MenuFactory.makeMenu(MenuFactory.FRAGMENTS, ActionNames.ADD));
90
        addMenu.add(MenuFactory.makeMenu(MenuFactory.CONFIG_ELEMENTS, ActionNames.ADD));
91
        addMenu.add(MenuFactory.makeMenu(MenuFactory.CONFIG_ELEMENTS, ActionNames.ADD));
91
        addMenu.add(MenuFactory.makeMenu(MenuFactory.TIMERS, ActionNames.ADD));
92
        addMenu.add(MenuFactory.makeMenu(MenuFactory.TIMERS, ActionNames.ADD));
92
        addMenu.add(MenuFactory.makeMenu(MenuFactory.PRE_PROCESSORS, ActionNames.ADD));
93
        addMenu.add(MenuFactory.makeMenu(MenuFactory.PRE_PROCESSORS, ActionNames.ADD));
(-)src/core/org/apache/jmeter/gui/util/MenuFactory.java (-2 / +17 lines)
Lines 67-72 Link Here
67
     *  and also for resource lookup in messages.properties
67
     *  and also for resource lookup in messages.properties
68
    */
68
    */
69
    public static final String THREADS = "menu_threads"; //$NON-NLS-1$
69
    public static final String THREADS = "menu_threads"; //$NON-NLS-1$
70
    
71
    public static final String FRAGMENTS = "menu_fragments"; //$NON-NLS-1$
70
72
71
    public static final String TIMERS = "menu_timer"; //$NON-NLS-1$
73
    public static final String TIMERS = "menu_timer"; //$NON-NLS-1$
72
74
Lines 119-130 Link Here
119
    private static final String[] MENU_PARENT_SAMPLER = new String[] {
121
    private static final String[] MENU_PARENT_SAMPLER = new String[] {
120
        MenuFactory.CONTROLLERS };
122
        MenuFactory.CONTROLLERS };
121
123
122
    private static final List<MenuInfo> timers, controllers, samplers, threads,
124
    private static final List<MenuInfo> timers, controllers, samplers, threads, 
123
        configElements, assertions, listeners, nonTestElements,
125
        fragments,configElements, assertions, listeners, nonTestElements,
124
        postProcessors, preProcessors;
126
        postProcessors, preProcessors;
125
127
126
    static {
128
    static {
127
        threads = new LinkedList<MenuInfo>();
129
        threads = new LinkedList<MenuInfo>();
130
        fragments = new LinkedList<MenuInfo>();
128
        timers = new LinkedList<MenuInfo>();
131
        timers = new LinkedList<MenuInfo>();
129
        controllers = new LinkedList<MenuInfo>();
132
        controllers = new LinkedList<MenuInfo>();
130
        samplers = new LinkedList<MenuInfo>();
133
        samplers = new LinkedList<MenuInfo>();
Lines 135-140 Link Here
135
        preProcessors = new LinkedList<MenuInfo>();
138
        preProcessors = new LinkedList<MenuInfo>();
136
        nonTestElements = new LinkedList<MenuInfo>();
139
        nonTestElements = new LinkedList<MenuInfo>();
137
        menuMap.put(THREADS, threads);
140
        menuMap.put(THREADS, threads);
141
        menuMap.put(FRAGMENTS, fragments);
138
        menuMap.put(TIMERS, timers);
142
        menuMap.put(TIMERS, timers);
139
        menuMap.put(ASSERTIONS, assertions);
143
        menuMap.put(ASSERTIONS, assertions);
140
        menuMap.put(CONFIG_ELEMENTS, configElements);
144
        menuMap.put(CONFIG_ELEMENTS, configElements);
Lines 465-470 Link Here
465
                if (categories.contains(THREADS)) {
469
                if (categories.contains(THREADS)) {
466
                    threads.add(new MenuInfo(item, name));
470
                    threads.add(new MenuInfo(item, name));
467
                }
471
                }
472
                if (categories.contains(FRAGMENTS)) {
473
                    fragments.add(new MenuInfo(item, name));
474
                }
468
                if (categories.contains(TIMERS)) {
475
                if (categories.contains(TIMERS)) {
469
                    timers.add(new MenuInfo(item, name));
476
                    timers.add(new MenuInfo(item, name));
470
                }
477
                }
Lines 549-554 Link Here
549
            return false;
556
            return false;
550
        }
557
        }
551
        TestElement parent = parentNode.getTestElement();
558
        TestElement parent = parentNode.getTestElement();
559
560
        // Force TestFragment to only be pastable under a Test Plan
561
        if (foundClass(nodes, new Class[]{org.apache.jmeter.control.TestFragmentController.class})){
562
            if (parent instanceof TestPlan)
563
                return true;
564
            return false;
565
        }
566
552
        if (parent instanceof WorkBench) {// allow everything else
567
        if (parent instanceof WorkBench) {// allow everything else
553
            return true;
568
            return true;
554
        }
569
        }
(-)src/core/org/apache/jmeter/resources/messages.properties (+2 lines)
Lines 488-493 Link Here
488
menu_expand_all=Expand All
488
menu_expand_all=Expand All
489
menu_generative_controller=Sampler
489
menu_generative_controller=Sampler
490
menu_threads=Threads (Users)
490
menu_threads=Threads (Users)
491
menu_fragments=Test Fragment
491
menu_listener=Listener
492
menu_listener=Listener
492
menu_logic_controller=Logic Controller
493
menu_logic_controller=Logic Controller
493
menu_merge=Merge
494
menu_merge=Merge
Lines 906-911 Link Here
906
textbox_tooltip_cell=Double click to view/edit
907
textbox_tooltip_cell=Double click to view/edit
907
thread_delay_properties=Thread Delay Properties
908
thread_delay_properties=Thread Delay Properties
908
thread_group_title=Thread Group
909
thread_group_title=Thread Group
910
test_fragment_title=Test Fragment
909
thread_properties=Thread Properties
911
thread_properties=Thread Properties
910
threadgroup=Thread Group
912
threadgroup=Thread Group
911
throughput_control_bynumber_label=Total Executions
913
throughput_control_bynumber_label=Total Executions

Return to bug 50475