KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > jmeter > assertions > gui > XMLConfPanel


1 /*
2  * Copyright 2005 The Apache Software Foundation.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16  */

17
18 package org.apache.jmeter.assertions.gui;
19
20 import java.awt.event.ActionEvent JavaDoc;
21 import java.awt.event.ActionListener JavaDoc;
22
23 import javax.swing.JCheckBox JavaDoc;
24 import javax.swing.JFrame JavaDoc;
25 import javax.swing.JPanel JavaDoc;
26
27 import org.apache.jmeter.util.JMeterUtils;
28
29 public class XMLConfPanel extends JPanel JavaDoc {
30     private JCheckBox JavaDoc validate, tolerant, whitespace, namespace;
31
32     /**
33      *
34      */

35     public XMLConfPanel() {
36         super();
37         init();
38     }
39     /**
40      * @param isDoubleBuffered
41      */

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     /**
53      * @return Returns the namespace.
54      */

55     public JCheckBox JavaDoc getNamespace() {
56         if (namespace == null) {
57             namespace = new JCheckBox JavaDoc(JMeterUtils.getResString("xml_namespace_button"));
58         }
59         return namespace;
60     }
61     /**
62      * @return Returns the tolerant.
63      */

64     public JCheckBox JavaDoc getTolerant() {
65         if (tolerant == null) {
66             tolerant = new JCheckBox JavaDoc(JMeterUtils.getResString("xml_tolerant_button"));
67             tolerant.addActionListener(new ActionListener JavaDoc() {
68
69                 public void actionPerformed(ActionEvent JavaDoc e) {
70                     tolerant();
71                 }});
72         }
73         return tolerant;
74     }
75     /**
76      * @return Returns the validate.
77      */

78     public JCheckBox JavaDoc getValidate() {
79         if (validate == null) {
80             validate = new JCheckBox JavaDoc(JMeterUtils.getResString("xml_validate_button"));
81         }
82         return validate;
83     }
84     /**
85      * @return Returns the whitespace.
86      */

87     public JCheckBox JavaDoc getWhitespace() {
88         if (whitespace == null) {
89             whitespace = new JCheckBox JavaDoc(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 JavaDoc[] args) {
129         JPanel JavaDoc comb = new JPanel JavaDoc();
130         
131         XMLConfPanel xml = new XMLConfPanel();
132         XPathPanel xpath = new XPathPanel();
133         JFrame JavaDoc frame = new JFrame JavaDoc(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