View Javadoc

1   /*
2    *  soapUI, copyright (C) 2004-2007 eviware.com 
3    *
4    *  soapUI is free software; you can redistribute it and/or modify it under the 
5    *  terms of version 2.1 of the GNU Lesser General Public License as published by 
6    *  the Free Software Foundation.
7    *
8    *  soapUI is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without 
9    *  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.editor.raw;
14  
15  import javax.swing.JComponent;
16  import javax.swing.JScrollPane;
17  import javax.swing.JTextArea;
18  
19  import com.eviware.soapui.impl.wsdl.panels.request.components.editor.XmlEditor;
20  import com.eviware.soapui.impl.wsdl.panels.request.components.editor.views.AbstractEditorView;
21  import com.eviware.soapui.support.UISupport;
22  
23  public abstract class RawXmlEditor extends AbstractEditorView
24  {
25  	private JTextArea textArea;
26  	private JScrollPane scrollPane;
27  
28  	public RawXmlEditor( String title, XmlEditor xmlEditor, String tooltip )
29  	{
30  		super( title, xmlEditor );
31  		
32  		textArea = new JTextArea();
33  		textArea.setEditable( false );
34  		textArea.setToolTipText( tooltip );
35  		scrollPane = new JScrollPane( textArea );
36  		UISupport.addPreviewCorner( scrollPane, true );
37  	}
38  
39  	@Override
40  	public void setXml( String xml )
41  	{
42  		textArea.setText( xml == null ? "" : getContent() );
43  		textArea.setCaretPosition( 0 );
44  	}
45  
46  	public abstract String getContent();
47  	
48  	public JComponent getComponent()
49  	{
50  		return scrollPane;
51  	}
52  
53  	public String getViewId()
54  	{
55  		return RawXmlEditorFactory.VIEW_ID;
56  	}
57  
58  	public boolean isInspectable()
59  	{
60  		return false;
61  	}
62  
63  	public boolean saveDocument( boolean validate )
64  	{
65  		return true;
66  	}
67  
68  	public void setEditable( boolean enabled )
69  	{
70  		
71  	}
72  
73  }