1 18 19 20 26 package org.apache.jmeter.assertions.gui; 27 28 import java.awt.BorderLayout ; 29 30 import javax.swing.BorderFactory ; 31 import javax.swing.JLabel ; 32 import javax.swing.JPanel ; 33 import javax.swing.JTextField ; 34 35 import org.apache.jmeter.assertions.MD5HexAssertion; 36 import org.apache.jmeter.gui.util.HorizontalPanel; 37 import org.apache.jmeter.testelement.TestElement; 38 import org.apache.jmeter.util.JMeterUtils; 39 40 public class MD5HexAssertionGUI extends AbstractAssertionGui { 41 42 private JTextField md5HexInput; 43 44 public MD5HexAssertionGUI() { 45 init(); 46 } 47 48 private void init() { 49 50 setLayout(new BorderLayout (0, 10)); 51 setBorder(makeBorder()); 52 53 add(makeTitlePanel(), BorderLayout.NORTH); 54 55 JPanel mainPanel = new JPanel (new BorderLayout ()); 56 57 HorizontalPanel md5HexPanel = new HorizontalPanel(); 59 md5HexPanel.setBorder( 60 BorderFactory.createTitledBorder( 61 BorderFactory.createEtchedBorder(), 62 JMeterUtils.getResString("md5hex_assertion_md5hex_test"))); 63 64 md5HexPanel.add( 65 new JLabel (JMeterUtils.getResString("md5hex_assertion_label"))); 66 67 md5HexInput = new JTextField (25); 68 md5HexPanel.add(md5HexInput); 70 71 mainPanel.add(md5HexPanel, BorderLayout.NORTH); 72 add(mainPanel, BorderLayout.CENTER); 73 74 } 75 76 public void configure(TestElement el) { 77 super.configure(el); 78 MD5HexAssertion assertion = (MD5HexAssertion)el; 79 this.md5HexInput.setText(String.valueOf(assertion.getAllowedMD5Hex())); 80 } 81 82 public String getLabelResource() { 83 return "md5hex_assertion_title"; 84 } 85 86 89 public TestElement createTestElement() { 90 91 MD5HexAssertion el = new MD5HexAssertion(); 92 modifyTestElement(el); 93 return el; 94 95 } 96 97 100 public void modifyTestElement(TestElement element) { 101 configureTestElement(element); 102 String md5HexString = this.md5HexInput.getText(); 103 if (md5HexString == null || md5HexString.length() == 0) { 105 md5HexString = ""; 106 } 107 ((MD5HexAssertion)element).setAllowedMD5Hex(md5HexString); 108 } 109 } 110 | Popular Tags |