001: /*
002: * Licensed to the Apache Software Foundation (ASF) under one or more
003: * contributor license agreements. See the NOTICE file distributed with
004: * this work for additional information regarding copyright ownership.
005: * The ASF licenses this file to You under the Apache License, Version 2.0
006: * (the "License"); you may not use this file except in compliance with
007: * the License. You may obtain a copy of the License at
008: *
009: * http://www.apache.org/licenses/LICENSE-2.0
010: *
011: * Unless required by applicable law or agreed to in writing, software
012: * distributed under the License is distributed on an "AS IS" BASIS,
013: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014: * See the License for the specific language governing permissions and
015: * limitations under the License.
016: *
017: */
018:
019: package org.apache.jmeter.assertions.gui;
020:
021: import java.awt.event.ActionEvent;
022: import java.awt.event.ActionListener;
023:
024: import javax.swing.JCheckBox;
025: import javax.swing.JFrame;
026: import javax.swing.JPanel;
027:
028: import org.apache.jmeter.util.JMeterUtils;
029:
030: public class XMLConfPanel extends JPanel {
031: private JCheckBox validate, tolerant, whitespace, namespace;
032:
033: /**
034: *
035: */
036: public XMLConfPanel() {
037: super ();
038: init();
039: }
040:
041: /**
042: * @param isDoubleBuffered
043: */
044: public XMLConfPanel(boolean isDoubleBuffered) {
045: super (isDoubleBuffered);
046: init();
047: }
048:
049: private void init() {
050: add(getTolerant());
051: add(getNamespace());
052: add(getValidate());
053: add(getWhitespace());
054: setDefaultValues();
055: }
056:
057: public void setDefaultValues() {
058: setWhitespace(false);
059: setValidate(false);
060: setTolerant(false);
061: setNamespace(false);
062: }
063:
064: /**
065: * @return Returns the namespace.
066: */
067: public JCheckBox getNamespace() {
068: if (namespace == null) {
069: namespace = new JCheckBox(JMeterUtils
070: .getResString("xml_namespace_button")); //$NON-NLS-1$
071: }
072: return namespace;
073: }
074:
075: /**
076: * @return Returns the tolerant.
077: */
078: public JCheckBox getTolerant() {
079: if (tolerant == null) {
080: tolerant = new JCheckBox(JMeterUtils
081: .getResString("xml_tolerant_button")); //$NON-NLS-1$
082: tolerant.addActionListener(new ActionListener() {
083:
084: public void actionPerformed(ActionEvent e) {
085: tolerant();
086: }
087: });
088: }
089: return tolerant;
090: }
091:
092: /**
093: * @return Returns the validate.
094: */
095: public JCheckBox getValidate() {
096: if (validate == null) {
097: validate = new JCheckBox(JMeterUtils
098: .getResString("xml_validate_button")); //$NON-NLS-1$
099: }
100: return validate;
101: }
102:
103: /**
104: * @return Returns the whitespace.
105: */
106: public JCheckBox getWhitespace() {
107: if (whitespace == null) {
108: whitespace = new JCheckBox(JMeterUtils
109: .getResString("xml_whitespace_button")); //$NON-NLS-1$
110: }
111: return whitespace;
112: }
113:
114: public boolean isNamespace() {
115: return getNamespace().isSelected();
116: }
117:
118: public void setNamespace(boolean namespace) {
119: getNamespace().setSelected(namespace);
120: }
121:
122: public boolean isTolerant() {
123: return getTolerant().isSelected();
124: }
125:
126: public void setTolerant(boolean tolerant) {
127: getTolerant().setSelected(tolerant);
128: }
129:
130: public boolean isWhitespace() {
131: return getWhitespace().isSelected();
132: }
133:
134: public void setWhitespace(boolean whitespace) {
135: getWhitespace().setSelected(whitespace);
136: }
137:
138: public boolean isValidate() {
139: return getValidate().isSelected();
140: }
141:
142: public void setValidate(boolean validating) {
143: getValidate().setSelected(validating);
144: }
145:
146: private void tolerant() {
147: getValidate().setEnabled(!isTolerant());
148: getWhitespace().setEnabled(!isTolerant());
149: getNamespace().setEnabled(!isTolerant());
150: }
151:
152: public static void main(String[] args) {
153: JPanel comb = new JPanel();
154:
155: XMLConfPanel xml = new XMLConfPanel();
156: XPathPanel xpath = new XPathPanel();
157: JFrame frame = new JFrame(xml.getClass().getName());
158: frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
159: comb.add(xpath);
160: comb.add(xml);
161: frame.add(comb);
162:
163: frame.pack();
164: frame.setVisible(true);
165:
166: }
167: }
|