You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jmeter-dev@jakarta.apache.org by se...@apache.org on 2008/07/06 23:47:15 UTC
svn commit: r674351 [4/11] - in /jakarta/jmeter/trunk/src:
components/org/apache/jmeter/config/ components/org/apache/jmeter/control/
components/org/apache/jmeter/control/gui/
components/org/apache/jmeter/extractor/
components/org/apache/jmeter/extract...
Modified: jakarta/jmeter/trunk/src/components/org/apache/jmeter/modifiers/gui/CounterConfigGui.java
URL: http://svn.apache.org/viewvc/jakarta/jmeter/trunk/src/components/org/apache/jmeter/modifiers/gui/CounterConfigGui.java?rev=674351&r1=674350&r2=674351&view=diff
==============================================================================
--- jakarta/jmeter/trunk/src/components/org/apache/jmeter/modifiers/gui/CounterConfigGui.java (original)
+++ jakarta/jmeter/trunk/src/components/org/apache/jmeter/modifiers/gui/CounterConfigGui.java Sun Jul 6 14:47:12 2008
@@ -13,7 +13,7 @@
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
- *
+ *
*/
package org.apache.jmeter.modifiers.gui;
@@ -28,55 +28,55 @@
import org.apache.jorphan.gui.layout.VerticalLayout;
public class CounterConfigGui extends AbstractPreProcessorGui {
- private JLabeledTextField startField, incrField, endField, varNameField, formatField;
+ private JLabeledTextField startField, incrField, endField, varNameField, formatField;
- private JCheckBox perUserField;
+ private JCheckBox perUserField;
- public CounterConfigGui() {
- super();
- init();
- }
-
- public String getLabelResource() {
- return "counter_config_title";//$NON-NLS-1$
- }
-
- /**
- * @see org.apache.jmeter.gui.JMeterGUIComponent#createTestElement()
- */
- public TestElement createTestElement() {
- CounterConfig config = new CounterConfig();
- modifyTestElement(config);
- return config;
- }
-
- /**
- * Modifies a given TestElement to mirror the data in the gui components.
- *
- * @see org.apache.jmeter.gui.JMeterGUIComponent#modifyTestElement(TestElement)
- */
- public void modifyTestElement(TestElement c) {
- if (c instanceof CounterConfig) {
- CounterConfig config = (CounterConfig) c;
- config.setStart(startField.getText());
- // Bug 22820 if (endField.getText().length() > 0)
- {
- config.setEnd(endField.getText());
- }
- config.setIncrement(incrField.getText());
- config.setVarName(varNameField.getText());
+ public CounterConfigGui() {
+ super();
+ init();
+ }
+
+ public String getLabelResource() {
+ return "counter_config_title";//$NON-NLS-1$
+ }
+
+ /**
+ * @see org.apache.jmeter.gui.JMeterGUIComponent#createTestElement()
+ */
+ public TestElement createTestElement() {
+ CounterConfig config = new CounterConfig();
+ modifyTestElement(config);
+ return config;
+ }
+
+ /**
+ * Modifies a given TestElement to mirror the data in the gui components.
+ *
+ * @see org.apache.jmeter.gui.JMeterGUIComponent#modifyTestElement(TestElement)
+ */
+ public void modifyTestElement(TestElement c) {
+ if (c instanceof CounterConfig) {
+ CounterConfig config = (CounterConfig) c;
+ config.setStart(startField.getText());
+ // Bug 22820 if (endField.getText().length() > 0)
+ {
+ config.setEnd(endField.getText());
+ }
+ config.setIncrement(incrField.getText());
+ config.setVarName(varNameField.getText());
config.setFormat(formatField.getText());
- config.setIsPerUser(perUserField.isSelected());
- }
- super.configureTestElement(c);
- }
-
+ config.setIsPerUser(perUserField.isSelected());
+ }
+ super.configureTestElement(c);
+ }
+
/**
* Implements JMeterGUIComponent.clearGui
*/
public void clearGui() {
super.clearGui();
-
+
startField.setText(""); //$NON-NLS-1$
incrField.setText(""); //$NON-NLS-1$
endField.setText(""); //$NON-NLS-1$
@@ -85,34 +85,34 @@
perUserField.setSelected(false);
}
- public void configure(TestElement element) {
- super.configure(element);
- CounterConfig config = (CounterConfig) element;
- startField.setText(config.getStartAsString());
- endField.setText(config.getEndAsString());
- incrField.setText(config.getIncrementAsString());
+ public void configure(TestElement element) {
+ super.configure(element);
+ CounterConfig config = (CounterConfig) element;
+ startField.setText(config.getStartAsString());
+ endField.setText(config.getEndAsString());
+ incrField.setText(config.getIncrementAsString());
formatField.setText(config.getFormat());
- varNameField.setText(config.getVarName());
- perUserField.setSelected(config.isPerUser());
- }
-
- private void init() {
- setBorder(makeBorder());
- setLayout(new VerticalLayout(5, VerticalLayout.BOTH));
-
- startField = new JLabeledTextField(JMeterUtils.getResString("start"));//$NON-NLS-1$
- incrField = new JLabeledTextField(JMeterUtils.getResString("increment"));//$NON-NLS-1$
- endField = new JLabeledTextField(JMeterUtils.getResString("max"));//$NON-NLS-1$
- varNameField = new JLabeledTextField(JMeterUtils.getResString("var_name"));//$NON-NLS-1$
+ varNameField.setText(config.getVarName());
+ perUserField.setSelected(config.isPerUser());
+ }
+
+ private void init() {
+ setBorder(makeBorder());
+ setLayout(new VerticalLayout(5, VerticalLayout.BOTH));
+
+ startField = new JLabeledTextField(JMeterUtils.getResString("start"));//$NON-NLS-1$
+ incrField = new JLabeledTextField(JMeterUtils.getResString("increment"));//$NON-NLS-1$
+ endField = new JLabeledTextField(JMeterUtils.getResString("max"));//$NON-NLS-1$
+ varNameField = new JLabeledTextField(JMeterUtils.getResString("var_name"));//$NON-NLS-1$
formatField = new JLabeledTextField(JMeterUtils.getResString("format"));//$NON-NLS-1$
- perUserField = new JCheckBox(JMeterUtils.getResString("counter_per_user"));//$NON-NLS-1$
+ perUserField = new JCheckBox(JMeterUtils.getResString("counter_per_user"));//$NON-NLS-1$
- add(makeTitlePanel());
- add(startField);
- add(incrField);
- add(endField);
+ add(makeTitlePanel());
+ add(startField);
+ add(incrField);
+ add(endField);
add(formatField);
- add(varNameField);
- add(perUserField);
- }
+ add(varNameField);
+ add(perUserField);
+ }
}
Modified: jakarta/jmeter/trunk/src/components/org/apache/jmeter/modifiers/gui/UserParametersGui.java
URL: http://svn.apache.org/viewvc/jakarta/jmeter/trunk/src/components/org/apache/jmeter/modifiers/gui/UserParametersGui.java?rev=674351&r1=674350&r2=674351&view=diff
==============================================================================
--- jakarta/jmeter/trunk/src/components/org/apache/jmeter/modifiers/gui/UserParametersGui.java (original)
+++ jakarta/jmeter/trunk/src/components/org/apache/jmeter/modifiers/gui/UserParametersGui.java Sun Jul 6 14:47:12 2008
@@ -13,7 +13,7 @@
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
- *
+ *
*/
package org.apache.jmeter.modifiers.gui;
@@ -48,264 +48,264 @@
import org.apache.log.Logger;
public class UserParametersGui extends AbstractPreProcessorGui {
- private static final Logger log = LoggingManager.getLoggerForClass();
+ private static final Logger log = LoggingManager.getLoggerForClass();
- private String THREAD_COLUMNS_PREFIX = JMeterUtils.getResString("user") + "_"; // $NON-NLS-1$ $NON-NLS-2$
+ private String THREAD_COLUMNS_PREFIX = JMeterUtils.getResString("user") + "_"; // $NON-NLS-1$ $NON-NLS-2$
- private JTable paramTable;
+ private JTable paramTable;
- private PowerTableModel tableModel;
+ private PowerTableModel tableModel;
- private int numUserColumns = 1;
-
- private JButton addParameterButton, addUserButton, deleteRowButton, deleteColumnButton;
-
- private JCheckBox perIterationCheck;
-
- public UserParametersGui() {
- super();
- init();
- }
-
- public String getLabelResource() {
- return "user_parameters_title"; // $NON-NLS-1$
- }
-
- public void configure(TestElement el) {
- initTableModel();
- paramTable.setModel(tableModel);
- UserParameters params = (UserParameters) el;
- CollectionProperty names = params.getNames();
- CollectionProperty threadValues = params.getThreadLists();
- tableModel.setColumnData(0, (List) names.getObjectValue());
- PropertyIterator iter = threadValues.iterator();
- if (iter.hasNext()) {
- tableModel.setColumnData(1, (List) iter.next().getObjectValue());
- }
- int count = 2;
- while (iter.hasNext()) {
- String colName = THREAD_COLUMNS_PREFIX + count;
- tableModel.addNewColumn(colName, String.class);
- tableModel.setColumnData(count, (List) iter.next().getObjectValue());
- count++;
- }
- perIterationCheck.setSelected(params.isPerIteration());
- super.configure(el);
- }
-
- /**
- * @see org.apache.jmeter.gui.JMeterGUIComponent#createTestElement()
- */
- public TestElement createTestElement() {
- UserParameters params = new UserParameters();
- modifyTestElement(params);
- return params;
- }
-
- /**
- * Modifies a given TestElement to mirror the data in the gui components.
- *
- * @see org.apache.jmeter.gui.JMeterGUIComponent#modifyTestElement(TestElement)
- */
- public void modifyTestElement(TestElement params) {
- if (paramTable.isEditing()) {
- paramTable.getCellEditor().stopCellEditing();
- }
- ((UserParameters) params).setNames(new CollectionProperty(UserParameters.NAMES, tableModel
- .getColumnData(JMeterUtils.getResString("name")))); // $NON-NLS-1$
- CollectionProperty threadLists = new CollectionProperty(UserParameters.THREAD_VALUES, new ArrayList());
- log.debug("making threadlists from gui = " + threadLists);
- for (int x = 1; x < tableModel.getColumnCount(); x++) {
- threadLists.addItem(tableModel.getColumnData(THREAD_COLUMNS_PREFIX + x));
- log.debug("Adding column to threadlist: " + tableModel.getColumnData(THREAD_COLUMNS_PREFIX + x));
- log.debug("Threadlists now = " + threadLists);
- }
- log.debug("In the end, threadlists = " + threadLists);
- ((UserParameters) params).setThreadLists(threadLists);
- ((UserParameters) params).setPerIteration(perIterationCheck.isSelected());
- super.configureTestElement(params);
- }
+ private int numUserColumns = 1;
+
+ private JButton addParameterButton, addUserButton, deleteRowButton, deleteColumnButton;
+
+ private JCheckBox perIterationCheck;
+
+ public UserParametersGui() {
+ super();
+ init();
+ }
+
+ public String getLabelResource() {
+ return "user_parameters_title"; // $NON-NLS-1$
+ }
+
+ public void configure(TestElement el) {
+ initTableModel();
+ paramTable.setModel(tableModel);
+ UserParameters params = (UserParameters) el;
+ CollectionProperty names = params.getNames();
+ CollectionProperty threadValues = params.getThreadLists();
+ tableModel.setColumnData(0, (List) names.getObjectValue());
+ PropertyIterator iter = threadValues.iterator();
+ if (iter.hasNext()) {
+ tableModel.setColumnData(1, (List) iter.next().getObjectValue());
+ }
+ int count = 2;
+ while (iter.hasNext()) {
+ String colName = THREAD_COLUMNS_PREFIX + count;
+ tableModel.addNewColumn(colName, String.class);
+ tableModel.setColumnData(count, (List) iter.next().getObjectValue());
+ count++;
+ }
+ perIterationCheck.setSelected(params.isPerIteration());
+ super.configure(el);
+ }
+
+ /**
+ * @see org.apache.jmeter.gui.JMeterGUIComponent#createTestElement()
+ */
+ public TestElement createTestElement() {
+ UserParameters params = new UserParameters();
+ modifyTestElement(params);
+ return params;
+ }
+
+ /**
+ * Modifies a given TestElement to mirror the data in the gui components.
+ *
+ * @see org.apache.jmeter.gui.JMeterGUIComponent#modifyTestElement(TestElement)
+ */
+ public void modifyTestElement(TestElement params) {
+ if (paramTable.isEditing()) {
+ paramTable.getCellEditor().stopCellEditing();
+ }
+ ((UserParameters) params).setNames(new CollectionProperty(UserParameters.NAMES, tableModel
+ .getColumnData(JMeterUtils.getResString("name")))); // $NON-NLS-1$
+ CollectionProperty threadLists = new CollectionProperty(UserParameters.THREAD_VALUES, new ArrayList());
+ log.debug("making threadlists from gui = " + threadLists);
+ for (int x = 1; x < tableModel.getColumnCount(); x++) {
+ threadLists.addItem(tableModel.getColumnData(THREAD_COLUMNS_PREFIX + x));
+ log.debug("Adding column to threadlist: " + tableModel.getColumnData(THREAD_COLUMNS_PREFIX + x));
+ log.debug("Threadlists now = " + threadLists);
+ }
+ log.debug("In the end, threadlists = " + threadLists);
+ ((UserParameters) params).setThreadLists(threadLists);
+ ((UserParameters) params).setPerIteration(perIterationCheck.isSelected());
+ super.configureTestElement(params);
+ }
/**
* Implements JMeterGUIComponent.clearGui
*/
public void clearGui() {
super.clearGui();
-
+
initTableModel();
paramTable.setModel(tableModel);
perIterationCheck.setSelected(false);
- }
+ }
+
+ private void init() {
+ setBorder(makeBorder());
+ setLayout(new BorderLayout());
+ JPanel vertPanel = new VerticalPanel();
+ vertPanel.add(makeTitlePanel());
+
+ perIterationCheck = new JCheckBox(JMeterUtils.getResString("update_per_iter"), true); // $NON-NLS-1$
+ Box perIterationPanel = Box.createHorizontalBox();
+ perIterationPanel.add(perIterationCheck);
+ perIterationPanel.add(Box.createHorizontalGlue());
+ vertPanel.add(perIterationPanel);
+ add(vertPanel, BorderLayout.NORTH);
- private void init() {
- setBorder(makeBorder());
- setLayout(new BorderLayout());
- JPanel vertPanel = new VerticalPanel();
- vertPanel.add(makeTitlePanel());
-
- perIterationCheck = new JCheckBox(JMeterUtils.getResString("update_per_iter"), true); // $NON-NLS-1$
- Box perIterationPanel = Box.createHorizontalBox();
- perIterationPanel.add(perIterationCheck);
- perIterationPanel.add(Box.createHorizontalGlue());
- vertPanel.add(perIterationPanel);
- add(vertPanel, BorderLayout.NORTH);
-
- add(makeParameterPanel(), BorderLayout.CENTER);
- }
-
- private JPanel makeParameterPanel() {
- JLabel tableLabel = new JLabel(JMeterUtils.getResString("user_parameters_table")); // $NON-NLS-1$
- initTableModel();
- paramTable = new JTable(tableModel);
- // paramTable.setRowSelectionAllowed(true);
- // paramTable.setColumnSelectionAllowed(true);
- paramTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
- // paramTable.setCellSelectionEnabled(true);
- // paramTable.setPreferredScrollableViewportSize(new Dimension(100,
- // 70));
-
- JPanel paramPanel = new JPanel(new BorderLayout());
- paramPanel.add(tableLabel, BorderLayout.NORTH);
- JScrollPane scroll = new JScrollPane(paramTable);
- scroll.setPreferredSize(scroll.getMinimumSize());
- paramPanel.add(scroll, BorderLayout.CENTER);
- paramPanel.add(makeButtonPanel(), BorderLayout.SOUTH);
- return paramPanel;
- }
-
- protected void initTableModel() {
- tableModel = new PowerTableModel(new String[] { JMeterUtils.getResString("name"), // $NON-NLS-1$
- THREAD_COLUMNS_PREFIX + numUserColumns }, new Class[] { String.class, String.class });
- }
-
- private JPanel makeButtonPanel() {
- JPanel buttonPanel = new JPanel();
- buttonPanel.setLayout(new GridLayout(2, 2));
- addParameterButton = new JButton(JMeterUtils.getResString("add_parameter")); // $NON-NLS-1$
- addUserButton = new JButton(JMeterUtils.getResString("add_user")); // $NON-NLS-1$
- deleteRowButton = new JButton(JMeterUtils.getResString("delete_parameter")); // $NON-NLS-1$
- deleteColumnButton = new JButton(JMeterUtils.getResString("delete_user")); // $NON-NLS-1$
- buttonPanel.add(addParameterButton);
- buttonPanel.add(deleteRowButton);
- buttonPanel.add(addUserButton);
- buttonPanel.add(deleteColumnButton);
- addParameterButton.addActionListener(new AddParamAction());
- addUserButton.addActionListener(new AddUserAction());
- deleteRowButton.addActionListener(new DeleteRowAction());
- deleteColumnButton.addActionListener(new DeleteColumnAction());
- return buttonPanel;
- }
-
- private class AddParamAction implements ActionListener {
- public void actionPerformed(ActionEvent e) {
- if (paramTable.isEditing()) {
- TableCellEditor cellEditor = paramTable.getCellEditor(paramTable.getEditingRow(), paramTable
- .getEditingColumn());
- cellEditor.stopCellEditing();
- }
-
- tableModel.addNewRow();
- tableModel.fireTableDataChanged();
-
- // Enable DELETE (which may already be enabled, but it won't hurt)
- deleteRowButton.setEnabled(true);
-
- // Highlight (select) the appropriate row.
- int rowToSelect = tableModel.getRowCount() - 1;
- paramTable.setRowSelectionInterval(rowToSelect, rowToSelect);
- }
- }
-
- private class AddUserAction implements ActionListener {
- public void actionPerformed(ActionEvent e) {
-
- if (paramTable.isEditing()) {
- TableCellEditor cellEditor = paramTable.getCellEditor(paramTable.getEditingRow(), paramTable
- .getEditingColumn());
- cellEditor.stopCellEditing();
- }
-
- tableModel.addNewColumn(THREAD_COLUMNS_PREFIX + tableModel.getColumnCount(), String.class);
- tableModel.fireTableDataChanged();
-
- // Enable DELETE (which may already be enabled, but it won't hurt)
- deleteColumnButton.setEnabled(true);
-
- // Highlight (select) the appropriate row.
- int colToSelect = tableModel.getColumnCount() - 1;
- paramTable.setColumnSelectionInterval(colToSelect, colToSelect);
- }
- }
-
- private class DeleteRowAction implements ActionListener {
- public void actionPerformed(ActionEvent e) {
- if (paramTable.isEditing()) {
- TableCellEditor cellEditor = paramTable.getCellEditor(paramTable.getEditingRow(), paramTable
- .getEditingColumn());
- cellEditor.cancelCellEditing();
- }
-
- int rowSelected = paramTable.getSelectedRow();
- if (rowSelected >= 0) {
- tableModel.removeRow(rowSelected);
- tableModel.fireTableDataChanged();
-
- // Disable DELETE if there are no rows in the table to delete.
- if (tableModel.getRowCount() == 0) {
- deleteRowButton.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;
- }
-
- paramTable.setRowSelectionInterval(rowToSelect, rowToSelect);
- }
- }
- }
- }
-
- private class DeleteColumnAction implements ActionListener {
- public void actionPerformed(ActionEvent e) {
- if (paramTable.isEditing()) {
- TableCellEditor cellEditor = paramTable.getCellEditor(paramTable.getEditingRow(), paramTable
- .getEditingColumn());
- cellEditor.cancelCellEditing();
- }
-
- int colSelected = paramTable.getSelectedColumn();
- if (colSelected == 0 || colSelected == 1) {
- JOptionPane.showMessageDialog(null,
- JMeterUtils.getResString("column_delete_disallowed"), // $NON-NLS-1$
- "Error",
- JOptionPane.ERROR_MESSAGE);
- return;
- }
- if (colSelected >= 0) {
- tableModel.removeColumn(colSelected);
- tableModel.fireTableDataChanged();
-
- // Disable DELETE if there are no rows in the table to delete.
- if (tableModel.getColumnCount() == 0) {
- deleteColumnButton.setEnabled(false);
- }
-
- // Table still contains one or more rows, so highlight (select)
- // the appropriate one.
- else {
-
- if (colSelected >= tableModel.getColumnCount()) {
- colSelected = colSelected - 1;
- }
-
- paramTable.setColumnSelectionInterval(colSelected, colSelected);
- }
- }
- }
- }
+ add(makeParameterPanel(), BorderLayout.CENTER);
+ }
+
+ private JPanel makeParameterPanel() {
+ JLabel tableLabel = new JLabel(JMeterUtils.getResString("user_parameters_table")); // $NON-NLS-1$
+ initTableModel();
+ paramTable = new JTable(tableModel);
+ // paramTable.setRowSelectionAllowed(true);
+ // paramTable.setColumnSelectionAllowed(true);
+ paramTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
+ // paramTable.setCellSelectionEnabled(true);
+ // paramTable.setPreferredScrollableViewportSize(new Dimension(100,
+ // 70));
+
+ JPanel paramPanel = new JPanel(new BorderLayout());
+ paramPanel.add(tableLabel, BorderLayout.NORTH);
+ JScrollPane scroll = new JScrollPane(paramTable);
+ scroll.setPreferredSize(scroll.getMinimumSize());
+ paramPanel.add(scroll, BorderLayout.CENTER);
+ paramPanel.add(makeButtonPanel(), BorderLayout.SOUTH);
+ return paramPanel;
+ }
+
+ protected void initTableModel() {
+ tableModel = new PowerTableModel(new String[] { JMeterUtils.getResString("name"), // $NON-NLS-1$
+ THREAD_COLUMNS_PREFIX + numUserColumns }, new Class[] { String.class, String.class });
+ }
+
+ private JPanel makeButtonPanel() {
+ JPanel buttonPanel = new JPanel();
+ buttonPanel.setLayout(new GridLayout(2, 2));
+ addParameterButton = new JButton(JMeterUtils.getResString("add_parameter")); // $NON-NLS-1$
+ addUserButton = new JButton(JMeterUtils.getResString("add_user")); // $NON-NLS-1$
+ deleteRowButton = new JButton(JMeterUtils.getResString("delete_parameter")); // $NON-NLS-1$
+ deleteColumnButton = new JButton(JMeterUtils.getResString("delete_user")); // $NON-NLS-1$
+ buttonPanel.add(addParameterButton);
+ buttonPanel.add(deleteRowButton);
+ buttonPanel.add(addUserButton);
+ buttonPanel.add(deleteColumnButton);
+ addParameterButton.addActionListener(new AddParamAction());
+ addUserButton.addActionListener(new AddUserAction());
+ deleteRowButton.addActionListener(new DeleteRowAction());
+ deleteColumnButton.addActionListener(new DeleteColumnAction());
+ return buttonPanel;
+ }
+
+ private class AddParamAction implements ActionListener {
+ public void actionPerformed(ActionEvent e) {
+ if (paramTable.isEditing()) {
+ TableCellEditor cellEditor = paramTable.getCellEditor(paramTable.getEditingRow(), paramTable
+ .getEditingColumn());
+ cellEditor.stopCellEditing();
+ }
+
+ tableModel.addNewRow();
+ tableModel.fireTableDataChanged();
+
+ // Enable DELETE (which may already be enabled, but it won't hurt)
+ deleteRowButton.setEnabled(true);
+
+ // Highlight (select) the appropriate row.
+ int rowToSelect = tableModel.getRowCount() - 1;
+ paramTable.setRowSelectionInterval(rowToSelect, rowToSelect);
+ }
+ }
+
+ private class AddUserAction implements ActionListener {
+ public void actionPerformed(ActionEvent e) {
+
+ if (paramTable.isEditing()) {
+ TableCellEditor cellEditor = paramTable.getCellEditor(paramTable.getEditingRow(), paramTable
+ .getEditingColumn());
+ cellEditor.stopCellEditing();
+ }
+
+ tableModel.addNewColumn(THREAD_COLUMNS_PREFIX + tableModel.getColumnCount(), String.class);
+ tableModel.fireTableDataChanged();
+
+ // Enable DELETE (which may already be enabled, but it won't hurt)
+ deleteColumnButton.setEnabled(true);
+
+ // Highlight (select) the appropriate row.
+ int colToSelect = tableModel.getColumnCount() - 1;
+ paramTable.setColumnSelectionInterval(colToSelect, colToSelect);
+ }
+ }
+
+ private class DeleteRowAction implements ActionListener {
+ public void actionPerformed(ActionEvent e) {
+ if (paramTable.isEditing()) {
+ TableCellEditor cellEditor = paramTable.getCellEditor(paramTable.getEditingRow(), paramTable
+ .getEditingColumn());
+ cellEditor.cancelCellEditing();
+ }
+
+ int rowSelected = paramTable.getSelectedRow();
+ if (rowSelected >= 0) {
+ tableModel.removeRow(rowSelected);
+ tableModel.fireTableDataChanged();
+
+ // Disable DELETE if there are no rows in the table to delete.
+ if (tableModel.getRowCount() == 0) {
+ deleteRowButton.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;
+ }
+
+ paramTable.setRowSelectionInterval(rowToSelect, rowToSelect);
+ }
+ }
+ }
+ }
+
+ private class DeleteColumnAction implements ActionListener {
+ public void actionPerformed(ActionEvent e) {
+ if (paramTable.isEditing()) {
+ TableCellEditor cellEditor = paramTable.getCellEditor(paramTable.getEditingRow(), paramTable
+ .getEditingColumn());
+ cellEditor.cancelCellEditing();
+ }
+
+ int colSelected = paramTable.getSelectedColumn();
+ if (colSelected == 0 || colSelected == 1) {
+ JOptionPane.showMessageDialog(null,
+ JMeterUtils.getResString("column_delete_disallowed"), // $NON-NLS-1$
+ "Error",
+ JOptionPane.ERROR_MESSAGE);
+ return;
+ }
+ if (colSelected >= 0) {
+ tableModel.removeColumn(colSelected);
+ tableModel.fireTableDataChanged();
+
+ // Disable DELETE if there are no rows in the table to delete.
+ if (tableModel.getColumnCount() == 0) {
+ deleteColumnButton.setEnabled(false);
+ }
+
+ // Table still contains one or more rows, so highlight (select)
+ // the appropriate one.
+ else {
+
+ if (colSelected >= tableModel.getColumnCount()) {
+ colSelected = colSelected - 1;
+ }
+
+ paramTable.setColumnSelectionInterval(colSelected, colSelected);
+ }
+ }
+ }
+ }
}
Modified: jakarta/jmeter/trunk/src/components/org/apache/jmeter/reporters/MailerModel.java
URL: http://svn.apache.org/viewvc/jakarta/jmeter/trunk/src/components/org/apache/jmeter/reporters/MailerModel.java?rev=674351&r1=674350&r2=674351&view=diff
==============================================================================
--- jakarta/jmeter/trunk/src/components/org/apache/jmeter/reporters/MailerModel.java (original)
+++ jakarta/jmeter/trunk/src/components/org/apache/jmeter/reporters/MailerModel.java Sun Jul 6 14:47:12 2008
@@ -13,7 +13,7 @@
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
- *
+ *
*/
package org.apache.jmeter.reporters;
@@ -41,346 +41,346 @@
/**
* The model for a MailerVisualizer.
- *
+ *
*/
public class MailerModel extends AbstractTestElement implements Serializable {
- private static final Logger log = LoggingManager.getLoggerForClass();
+ private static final Logger log = LoggingManager.getLoggerForClass();
- private static final String MAIL_SMTP_HOST = "mail.smtp.host"; //$NON-NLS-1$
+ private static final String MAIL_SMTP_HOST = "mail.smtp.host"; //$NON-NLS-1$
- private long failureCount = 0;
+ private long failureCount = 0;
- private long successCount = 0;
+ private long successCount = 0;
- private boolean failureMsgSent = false;
-
- private boolean siteDown = false;
-
- private boolean successMsgSent = false;
-
- private static final String FROM_KEY = "MailerModel.fromAddress"; //$NON-NLS-1$
-
- private static final String TO_KEY = "MailerModel.addressie"; //$NON-NLS-1$
-
- private static final String HOST_KEY = "MailerModel.smtpHost"; //$NON-NLS-1$
-
- private static final String SUCCESS_SUBJECT = "MailerModel.successSubject"; //$NON-NLS-1$
-
- private static final String FAILURE_SUBJECT = "MailerModel.failureSubject"; //$NON-NLS-1$
-
- private static final String FAILURE_LIMIT_KEY = "MailerModel.failureLimit"; //$NON-NLS-1$
-
- private static final String SUCCESS_LIMIT_KEY = "MailerModel.successLimit"; //$NON-NLS-1$
-
- private static final String DEFAULT_LIMIT = "2"; //$NON-NLS-1$
-
- /** The listener for changes. */
- transient ChangeListener changeListener;
-
- /**
- * Constructs a MailerModel.
- */
- public MailerModel() {
- super();
-
- setProperty(SUCCESS_LIMIT_KEY, JMeterUtils.getPropDefault("mailer.successlimit", DEFAULT_LIMIT)); //$NON-NLS-1$
- setProperty(FAILURE_LIMIT_KEY, JMeterUtils.getPropDefault("mailer.failurelimit", DEFAULT_LIMIT)); //$NON-NLS-1$
- }
-
- public void addChangeListener(ChangeListener list) {
- changeListener = list;
- }
-
- public Object clone() {
- MailerModel m = (MailerModel) super.clone();
- m.changeListener = changeListener;
- return m;
- }
-
- /**
- * Returns wether there had been more failures than acceptable.
- *
- * @return a boolean value indicating whether the limit of acceptable
- * failures has been reached.
- */
- public synchronized boolean isFailing() {
- return (failureCount > getFailureLimit());
- }
-
- public void notifyChangeListeners() {
- if (changeListener != null) {
- changeListener.stateChanged(new ChangeEvent(this));
- }
- }
-
- /**
- * Gets a Vector of String-objects. Each String is one mail-address of the
- * addresses-String set by <code>setToAddress(str)</code>. The addresses
- * must be seperated by commas. Only String-objects containing a "@" are
- * added to the returned Vector.
- *
- * @return a Vector of String-objects wherein each String represents a
- * mail-address.
- */
- public synchronized Vector getAddressVector() {
- String theAddressie = getToAddress();
- Vector addressVector = new Vector();
-
- if (theAddressie != null) {
- String addressSep = ","; //$NON-NLS-1$
-
- StringTokenizer next = new StringTokenizer(theAddressie, addressSep);
-
- while (next.hasMoreTokens()) {
- String theToken = next.nextToken().trim();
-
- if (theToken.indexOf("@") > 0) { //$NON-NLS-1$
- addressVector.addElement(theToken);
- }
- }
- } else {
- return new Vector(0);
- }
-
- return addressVector;
- }
-
- /**
- * Adds a SampleResult. If SampleResult represents a change concerning the
- * failure/success of the sampling a message might be send to the addressies
- * according to the settings of <code>successCount</code> and
- * <code>failureCount</code>.
- *
- * @param sample
- * the SampleResult encapsulating informations about the last
- * sample.
- */
- public synchronized void add(SampleResult sample) {
-
- // -1 is the code for a failed sample.
- //
- if (!sample.isSuccessful()) {
- failureCount++;
- successCount = 0;
- } else {
- successCount++;
- }
-
- if (this.isFailing() && !siteDown && !failureMsgSent) {
- // Send the mail ...
- Vector addressVector = getAddressVector();
-
- if (addressVector.size() != 0) {
- try {
- sendMail(getFromAddress(), addressVector, getFailureSubject(), "URL Failed: "
- + sample.getSampleLabel(), getSmtpHost());
- } catch (Exception e) {
- log.error("Problem sending mail", e);
- }
- siteDown = true;
- failureMsgSent = true;
- successCount = 0;
- successMsgSent = false;
- }
- }
-
- if (siteDown && (sample.getTime() != -1) && !successMsgSent) {
- // Send the mail ...
- if (successCount > getSuccessLimit()) {
- Vector addressVector = getAddressVector();
-
- try {
- sendMail(getFromAddress(), addressVector, getSuccessSubject(), "URL Restarted: "
- + sample.getSampleLabel(), getSmtpHost());
- } catch (Exception e) {
- log.error("Problem sending mail", e);
- }
- siteDown = false;
- successMsgSent = true;
- failureCount = 0;
- failureMsgSent = false;
- }
- }
-
- if (successMsgSent && failureMsgSent) {
- clear();
- }
- notifyChangeListeners();
- }
-
- /**
- * Resets the state of this object to its default. But: This method does not
- * reset any mail-specific attributes (like sender, mail-subject...) since
- * they are independent of the sampling.
- */
- public synchronized void clear() {// TODO: should this be clearData()?
- failureCount = 0;
- successCount = 0;
- siteDown = false;
- successMsgSent = false;
- failureMsgSent = false;
- notifyChangeListeners();
- }
-
- /**
- * Returns a String-representation of this object. Returns always
- * "E-Mail-Notification". Might be enhanced in future versions to return
- * some kind of String-representation of the mail-parameters (like sender,
- * addressies, smtpHost...).
- *
- * @return A String-representation of this object.
- */
- public String toString() {
- return "E-Mail Notification";
- }
-
- /**
- * Sends a mail with the given parameters using SMTP.
- *
- * @param from
- * the sender of the mail as shown in the mail-client.
- * @param vEmails
- * all receivers of the mail. The receivers are seperated by
- * commas.
- * @param subject
- * the subject of the mail.
- * @param attText
- * the message-body.
- * @param smtpHost
- * the smtp-server used to send the mail.
- */
- public synchronized void sendMail(String from, Vector vEmails, String subject, String attText, String smtpHost)
- throws AddressException, MessagingException {
- String host = smtpHost;
- boolean debug = Boolean.valueOf(host).booleanValue();
- // InetAddress remote = InetAddress.getByName(host);
-
- InternetAddress[] address = new InternetAddress[vEmails.size()];
-
- for (int k = 0; k < vEmails.size(); k++) {
- address[k] = new InternetAddress(vEmails.elementAt(k).toString());
- }
-
- // create some properties and get the default Session
- Properties props = new Properties();
-
- props.put(MAIL_SMTP_HOST, host);
- Session session = Session.getDefaultInstance(props, null);
- // N.B. properties are only used when the default session is first
- // created
- // so check if the mail host needs to be reset...
- props = session.getProperties();
- if (!host.equalsIgnoreCase(props.getProperty(MAIL_SMTP_HOST))) {
- props.setProperty(MAIL_SMTP_HOST, host);
- }
-
- session.setDebug(debug);
-
- // create a message
- Message msg = new MimeMessage(session);
-
- msg.setFrom(new InternetAddress(from));
- msg.setRecipients(Message.RecipientType.TO, address);
- msg.setSubject(subject);
- msg.setText(attText);
- Transport.send(msg);
- }
-
- public synchronized void sendTestMail() throws AddressException, MessagingException {
- String to = getToAddress();
- String from = getFromAddress();
- String subject = "Testing mail-addresses";
- String smtpHost = getSmtpHost();
- String attText = "JMeter-Testmail" + "\n" + "To: " + to + "\n" + "From: " + from + "\n" + "Via: " + smtpHost
- + "\n" + "Fail Subject: " + getFailureSubject() + "\n" + "Success Subject: " + getSuccessSubject();
-
- log.info(attText);
-
- Vector destination = new Vector();
- destination.add(to);
-
- sendMail(from, destination, subject, attText, smtpHost);
- log.info("Test mail sent successfully!!");
- }
-
- // ////////////////////////////////////////////////////////////
- //
- // setter/getter - JavaDoc-Comments not needed...
- //
- // ////////////////////////////////////////////////////////////
-
- public void setToAddress(String str) {
- setProperty(TO_KEY, str);
- }
-
- public void setFromAddress(String str) {
- setProperty(FROM_KEY, str);
- }
-
- public void setSmtpHost(String str) {
- setProperty(HOST_KEY, str);
- }
-
- public void setFailureSubject(String str) {
- setProperty(FAILURE_SUBJECT, str);
- }
-
- public void setSuccessSubject(String str) {
- setProperty(SUCCESS_SUBJECT, str);
- }
-
- public void setSuccessLimit(String limit) {
- setProperty(SUCCESS_LIMIT_KEY, limit);
- }
-
- // private void setSuccessCount(long count)
- // {
- // this.successCount = count;
- // }
-
- public void setFailureLimit(String limit) {
- setProperty(FAILURE_LIMIT_KEY, limit);
- }
-
- // private void setFailureCount(long count)
- // {
- // this.failureCount = count;
- // }
-
- public String getToAddress() {
- return getPropertyAsString(TO_KEY);
- }
-
- public String getFromAddress() {
- return getPropertyAsString(FROM_KEY);
- }
-
- public String getSmtpHost() {
- return getPropertyAsString(HOST_KEY);
- }
-
- public String getFailureSubject() {
- return getPropertyAsString(FAILURE_SUBJECT);
- }
-
- public String getSuccessSubject() {
- return getPropertyAsString(SUCCESS_SUBJECT);
- }
-
- public long getSuccessLimit() {
- return getPropertyAsLong(SUCCESS_LIMIT_KEY);
- }
-
- public long getSuccessCount() {
- return successCount;
- }
-
- public long getFailureLimit() {
- return getPropertyAsLong(FAILURE_LIMIT_KEY);
- }
-
- public long getFailureCount() {
- return this.failureCount;
- }
+ private boolean failureMsgSent = false;
+
+ private boolean siteDown = false;
+
+ private boolean successMsgSent = false;
+
+ private static final String FROM_KEY = "MailerModel.fromAddress"; //$NON-NLS-1$
+
+ private static final String TO_KEY = "MailerModel.addressie"; //$NON-NLS-1$
+
+ private static final String HOST_KEY = "MailerModel.smtpHost"; //$NON-NLS-1$
+
+ private static final String SUCCESS_SUBJECT = "MailerModel.successSubject"; //$NON-NLS-1$
+
+ private static final String FAILURE_SUBJECT = "MailerModel.failureSubject"; //$NON-NLS-1$
+
+ private static final String FAILURE_LIMIT_KEY = "MailerModel.failureLimit"; //$NON-NLS-1$
+
+ private static final String SUCCESS_LIMIT_KEY = "MailerModel.successLimit"; //$NON-NLS-1$
+
+ private static final String DEFAULT_LIMIT = "2"; //$NON-NLS-1$
+
+ /** The listener for changes. */
+ transient ChangeListener changeListener;
+
+ /**
+ * Constructs a MailerModel.
+ */
+ public MailerModel() {
+ super();
+
+ setProperty(SUCCESS_LIMIT_KEY, JMeterUtils.getPropDefault("mailer.successlimit", DEFAULT_LIMIT)); //$NON-NLS-1$
+ setProperty(FAILURE_LIMIT_KEY, JMeterUtils.getPropDefault("mailer.failurelimit", DEFAULT_LIMIT)); //$NON-NLS-1$
+ }
+
+ public void addChangeListener(ChangeListener list) {
+ changeListener = list;
+ }
+
+ public Object clone() {
+ MailerModel m = (MailerModel) super.clone();
+ m.changeListener = changeListener;
+ return m;
+ }
+
+ /**
+ * Returns wether there had been more failures than acceptable.
+ *
+ * @return a boolean value indicating whether the limit of acceptable
+ * failures has been reached.
+ */
+ public synchronized boolean isFailing() {
+ return (failureCount > getFailureLimit());
+ }
+
+ public void notifyChangeListeners() {
+ if (changeListener != null) {
+ changeListener.stateChanged(new ChangeEvent(this));
+ }
+ }
+
+ /**
+ * Gets a Vector of String-objects. Each String is one mail-address of the
+ * addresses-String set by <code>setToAddress(str)</code>. The addresses
+ * must be seperated by commas. Only String-objects containing a "@" are
+ * added to the returned Vector.
+ *
+ * @return a Vector of String-objects wherein each String represents a
+ * mail-address.
+ */
+ public synchronized Vector getAddressVector() {
+ String theAddressie = getToAddress();
+ Vector addressVector = new Vector();
+
+ if (theAddressie != null) {
+ String addressSep = ","; //$NON-NLS-1$
+
+ StringTokenizer next = new StringTokenizer(theAddressie, addressSep);
+
+ while (next.hasMoreTokens()) {
+ String theToken = next.nextToken().trim();
+
+ if (theToken.indexOf("@") > 0) { //$NON-NLS-1$
+ addressVector.addElement(theToken);
+ }
+ }
+ } else {
+ return new Vector(0);
+ }
+
+ return addressVector;
+ }
+
+ /**
+ * Adds a SampleResult. If SampleResult represents a change concerning the
+ * failure/success of the sampling a message might be send to the addressies
+ * according to the settings of <code>successCount</code> and
+ * <code>failureCount</code>.
+ *
+ * @param sample
+ * the SampleResult encapsulating informations about the last
+ * sample.
+ */
+ public synchronized void add(SampleResult sample) {
+
+ // -1 is the code for a failed sample.
+ //
+ if (!sample.isSuccessful()) {
+ failureCount++;
+ successCount = 0;
+ } else {
+ successCount++;
+ }
+
+ if (this.isFailing() && !siteDown && !failureMsgSent) {
+ // Send the mail ...
+ Vector addressVector = getAddressVector();
+
+ if (addressVector.size() != 0) {
+ try {
+ sendMail(getFromAddress(), addressVector, getFailureSubject(), "URL Failed: "
+ + sample.getSampleLabel(), getSmtpHost());
+ } catch (Exception e) {
+ log.error("Problem sending mail", e);
+ }
+ siteDown = true;
+ failureMsgSent = true;
+ successCount = 0;
+ successMsgSent = false;
+ }
+ }
+
+ if (siteDown && (sample.getTime() != -1) && !successMsgSent) {
+ // Send the mail ...
+ if (successCount > getSuccessLimit()) {
+ Vector addressVector = getAddressVector();
+
+ try {
+ sendMail(getFromAddress(), addressVector, getSuccessSubject(), "URL Restarted: "
+ + sample.getSampleLabel(), getSmtpHost());
+ } catch (Exception e) {
+ log.error("Problem sending mail", e);
+ }
+ siteDown = false;
+ successMsgSent = true;
+ failureCount = 0;
+ failureMsgSent = false;
+ }
+ }
+
+ if (successMsgSent && failureMsgSent) {
+ clear();
+ }
+ notifyChangeListeners();
+ }
+
+ /**
+ * Resets the state of this object to its default. But: This method does not
+ * reset any mail-specific attributes (like sender, mail-subject...) since
+ * they are independent of the sampling.
+ */
+ public synchronized void clear() {// TODO: should this be clearData()?
+ failureCount = 0;
+ successCount = 0;
+ siteDown = false;
+ successMsgSent = false;
+ failureMsgSent = false;
+ notifyChangeListeners();
+ }
+
+ /**
+ * Returns a String-representation of this object. Returns always
+ * "E-Mail-Notification". Might be enhanced in future versions to return
+ * some kind of String-representation of the mail-parameters (like sender,
+ * addressies, smtpHost...).
+ *
+ * @return A String-representation of this object.
+ */
+ public String toString() {
+ return "E-Mail Notification";
+ }
+
+ /**
+ * Sends a mail with the given parameters using SMTP.
+ *
+ * @param from
+ * the sender of the mail as shown in the mail-client.
+ * @param vEmails
+ * all receivers of the mail. The receivers are seperated by
+ * commas.
+ * @param subject
+ * the subject of the mail.
+ * @param attText
+ * the message-body.
+ * @param smtpHost
+ * the smtp-server used to send the mail.
+ */
+ public synchronized void sendMail(String from, Vector vEmails, String subject, String attText, String smtpHost)
+ throws AddressException, MessagingException {
+ String host = smtpHost;
+ boolean debug = Boolean.valueOf(host).booleanValue();
+ // InetAddress remote = InetAddress.getByName(host);
+
+ InternetAddress[] address = new InternetAddress[vEmails.size()];
+
+ for (int k = 0; k < vEmails.size(); k++) {
+ address[k] = new InternetAddress(vEmails.elementAt(k).toString());
+ }
+
+ // create some properties and get the default Session
+ Properties props = new Properties();
+
+ props.put(MAIL_SMTP_HOST, host);
+ Session session = Session.getDefaultInstance(props, null);
+ // N.B. properties are only used when the default session is first
+ // created
+ // so check if the mail host needs to be reset...
+ props = session.getProperties();
+ if (!host.equalsIgnoreCase(props.getProperty(MAIL_SMTP_HOST))) {
+ props.setProperty(MAIL_SMTP_HOST, host);
+ }
+
+ session.setDebug(debug);
+
+ // create a message
+ Message msg = new MimeMessage(session);
+
+ msg.setFrom(new InternetAddress(from));
+ msg.setRecipients(Message.RecipientType.TO, address);
+ msg.setSubject(subject);
+ msg.setText(attText);
+ Transport.send(msg);
+ }
+
+ public synchronized void sendTestMail() throws AddressException, MessagingException {
+ String to = getToAddress();
+ String from = getFromAddress();
+ String subject = "Testing mail-addresses";
+ String smtpHost = getSmtpHost();
+ String attText = "JMeter-Testmail" + "\n" + "To: " + to + "\n" + "From: " + from + "\n" + "Via: " + smtpHost
+ + "\n" + "Fail Subject: " + getFailureSubject() + "\n" + "Success Subject: " + getSuccessSubject();
+
+ log.info(attText);
+
+ Vector destination = new Vector();
+ destination.add(to);
+
+ sendMail(from, destination, subject, attText, smtpHost);
+ log.info("Test mail sent successfully!!");
+ }
+
+ // ////////////////////////////////////////////////////////////
+ //
+ // setter/getter - JavaDoc-Comments not needed...
+ //
+ // ////////////////////////////////////////////////////////////
+
+ public void setToAddress(String str) {
+ setProperty(TO_KEY, str);
+ }
+
+ public void setFromAddress(String str) {
+ setProperty(FROM_KEY, str);
+ }
+
+ public void setSmtpHost(String str) {
+ setProperty(HOST_KEY, str);
+ }
+
+ public void setFailureSubject(String str) {
+ setProperty(FAILURE_SUBJECT, str);
+ }
+
+ public void setSuccessSubject(String str) {
+ setProperty(SUCCESS_SUBJECT, str);
+ }
+
+ public void setSuccessLimit(String limit) {
+ setProperty(SUCCESS_LIMIT_KEY, limit);
+ }
+
+ // private void setSuccessCount(long count)
+ // {
+ // this.successCount = count;
+ // }
+
+ public void setFailureLimit(String limit) {
+ setProperty(FAILURE_LIMIT_KEY, limit);
+ }
+
+ // private void setFailureCount(long count)
+ // {
+ // this.failureCount = count;
+ // }
+
+ public String getToAddress() {
+ return getPropertyAsString(TO_KEY);
+ }
+
+ public String getFromAddress() {
+ return getPropertyAsString(FROM_KEY);
+ }
+
+ public String getSmtpHost() {
+ return getPropertyAsString(HOST_KEY);
+ }
+
+ public String getFailureSubject() {
+ return getPropertyAsString(FAILURE_SUBJECT);
+ }
+
+ public String getSuccessSubject() {
+ return getPropertyAsString(SUCCESS_SUBJECT);
+ }
+
+ public long getSuccessLimit() {
+ return getPropertyAsLong(SUCCESS_LIMIT_KEY);
+ }
+
+ public long getSuccessCount() {
+ return successCount;
+ }
+
+ public long getFailureLimit() {
+ return getPropertyAsLong(FAILURE_LIMIT_KEY);
+ }
+
+ public long getFailureCount() {
+ return this.failureCount;
+ }
}
Modified: jakarta/jmeter/trunk/src/components/org/apache/jmeter/reporters/MailerResultCollector.java
URL: http://svn.apache.org/viewvc/jakarta/jmeter/trunk/src/components/org/apache/jmeter/reporters/MailerResultCollector.java?rev=674351&r1=674350&r2=674351&view=diff
==============================================================================
--- jakarta/jmeter/trunk/src/components/org/apache/jmeter/reporters/MailerResultCollector.java (original)
+++ jakarta/jmeter/trunk/src/components/org/apache/jmeter/reporters/MailerResultCollector.java Sun Jul 6 14:47:12 2008
@@ -13,7 +13,7 @@
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
- *
+ *
*/
package org.apache.jmeter.reporters;
@@ -29,30 +29,30 @@
* @version $Revision$
*/
public class MailerResultCollector extends ResultCollector implements Serializable {
- public static final String MAILER_MODEL = "MailerResultCollector.mailer_model"; //$NON-NLS-1$
+ public static final String MAILER_MODEL = "MailerResultCollector.mailer_model"; //$NON-NLS-1$
- public MailerResultCollector() {
- super();
- setProperty(new TestElementProperty(MAILER_MODEL, new MailerModel()));
- }
-
- public void clear() {
- super.clear();
- setProperty(new TestElementProperty(MAILER_MODEL, new MailerModel()));
- }
-
- /*
- * (non-Javadoc)
- *
- * @see SampleListener#sampleOccurred(SampleEvent)
- */
- public void sampleOccurred(SampleEvent e) {
- // TODO Auto-generated method stub
- super.sampleOccurred(e);
- getMailerModel().add(e.getResult());
- }
-
- public MailerModel getMailerModel() {
- return (MailerModel) getProperty(MAILER_MODEL).getObjectValue();
- }
+ public MailerResultCollector() {
+ super();
+ setProperty(new TestElementProperty(MAILER_MODEL, new MailerModel()));
+ }
+
+ public void clear() {
+ super.clear();
+ setProperty(new TestElementProperty(MAILER_MODEL, new MailerModel()));
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see SampleListener#sampleOccurred(SampleEvent)
+ */
+ public void sampleOccurred(SampleEvent e) {
+ // TODO Auto-generated method stub
+ super.sampleOccurred(e);
+ getMailerModel().add(e.getResult());
+ }
+
+ public MailerModel getMailerModel() {
+ return (MailerModel) getProperty(MAILER_MODEL).getObjectValue();
+ }
}
Modified: jakarta/jmeter/trunk/src/components/org/apache/jmeter/sampler/DebugSampler.java
URL: http://svn.apache.org/viewvc/jakarta/jmeter/trunk/src/components/org/apache/jmeter/sampler/DebugSampler.java?rev=674351&r1=674350&r2=674351&view=diff
==============================================================================
--- jakarta/jmeter/trunk/src/components/org/apache/jmeter/sampler/DebugSampler.java (original)
+++ jakarta/jmeter/trunk/src/components/org/apache/jmeter/sampler/DebugSampler.java Sun Jul 6 14:47:12 2008
@@ -13,7 +13,7 @@
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
- *
+ *
*/
package org.apache.jmeter.sampler;
@@ -34,94 +34,94 @@
/**
* The Debug Sampler can be used to "sample" JMeter variables, JMeter properties and System Properties.
- *
+ *
*/
public class DebugSampler extends AbstractSampler implements TestBean {
-
+
private static final long serialVersionUID = 232L;
-
- private boolean displayJMeterVariables;
-
- private boolean displayJMeterProperties;
-
- private boolean displaySystemProperties;
-
- public SampleResult sample(Entry e) {
+
+ private boolean displayJMeterVariables;
+
+ private boolean displayJMeterProperties;
+
+ private boolean displaySystemProperties;
+
+ public SampleResult sample(Entry e) {
SampleResult res = new SampleResult();
res.setSampleLabel(getName());
res.sampleStart();
StringBuffer sb = new StringBuffer(100);
StringBuffer rd = new StringBuffer(20); // for request Data
if (isDisplayJMeterVariables()){
- rd.append("JMeterVariables\n");
- sb.append("JMeterVariables:\n");
- formatSet(sb, JMeterContextService.getContext().getVariables().entrySet());
- sb.append("\n");
+ rd.append("JMeterVariables\n");
+ sb.append("JMeterVariables:\n");
+ formatSet(sb, JMeterContextService.getContext().getVariables().entrySet());
+ sb.append("\n");
}
-
+
if (isDisplayJMeterProperties()){
- rd.append("JMeterProperties\n");
- sb.append("JMeterProperties:\n");
- formatSet(sb, JMeterUtils.getJMeterProperties().entrySet());
- sb.append("\n");
+ rd.append("JMeterProperties\n");
+ sb.append("JMeterProperties:\n");
+ formatSet(sb, JMeterUtils.getJMeterProperties().entrySet());
+ sb.append("\n");
}
-
+
if (isDisplaySystemProperties()){
- rd.append("SystemProperties\n");
- sb.append("SystemProperties:\n");
- formatSet(sb, System.getProperties().entrySet());
- sb.append("\n");
+ rd.append("SystemProperties\n");
+ sb.append("SystemProperties:\n");
+ formatSet(sb, System.getProperties().entrySet());
+ sb.append("\n");
}
-
+
res.setResponseData(sb.toString().getBytes());
res.setDataType(SampleResult.TEXT);
res.setSamplerData(rd.toString());
res.setSuccessful(true);
res.sampleEnd();
return res;
- }
+ }
- private void formatSet(StringBuffer sb, Set s) {
- ArrayList al = new ArrayList(s);
- Collections.sort(al, new Comparator(){
- public int compare(Object o1, Object o2) {
- String m1,m2;
- m1=(String)((Map.Entry)o1).getKey();
- m2=(String)((Map.Entry)o2).getKey();
- return m1.compareTo(m2);
- }
- });
- Iterator i = al.iterator();
- while(i.hasNext()){
- Map.Entry me = (Map.Entry) i.next();
- sb.append(me.getKey());
- sb.append("=");
- sb.append(me.getValue());
- sb.append("\n");
- }
- }
+ private void formatSet(StringBuffer sb, Set s) {
+ ArrayList al = new ArrayList(s);
+ Collections.sort(al, new Comparator(){
+ public int compare(Object o1, Object o2) {
+ String m1,m2;
+ m1=(String)((Map.Entry)o1).getKey();
+ m2=(String)((Map.Entry)o2).getKey();
+ return m1.compareTo(m2);
+ }
+ });
+ Iterator i = al.iterator();
+ while(i.hasNext()){
+ Map.Entry me = (Map.Entry) i.next();
+ sb.append(me.getKey());
+ sb.append("=");
+ sb.append(me.getValue());
+ sb.append("\n");
+ }
+ }
public boolean isDisplayJMeterVariables() {
- return displayJMeterVariables;
- }
+ return displayJMeterVariables;
+ }
- public void setDisplayJMeterVariables(boolean displayJMeterVariables) {
- this.displayJMeterVariables = displayJMeterVariables;
- }
-
- public boolean isDisplayJMeterProperties() {
- return displayJMeterProperties;
- }
-
- public void setDisplayJMeterProperties(boolean displayJMeterPropterties) {
- this.displayJMeterProperties = displayJMeterPropterties;
- }
-
- public boolean isDisplaySystemProperties() {
- return displaySystemProperties;
- }
-
- public void setDisplaySystemProperties(boolean displaySystemProperties) {
- this.displaySystemProperties = displaySystemProperties;
- }
+ public void setDisplayJMeterVariables(boolean displayJMeterVariables) {
+ this.displayJMeterVariables = displayJMeterVariables;
+ }
+
+ public boolean isDisplayJMeterProperties() {
+ return displayJMeterProperties;
+ }
+
+ public void setDisplayJMeterProperties(boolean displayJMeterPropterties) {
+ this.displayJMeterProperties = displayJMeterPropterties;
+ }
+
+ public boolean isDisplaySystemProperties() {
+ return displaySystemProperties;
+ }
+
+ public void setDisplaySystemProperties(boolean displaySystemProperties) {
+ this.displaySystemProperties = displaySystemProperties;
+ }
}
Modified: jakarta/jmeter/trunk/src/components/org/apache/jmeter/sampler/DebugSamplerBeanInfo.java
URL: http://svn.apache.org/viewvc/jakarta/jmeter/trunk/src/components/org/apache/jmeter/sampler/DebugSamplerBeanInfo.java?rev=674351&r1=674350&r2=674351&view=diff
==============================================================================
--- jakarta/jmeter/trunk/src/components/org/apache/jmeter/sampler/DebugSamplerBeanInfo.java (original)
+++ jakarta/jmeter/trunk/src/components/org/apache/jmeter/sampler/DebugSamplerBeanInfo.java Sun Jul 6 14:47:12 2008
@@ -13,7 +13,7 @@
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
- *
+ *
*/
package org.apache.jmeter.sampler;
@@ -23,20 +23,20 @@
import org.apache.jmeter.testbeans.BeanInfoSupport;
public class DebugSamplerBeanInfo extends BeanInfoSupport {
- public DebugSamplerBeanInfo() {
- super(DebugSampler.class);
- PropertyDescriptor p;
-
- p = property("displayJMeterVariables");
- p.setValue(NOT_UNDEFINED, Boolean.TRUE);
- p.setValue(DEFAULT, Boolean.TRUE);
-
- p = property("displayJMeterProperties");
- p.setValue(NOT_UNDEFINED, Boolean.TRUE);
- p.setValue(DEFAULT, Boolean.FALSE);
-
- p = property("displaySystemProperties");
- p.setValue(NOT_UNDEFINED, Boolean.TRUE);
- p.setValue(DEFAULT, Boolean.FALSE);
+ public DebugSamplerBeanInfo() {
+ super(DebugSampler.class);
+ PropertyDescriptor p;
+
+ p = property("displayJMeterVariables");
+ p.setValue(NOT_UNDEFINED, Boolean.TRUE);
+ p.setValue(DEFAULT, Boolean.TRUE);
+
+ p = property("displayJMeterProperties");
+ p.setValue(NOT_UNDEFINED, Boolean.TRUE);
+ p.setValue(DEFAULT, Boolean.FALSE);
+
+ p = property("displaySystemProperties");
+ p.setValue(NOT_UNDEFINED, Boolean.TRUE);
+ p.setValue(DEFAULT, Boolean.FALSE);
}
}
Modified: jakarta/jmeter/trunk/src/components/org/apache/jmeter/sampler/TestAction.java
URL: http://svn.apache.org/viewvc/jakarta/jmeter/trunk/src/components/org/apache/jmeter/sampler/TestAction.java?rev=674351&r1=674350&r2=674351&view=diff
==============================================================================
--- jakarta/jmeter/trunk/src/components/org/apache/jmeter/sampler/TestAction.java (original)
+++ jakarta/jmeter/trunk/src/components/org/apache/jmeter/sampler/TestAction.java Sun Jul 6 14:47:12 2008
@@ -13,7 +13,7 @@
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
- *
+ *
*/
package org.apache.jmeter.sampler;
@@ -30,93 +30,93 @@
/**
* Dummy Sampler used to pause or stop a thread or the test;
* intended for use in Conditional Controllers.
- *
+ *
*/
public class TestAction extends AbstractSampler {
-
- private static final Logger log = LoggingManager.getLoggerForClass();
-
- // Actions
- public final static int STOP = 0;
- public final static int PAUSE = 1;
-
- // Action targets
- public final static int THREAD = 0;
- // public final static int THREAD_GROUP = 1;
- public final static int TEST = 2;
-
- // Identifiers
- private final static String TARGET = "ActionProcessor.target"; //$NON-NLS-1$
- private final static String ACTION = "ActionProcessor.action"; //$NON-NLS-1$
- private final static String DURATION = "ActionProcessor.duration"; //$NON-NLS-1$
-
- public TestAction() {
- super();
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.apache.jmeter.samplers.Sampler#sample(org.apache.jmeter.samplers.Entry)
- */
- public SampleResult sample(Entry e) {
- JMeterContext context = JMeterContextService.getContext();
- int target = getTarget();
- int action = getAction();
+ private static final Logger log = LoggingManager.getLoggerForClass();
+
+ // Actions
+ public final static int STOP = 0;
+ public final static int PAUSE = 1;
+
+ // Action targets
+ public final static int THREAD = 0;
+ // public final static int THREAD_GROUP = 1;
+ public final static int TEST = 2;
+
+ // Identifiers
+ private final static String TARGET = "ActionProcessor.target"; //$NON-NLS-1$
+ private final static String ACTION = "ActionProcessor.action"; //$NON-NLS-1$
+ private final static String DURATION = "ActionProcessor.duration"; //$NON-NLS-1$
+
+ public TestAction() {
+ super();
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.apache.jmeter.samplers.Sampler#sample(org.apache.jmeter.samplers.Entry)
+ */
+ public SampleResult sample(Entry e) {
+ JMeterContext context = JMeterContextService.getContext();
+
+ int target = getTarget();
+ int action = getAction();
if (action == PAUSE) {
pause(getDurationAsString());
} else if (action == STOP) {
- if (target == THREAD) {
+ if (target == THREAD) {
context.getThread().stop();
- }
- // Not yet implemented
- // else if (target==THREAD_GROUP)
- // {
- // }
- else if (target == TEST) {
- context.getEngine().askThreadsToStop();
- }
+ }
+ // Not yet implemented
+ // else if (target==THREAD_GROUP)
+ // {
+ // }
+ else if (target == TEST) {
+ context.getEngine().askThreadsToStop();
+ }
}
- return null; // This means no sample is saved
- }
+ return null; // This means no sample is saved
+ }
private void pause(String mili_s) {
- int milis;
- try {
- milis=Integer.parseInt(mili_s);
- } catch (NumberFormatException e){
- log.warn("Could not create number from "+mili_s);
- milis=0;
- }
+ int milis;
+ try {
+ milis=Integer.parseInt(mili_s);
+ } catch (NumberFormatException e){
+ log.warn("Could not create number from "+mili_s);
+ milis=0;
+ }
try {
Thread.sleep(milis);
} catch (InterruptedException e) {
}
}
- public void setTarget(int target) {
- setProperty(new IntegerProperty(TARGET, target));
- }
-
- public int getTarget() {
- return getPropertyAsInt(TARGET);
- }
-
- public void setAction(int action) {
- setProperty(new IntegerProperty(ACTION, action));
- }
-
- public int getAction() {
- return getPropertyAsInt(ACTION);
- }
-
- public void setDuration(String duration) {
- setProperty(new StringProperty(DURATION, duration));
- }
-
- public String getDurationAsString() {
- return getPropertyAsString(DURATION);
- }
+ public void setTarget(int target) {
+ setProperty(new IntegerProperty(TARGET, target));
+ }
+
+ public int getTarget() {
+ return getPropertyAsInt(TARGET);
+ }
+
+ public void setAction(int action) {
+ setProperty(new IntegerProperty(ACTION, action));
+ }
+
+ public int getAction() {
+ return getPropertyAsInt(ACTION);
+ }
+
+ public void setDuration(String duration) {
+ setProperty(new StringProperty(DURATION, duration));
+ }
+
+ public String getDurationAsString() {
+ return getPropertyAsString(DURATION);
+ }
}
\ No newline at end of file
Modified: jakarta/jmeter/trunk/src/components/org/apache/jmeter/sampler/gui/TestActionGui.java
URL: http://svn.apache.org/viewvc/jakarta/jmeter/trunk/src/components/org/apache/jmeter/sampler/gui/TestActionGui.java?rev=674351&r1=674350&r2=674351&view=diff
==============================================================================
--- jakarta/jmeter/trunk/src/components/org/apache/jmeter/sampler/gui/TestActionGui.java (original)
+++ jakarta/jmeter/trunk/src/components/org/apache/jmeter/sampler/gui/TestActionGui.java Sun Jul 6 14:47:12 2008
@@ -13,7 +13,7 @@
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
- *
+ *
*/
package org.apache.jmeter.sampler.gui;
@@ -40,99 +40,99 @@
import org.apache.jorphan.gui.layout.VerticalLayout;
public class TestActionGui extends AbstractSamplerGui {
- // Gui components
- private JComboBox targetBox;
+ // Gui components
+ private JComboBox targetBox;
- // private ButtonGroup actionButtons;
- private JRadioButton pauseButton;
+ // private ButtonGroup actionButtons;
+ private JRadioButton pauseButton;
- private JRadioButton stopButton;
+ private JRadioButton stopButton;
- private JTextField durationField;
-
- // State variables
- private int target;
-
- private int action;
-
- private String durationString;
-
- // String in the panel
- private static final String targetLabel = JMeterUtils.getResString("test_action_target"); // $NON-NLS-1$
-
- private static final String threadTarget = JMeterUtils.getResString("test_action_target_thread"); // $NON-NLS-1$
-
- private static final String testTarget = JMeterUtils.getResString("test_action_target_test"); // $NON-NLS-1$
-
- private static final String actionLabel = JMeterUtils.getResString("test_action_action"); // $NON-NLS-1$
-
- private static final String pauseAction = JMeterUtils.getResString("test_action_pause"); // $NON-NLS-1$
-
- private static final String stopAction = JMeterUtils.getResString("test_action_stop"); // $NON-NLS-1$
-
- private static final String durationLabel = JMeterUtils.getResString("test_action_duration"); // $NON-NLS-1$
-
- public TestActionGui() {
- super();
- target = TestAction.THREAD;
- action = TestAction.PAUSE;
- durationString = ""; // $NON-NLS-1$
- init();
- }
-
- public String getLabelResource() {
- return "test_action_title"; // $NON-NLS-1$
- }
-
- public void configure(TestElement element) {
- super.configure(element);
- TestAction ta = (TestAction) element;
-
- target = ta.getTarget();
- if (target == TestAction.THREAD) {
- targetBox.setSelectedItem(threadTarget);
- } else {
- targetBox.setSelectedItem(testTarget);
- }
- action = ta.getAction();
- if (action == TestAction.PAUSE) {
- pauseButton.setSelected(true);
- } else {
- stopButton.setSelected(true);
- }
-
- durationString = ta.getDurationAsString();
- durationField.setText(durationString);
- }
-
- /**
- * @see org.apache.jmeter.gui.JMeterGUIComponent#createTestElement()
- */
- public TestElement createTestElement() {
- TestAction ta = new TestAction();
- modifyTestElement(ta);
- return ta;
- }
-
- /**
- * Modifies a given TestElement to mirror the data in the gui components.
- *
- * @see org.apache.jmeter.gui.JMeterGUIComponent#modifyTestElement(TestElement)
- */
- public void modifyTestElement(TestElement element) {
- super.configureTestElement(element);
- TestAction ta = (TestAction) element;
- ta.setAction(action);
- ta.setTarget(target);
- ta.setDuration(durationString);
- }
+ private JTextField durationField;
+
+ // State variables
+ private int target;
+
+ private int action;
+
+ private String durationString;
+
+ // String in the panel
+ private static final String targetLabel = JMeterUtils.getResString("test_action_target"); // $NON-NLS-1$
+
+ private static final String threadTarget = JMeterUtils.getResString("test_action_target_thread"); // $NON-NLS-1$
+
+ private static final String testTarget = JMeterUtils.getResString("test_action_target_test"); // $NON-NLS-1$
+
+ private static final String actionLabel = JMeterUtils.getResString("test_action_action"); // $NON-NLS-1$
+
+ private static final String pauseAction = JMeterUtils.getResString("test_action_pause"); // $NON-NLS-1$
+
+ private static final String stopAction = JMeterUtils.getResString("test_action_stop"); // $NON-NLS-1$
+
+ private static final String durationLabel = JMeterUtils.getResString("test_action_duration"); // $NON-NLS-1$
+
+ public TestActionGui() {
+ super();
+ target = TestAction.THREAD;
+ action = TestAction.PAUSE;
+ durationString = ""; // $NON-NLS-1$
+ init();
+ }
+
+ public String getLabelResource() {
+ return "test_action_title"; // $NON-NLS-1$
+ }
+
+ public void configure(TestElement element) {
+ super.configure(element);
+ TestAction ta = (TestAction) element;
+
+ target = ta.getTarget();
+ if (target == TestAction.THREAD) {
+ targetBox.setSelectedItem(threadTarget);
+ } else {
+ targetBox.setSelectedItem(testTarget);
+ }
+ action = ta.getAction();
+ if (action == TestAction.PAUSE) {
+ pauseButton.setSelected(true);
+ } else {
+ stopButton.setSelected(true);
+ }
+
+ durationString = ta.getDurationAsString();
+ durationField.setText(durationString);
+ }
+
+ /**
+ * @see org.apache.jmeter.gui.JMeterGUIComponent#createTestElement()
+ */
+ public TestElement createTestElement() {
+ TestAction ta = new TestAction();
+ modifyTestElement(ta);
+ return ta;
+ }
+
+ /**
+ * Modifies a given TestElement to mirror the data in the gui components.
+ *
+ * @see org.apache.jmeter.gui.JMeterGUIComponent#modifyTestElement(TestElement)
+ */
+ public void modifyTestElement(TestElement element) {
+ super.configureTestElement(element);
+ TestAction ta = (TestAction) element;
+ ta.setAction(action);
+ ta.setTarget(target);
+ ta.setDuration(durationString);
+ }
/**
* Implements JMeterGUIComponent.clearGui
*/
public void clearGui() {
super.clearGui();
-
+
targetBox.setSelectedIndex(0);
durationString = ""; //$NON-NLS-1$
durationField.setText(""); //$NON-NLS-1$
@@ -140,77 +140,77 @@
stopButton.setSelected(false);
action = TestAction.PAUSE;
target = TestAction.THREAD;
-
- }
- private void init() {
- setLayout(new VerticalLayout(5, VerticalLayout.BOTH, VerticalLayout.TOP));
- setBorder(makeBorder());
- add(makeTitlePanel());
-
- // Target
- HorizontalPanel targetPanel = new HorizontalPanel();
- targetPanel.add(new JLabel(targetLabel));
- DefaultComboBoxModel targetModel = new DefaultComboBoxModel();
- targetModel.addElement(threadTarget);
- targetModel.addElement(testTarget);
- targetBox = new JComboBox(targetModel);
- targetBox.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent e) {
- if (((String) targetBox.getSelectedItem()).equals(threadTarget)) {
- target = TestAction.THREAD;
- } else {
- target = TestAction.TEST;
- }
- }
- });
- targetPanel.add(targetBox);
- add(targetPanel);
-
- // Action
- HorizontalPanel actionPanel = new HorizontalPanel();
- ButtonGroup actionButtons = new ButtonGroup();
- pauseButton = new JRadioButton(pauseAction, true);
- pauseButton.addChangeListener(new ChangeListener() {
- public void stateChanged(ChangeEvent e) {
- if (pauseButton.isSelected()) {
- action = TestAction.PAUSE;
- durationField.setEnabled(true);
- }
-
- }
- });
- stopButton = new JRadioButton(stopAction, false);
- stopButton.addChangeListener(new ChangeListener() {
- public void stateChanged(ChangeEvent e) {
- if (stopButton.isSelected()) {
- action = TestAction.STOP;
- durationField.setEnabled(false);
- }
- }
- });
- actionButtons.add(pauseButton);
- actionButtons.add(stopButton);
- actionPanel.add(new JLabel(actionLabel));
- actionPanel.add(pauseButton);
- actionPanel.add(stopButton);
- add(actionPanel);
-
- // Duration
- HorizontalPanel durationPanel = new HorizontalPanel();
- durationField = new JTextField(15);
- durationField.setText("");
- durationField.addFocusListener(new FocusListener() {
- public void focusLost(FocusEvent e) {
- durationString = durationField.getText();
- }
-
- public void focusGained(FocusEvent e) {
- }
- });
- durationPanel.add(new JLabel(durationLabel));
- durationPanel.add(durationField);
- add(durationPanel);
- }
+ }
+
+ private void init() {
+ setLayout(new VerticalLayout(5, VerticalLayout.BOTH, VerticalLayout.TOP));
+ setBorder(makeBorder());
+ add(makeTitlePanel());
+
+ // Target
+ HorizontalPanel targetPanel = new HorizontalPanel();
+ targetPanel.add(new JLabel(targetLabel));
+ DefaultComboBoxModel targetModel = new DefaultComboBoxModel();
+ targetModel.addElement(threadTarget);
+ targetModel.addElement(testTarget);
+ targetBox = new JComboBox(targetModel);
+ targetBox.addActionListener(new ActionListener() {
+ public void actionPerformed(ActionEvent e) {
+ if (((String) targetBox.getSelectedItem()).equals(threadTarget)) {
+ target = TestAction.THREAD;
+ } else {
+ target = TestAction.TEST;
+ }
+ }
+ });
+ targetPanel.add(targetBox);
+ add(targetPanel);
+
+ // Action
+ HorizontalPanel actionPanel = new HorizontalPanel();
+ ButtonGroup actionButtons = new ButtonGroup();
+ pauseButton = new JRadioButton(pauseAction, true);
+ pauseButton.addChangeListener(new ChangeListener() {
+ public void stateChanged(ChangeEvent e) {
+ if (pauseButton.isSelected()) {
+ action = TestAction.PAUSE;
+ durationField.setEnabled(true);
+ }
+
+ }
+ });
+ stopButton = new JRadioButton(stopAction, false);
+ stopButton.addChangeListener(new ChangeListener() {
+ public void stateChanged(ChangeEvent e) {
+ if (stopButton.isSelected()) {
+ action = TestAction.STOP;
+ durationField.setEnabled(false);
+ }
+ }
+ });
+ actionButtons.add(pauseButton);
+ actionButtons.add(stopButton);
+ actionPanel.add(new JLabel(actionLabel));
+ actionPanel.add(pauseButton);
+ actionPanel.add(stopButton);
+ add(actionPanel);
+
+ // Duration
+ HorizontalPanel durationPanel = new HorizontalPanel();
+ durationField = new JTextField(15);
+ durationField.setText("");
+ durationField.addFocusListener(new FocusListener() {
+ public void focusLost(FocusEvent e) {
+ durationString = durationField.getText();
+ }
+
+ public void focusGained(FocusEvent e) {
+ }
+ });
+ durationPanel.add(new JLabel(durationLabel));
+ durationPanel.add(durationField);
+ add(durationPanel);
+ }
}
Modified: jakarta/jmeter/trunk/src/components/org/apache/jmeter/timers/BeanShellTimer.java
URL: http://svn.apache.org/viewvc/jakarta/jmeter/trunk/src/components/org/apache/jmeter/timers/BeanShellTimer.java?rev=674351&r1=674350&r2=674351&view=diff
==============================================================================
--- jakarta/jmeter/trunk/src/components/org/apache/jmeter/timers/BeanShellTimer.java (original)
+++ jakarta/jmeter/trunk/src/components/org/apache/jmeter/timers/BeanShellTimer.java Sun Jul 6 14:47:12 2008
@@ -5,15 +5,15 @@
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
- *
+ *
*/
package org.apache.jmeter.timers;
@@ -30,7 +30,7 @@
public class BeanShellTimer extends BeanShellTestElement implements Cloneable, Timer, TestBean {
private static final Logger log = LoggingManager.getLoggerForClass();
-
+
private static final long serialVersionUID = 4;
// can be specified in jmeter.properties
@@ -39,18 +39,18 @@
protected String getInitFileProperty() {
return INIT_FILE;
}
-
+
/*
- * (non-Javadoc)
- *
- * @see org.apache.jmeter.timers.Timer#delay()
- */
- public long delay() {
+ * (non-Javadoc)
+ *
+ * @see org.apache.jmeter.timers.Timer#delay()
+ */
+ public long delay() {
String ret="0";
final BeanShellInterpreter bshInterpreter = getBeanShellInterpreter();
- if (bshInterpreter == null) {
- log.error("BeanShell not found");
- return 0;
+ if (bshInterpreter == null) {
+ log.error("BeanShell not found");
+ return 0;
}
JMeterContext jmctx = JMeterContextService.getContext();
JMeterVariables vars = jmctx.getVariables();
@@ -64,10 +64,10 @@
log.warn("Problem in BeanShell script "+e);
}
try {
- return Long.decode(ret).longValue();
+ return Long.decode(ret).longValue();
} catch (NumberFormatException e){
- log.warn(e.getLocalizedMessage());
- return 0;
+ log.warn(e.getLocalizedMessage());
+ return 0;
}
- }
+ }
}
Modified: jakarta/jmeter/trunk/src/components/org/apache/jmeter/timers/BeanShellTimerBeanInfo.java
URL: http://svn.apache.org/viewvc/jakarta/jmeter/trunk/src/components/org/apache/jmeter/timers/BeanShellTimerBeanInfo.java?rev=674351&r1=674350&r2=674351&view=diff
==============================================================================
--- jakarta/jmeter/trunk/src/components/org/apache/jmeter/timers/BeanShellTimerBeanInfo.java (original)
+++ jakarta/jmeter/trunk/src/components/org/apache/jmeter/timers/BeanShellTimerBeanInfo.java Sun Jul 6 14:47:12 2008
@@ -5,15 +5,15 @@
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
- *
+ *
*/
package org.apache.jmeter.timers;
@@ -22,8 +22,8 @@
public class BeanShellTimerBeanInfo extends BeanShellBeanInfoSupport {
- public BeanShellTimerBeanInfo() {
- super(BeanShellTimer.class);
- }
+ public BeanShellTimerBeanInfo() {
+ super(BeanShellTimer.class);
+ }
}
---------------------------------------------------------------------
To unsubscribe, e-mail: jmeter-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: jmeter-dev-help@jakarta.apache.org