| 1 | |
package kg.apc.jmeter.modifiers; |
| 2 | |
|
| 3 | |
import kg.apc.jmeter.JMeterPluginsUtils; |
| 4 | |
import kg.apc.jmeter.gui.GuiBuilderHelper; |
| 5 | |
import org.apache.jmeter.processor.gui.AbstractPostProcessorGui; |
| 6 | |
import org.apache.jmeter.testelement.TestElement; |
| 7 | |
|
| 8 | |
import javax.swing.*; |
| 9 | |
import java.awt.*; |
| 10 | |
|
| 11 | |
public class FifoPutPostProcessorGui extends AbstractPostProcessorGui { |
| 12 | |
|
| 13 | |
public static final String WIKIPAGE = "InterThreadCommunication"; |
| 14 | |
private JTextField queueName; |
| 15 | |
private JTextArea value; |
| 16 | |
|
| 17 | |
public FifoPutPostProcessorGui() { |
| 18 | 6 | super(); |
| 19 | 6 | init(); |
| 20 | 6 | initFields(); |
| 21 | 6 | } |
| 22 | |
|
| 23 | |
@Override |
| 24 | |
public String getStaticLabel() { |
| 25 | 14 | return JMeterPluginsUtils.prefixLabel("Inter-Thread Communication PostProcessor"); |
| 26 | |
} |
| 27 | |
|
| 28 | |
@Override |
| 29 | |
public String getLabelResource() { |
| 30 | 1 | return getClass().getCanonicalName(); |
| 31 | |
} |
| 32 | |
|
| 33 | |
@Override |
| 34 | |
public void configure(TestElement element) { |
| 35 | 1 | super.configure(element); |
| 36 | 1 | if (element instanceof FifoPutPostProcessor) { |
| 37 | 0 | FifoPutPostProcessor el = (FifoPutPostProcessor) element; |
| 38 | 0 | queueName.setText(el.getQueueName()); |
| 39 | 0 | value.setText(el.getValue()); |
| 40 | |
} |
| 41 | 1 | } |
| 42 | |
|
| 43 | |
@Override |
| 44 | |
public TestElement createTestElement() { |
| 45 | 1 | FifoPutPostProcessor preproc = new FifoPutPostProcessor(); |
| 46 | 1 | modifyTestElement(preproc); |
| 47 | 1 | preproc.setComment(JMeterPluginsUtils.getWikiLinkText(WIKIPAGE)); |
| 48 | 1 | return preproc; |
| 49 | |
} |
| 50 | |
|
| 51 | |
@Override |
| 52 | |
public void modifyTestElement(TestElement te) { |
| 53 | 2 | configureTestElement(te); |
| 54 | 2 | if (te instanceof FifoPutPostProcessor) { |
| 55 | 2 | FifoPutPostProcessor preproc = (FifoPutPostProcessor) te; |
| 56 | 2 | preproc.setValue(value.getText()); |
| 57 | 2 | preproc.setQueueName(queueName.getText()); |
| 58 | |
} |
| 59 | 2 | } |
| 60 | |
|
| 61 | |
@Override |
| 62 | |
public void clearGui() { |
| 63 | 1 | super.clearGui(); |
| 64 | 1 | initFields(); |
| 65 | 1 | } |
| 66 | |
|
| 67 | |
private void init() { |
| 68 | 6 | setLayout(new BorderLayout(0, 5)); |
| 69 | 6 | setBorder(makeBorder()); |
| 70 | |
|
| 71 | 6 | add(JMeterPluginsUtils.addHelpLinkToPanel(makeTitlePanel(), WIKIPAGE), BorderLayout.NORTH); |
| 72 | |
|
| 73 | 6 | JPanel mainPanel = new JPanel(new GridBagLayout()); |
| 74 | |
|
| 75 | 6 | GridBagConstraints labelConstraints = new GridBagConstraints(); |
| 76 | 6 | labelConstraints.anchor = GridBagConstraints.FIRST_LINE_END; |
| 77 | |
|
| 78 | 6 | GridBagConstraints editConstraints = new GridBagConstraints(); |
| 79 | 6 | editConstraints.anchor = GridBagConstraints.FIRST_LINE_START; |
| 80 | 6 | editConstraints.weightx = 1.0; |
| 81 | 6 | editConstraints.fill = GridBagConstraints.HORIZONTAL; |
| 82 | |
|
| 83 | 6 | addToPanel(mainPanel, labelConstraints, 0, 0, new JLabel("FIFO Queue Name to Put Data Into: ", JLabel.RIGHT)); |
| 84 | 6 | addToPanel(mainPanel, editConstraints, 1, 0, queueName = new JTextField(20)); |
| 85 | |
|
| 86 | 6 | editConstraints.insets = new java.awt.Insets(4, 0, 0, 0); |
| 87 | 6 | labelConstraints.insets = new java.awt.Insets(4, 0, 0, 0); |
| 88 | |
|
| 89 | 6 | addToPanel(mainPanel, labelConstraints, 0, 6, new JLabel("Value to Put: ", JLabel.RIGHT)); |
| 90 | 6 | editConstraints.fill = GridBagConstraints.BOTH; |
| 91 | 6 | value = new JTextArea(); |
| 92 | 6 | addToPanel(mainPanel, editConstraints, 1, 6, GuiBuilderHelper.getTextAreaScrollPaneContainer(value, 10)); |
| 93 | |
|
| 94 | 6 | JPanel container = new JPanel(new BorderLayout()); |
| 95 | 6 | container.add(mainPanel, BorderLayout.NORTH); |
| 96 | 6 | add(container, BorderLayout.CENTER); |
| 97 | 6 | } |
| 98 | |
|
| 99 | |
private void addToPanel(JPanel panel, GridBagConstraints constraints, int col, int row, JComponent component) { |
| 100 | 24 | constraints.gridx = col; |
| 101 | 24 | constraints.gridy = row; |
| 102 | 24 | panel.add(component, constraints); |
| 103 | 24 | } |
| 104 | |
|
| 105 | |
private void initFields() { |
| 106 | 7 | queueName.setText("SYNC_FIFO"); |
| 107 | 7 | value.setText(""); |
| 108 | 7 | } |
| 109 | |
} |