Author: sebb Date: Tue Nov 11 17:23:28 2008 New Revision: 713239 URL: http://svn.apache.org/viewvc?rev=713239&view=rev Log: Enhance PowerTableModel to support header resource names; use this to fix locale changes in Proxy, Response Assertion, Cookie Manager
Modified: jakarta/jmeter/trunk/src/components/org/apache/jmeter/assertions/gui/AssertionGui.java jakarta/jmeter/trunk/src/core/org/apache/jmeter/gui/util/PowerTableModel.java jakarta/jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/gui/CookiePanel.java jakarta/jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/proxy/gui/ProxyControlGui.java jakarta/jmeter/trunk/xdocs/changes.xml Modified: jakarta/jmeter/trunk/src/components/org/apache/jmeter/assertions/gui/AssertionGui.java URL: http://svn.apache.org/viewvc/jakarta/jmeter/trunk/src/components/org/apache/jmeter/assertions/gui/AssertionGui.java?rev=713239&r1=713238&r2=713239&view=diff ============================================================================== --- jakarta/jmeter/trunk/src/components/org/apache/jmeter/assertions/gui/AssertionGui.java (original) +++ jakarta/jmeter/trunk/src/components/org/apache/jmeter/assertions/gui/AssertionGui.java Tue Nov 11 17:23:28 2008 @@ -47,7 +47,8 @@ */ public class AssertionGui extends AbstractAssertionGui { /** The name of the table column in the list of patterns. */ - private static final String COL_NAME = JMeterUtils.getResString("assertion_patterns_to_test"); //$NON-NLS-1$ + + private static final String COL_RESOURCE_NAME = "assertion_patterns_to_test"; //$NON-NLS-1$ /** Radio button indicating that the text response should be tested. */ private JRadioButton responseStringButton; @@ -137,7 +138,7 @@ saveScopeSettings(ra); ra.clearTestStrings(); - String[] testStrings = tableModel.getData().getColumn(COL_NAME); + String[] testStrings = tableModel.getData().getColumn(COL_RESOURCE_NAME); for (int i = 0; i < testStrings.length; i++) { ra.addTestString(testStrings[i]); } @@ -345,7 +346,7 @@ * @return a new panel for adding string patterns */ private JPanel createStringPanel() { - tableModel = new PowerTableModel(new String[] { COL_NAME }, new Class[] { String.class }); + tableModel = new PowerTableModel(new String[] { COL_RESOURCE_NAME }, new Class[] { String.class }, true); stringTable = new JTable(tableModel); TextAreaCellRenderer renderer = new TextAreaCellRenderer(); Modified: jakarta/jmeter/trunk/src/core/org/apache/jmeter/gui/util/PowerTableModel.java URL: http://svn.apache.org/viewvc/jakarta/jmeter/trunk/src/core/org/apache/jmeter/gui/util/PowerTableModel.java?rev=713239&r1=713238&r2=713239&view=diff ============================================================================== --- jakarta/jmeter/trunk/src/core/org/apache/jmeter/gui/util/PowerTableModel.java (original) +++ jakarta/jmeter/trunk/src/core/org/apache/jmeter/gui/util/PowerTableModel.java Tue Nov 11 17:23:28 2008 @@ -24,6 +24,7 @@ import javax.swing.table.DefaultTableModel; +import org.apache.jmeter.util.JMeterUtils; import org.apache.jorphan.collections.Data; import org.apache.jorphan.logging.LoggingManager; import org.apache.log.Logger; @@ -31,19 +32,39 @@ public class PowerTableModel extends DefaultTableModel { private static final Logger log = LoggingManager.getLoggerForClass(); - Data model = new Data(); + private Data model = new Data(); - Class[] columnClasses; + private Class[] columnClasses; - public PowerTableModel(String[] headers, Class[] cc) { - if (headers.length != cc.length){ - throw new IllegalArgumentException("Header and column array sizes differ"); - } - model.setHeaders(headers); - columnClasses = cc; + private final boolean headersAreResouceNames; + + /** + * Define a table with fixed headers. + * + * @param headers list of header names + * @param columnClasses list of column classes + */ + public PowerTableModel(String[] headers, Class[] columnClasses) { + this(headers, columnClasses, false); } - public PowerTableModel() { + /** + * Define a table with header names that can be locale-sensitive. + * If the useAsResourceNames parameter is true, then the header + * values are assumed to be resource names when generating the column headings. + * The column names in the data table are not translated. + * + * @param headers list of header names + * @param columnClasses list of column classes + * @param useAsResourceNames set true to use the headers as resource names + */ + public PowerTableModel(String[] headers, Class[] columnClasses, boolean useAsResourceNames) { + if (headers.length != columnClasses.length){ + throw new IllegalArgumentException("Header and column array sizes differ"); + } + this.model.setHeaders(headers); + this.columnClasses = columnClasses; + this.headersAreResouceNames = useAsResourceNames; } public void setRowValues(int row, Object[] values) { @@ -237,7 +258,11 @@ * @return the ColumnName value */ public String getColumnName(int column) { - return model.getHeaders()[column]; + String rawName = model.getHeaders()[column]; + if (headersAreResouceNames){ + return JMeterUtils.getResString(rawName); + } + return rawName; } public boolean isCellEditable(int row, int column) { Modified: jakarta/jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/gui/CookiePanel.java URL: http://svn.apache.org/viewvc/jakarta/jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/gui/CookiePanel.java?rev=713239&r1=713238&r2=713239&view=diff ============================================================================== --- jakarta/jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/gui/CookiePanel.java (original) +++ jakarta/jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/gui/CookiePanel.java Tue Nov 11 17:23:28 2008 @@ -59,6 +59,7 @@ private static final Logger log = LoggingManager.getLoggerForClass(); + //++ Action command names private static final String ADD_COMMAND = "Add"; //$NON-NLS-1$ private static final String DELETE_COMMAND = "Delete"; //$NON-NLS-1$ @@ -66,6 +67,7 @@ private static final String LOAD_COMMAND = "Load"; //$NON-NLS-1$ private static final String SAVE_COMMAND = "Save"; //$NON-NLS-1$ + //-- private JTable cookieTable; @@ -73,14 +75,12 @@ private JCheckBox clearEachIteration; - private static final String clearEachIterationLabel = "clear_cookies_per_iter"; //$NON-NLS-1$ - - private static final String[] columnNames = { - JMeterUtils.getResString("name"), //$NON-NLS-1$ - JMeterUtils.getResString("value"), //$NON-NLS-1$ - JMeterUtils.getResString("domain"), //$NON-NLS-1$ - JMeterUtils.getResString("path"), //$NON-NLS-1$ - JMeterUtils.getResString("secure"), //$NON-NLS-1$ + private static final String[] COLUMN_RESOURCE_NAMES = { + ("name"), //$NON-NLS-1$ + ("value"), //$NON-NLS-1$ + ("domain"), //$NON-NLS-1$ + ("path"), //$NON-NLS-1$ + ("secure"), //$NON-NLS-1$ // removed expiration because it's just an annoyance for static cookies }; @@ -292,8 +292,9 @@ * Shows the main cookie configuration panel. */ private void init() { - tableModel = new PowerTableModel(columnNames, columnClasses); - clearEachIteration = new JCheckBox(JMeterUtils.getResString(clearEachIterationLabel), false); + tableModel = new PowerTableModel(COLUMN_RESOURCE_NAMES, columnClasses, true); + clearEachIteration = + new JCheckBox(JMeterUtils.getResString("clear_cookies_per_iter"), false); //$NON-NLS-1$ policy = new JLabeledChoice( JMeterUtils.getResString("cookie_manager_policy"), //$NON-NLS-1$ policies); Modified: jakarta/jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/proxy/gui/ProxyControlGui.java URL: http://svn.apache.org/viewvc/jakarta/jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/proxy/gui/ProxyControlGui.java?rev=713239&r1=713238&r2=713239&view=diff ============================================================================== --- jakarta/jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/proxy/gui/ProxyControlGui.java (original) +++ jakarta/jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/proxy/gui/ProxyControlGui.java Tue Nov 11 17:23:28 2008 @@ -178,9 +178,10 @@ private static final String DELETE_EXCLUDE = "delete_exclude"; // $NON-NLS-1$ //- action names - private static final String INCLUDE_COL = JMeterUtils.getResString("patterns_to_include"); // $NON-NLS-1$ + // Resource names for column headers + private static final String INCLUDE_COL = "patterns_to_include"; // $NON-NLS-1$ - private static final String EXCLUDE_COL = JMeterUtils.getResString("patterns_to_exclude"); // $NON-NLS-1$ + private static final String EXCLUDE_COL = "patterns_to_exclude"; // $NON-NLS-1$ // Used by itemListener private static final String PORTFIELD = "portField"; // $NON-NLS-1$ @@ -690,7 +691,7 @@ } private JPanel createIncludePanel() { - includeModel = new PowerTableModel(new String[] { INCLUDE_COL }, new Class[] { String.class }); + includeModel = new PowerTableModel(new String[] { INCLUDE_COL }, new Class[] { String.class }, true); includeTable = new JTable(includeModel); includeTable.setPreferredScrollableViewportSize(new Dimension(100, 30)); @@ -705,7 +706,7 @@ } private JPanel createExcludePanel() { - excludeModel = new PowerTableModel(new String[] { EXCLUDE_COL }, new Class[] { String.class }); + excludeModel = new PowerTableModel(new String[] { EXCLUDE_COL }, new Class[] { String.class }, true); excludeTable = new JTable(excludeModel); excludeTable.setPreferredScrollableViewportSize(new Dimension(100, 30)); Modified: jakarta/jmeter/trunk/xdocs/changes.xml URL: http://svn.apache.org/viewvc/jakarta/jmeter/trunk/xdocs/changes.xml?rev=713239&r1=713238&r2=713239&view=diff ============================================================================== --- jakarta/jmeter/trunk/xdocs/changes.xml (original) +++ jakarta/jmeter/trunk/xdocs/changes.xml Tue Nov 11 17:23:28 2008 @@ -164,6 +164,7 @@ <li>Bug 44941 - Throughput controllers should not share global counters</li> <li>Various ReceiveSubscriber thread-safety fixes</li> <li>JMSPublisher and Subscriber fixes: thread-safety, support dynamic locale changes, locale independence for JMX attribute values</li> +<li>Enhance PowerTableModel to support header resource names; use this to fix locale changes in Proxy, Response Assertion, Cookie Manager</li> </ul> <h3>Improvements</h3> --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]