Code Monkey home page Code Monkey logo

Comments (5)

asfimport avatar asfimport commented on May 18, 2024

khammond25 (migrated from Bugzilla):
*** #759 has been marked as a duplicate of this bug. ***

from jmeter.

asfimport avatar asfimport commented on May 18, 2024

khammond25 (migrated from Bugzilla):
Created attachment patch.ArgumentsPanel.diff: Patch for ArgumentsPanel.java; file contains the diff

patch.ArgumentsPanel.diff
--- \jakarta-jmeter-cvs\jakarta-jmeter\src\org\apache\jmeter\config\gui\ArgumentsPanel.java	Thu Jul 26 00:34:44 2001
+++ \jakarta-jmeter-nightly\2001.09.15\jakarta-jmeter\src\org\apache\jmeter\config\gui\ArgumentsPanel.java	Thu Sep 20 13:32:52 2001
@@ -117,9 +117,14 @@
 	 ***********************************************************/
 	public void keyReleased(KeyEvent e)
 	{
-		tableModel.setValueAt(table.getValueAt(table.getSelectedRow(), table.getSelectedColumn()),
-				table.getSelectedRow(), table.getSelectedColumn());
-		this.repaint();
+		/* Note sure why we have code here, so I commented it out. Seems to work fine. [khammond]
+		if (tableModel.getRowCount() > 0)
+		{
+			tableModel.setValueAt(table.getValueAt(table.getSelectedRow(), table.getSelectedColumn()),
+					table.getSelectedRow(), table.getSelectedColumn());
+			this.repaint();
+		}
+		*/
 	}
 
 	/************************************************************
@@ -148,15 +153,67 @@
 	public void actionPerformed(ActionEvent e)
 	{
 		String action = e.getActionCommand();
+
 		if(action.equals("Delete"))
 		{
-			tableModel.removeRow(table.getSelectedRow());
-			tableModel.fireTableDataChanged();
+			if (tableModel.getRowCount() > 0)
+			{
+				// 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();
+				}
+
+				int rowSelected = table.getSelectedRow();
+
+				tableModel.removeRow(rowSelected);
+				tableModel.fireTableDataChanged();
+
+				// Disable the DELETE button if no rows remaining after delete
+				if (tableModel.getRowCount() == 0)
+				{
+					delete.setEnabled(false);
+				}
+
+				// Table still contains one or more rows, so highlight (select)
+				// the appropriate one. 
+				else
+				{
+					int rowToSelect = rowSelected;
+
+					if (rowSelected >= tableModel.getRowCount())
+					{
+						rowToSelect = rowSelected - 1;
+					}
+
+					table.setRowSelectionInterval(rowToSelect, rowToSelect);
+				}
+			}
 		}
 		else if(action.equals("Add"))
 		{
+			// If a table cell is being edited, we should accept the current value
+			// and stop the editing before adding a new row.
+			if (table.isEditing())
+			{
+				TableCellEditor cellEditor = table.getCellEditor(table.getEditingRow(), table.getEditingColumn());
+				cellEditor.stopCellEditing();
+			}
+
 			tableModel.addNewRow();
 			tableModel.fireTableDataChanged();
+
+			// Enabled the DELETE button if it is currently disabled.
+			if (!delete.isEnabled())
+			{
+				delete.setEnabled(true);
+			}
+
+			// Highlight (select) the appropriate row.
+			int rowToSelect = tableModel.getRowCount() - 1;
+			table.setRowSelectionInterval(rowToSelect, rowToSelect);
 		}
 	}
 
@@ -178,13 +235,22 @@
 
 		scroller.setColumnHeaderView(table.getTableHeader());
 		this.add(scroller);
+
+		// ADD button
 		add = new JButton(JMeterUtils.getResString("add"));
+		add.setMnemonic('A');
 		add.setActionCommand("Add");
+		add.addActionListener(this);
+
+		// DELETE button
 		delete = new JButton(JMeterUtils.getResString("delete"));
+		delete.setEnabled(false);  // disabled by default
+		delete.setMnemonic('D');
 		delete.setActionCommand("Delete");
-		JPanel buttonPanel = new JPanel();
-		add.addActionListener(this);
 		delete.addActionListener(this);
+
+		// Button Panel
+		JPanel buttonPanel = new JPanel();
 		buttonPanel.add(add);
 		buttonPanel.add(delete);
 		this.add(buttonPanel);
@@ -322,5 +388,4 @@
 			}
 		}
 	}
-
 }

from jmeter.

asfimport avatar asfimport commented on May 18, 2024

khammond25 (migrated from Bugzilla):
The attachment contain a fix for this bug and a fix for #767. It also
contains the following new functionality:

  1. ADD and DELETE buttons behave more user-friendly. They now select a row
    after the button is pressed.
  2. ADD and DELETE buttons now have mnemonics. After creating the first row, you
    can add/edit the remaining rows using just your keyboard (never have to move
    your mouse pointer to the next row and click).
  3. The DELETE button is set to disabled (grayed out) when there are no rows in
    the table.

from jmeter.

asfimport avatar asfimport commented on May 18, 2024

Jordi Salvat i Alabart (migrated from Bugzilla):
Marking all bugs RESOLVED before JMeter 1.8's release date as VERIFIED.
Yes, it's pretty poor QA procedure, but there's bugs here lingering since JMeter
1.6, and we need to clean up a little.

from jmeter.

asfimport avatar asfimport commented on May 18, 2024

Jordi Salvat i Alabart (migrated from Bugzilla):
Bulk-closing all bugs RESOLVED before JMeter 1.8 release date.

from jmeter.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.