Source code: org/apache/jmeter/assertions/gui/XMLSchemaAssertionGUI.java
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;
21 import javax.swing.BorderFactory;
22 import javax.swing.JLabel;
23 import javax.swing.JPanel;
24 import javax.swing.JTextField;
25 // import javax.swing.event.ChangeEvent;
26 import org.apache.jmeter.assertions.XMLSchemaAssertion;
27 import org.apache.jmeter.gui.util.HorizontalPanel;
28 import org.apache.jmeter.gui.util.VerticalPanel;
29 import org.apache.jmeter.testelement.TestElement;
30 import org.apache.jmeter.util.JMeterUtils;
31 import org.apache.jorphan.logging.LoggingManager;
32 import org.apache.log.Logger;
33
34 // See Bug 34383
35
36 /**
37 * XMLSchemaAssertionGUI.java author <a href="mailto:d.maung@mdl.com">Dave Maung</a>
38 *
39 */
40
41 public class XMLSchemaAssertionGUI extends AbstractAssertionGui {
42 // class attributes
43 transient private static Logger log = LoggingManager.getLoggerForClass();
44
45 private JTextField xmlSchema;
46
47 /**
48 * The constructor.
49 */
50 public XMLSchemaAssertionGUI() {
51 init();
52 }
53
54 /**
55 * Returns the label to be shown within the JTree-Component.
56 */
57 public String getLabelResource() {
58 return "xmlschema_assertion_title";
59 }
60
61 /**
62 * create Test Element
63 */
64 public TestElement createTestElement() {
65 log.debug("XMLSchemaAssertionGui.createTestElement() called");
66 XMLSchemaAssertion el = new XMLSchemaAssertion();
67 modifyTestElement(el);
68 return el;
69 }
70
71 /**
72 * Modifies a given TestElement to mirror the data in the gui components.
73 *
74 * @see org.apache.jmeter.gui.JMeterGUIComponent#modifyTestElement(TestElement)
75 */
76 public void modifyTestElement(TestElement inElement) {
77
78 log.debug("XMLSchemaAssertionGui.modifyTestElement() called");
79 configureTestElement(inElement);
80 ((XMLSchemaAssertion) inElement).setXsdFileName(xmlSchema.getText());
81 }
82
83 /**
84 * Configures the GUI from the associated test element.
85 *
86 * @param el -
87 * the test element (should be XMLSchemaAssertion)
88 */
89 public void configure(TestElement el) {
90 super.configure(el);
91 XMLSchemaAssertion assertion = (XMLSchemaAssertion) el;
92 xmlSchema.setText(assertion.getXsdFileName());
93 }
94
95 /**
96 * Inits the GUI.
97 */
98 private void init() {
99 setLayout(new BorderLayout(0, 10));
100 setBorder(makeBorder());
101
102 add(makeTitlePanel(), BorderLayout.NORTH);
103
104 JPanel mainPanel = new JPanel(new BorderLayout());
105
106 // USER_INPUT
107 VerticalPanel assertionPanel = new VerticalPanel();
108 assertionPanel.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), "XML Schema"));
109
110 // doctype
111 HorizontalPanel xmlSchemaPanel = new HorizontalPanel();
112
113 xmlSchemaPanel.add(new JLabel(JMeterUtils.getResString("xmlschema_assertion_label")));
114
115 xmlSchema = new JTextField(26);
116 xmlSchemaPanel.add(xmlSchema);
117
118 assertionPanel.add(xmlSchemaPanel);
119
120 mainPanel.add(assertionPanel, BorderLayout.NORTH);
121 add(mainPanel, BorderLayout.CENTER);
122 }
123
124 // public void stateChanged(ChangeEvent e) {
125 // log.debug("XMLSchemaAssertionGui.stateChanged() called");
126 // }
127
128 }