On 12 March 2016 at 21:41, Philippe Mouawad <[email protected]> wrote: > Hello, > -1 for a new property saveconfig.sort
Please read the bug and the patch. The sortOrder field is temporary. > Let's decide of a sort order and impose it. +1 > Regards > > On Sat, Mar 12, 2016 at 10:37 PM, <[email protected]> wrote: > >> Author: sebb >> Date: Sat Mar 12 21:37:42 2016 >> New Revision: 1734740 >> >> URL: http://svn.apache.org/viewvc?rev=1734740&view=rev >> Log: >> Sample Result SaveConfig Dialog is generated in random order >> TODO - remove the test code when the sort order is decided >> Bugzilla Id: 59171 >> >> Modified: >> jmeter/trunk/src/core/org/apache/jmeter/gui/SavePropertyDialog.java >> >> Modified: >> jmeter/trunk/src/core/org/apache/jmeter/gui/SavePropertyDialog.java >> URL: >> http://svn.apache.org/viewvc/jmeter/trunk/src/core/org/apache/jmeter/gui/SavePropertyDialog.java?rev=1734740&r1=1734739&r2=1734740&view=diff >> >> ============================================================================== >> --- jmeter/trunk/src/core/org/apache/jmeter/gui/SavePropertyDialog.java >> (original) >> +++ jmeter/trunk/src/core/org/apache/jmeter/gui/SavePropertyDialog.java >> Sat Mar 12 21:37:42 2016 >> @@ -28,7 +28,11 @@ import java.awt.event.ActionEvent; >> import java.awt.event.ActionListener; >> import java.lang.reflect.InvocationTargetException; >> import java.lang.reflect.Method; >> +import java.util.ArrayList; >> +import java.util.Collections; >> +import java.util.Comparator; >> import java.util.HashMap; >> +import java.util.List; >> import java.util.Map; >> >> import javax.swing.JButton; >> @@ -98,6 +102,7 @@ public class SavePropertyDialog extends >> int x = (countMethods(methods) / 3) + 1; >> log.debug("grid panel is " + 3 + " by " + x); >> JPanel checkPanel = new JPanel(new GridLayout(x, 3)); >> + List<JCheckBox> checks = new ArrayList<>(); >> for (Method method : methods) { >> String name = method.getName(); >> if (name.startsWith(NAME_SAVE_PFX) && >> method.getParameterTypes().length == 0) { >> @@ -106,7 +111,7 @@ public class SavePropertyDialog extends >> JCheckBox check = new JCheckBox( >> JMeterUtils.getResString(RESOURCE_PREFIX + >> name), >> ((Boolean) method.invoke(saveConfig, new >> Object[0])).booleanValue()); >> - checkPanel.add(check, BorderLayout.NORTH); >> + checks.add(check); >> check.addActionListener(this); >> String actionCommand = NAME_SET_PREFIX + name; // >> $NON-NLS-1$ >> check.setActionCommand(actionCommand); >> @@ -118,6 +123,22 @@ public class SavePropertyDialog extends >> } >> } >> } >> + // sortOrder is a temporary hack to allow easy testing of sort >> alternatives (Bug 59171) >> + final String sortOrder = >> JMeterUtils.getPropDefault("saveconfig.sort", ""); >> + if (sortOrder.length() > 0) { >> + Collections.sort(checks, new Comparator<JCheckBox>(){ >> + @Override >> + public int compare(JCheckBox o1, JCheckBox o2) { >> + if ("text".equals(sortOrder)) { >> + return >> o1.getText().compareToIgnoreCase(o2.getText()); // depends on language >> + } else { >> + return >> o1.getActionCommand().compareToIgnoreCase(o2.getActionCommand()); // >> propName >> + } >> + }}); >> + } >> + for(JCheckBox check : checks) { >> + checkPanel.add(check, BorderLayout.NORTH); >> + } >> getContentPane().add(checkPanel, BorderLayout.NORTH); >> JButton exit = new JButton(JMeterUtils.getResString("done")); // >> $NON-NLS-1$ >> this.getContentPane().add(exit, BorderLayout.SOUTH); >> >> >> > > > -- > Cordialement. > Philippe Mouawad.
