View Javadoc

1   /*
2    *  soapUI, copyright (C) 2004-2010 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.SoapUI;
20  import com.eviware.soapui.settings.UISettings;
21  import com.eviware.soapui.support.UISupport;
22  import com.eviware.soapui.support.editor.views.AbstractXmlEditorView;
23  import com.eviware.soapui.support.editor.xml.XmlDocument;
24  import com.eviware.soapui.support.editor.xml.XmlEditor;
25  
26  public abstract class RawXmlEditor<T extends XmlDocument> extends AbstractXmlEditorView<T>
27  {
28  	private JTextArea textArea;
29  	private JScrollPane scrollPane;
30  
31  	public RawXmlEditor( String title, XmlEditor<T> xmlEditor, String tooltip )
32  	{
33  		super( title, xmlEditor, RawXmlEditorFactory.VIEW_ID );
34  
35  		textArea = new JTextArea();
36  		textArea.setEditable( false );
37  		textArea.setLineWrap( SoapUI.getSettings().getBoolean( UISettings.WRAP_RAW_MESSAGES ) );
38  		textArea.setToolTipText( tooltip );
39  		scrollPane = new JScrollPane( textArea );
40  		UISupport.addPreviewCorner( scrollPane, true );
41  	}
42  
43  	@Override
44  	public void setXml( String xml )
45  	{
46  		textArea.setText( getContent() );
47  		textArea.setLineWrap( SoapUI.getSettings().getBoolean( UISettings.WRAP_RAW_MESSAGES ) );
48  		textArea.setCaretPosition( 0 );
49  	}
50  
51  	public abstract String getContent();
52  
53  	public JComponent getComponent()
54  	{
55  		return scrollPane;
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  }