KickJava   Java API By Example, From Geeks To Geeks.

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


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.BorderLayout JavaDoc;
21
22 import javax.swing.BorderFactory JavaDoc;
23 import javax.swing.JPanel JavaDoc;
24
25 import org.apache.jmeter.assertions.XPathAssertion;
26 import org.apache.jmeter.testelement.TestElement;
27 import org.apache.jmeter.util.JMeterUtils;
28 import org.apache.jorphan.gui.layout.VerticalLayout;
29
30 import org.apache.jorphan.logging.LoggingManager;
31 import org.apache.log.Logger;
32
33 /**
34  *
35  * author <a HREF="mailto:jspears@astrology.com">Justin Spears </a>
36  *
37  */

38
39 public class XPathAssertionGui extends AbstractAssertionGui
40 {
41
42     private static transient Logger log = LoggingManager.getLoggerForClass();
43     private static final String JavaDoc OPERATOR_KEY = null;
44
45     private int execState;
46     private XPathPanel xpath;
47     private XMLConfPanel xml;
48     
49     public XPathAssertionGui() {
50         init();
51     }
52
53     /**
54      * Returns the label to be shown within the JTree-Component.
55      */

56     public String JavaDoc getLabelResource()
57     {
58         return "xpath_assertion_title";
59     }
60
61     /**
62      * Create test element
63      */

64     public TestElement createTestElement()
65     {
66         XPathAssertion el = new XPathAssertion();
67         modifyTestElement(el);
68         return el;
69     }
70    
71     public String JavaDoc getXPathAttributesTitle()
72     {
73         return JMeterUtils.getResString("xpath_assertion_test");
74     }
75     
76     public void configure(TestElement el)
77     {
78         super.configure(el);
79         XPathAssertion assertion = (XPathAssertion) el;
80         xpath.setXPath(assertion.getXPathString());
81         xpath.setNegated(assertion.isNegated());
82         
83         xml.setWhitespace(assertion.isWhitespace());
84         xml.setValidate(assertion.isValidating());
85         xml.setTolerant(assertion.isTolerant());
86         xml.setNamespace(assertion.isNamespace());
87         
88     }
89
90     private void init()
91     {
92         setLayout(
93             new VerticalLayout(5, VerticalLayout.LEFT, VerticalLayout.TOP));
94         setBorder(makeBorder());
95     
96         add(makeTitlePanel());
97     
98         // USER_INPUT
99
JPanel JavaDoc sizePanel = new JPanel JavaDoc(new BorderLayout JavaDoc());
100         sizePanel.setBorder(BorderFactory.createEmptyBorder(0, 10, 10, 10));
101         sizePanel.setBorder(
102             BorderFactory.createTitledBorder(
103                 BorderFactory.createEtchedBorder(),
104                 getXPathAttributesTitle()));
105         xpath = new XPathPanel();
106         sizePanel.add(xpath);
107         
108         xml = new XMLConfPanel();
109         xpath = new XPathPanel();
110         
111         xml.setBorder(
112                 BorderFactory.createTitledBorder(
113                     BorderFactory.createEtchedBorder(),
114                     JMeterUtils.getResString("xpath_assertion_option")));
115         add(xml);
116        
117         add(sizePanel);
118     }
119
120     /**
121      * Modifies a given TestElement to mirror the data in the gui components.
122      * @see org.apache.jmeter.gui.JMeterGUIComponent#modifyTestElement(TestElement)
123      */

124     public void modifyTestElement(TestElement el)
125     {
126         super.configureTestElement(el);
127         if (el instanceof XPathAssertion ) {
128             XPathAssertion assertion = (XPathAssertion) el;
129             assertion.setValidating(xml.isValidate());
130             assertion.setWhitespace(xml.isWhitespace());
131             assertion.setTolerant(xml.isTolerant());
132             assertion.setNamespace(xml.isNamespace());
133             assertion.setNegated(xpath.isNegated());
134             assertion.setXPathString(xpath.getXPath());
135         }
136     }
137 }
138
Popular Tags