mirror of https://github.com/apache/jmeter.git
Bug 58864 : when moving parameter with up / down, ensure that the selection remains visible
#resolve #78
Bugzilla Id: 58864
git-svn-id: https://svn.apache.org/repos/asf/jmeter/trunk@1726914 13f79535-47bb-0310-9956-ffa450edef68
Former-commit-id: 48e9b94771
This commit is contained in:
parent
ff2d96c594
commit
2bdd4541c9
|
|
@ -22,6 +22,7 @@ import java.awt.BorderLayout;
|
|||
import java.awt.Color;
|
||||
import java.awt.Component;
|
||||
import java.awt.FlowLayout;
|
||||
import java.awt.Rectangle;
|
||||
import java.awt.datatransfer.DataFlavor;
|
||||
import java.awt.datatransfer.UnsupportedFlavorException;
|
||||
import java.awt.event.ActionEvent;
|
||||
|
|
@ -37,6 +38,7 @@ import javax.swing.JLabel;
|
|||
import javax.swing.JOptionPane;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.JTable;
|
||||
import javax.swing.JViewport;
|
||||
import javax.swing.ListSelectionModel;
|
||||
import javax.swing.table.TableCellEditor;
|
||||
|
||||
|
|
@ -258,7 +260,7 @@ public class ArgumentsPanel extends AbstractConfigGui implements ActionListener
|
|||
tableModel.addRow(arg);
|
||||
}
|
||||
}
|
||||
checkDeleteStatus();
|
||||
checkButtonsStatus();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -384,7 +386,7 @@ public class ArgumentsPanel extends AbstractConfigGui implements ActionListener
|
|||
*/
|
||||
private void moveDown() {
|
||||
//get the selected rows before stopping editing
|
||||
// or the selected will be unselected
|
||||
// or the selected rows will be unselected
|
||||
int[] rowsSelected = table.getSelectedRows();
|
||||
GuiUtils.stopTableEditing(table);
|
||||
|
||||
|
|
@ -397,15 +399,48 @@ public class ArgumentsPanel extends AbstractConfigGui implements ActionListener
|
|||
for (int rowSelected : rowsSelected) {
|
||||
table.addRowSelectionInterval(rowSelected + 1, rowSelected + 1);
|
||||
}
|
||||
|
||||
scrollToRowIfNotVisible(rowsSelected[0]+1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* ensure that a row is visible in the viewport
|
||||
* @param rowIndx row index
|
||||
*/
|
||||
private void scrollToRowIfNotVisible(int rowIndx) {
|
||||
if(table.getParent() instanceof JViewport) {
|
||||
Rectangle visibleRect = table.getVisibleRect();
|
||||
final int cellIndex = 0;
|
||||
Rectangle cellRect = table.getCellRect(rowIndx, cellIndex, false);
|
||||
if (visibleRect.y > cellRect.y) {
|
||||
table.scrollRectToVisible(cellRect);
|
||||
} else {
|
||||
Rectangle rect2 = table.getCellRect(rowIndx + getNumberOfVisibleRows(table), cellIndex, true);
|
||||
int width = rect2.y - cellRect.y;
|
||||
table.scrollRectToVisible(new Rectangle(cellRect.x, cellRect.y, cellRect.width, cellRect.height + width));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param table {@link JTable}
|
||||
* @return number of visible rows
|
||||
*/
|
||||
private static int getNumberOfVisibleRows(JTable table) {
|
||||
Rectangle vr = table.getVisibleRect();
|
||||
int first = table.rowAtPoint(vr.getLocation());
|
||||
vr.translate(0, vr.height);
|
||||
return table.rowAtPoint(vr.getLocation()) - first;
|
||||
}
|
||||
|
||||
/**
|
||||
* Move a row down
|
||||
*/
|
||||
private void moveUp() {
|
||||
//get the selected rows before stopping editing
|
||||
// or the selected will be unselected
|
||||
// or the selected rows will be unselected
|
||||
int[] rowsSelected = table.getSelectedRows();
|
||||
GuiUtils.stopTableEditing(table);
|
||||
|
||||
|
|
@ -414,9 +449,12 @@ public class ArgumentsPanel extends AbstractConfigGui implements ActionListener
|
|||
for (int rowSelected : rowsSelected) {
|
||||
tableModel.moveRow(rowSelected, rowSelected + 1, rowSelected - 1);
|
||||
}
|
||||
|
||||
for (int rowSelected : rowsSelected) {
|
||||
table.addRowSelectionInterval(rowSelected - 1, rowSelected - 1);
|
||||
}
|
||||
|
||||
scrollToRowIfNotVisible(rowsSelected[0]-1);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -186,6 +186,7 @@ Summary
|
|||
<li><bug>58810</bug>Config Element Counter (and others): Check Boxes Toggle Area Too Big</li>
|
||||
<li><bug>56554</bug>JSR223 Test Element : Generate compilation cache key automatically. Contributed by Benoit Wiart (benoit dot wiart at gmail.com)</li>
|
||||
<li><bug>58911</bug>Header Manager : it should be possible to copy/paste between Header Managers. Contributed by Benoit Wiart (benoit dot wiart at gmail.com)</li>
|
||||
<li><bug>58864</bug>Arguments Panel : when moving parameter with up / down, ensure that the selection remains visible. Based on a contribution by Benoit Wiart (benoit dot wiart at gmail.com)</li>
|
||||
</ul>
|
||||
<ch_section>Non-functional changes</ch_section>
|
||||
<ul>
|
||||
|
|
|
|||
Loading…
Reference in New Issue