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.BorderLayout;
022: import javax.swing.BorderFactory;
023: import javax.swing.JLabel;
024: import javax.swing.JPanel;
025: import javax.swing.JTextField; // import javax.swing.event.ChangeEvent;
026: import org.apache.jmeter.assertions.XMLSchemaAssertion;
027: import org.apache.jmeter.gui.util.HorizontalPanel;
028: import org.apache.jmeter.gui.util.VerticalPanel;
029: import org.apache.jmeter.testelement.TestElement;
030: import org.apache.jmeter.util.JMeterUtils;
031: import org.apache.jorphan.logging.LoggingManager;
032: import org.apache.log.Logger;
033:
034: // See Bug 34383
035:
036: /**
037: * XMLSchemaAssertionGUI.java author <a href="mailto:d.maung@mdl.com">Dave Maung</a>
038: *
039: */
040:
041: public class XMLSchemaAssertionGUI extends AbstractAssertionGui {
042: // class attributes
043: private static final Logger log = LoggingManager
044: .getLoggerForClass();
045:
046: private JTextField xmlSchema;
047:
048: /**
049: * The constructor.
050: */
051: public XMLSchemaAssertionGUI() {
052: init();
053: }
054:
055: /**
056: * Returns the label to be shown within the JTree-Component.
057: */
058: public String getLabelResource() {
059: return "xmlschema_assertion_title"; //$NON-NLS-1$
060: }
061:
062: /**
063: * create Test Element
064: */
065: public TestElement createTestElement() {
066: log.debug("XMLSchemaAssertionGui.createTestElement() called");
067: XMLSchemaAssertion el = new XMLSchemaAssertion();
068: modifyTestElement(el);
069: return el;
070: }
071:
072: /**
073: * Modifies a given TestElement to mirror the data in the gui components.
074: *
075: * @see org.apache.jmeter.gui.JMeterGUIComponent#modifyTestElement(TestElement)
076: */
077: public void modifyTestElement(TestElement inElement) {
078:
079: log.debug("XMLSchemaAssertionGui.modifyTestElement() called");
080: configureTestElement(inElement);
081: ((XMLSchemaAssertion) inElement).setXsdFileName(xmlSchema
082: .getText());
083: }
084:
085: /**
086: * Implements JMeterGUIComponent.clearGui
087: */
088: public void clearGui() {
089: super .clearGui();
090:
091: xmlSchema.setText(""); //$NON-NLS-1$
092: }
093:
094: /**
095: * Configures the GUI from the associated test element.
096: *
097: * @param el -
098: * the test element (should be XMLSchemaAssertion)
099: */
100: public void configure(TestElement el) {
101: super .configure(el);
102: XMLSchemaAssertion assertion = (XMLSchemaAssertion) el;
103: xmlSchema.setText(assertion.getXsdFileName());
104: }
105:
106: /**
107: * Inits the GUI.
108: */
109: private void init() {
110: setLayout(new BorderLayout(0, 10));
111: setBorder(makeBorder());
112:
113: add(makeTitlePanel(), BorderLayout.NORTH);
114:
115: JPanel mainPanel = new JPanel(new BorderLayout());
116:
117: // USER_INPUT
118: VerticalPanel assertionPanel = new VerticalPanel();
119: assertionPanel.setBorder(BorderFactory.createTitledBorder(
120: BorderFactory.createEtchedBorder(), "XML Schema"));
121:
122: // doctype
123: HorizontalPanel xmlSchemaPanel = new HorizontalPanel();
124:
125: xmlSchemaPanel.add(new JLabel(JMeterUtils
126: .getResString("xmlschema_assertion_label"))); //$NON-NLS-1$
127:
128: xmlSchema = new JTextField(26);
129: xmlSchemaPanel.add(xmlSchema);
130:
131: assertionPanel.add(xmlSchemaPanel);
132:
133: mainPanel.add(assertionPanel, BorderLayout.NORTH);
134: add(mainPanel, BorderLayout.CENTER);
135: }
136:
137: // public void stateChanged(ChangeEvent e) {
138: // log.debug("XMLSchemaAssertionGui.stateChanged() called");
139: // }
140:
141: }
|