01: /*
02: * soapUI, copyright (C) 2004-2007 eviware.com
03: *
04: * soapUI is free software; you can redistribute it and/or modify it under the
05: * terms of version 2.1 of the GNU Lesser General Public License as published by
06: * the Free Software Foundation.
07: *
08: * soapUI is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
09: * even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
10: * See the GNU Lesser General Public License for more details at gnu.org.
11: */
12:
13: package com.eviware.soapui.impl.wsdl.panels.request.components;
14:
15: import java.beans.PropertyChangeEvent;
16: import java.beans.PropertyChangeListener;
17:
18: import org.apache.xmlbeans.SchemaTypeSystem;
19: import org.apache.xmlbeans.XmlBeans;
20:
21: import com.eviware.soapui.SoapUI;
22: import com.eviware.soapui.impl.wsdl.WsdlInterface;
23: import com.eviware.soapui.impl.wsdl.WsdlRequest;
24: import com.eviware.soapui.impl.wsdl.panels.request.components.editor.support.AbstractXmlDocument;
25: import com.eviware.soapui.impl.wsdl.support.wsdl.WsdlContext;
26:
27: /**
28: * XmlDocument for a WsdlRequest
29: *
30: * @author ole.matzura
31: */
32:
33: public class RequestXmlDocument extends AbstractXmlDocument implements
34: PropertyChangeListener {
35: private final WsdlRequest request;
36: private boolean updating;
37:
38: public RequestXmlDocument(WsdlRequest request) {
39: this .request = request;
40: request.addPropertyChangeListener(WsdlRequest.REQUEST_PROPERTY,
41: this );
42: }
43:
44: public String getXml() {
45: return request.getRequestContent();
46: }
47:
48: public void setXml(String xml) {
49: request.setRequestContent(xml);
50: }
51:
52: public void propertyChange(PropertyChangeEvent evt) {
53: if (!updating)
54: fireXmlChanged((String) evt.getOldValue(), (String) evt
55: .getNewValue());
56: }
57:
58: public SchemaTypeSystem getTypeSystem() {
59: WsdlInterface iface = (WsdlInterface) request.getOperation()
60: .getInterface();
61: WsdlContext wsdlContext = iface.getWsdlContext();
62: try {
63: return wsdlContext.getSchemaTypeSystem();
64: } catch (Exception e1) {
65: SoapUI.logError(e1);
66: return XmlBeans.getBuiltinTypeSystem();
67: }
68: }
69:
70: public void release() {
71: request.removePropertyChangeListener(
72: WsdlRequest.REQUEST_PROPERTY, this);
73: }
74: }
|