View Javadoc

1   /*
2    *  soapUI, copyright (C) 2004-2008 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.support.editor.views.xml.raw;
14  
15  import javax.swing.JComponent;
16  import javax.swing.JScrollPane;
17  import javax.swing.JTextArea;
18  
19  import com.eviware.soapui.support.UISupport;
20  import com.eviware.soapui.support.editor.views.AbstractXmlEditorView;
21  import com.eviware.soapui.support.editor.xml.XmlDocument;
22  import com.eviware.soapui.support.editor.xml.XmlEditor;
23  
24  public abstract class RawXmlEditor<T extends XmlDocument> extends AbstractXmlEditorView<T>
25  {
26  	private JTextArea textArea;
27  	private JScrollPane scrollPane;
28  
29  	public RawXmlEditor( String title, XmlEditor<T> xmlEditor, String tooltip )
30  	{
31  		super( title, xmlEditor, RawXmlEditorFactory.VIEW_ID );
32  		
33  		textArea = new JTextArea();
34  		textArea.setEditable( false );
35  		textArea.setToolTipText( tooltip );
36  		scrollPane = new JScrollPane( textArea );
37  		UISupport.addPreviewCorner( scrollPane, true );
38  	}
39  
40  	@Override
41  	public void setXml( String xml )
42  	{
43  		textArea.setText( xml == null ? "" : getContent() );
44  		textArea.setCaretPosition( 0 );
45  	}
46  
47  	public abstract String getContent();
48  	
49  	public JComponent getComponent()
50  	{
51  		return scrollPane;
52  	}
53  
54  	public boolean isInspectable()
55  	{
56  		return false;
57  	}
58  
59  	public boolean saveDocument( boolean validate )
60  	{
61  		return true;
62  	}
63  
64  	public void setEditable( boolean enabled )
65  	{
66  		
67  	}
68  
69  }