1 17 18 package org.apache.jmeter.assertions.gui; 19 20 import java.awt.event.ActionEvent ; 21 import java.awt.event.ActionListener ; 22 23 import javax.swing.JCheckBox ; 24 import javax.swing.JFrame ; 25 import javax.swing.JPanel ; 26 27 import org.apache.jmeter.util.JMeterUtils; 28 29 public class XMLConfPanel extends JPanel { 30 private JCheckBox validate, tolerant, whitespace, namespace; 31 32 35 public XMLConfPanel() { 36 super(); 37 init(); 38 } 39 42 public XMLConfPanel(boolean isDoubleBuffered) { 43 super( isDoubleBuffered); 44 init(); 45 } 46 private void init() { 47 add(getTolerant()); 48 add(getNamespace()); 49 add(getValidate()); 50 add(getWhitespace()); 51 } 52 55 public JCheckBox getNamespace() { 56 if (namespace == null) { 57 namespace = new JCheckBox (JMeterUtils.getResString("xml_namespace_button")); 58 } 59 return namespace; 60 } 61 64 public JCheckBox getTolerant() { 65 if (tolerant == null) { 66 tolerant = new JCheckBox (JMeterUtils.getResString("xml_tolerant_button")); 67 tolerant.addActionListener(new ActionListener () { 68 69 public void actionPerformed(ActionEvent e) { 70 tolerant(); 71 }}); 72 } 73 return tolerant; 74 } 75 78 public JCheckBox getValidate() { 79 if (validate == null) { 80 validate = new JCheckBox (JMeterUtils.getResString("xml_validate_button")); 81 } 82 return validate; 83 } 84 87 public JCheckBox getWhitespace() { 88 if (whitespace == null) { 89 whitespace = new JCheckBox (JMeterUtils.getResString("xml_whitespace_button")); 90 } 91 return whitespace; 92 } 93 public boolean isNamespace() { 94 return getNamespace().isSelected(); 95 } 96 public void setNamespace(boolean namespace) { 97 getNamespace().setSelected(namespace); 98 } 99 public boolean isTolerant() { 100 return getTolerant().isSelected(); 101 } 102 103 public void setTolerant(boolean tolerant) { 104 getTolerant().setSelected(tolerant); 105 } 106 107 public boolean isWhitespace() { 108 return getWhitespace().isSelected(); 109 } 110 111 public void setWhitespace(boolean whitespace) { 112 getWhitespace().setSelected(whitespace); 113 } 114 115 public boolean isValidate() { 116 return getValidate().isSelected(); 117 } 118 119 public void setValidate(boolean validating) { 120 getValidate().setSelected(validating); 121 } 122 123 private void tolerant() { 124 getValidate().setEnabled(!isTolerant()); 125 getWhitespace().setEnabled(!isTolerant()); 126 getNamespace().setEnabled(!isTolerant()); 127 } 128 public static void main(String [] args) { 129 JPanel comb = new JPanel (); 130 131 XMLConfPanel xml = new XMLConfPanel(); 132 XPathPanel xpath = new XPathPanel(); 133 JFrame frame = new JFrame (xml.getClass().getName()); 134 frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); 135 comb.add(xpath); 136 comb.add(xml); 137 frame.add(comb); 138 139 frame.pack(); 140 frame.setVisible(true); 141 142 } 143 } 144 | Popular Tags |