Thanks Milamber, Will fix it this evening. Regards Philippe
On Wed, Oct 12, 2011 at 12:21 AM, Milamber <milam...@apache.org> wrote: > Hello, > > This commit adds a Up/Down button on Function Helper Dialog window. > This is not good, because moving the ordering parameters make some > errors in function helper results (tested with the new ramdom string > function). > > Milamber > > Le 07/10/2011 20:30, pmoua...@apache.org a ecrit : > > Author: pmouawad > > Date: Fri Oct 7 20:30:33 2011 > > New Revision: 1180205 > > > > URL: http://svn.apache.org/viewvc?rev=1180205&view=rev > > Log: > > Bug 51817 - Moving variables up and down in User Defined Variables > control. > > > > Fixed a ConcurrentModificationException in ObjectTableModel#moveRow I had > to use. > > > > Modified: > > > jakarta/jmeter/trunk/src/core/org/apache/jmeter/config/gui/ArgumentsPanel.java > > > jakarta/jmeter/trunk/src/core/org/apache/jmeter/resources/messages.properties > > > jakarta/jmeter/trunk/src/jorphan/org/apache/jorphan/gui/ObjectTableModel.java > > > > Modified: > jakarta/jmeter/trunk/src/core/org/apache/jmeter/config/gui/ArgumentsPanel.java > > URL: > http://svn.apache.org/viewvc/jakarta/jmeter/trunk/src/core/org/apache/jmeter/config/gui/ArgumentsPanel.java?rev=1180205&r1=1180204&r2=1180205&view=diff > > > ============================================================================== > > --- > jakarta/jmeter/trunk/src/core/org/apache/jmeter/config/gui/ArgumentsPanel.java > (original) > > +++ > jakarta/jmeter/trunk/src/core/org/apache/jmeter/config/gui/ArgumentsPanel.java > Fri Oct 7 20:30:33 2011 > > @@ -81,12 +81,24 @@ public class ArgumentsPanel extends Abst > > */ > > private boolean standalone = true; > > > > + /** Button to move a argument up*/ > > + private JButton up; > > + > > + /** Button to move a argument down*/ > > + private JButton down; > > + > > /** Command for adding a row to the table. */ > > private static final String ADD = "add"; // $NON-NLS-1$ > > > > /** Command for removing a row from the table. */ > > private static final String DELETE = "delete"; // $NON-NLS-1$ > > > > + /** Command for moving a row up in the table. */ > > + private static final String UP = "up"; // $NON-NLS-1$ > > + > > + /** Command for moving a row down in the table. */ > > + private static final String DOWN = "down"; // $NON-NLS-1$ > > + > > public static final String COLUMN_RESOURCE_NAMES_0 = "name"; // > $NON-NLS-1$ > > > > public static final String COLUMN_RESOURCE_NAMES_1 = "value"; // > $NON-NLS-1$ > > @@ -239,6 +251,11 @@ public class ArgumentsPanel extends Abst > > } else { > > delete.setEnabled(true); > > } > > + > > + if(tableModel.getRowCount()>1) { > > + up.setEnabled(true); > > + down.setEnabled(true); > > + } > > } > > > > @Override > > @@ -268,19 +285,56 @@ public class ArgumentsPanel extends Abst > > deleteArgument(); > > } else if (action.equals(ADD)) { > > addArgument(); > > + } else if (action.equals(UP)) { > > + moveUp(); > > + } else if (action.equals(DOWN)) { > > + moveDown(); > > } > > } > > > > /** > > - * Remove the currently selected argument from the table. > > + * Cancel cell editing if it is being edited > > */ > > - protected void deleteArgument() { > > + private void cancelEditing() { > > // If a table cell is being edited, we must cancel the editing > before > > // deleting the row > > if (table.isEditing()) { > > TableCellEditor cellEditor = > table.getCellEditor(table.getEditingRow(), table.getEditingColumn()); > > cellEditor.cancelCellEditing(); > > } > > + } > > + > > + /** > > + * Move a row down > > + */ > > + private void moveDown() { > > + cancelEditing(); > > + > > + int rowSelected = table.getSelectedRow(); > > + if (rowSelected < table.getRowCount()-1) { > > + tableModel.moveRow(rowSelected, rowSelected+1, > rowSelected+1); > > + table.setRowSelectionInterval(rowSelected+1, rowSelected+1); > > + } > > + } > > + > > + /** > > + * Move a row down > > + */ > > + private void moveUp() { > > + cancelEditing(); > > + > > + int rowSelected = table.getSelectedRow(); > > + if (rowSelected > 0) { > > + tableModel.moveRow(rowSelected, rowSelected+1, > rowSelected-1); > > + table.setRowSelectionInterval(rowSelected-1, rowSelected-1); > > + } > > + } > > + > > + /** > > + * Remove the currently selected argument from the table. > > + */ > > + protected void deleteArgument() { > > + cancelEditing(); > > > > int rowSelected = table.getSelectedRow(); > > if (rowSelected >= 0) { > > @@ -291,6 +345,11 @@ public class ArgumentsPanel extends Abst > > if (tableModel.getRowCount() == 0) { > > delete.setEnabled(false); > > } > > + > > + if(tableModel.getRowCount()>1) { > > + up.setEnabled(true); > > + down.setEnabled(true); > > + } > > > > // Table still contains one or more rows, so highlight > (select) > > // the appropriate one. > > @@ -318,7 +377,10 @@ public class ArgumentsPanel extends Abst > > > > // Enable DELETE (which may already be enabled, but it won't > hurt) > > delete.setEnabled(true); > > - > > + if(tableModel.getRowCount()>1) { > > + up.setEnabled(true); > > + down.setEnabled(true); > > + } > > // Highlight (select) the appropriate row. > > int rowToSelect = tableModel.getRowCount() - 1; > > table.setRowSelectionInterval(rowToSelect, rowToSelect); > > @@ -417,6 +479,12 @@ public class ArgumentsPanel extends Abst > > delete = new JButton(JMeterUtils.getResString("delete")); // > $NON-NLS-1$ > > delete.setActionCommand(DELETE); > > > > + up = new JButton(JMeterUtils.getResString("up")); // $NON-NLS-1$ > > + up.setActionCommand(UP); > > + > > + down = new JButton(JMeterUtils.getResString("down")); // > $NON-NLS-1$ > > + down.setActionCommand(DOWN); > > + > > checkDeleteStatus(); > > > > JPanel buttonPanel = new JPanel(); > > @@ -426,8 +494,12 @@ public class ArgumentsPanel extends Abst > > } > > add.addActionListener(this); > > delete.addActionListener(this); > > + up.addActionListener(this); > > + down.addActionListener(this); > > buttonPanel.add(add); > > buttonPanel.add(delete); > > + buttonPanel.add(up); > > + buttonPanel.add(down); > > return buttonPanel; > > } > > > > > > Modified: > jakarta/jmeter/trunk/src/core/org/apache/jmeter/resources/messages.properties > > URL: > http://svn.apache.org/viewvc/jakarta/jmeter/trunk/src/core/org/apache/jmeter/resources/messages.properties?rev=1180205&r1=1180204&r2=1180205&view=diff > > > ============================================================================== > > --- > jakarta/jmeter/trunk/src/core/org/apache/jmeter/resources/messages.properties > (original) > > +++ > jakarta/jmeter/trunk/src/core/org/apache/jmeter/resources/messages.properties > Fri Oct 7 20:30:33 2011 > > @@ -191,6 +191,7 @@ distribution_note1=The graph will update > > dn=DN > > domain=Domain > > done=Done > > +down=Down > > duration=Duration (seconds) > > duration_assertion_duration_test=Duration to Assert > > duration_assertion_failure=The operation lasted too long\: It took {0} > milliseconds, but should not have lasted longer than {1} milliseconds. > > @@ -939,6 +940,7 @@ uniform_timer_delay=Constant Delay Offse > > uniform_timer_memo=Adds a random delay with a uniform distribution > > uniform_timer_range=Random Delay Maximum (in milliseconds)\: > > uniform_timer_title=Uniform Random Timer > > +up=Up > > update_per_iter=Update Once Per Iteration > > upload=File Upload > > upper_bound=Upper Bound > > > > Modified: > jakarta/jmeter/trunk/src/jorphan/org/apache/jorphan/gui/ObjectTableModel.java > > URL: > http://svn.apache.org/viewvc/jakarta/jmeter/trunk/src/jorphan/org/apache/jorphan/gui/ObjectTableModel.java?rev=1180205&r1=1180204&r2=1180205&view=diff > > > ============================================================================== > > --- > jakarta/jmeter/trunk/src/jorphan/org/apache/jorphan/gui/ObjectTableModel.java > (original) > > +++ > jakarta/jmeter/trunk/src/jorphan/org/apache/jorphan/gui/ObjectTableModel.java > Fri Oct 7 20:30:33 2011 > > @@ -202,7 +202,7 @@ public class ObjectTableModel extends De > > /** {@inheritDoc} */ > > @Override > > public void moveRow(int start, int end, int to) { > > - List<Object> subList = objects.subList(start, end); > > + List<Object> subList = new ArrayList(objects.subList(start, > end)); > > for (int x = end - 1; x >= start; x--) { > > objects.remove(x); > > } > > > > > > > > --------------------------------------------------------------------- > > To unsubscribe, e-mail: notifications-unsubscr...@jakarta.apache.org > > For additional commands, e-mail: notifications-h...@jakarta.apache.org > > > > > > > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: dev-unsubscr...@jakarta.apache.org > For additional commands, e-mail: dev-h...@jakarta.apache.org > > -- Cordialement. Philippe Mouawad.