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

(-)a/src/components/org/apache/jmeter/control/gui/ThroughputControllerGui.java (-15 / +18 lines)
Lines 38-44 import org.apache.jorphan.gui.layout.VerticalLayout; Link Here
38
public class ThroughputControllerGui extends AbstractControllerGui {
38
public class ThroughputControllerGui extends AbstractControllerGui {
39
    private static final long serialVersionUID = 240L;
39
    private static final long serialVersionUID = 240L;
40
40
41
    private JComboBox styleBox;
41
    private JComboBox<String> styleBox;
42
42
43
    private int style;
43
    private int style;
44
44
Lines 74-95 public class ThroughputControllerGui extends AbstractControllerGui { Link Here
74
     * @see org.apache.jmeter.gui.JMeterGUIComponent#modifyTestElement(TestElement)
74
     * @see org.apache.jmeter.gui.JMeterGUIComponent#modifyTestElement(TestElement)
75
     */
75
     */
76
    @Override
76
    @Override
77
    public void modifyTestElement(TestElement tc) {
77
    public void modifyTestElement(TestElement te) {
78
        configureTestElement(tc);
78
        configureTestElement(te);
79
        ((ThroughputController) tc).setStyle(style);
79
        ThroughputController tc = (ThroughputController) te;
80
        ((ThroughputController) tc).setPerThread(isPerThread);
80
        tc.setStyle(style);
81
        tc.setPerThread(isPerThread);
82
        String throughputText = throughput.getText().trim();
81
        if (style == ThroughputController.BYNUMBER) {
83
        if (style == ThroughputController.BYNUMBER) {
82
            try {
84
            try {
83
                ((ThroughputController) tc).setMaxThroughput(Integer.parseInt(throughput.getText().trim()));
85
                tc.setMaxThroughput(Integer.parseInt(throughputText));
84
            } catch (NumberFormatException e) {
86
            } catch (NumberFormatException e) {
85
                // In case we are converting back from floating point, drop the decimal fraction
87
                // In case we are converting back from floating point, drop the decimal fraction
86
                ((ThroughputController) tc).setMaxThroughput(throughput.getText().trim().split("\\.")[0]); // $NON-NLS-1$
88
                tc.setMaxThroughput(throughputText.split("\\.")[0]); // $NON-NLS-1$
87
            }
89
            }
88
        } else {
90
        } else {
89
            try {
91
            try {
90
                ((ThroughputController) tc).setPercentThroughput(Float.parseFloat(throughput.getText().trim()));
92
                tc.setPercentThroughput(Float.parseFloat(throughputText));
91
            } catch (NumberFormatException e) {
93
            } catch (NumberFormatException e) {
92
                ((ThroughputController) tc).setPercentThroughput(throughput.getText());
94
                tc.setPercentThroughput(throughputText);
93
            }
95
            }
94
        }
96
        }
95
    }
97
    }
Lines 108-121 public class ThroughputControllerGui extends AbstractControllerGui { Link Here
108
    @Override
110
    @Override
109
    public void configure(TestElement el) {
111
    public void configure(TestElement el) {
110
        super.configure(el);
112
        super.configure(el);
111
        if (((ThroughputController) el).getStyle() == ThroughputController.BYNUMBER) {
113
        ThroughputController tc = (ThroughputController) el;
114
        if (tc.getStyle() == ThroughputController.BYNUMBER) {
112
            styleBox.getModel().setSelectedItem(BYNUMBER_LABEL);
115
            styleBox.getModel().setSelectedItem(BYNUMBER_LABEL);
113
            throughput.setText(((ThroughputController) el).getMaxThroughput());
116
            throughput.setText(tc.getMaxThroughput());
114
        } else {
117
        } else {
115
            styleBox.setSelectedItem(BYPERCENT_LABEL);
118
            styleBox.setSelectedItem(BYPERCENT_LABEL);
116
            throughput.setText(((ThroughputController) el).getPercentThroughput());
119
            throughput.setText(tc.getPercentThroughput());
117
        }
120
        }
118
        perthread.setSelected(((ThroughputController) el).isPerThread());
121
        perthread.setSelected(tc.isPerThread());
119
    }
122
    }
120
123
121
    @Override
124
    @Override
Lines 128-137 public class ThroughputControllerGui extends AbstractControllerGui { Link Here
128
        setBorder(makeBorder());
131
        setBorder(makeBorder());
129
        add(makeTitlePanel());
132
        add(makeTitlePanel());
130
133
131
        DefaultComboBoxModel styleModel = new DefaultComboBoxModel();
134
        DefaultComboBoxModel<String> styleModel = new DefaultComboBoxModel<String>();
132
        styleModel.addElement(BYNUMBER_LABEL);
135
        styleModel.addElement(BYNUMBER_LABEL);
133
        styleModel.addElement(BYPERCENT_LABEL);
136
        styleModel.addElement(BYPERCENT_LABEL);
134
        styleBox = new JComboBox(styleModel);
137
        styleBox = new JComboBox<String>(styleModel);
135
        styleBox.addActionListener(new ActionListener() {
138
        styleBox.addActionListener(new ActionListener() {
136
            @Override
139
            @Override
137
            public void actionPerformed(ActionEvent e) {
140
            public void actionPerformed(ActionEvent e) {
(-)a/src/components/org/apache/jmeter/visualizers/StatVisualizer.java (-1 / +1 lines)
Lines 55-61 import org.apache.jorphan.reflect.Functor; Link Here
55
import org.apache.jorphan.util.JOrphanUtils;
55
import org.apache.jorphan.util.JOrphanUtils;
56
56
57
/**
57
/**
58
 * Aggregrate Table-Based Reporting Visualizer for JMeter. Props to the people
58
 * Aggregate Table-Based Reporting Visualizer for JMeter. Props to the people
59
 * who've done the other visualizers ahead of me (Stefano Mazzocchi), who I
59
 * who've done the other visualizers ahead of me (Stefano Mazzocchi), who I
60
 * borrowed code from to start me off (and much code may still exist). Thank
60
 * borrowed code from to start me off (and much code may still exist). Thank
61
 * you!
61
 * you!
(-)a/src/core/org/apache/jmeter/gui/JMeterGUIComponent.java (-1 / +1 lines)
Lines 84-90 public interface JMeterGUIComponent extends ClearGui { Link Here
84
     * the component's label in the local language. The resource name is fixed,
84
     * the component's label in the local language. The resource name is fixed,
85
     * and does not vary with the selected language.
85
     * and does not vary with the selected language.
86
     *
86
     *
87
     * Normally this method should be overriden in preference to overriding
87
     * Normally this method should be overridden in preference to overriding
88
     * getStaticLabel(). However where the resource name is not available or required,
88
     * getStaticLabel(). However where the resource name is not available or required,
89
     * getStaticLabel() may be overridden instead.
89
     * getStaticLabel() may be overridden instead.
90
     *
90
     *
(-)a/src/core/org/apache/jmeter/save/CSVSaveService.java (-9 / +4 lines)
Lines 570-577 public final class CSVSaveService { Link Here
570
                            Perl5Compiler.READ_ONLY_MASK);
570
                            Perl5Compiler.READ_ONLY_MASK);
571
            if (matcher.matches(input, pattern)) {
571
            if (matcher.matches(input, pattern)) {
572
                delim = matcher.getMatch().group(2);
572
                delim = matcher.getMatch().group(2);
573
                parts = splitHeader(headerLine, delim);// now validate the
573
                parts = splitHeader(headerLine, delim);// now validate the result
574
                                                       // result
575
            }
574
            }
576
        }
575
        }
577
576
Lines 793-803 public final class CSVSaveService { Link Here
793
            }
792
            }
794
        }
793
        }
795
794
796
        // These methods handle parameters that could contain delimiters or
795
        // These handle parameters that could contain delimiters or quotes
797
        // quotes:
798
        public void append(String s) {
796
        public void append(String s) {
799
            addDelim();
797
            addDelim();
800
            // if (s == null) return;
801
            sb.append(quoteDelimiters(s, specials));
798
            sb.append(quoteDelimiters(s, specials));
802
        }
799
        }
803
800
Lines 805-812 public final class CSVSaveService { Link Here
805
            append(String.valueOf(obj));
802
            append(String.valueOf(obj));
806
        }
803
        }
807
804
808
        // These methods handle parameters that cannot contain delimiters or
805
        // These handle parameters that cannot contain delimiters or quotes
809
        // quotes
810
        public void append(int i) {
806
        public void append(int i) {
811
            addDelim();
807
            addDelim();
812
            sb.append(i);
808
            sb.append(i);
Lines 900-907 public final class CSVSaveService { Link Here
900
            if (message != null) {
896
            if (message != null) {
901
                text.append(message);
897
                text.append(message);
902
            } else {
898
            } else {
903
                text.append(""); // Need to append something so delimiter is
899
                text.append(""); // Need to append something so delimiter is added
904
                                 // added
905
            }
900
            }
906
        }
901
        }
907
902
(-)a/src/core/org/apache/jmeter/testbeans/gui/TestBeanGUI.java (-16 / +10 lines)
Lines 168-185 public class TestBeanGUI extends AbstractJMeterGuiComponent implements JMeterGUI Link Here
168
            beanInfo = Introspector.getBeanInfo(testBeanClass);
168
            beanInfo = Introspector.getBeanInfo(testBeanClass);
169
        } catch (IntrospectionException e) {
169
        } catch (IntrospectionException e) {
170
            log.error("Can't get beanInfo for " + testBeanClass.getName(), e);
170
            log.error("Can't get beanInfo for " + testBeanClass.getName(), e);
171
            throw new Error(e.toString()); // Programming error. Don't
171
            throw new Error(e.toString()); // Programming error. Don't continue.
172
                                            // continue.
173
        }
172
        }
174
173
175
        customizerClass = beanInfo.getBeanDescriptor().getCustomizerClass();
174
        customizerClass = beanInfo.getBeanDescriptor().getCustomizerClass();
176
175
177
        // Creation of the customizer and GUI initialization is delayed until
176
        // Creation of the customizer and GUI initialization is delayed until
178
        // the
177
        // the first configure call. We don't need all that just to find out
179
        // first
178
        // the static label, menu categories, etc!
180
        // configure call. We don't need all that just to find out the static
181
        // label, menu
182
        // categories, etc!
183
        initialized = false;
179
        initialized = false;
184
        JMeterUtils.addLocaleChangeListener(this);
180
        JMeterUtils.addLocaleChangeListener(this);
185
    }
181
    }
Lines 215-221 public TestElement createTestElement() { Link Here
215
        try {
211
        try {
216
            TestElement element = (TestElement) testBeanClass.newInstance();
212
            TestElement element = (TestElement) testBeanClass.newInstance();
217
            // In other GUI component, clearGUI resets the value to defaults one as there is one GUI per Element
213
            // In other GUI component, clearGUI resets the value to defaults one as there is one GUI per Element
218
            // With TestBeanGUI as it's shared, its default values are only known here, we must call setValues with 
214
            // With TestBeanGUI as it's shared, its default values are only known here, we must call setValues with
219
            // element (as it holds default values)
215
            // element (as it holds default values)
220
            // otherwise we will get values as computed by customizer reset and not default ones
216
            // otherwise we will get values as computed by customizer reset and not default ones
221
            if(initialized) {
217
            if(initialized) {
Lines 228-239 public TestElement createTestElement() { Link Here
228
            return element;
224
            return element;
229
        } catch (InstantiationException e) {
225
        } catch (InstantiationException e) {
230
            log.error("Can't create test element", e);
226
            log.error("Can't create test element", e);
231
            throw new Error(e.toString()); // Programming error. Don't
227
            throw new Error(e.toString()); // Programming error. Don't continue.
232
                                            // continue.
233
        } catch (IllegalAccessException e) {
228
        } catch (IllegalAccessException e) {
234
            log.error("Can't create test element", e);
229
            log.error("Can't create test element", e);
235
            throw new Error(e.toString()); // Programming error. Don't
230
            throw new Error(e.toString()); // Programming error. Don't continue.
236
                                            // continue.
237
        }
231
        }
238
    }
232
    }
239
233
Lines 332-340 public TestElement createTestElement() { Link Here
332
326
333
        initialized = true;
327
        initialized = true;
334
    }
328
    }
335
    
329
336
    /**
330
    /**
337
     * Get values from element to fill propertyMap and setup customizer 
331
     * Get values from element to fill propertyMap and setup customizer
338
     * @param element TestElement
332
     * @param element TestElement
339
     */
333
     */
340
    private void setValues(TestElement element) {
334
    private void setValues(TestElement element) {
Lines 343-349 public TestElement createTestElement() { Link Here
343
            JMeterProperty jprop = jprops.next();
337
            JMeterProperty jprop = jprops.next();
344
            propertyMap.put(jprop.getName(), jprop.getObjectValue());
338
            propertyMap.put(jprop.getName(), jprop.getObjectValue());
345
        }
339
        }
346
        
340
347
        if (customizer != null) {
341
        if (customizer != null) {
348
            customizer.setObject(propertyMap);
342
            customizer.setObject(propertyMap);
349
        } else {
343
        } else {
Lines 389-395 public TestElement createTestElement() { Link Here
389
    public int setupGuiClasses() {
383
    public int setupGuiClasses() {
390
        return setupGuiClasses(new ArrayList<String>());
384
        return setupGuiClasses(new ArrayList<String>());
391
    }
385
    }
392
    
386
393
    /**
387
    /**
394
     * Setup GUI class
388
     * Setup GUI class
395
     * @param menuCategories List<String> menu categories
389
     * @param menuCategories List<String> menu categories
(-)a/src/core/org/apache/jmeter/util/JMeterUtils.java (-17 / +8 lines)
Lines 73-79 public class JMeterUtils implements UnitTestManager { Link Here
73
    // have been defined (Bug 52783)
73
    // have been defined (Bug 52783)
74
    private static class LazyPatternCacheHolder {
74
    private static class LazyPatternCacheHolder {
75
        public static final PatternCacheLRU INSTANCE = new PatternCacheLRU(
75
        public static final PatternCacheLRU INSTANCE = new PatternCacheLRU(
76
                getPropDefault("oro.patterncache.size",1000), // $NON-NLS-1$
76
                getPropDefault("oro.patterncache.size", 1000), // $NON-NLS-1$
77
                new Perl5Compiler());
77
                new Perl5Compiler());
78
    }
78
    }
79
79
Lines 91-101 public class JMeterUtils implements UnitTestManager { Link Here
91
91
92
    // What host am I running on?
92
    // What host am I running on?
93
93
94
    //@GuardedBy("this")
95
    private static String localHostIP = null;
94
    private static String localHostIP = null;
96
    //@GuardedBy("this")
97
    private static String localHostName = null;
95
    private static String localHostName = null;
98
    //@GuardedBy("this")
99
    private static String localHostFullName = null;
96
    private static String localHostFullName = null;
100
97
101
    private static volatile boolean ignoreResorces = false; // Special flag for use in debugging resources
98
    private static volatile boolean ignoreResorces = false; // Special flag for use in debugging resources
Lines 184-193 public class JMeterUtils implements UnitTestManager { Link Here
184
            p.load(is);
181
            p.load(is);
185
        } catch (IOException e) {
182
        } catch (IOException e) {
186
            try {
183
            try {
187
                is =
184
                is = ClassLoader.getSystemResourceAsStream("org/apache/jmeter/jmeter.properties"); // $NON-NLS-1$
188
                    ClassLoader.getSystemResourceAsStream("org/apache/jmeter/jmeter.properties"); // $NON-NLS-1$
189
                if (is == null) {
185
                if (is == null) {
190
                    throw new RuntimeException("Could not read JMeter properties file:"+file);
186
                    throw new RuntimeException("Could not read JMeter properties file:" + file);
191
                }
187
                }
192
                p.load(is);
188
                p.load(is);
193
            } catch (IOException ex) {
189
            } catch (IOException ex) {
Lines 381-389 public class JMeterUtils implements UnitTestManager { Link Here
381
            }
377
            }
382
        }
378
        }
383
        notifyLocaleChangeListeners();
379
        notifyLocaleChangeListeners();
384
        /*
380
        
385
         * Reset Locale if necessary so other locales are properly handled
381
        // Reset Locale if necessary so other locales are properly handled
386
         */
387
        if (def != null) {
382
        if (def != null) {
388
            Locale.setDefault(def);
383
            Locale.setDefault(def);
389
        }
384
        }
Lines 413-420 public class JMeterUtils implements UnitTestManager { Link Here
413
    private static void notifyLocaleChangeListeners() {
408
    private static void notifyLocaleChangeListeners() {
414
        LocaleChangeEvent event = new LocaleChangeEvent(JMeterUtils.class, locale);
409
        LocaleChangeEvent event = new LocaleChangeEvent(JMeterUtils.class, locale);
415
        @SuppressWarnings("unchecked") // clone will produce correct type
410
        @SuppressWarnings("unchecked") // clone will produce correct type
416
        // TODO but why do we need to clone the list?
411
        // cloning the list to avoid possible ConcurrentUpdateException when unsubscribing
417
        // ANS: to avoid possible ConcurrentUpdateException when unsubscribing
418
        // Could perhaps avoid need to clone by using a modern concurrent list
412
        // Could perhaps avoid need to clone by using a modern concurrent list
419
        Vector<LocaleChangeListener> listeners = (Vector<LocaleChangeListener>) localeChangeListeners.clone();
413
        Vector<LocaleChangeListener> listeners = (Vector<LocaleChangeListener>) localeChangeListeners.clone();
420
        for (LocaleChangeListener listener : listeners) {
414
        for (LocaleChangeListener listener : listeners) {
Lines 898-904 public class JMeterUtils implements UnitTestManager { Link Here
898
    }
892
    }
899
893
900
    /**
894
    /**
901
     * Instatiate an object and guarantee its class.
895
     * Instantiate an object and guarantee its class.
902
     *
896
     *
903
     * @param className
897
     * @param className
904
     *            The name of the class to instantiate.
898
     *            The name of the class to instantiate.
Lines 1107-1114 public class JMeterUtils implements UnitTestManager { Link Here
1107
        return retVal.toString();
1101
        return retVal.toString();
1108
    }
1102
    }
1109
1103
1110
    // End Method
1111
1112
    /**
1104
    /**
1113
     * Takes an array of strings and a tokenizer character, and returns a string
1105
     * Takes an array of strings and a tokenizer character, and returns a string
1114
     * of all the strings concatenated with the tokenizer string in between each
1106
     * of all the strings concatenated with the tokenizer string in between each
Lines 1166-1172 public class JMeterUtils implements UnitTestManager { Link Here
1166
    private static String jmDir; // JMeter Home directory (excludes trailing separator)
1158
    private static String jmDir; // JMeter Home directory (excludes trailing separator)
1167
    private static String jmBin; // JMeter bin directory (excludes trailing separator)
1159
    private static String jmBin; // JMeter bin directory (excludes trailing separator)
1168
1160
1169
1170
    /**
1161
    /**
1171
     * Gets the JMeter Version.
1162
     * Gets the JMeter Version.
1172
     *
1163
     *
Lines 1318-1324 public class JMeterUtils implements UnitTestManager { Link Here
1318
     */
1309
     */
1319
    public static final void clearMatcherMemory(Perl5Matcher matcher, Pattern pattern) {
1310
    public static final void clearMatcherMemory(Perl5Matcher matcher, Pattern pattern) {
1320
        try {
1311
        try {
1321
            if(pattern != null) {
1312
            if (pattern != null) {
1322
                matcher.matches("", pattern); // $NON-NLS-1$
1313
                matcher.matches("", pattern); // $NON-NLS-1$
1323
            }
1314
            }
1324
        } catch (Exception e) {
1315
        } catch (Exception e) {
(-)a/src/jorphan/org/apache/jorphan/gui/GuiUtils.java (-10 / +10 lines)
Lines 13-19 Link Here
13
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
 * See the License for the specific language governing permissions and
14
 * See the License for the specific language governing permissions and
15
 * limitations under the License.
15
 * limitations under the License.
16
 * 
16
 *
17
 */
17
 */
18
18
19
package org.apache.jorphan.gui;
19
package org.apache.jorphan.gui;
Lines 65-71 public final class GuiUtils { Link Here
65
65
66
    /**
66
    /**
67
     * Fix the size of a column according to the header text.
67
     * Fix the size of a column according to the header text.
68
     * 
68
     *
69
     * @param column to be resized
69
     * @param column to be resized
70
     * @param table containing the column
70
     * @param table containing the column
71
     */
71
     */
Lines 80-88 public final class GuiUtils { Link Here
80
        int width = c.getPreferredSize().width+10;
80
        int width = c.getPreferredSize().width+10;
81
        column.setMaxWidth(width);
81
        column.setMaxWidth(width);
82
        column.setPreferredWidth(width);
82
        column.setPreferredWidth(width);
83
        column.setResizable(false);        
83
        column.setResizable(false);
84
    }
84
    }
85
    
85
86
    /**
86
    /**
87
     * Create a GUI component JLabel + JComboBox with a left and right margin (5px)
87
     * Create a GUI component JLabel + JComboBox with a left and right margin (5px)
88
     * @param label
88
     * @param label
Lines 109-115 public final class GuiUtils { Link Here
109
            cellEditor.stopCellEditing();
109
            cellEditor.stopCellEditing();
110
        }
110
        }
111
    }
111
    }
112
    
112
113
    /**
113
    /**
114
     * Get pasted text from clipboard
114
     * Get pasted text from clipboard
115
     * @return String Pasted text
115
     * @return String Pasted text
Lines 132-143 public final class GuiUtils { Link Here
132
     * Make menu scrollable
132
     * Make menu scrollable
133
     * @param menu {@link JMenu}
133
     * @param menu {@link JMenu}
134
     */
134
     */
135
    public static void makeScrollableMenu(JMenu menu) { 
135
    public static void makeScrollableMenu(JMenu menu) {
136
        Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
136
        Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
137
        if(menu.getItemCount()>0) {
137
        if (menu.getItemCount() > 0) {
138
            // We use 80% of height
138
            double componentHeight = menu.getMenuComponent(0).getPreferredSize().getHeight();
139
            int maxItems = (int)Math.round(
139
            double screenHeight = screenSize.getHeight() * 0.8; // We use 80%
140
                    screenSize.getHeight()*0.8/menu.getMenuComponent(0).getPreferredSize().getHeight());
140
            int maxItems = (int) Math.round(screenHeight / componentHeight);
141
            MenuScroller.setScrollerFor(menu, maxItems, 200);
141
            MenuScroller.setScrollerFor(menu, maxItems, 200);
142
        }
142
        }
143
    }
143
    }
(-)a/src/reports/org/apache/jmeter/gui/ReportGuiPackage.java (-12 / +6 lines)
Lines 48-54 import org.apache.log.Logger; Link Here
48
 * the reporting tool. Because of how the gui components work, it
48
 * the reporting tool. Because of how the gui components work, it
49
 * was safer to just make a new class, rather than braking existing
49
 * was safer to just make a new class, rather than braking existing
50
 * JMeter gui code.
50
 * JMeter gui code.
51
 *
52
 */
51
 */
53
public final class ReportGuiPackage implements LocaleChangeListener {
52
public final class ReportGuiPackage implements LocaleChangeListener {
54
    /** Logging. */
53
    /** Logging. */
Lines 111-117 public final class ReportGuiPackage implements LocaleChangeListener { Link Here
111
     * @return the GuiPackage instance
110
     * @return the GuiPackage instance
112
     */
111
     */
113
    public static ReportGuiPackage getInstance() {
112
    public static ReportGuiPackage getInstance() {
114
        if (guiPack == null){
113
        if (guiPack == null) {
115
            log.error("ReportGuiPackage is null");
114
            log.error("ReportGuiPackage is null");
116
        }
115
        }
117
        return guiPack;
116
        return guiPack;
Lines 131-137 public final class ReportGuiPackage implements LocaleChangeListener { Link Here
131
    public static ReportGuiPackage getInstance(ReportTreeListener listener, ReportTreeModel treeModel) {
130
    public static ReportGuiPackage getInstance(ReportTreeListener listener, ReportTreeModel treeModel) {
132
        if (guiPack == null) {
131
        if (guiPack == null) {
133
            synchronized (LOCK) {
132
            synchronized (LOCK) {
134
                if(guiPack== null) {
133
                if (guiPack == null) {
135
                    guiPack = new ReportGuiPackage();
134
                    guiPack = new ReportGuiPackage();
136
                    guiPack.setTreeListener(listener);
135
                    guiPack.setTreeListener(listener);
137
                    guiPack.setTreeModel(treeModel);
136
                    guiPack.setTreeModel(treeModel);
Lines 303-322 public final class ReportGuiPackage implements LocaleChangeListener { Link Here
303
            return node;
302
            return node;
304
        } catch (NoClassDefFoundError e) {
303
        } catch (NoClassDefFoundError e) {
305
            log.error("Problem retrieving gui for " + objClass, e);
304
            log.error("Problem retrieving gui for " + objClass, e);
306
            throw new RuntimeException(e.toString(), e); // Probably a missing
305
            throw new RuntimeException(e.toString(), e); // Probably a missing jar
307
                                                        // jar
308
        } catch (ClassNotFoundException e) {
306
        } catch (ClassNotFoundException e) {
309
            log.error("Problem retrieving gui for " + objClass, e);
307
            log.error("Problem retrieving gui for " + objClass, e);
310
            throw new RuntimeException(e.toString(), e); // Programming error:
308
            throw new RuntimeException(e.toString(), e); // Programming error: bail out.
311
                                                        // bail out.
312
        } catch (InstantiationException e) {
309
        } catch (InstantiationException e) {
313
            log.error("Problem retrieving gui for " + objClass, e);
310
            log.error("Problem retrieving gui for " + objClass, e);
314
            throw new RuntimeException(e.toString(), e); // Programming error:
311
            throw new RuntimeException(e.toString(), e); // Programming error: bail out.
315
                                                        // bail out.
316
        } catch (IllegalAccessException e) {
312
        } catch (IllegalAccessException e) {
317
            log.error("Problem retrieving gui for " + objClass, e);
313
            log.error("Problem retrieving gui for " + objClass, e);
318
            throw new RuntimeException(e.toString(), e); // Programming error:
314
            throw new RuntimeException(e.toString(), e); // Programming error: bail out.
319
                                                        // bail out.
320
        }
315
        }
321
    }
316
    }
322
317
Lines 367-373 public final class ReportGuiPackage implements LocaleChangeListener { Link Here
367
    /**
362
    /**
368
     * Update the GUI for the currently selected node. The GUI component is
363
     * Update the GUI for the currently selected node. The GUI component is
369
     * configured to reflect the settings in the current tree node.
364
     * configured to reflect the settings in the current tree node.
370
     *
371
     */
365
     */
372
    public void updateCurrentGui() {
366
    public void updateCurrentGui() {
373
        updateCurrentNode();
367
        updateCurrentNode();
(-)a/src/reports/org/apache/jmeter/report/gui/tree/ReportTreeListener.java (-57 / +11 lines)
Lines 18-24 Link Here
18
18
19
package org.apache.jmeter.report.gui.tree;
19
package org.apache.jmeter.report.gui.tree;
20
20
21
import java.awt.Container;
22
import java.awt.event.ActionEvent;
21
import java.awt.event.ActionEvent;
23
import java.awt.event.ActionListener;
22
import java.awt.event.ActionListener;
24
import java.awt.event.InputEvent;
23
import java.awt.event.InputEvent;
Lines 48-55 import org.apache.log.Logger; Link Here
48
public class ReportTreeListener implements TreeSelectionListener, MouseListener, KeyListener, MouseMotionListener {
47
public class ReportTreeListener implements TreeSelectionListener, MouseListener, KeyListener, MouseMotionListener {
49
    private static final Logger log = LoggingManager.getLoggerForClass();
48
    private static final Logger log = LoggingManager.getLoggerForClass();
50
49
51
    // Container endWindow;
52
    // JPopupMenu pop;
53
    private TreePath currentPath;
50
    private TreePath currentPath;
54
51
55
    private ActionListener actionHandler;
52
    private ActionListener actionHandler;
Lines 64-72 public class ReportTreeListener implements TreeSelectionListener, MouseListener, Link Here
64
61
65
    private JLabel dragIcon = new JLabel(JMeterUtils.getImage("leafnode.gif"));
62
    private JLabel dragIcon = new JLabel(JMeterUtils.getImage("leafnode.gif"));
66
63
67
    /**
68
     * Constructor for the JMeterTreeListener object.
69
     */
70
    public ReportTreeListener(ReportTreeModel model) {
64
    public ReportTreeListener(ReportTreeModel model) {
71
        this.model = model;
65
        this.model = model;
72
        dragIcon.validate();
66
        dragIcon.validate();
Lines 82-128 public class ReportTreeListener implements TreeSelectionListener, MouseListener, Link Here
82
        model = m;
76
        model = m;
83
    }
77
    }
84
78
85
    /**
86
     * Sets the ActionHandler attribute of the JMeterTreeListener object.
87
     *
88
     * @param ah
89
     *            the new ActionHandler value
90
     */
91
    public void setActionHandler(ActionListener ah) {
79
    public void setActionHandler(ActionListener ah) {
92
        actionHandler = ah;
80
        actionHandler = ah;
93
    }
81
    }
94
82
95
    /**
96
     * Sets the JTree attribute of the JMeterTreeListener object.
97
     *
98
     * @param tree
99
     *            the new JTree value
100
     */
101
    public void setJTree(JTree tree) {
83
    public void setJTree(JTree tree) {
102
        this.tree = tree;
84
        this.tree = tree;
103
    }
85
    }
104
86
105
    /**
106
     * Sets the EndWindow attribute of the JMeterTreeListener object.
107
     *
108
     * @param window
109
     *            the new EndWindow value
110
     */
111
    public void setEndWindow(Container window) {
112
        // endWindow = window;
113
    }
114
115
    /**
116
     * Gets the JTree attribute of the JMeterTreeListener object.
117
     *
118
     * @return tree the current JTree value.
119
     */
120
    public JTree getJTree() {
87
    public JTree getJTree() {
121
        return tree;
88
        return tree;
122
    }
89
    }
123
90
124
    /**
91
    /**
125
     * Gets the CurrentNode attribute of the JMeterTreeListener object.
92
     * Gets the CurrentNode attribute of the ReportTreeNode.
126
     *
93
     *
127
     * @return the CurrentNode value
94
     * @return the CurrentNode value
128
     */
95
     */
Lines 164-170 public class ReportTreeListener implements TreeSelectionListener, MouseListener, Link Here
164
    }
131
    }
165
132
166
    @Override
133
    @Override
167
    public void mouseClicked(MouseEvent ev) {
134
    public void mouseClicked(MouseEvent e) {
168
    }
135
    }
169
136
170
    @Override
137
    @Override
Lines 198-212 public class ReportTreeListener implements TreeSelectionListener, MouseListener, Link Here
198
        return draggedNodes;
165
        return draggedNodes;
199
    }
166
    }
200
167
201
    /**
202
     * Tests if the node is being dragged into one of it's own sub-nodes, or
203
     * into itself.
204
     */
205
    private boolean isValidDragAction(ReportTreeNode[] source, ReportTreeNode dest) {
168
    private boolean isValidDragAction(ReportTreeNode[] source, ReportTreeNode dest) {
206
        boolean isValid = true;
169
        boolean isValid = true;
207
        TreeNode[] path = dest.getPath();
170
        TreeNode[] path = dest.getPath();
208
        for (int i = 0; i < path.length; i++) {
171
        for (TreeNode node : path) {
209
            if (contains(source, path[i])) {
172
            // Tests if the node is being dragged into itself or own sub-nodes.
173
            if (contains(source, node)) {
210
                isValid = false;
174
                isValid = false;
211
                break;
175
                break;
212
            }
176
            }
Lines 231-238 public class ReportTreeListener implements TreeSelectionListener, MouseListener, Link Here
231
    }
195
    }
232
196
233
    private boolean contains(Object[] container, Object item) {
197
    private boolean contains(Object[] container, Object item) {
234
        for (int i = 0; i < container.length; i++) {
198
        for (Object c : container) {
235
            if (container[i] == item) {
199
            if (c == item) {
236
                return true;
200
                return true;
237
            }
201
            }
238
        }
202
        }
Lines 251-258 public class ReportTreeListener implements TreeSelectionListener, MouseListener, Link Here
251
            currentPath = tree.getPathForLocation(e.getX(), e.getY());
215
            currentPath = tree.getPathForLocation(e.getX(), e.getY());
252
        }
216
        }
253
        if (selRow != -1) {
217
        if (selRow != -1) {
254
            // updateMainMenu(((JMeterGUIComponent)
255
            // getCurrentNode().getUserObject()).createPopupMenu());
256
            if (isRightClick(e)) {
218
            if (isRightClick(e)) {
257
                if (tree.getSelectionCount() < 2) {
219
                if (tree.getSelectionCount() < 2) {
258
                    tree.setSelectionPath(currentPath);
220
                    tree.setSelectionPath(currentPath);
Lines 273-279 public class ReportTreeListener implements TreeSelectionListener, MouseListener, Link Here
273
            if (draggedNodes[0].getUserObject() instanceof ReportGui) {
235
            if (draggedNodes[0].getUserObject() instanceof ReportGui) {
274
                dragging = false;
236
                dragging = false;
275
            }
237
            }
276
277
        }
238
        }
278
        changeSelectionIfDragging(e);
239
        changeSelectionIfDragging(e);
279
    }
240
    }
Lines 283-289 public class ReportTreeListener implements TreeSelectionListener, MouseListener, Link Here
283
    }
244
    }
284
245
285
    @Override
246
    @Override
286
    public void mouseExited(MouseEvent ev) {
247
    public void mouseExited(MouseEvent e) {
287
    }
248
    }
288
249
289
    @Override
250
    @Override
Lines 299-317 public class ReportTreeListener implements TreeSelectionListener, MouseListener, Link Here
299
    }
260
    }
300
261
301
    private boolean isRightClick(MouseEvent e) {
262
    private boolean isRightClick(MouseEvent e) {
302
        return e.isPopupTrigger() || (InputEvent.BUTTON2_MASK & e.getModifiers()) > 0 || (InputEvent.BUTTON3_MASK == e.getModifiers());
263
        return e.isPopupTrigger() || (InputEvent.BUTTON2_MASK & e.getModifiers()) > 0
264
                || (InputEvent.BUTTON3_MASK == e.getModifiers());
303
    }
265
    }
304
266
305
    /*
306
     * NOTUSED private void updateMainMenu(JPopupMenu menu) { try { MainFrame
307
     * mainFrame = GuiPackage.getInstance().getMainFrame();
308
     * mainFrame.setEditMenu(menu); } catch (NullPointerException e) {
309
     * log.error("Null pointer: JMeterTreeListener.updateMenuItem()", e);
310
     * log.error("", e); } }
311
     */
312
313
    private void displayPopUp(MouseEvent e) {
267
    private void displayPopUp(MouseEvent e) {
314
        JPopupMenu pop = getCurrentNode().createPopupMenu();
268
        JPopupMenu pop = getCurrentNode().createPopupMenu();
269
        // Should this just be GuiPackage - duplicate code in displayPopUp?
315
        ReportGuiPackage.getInstance().displayPopUp(e, pop);
270
        ReportGuiPackage.getInstance().displayPopUp(e, pop);
316
    }
271
    }
317
272
318
- 

Return to bug 57110