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.inspectors.attachments;
14  
15  import java.beans.PropertyChangeEvent;
16  import java.beans.PropertyChangeListener;
17  
18  import javax.swing.JComponent;
19  
20  import com.eviware.soapui.impl.wsdl.AttachmentContainer;
21  import com.eviware.soapui.impl.wsdl.panels.request.components.editor.XmlLocation;
22  import com.eviware.soapui.impl.wsdl.panels.request.components.editor.inspectors.AbstractXmlInspector;
23  
24  public class AttachmentsInspector extends AbstractXmlInspector implements PropertyChangeListener
25  {
26  	private AttachmentContainer container;
27  	private AttachmentPanel attachmentsPanel;
28  
29  	public AttachmentsInspector( AttachmentContainer container)
30  	{
31  		super( "Attachments (" + container.getAttachmentCount() + ")", "Files attached to this request",
32  					true, AttachmentsInspectorFactory.INSPECTOR_ID );
33  		this.container = container;
34  		
35  		container.addAttachmentsChangeListener( this );
36  	}
37  
38  	public JComponent getComponent()
39  	{
40  		if( attachmentsPanel == null )
41  			attachmentsPanel = new AttachmentPanel( container );
42  		
43  		return attachmentsPanel;
44  	}
45  
46  	@Override
47  	public void release()
48  	{
49  		super.release();
50  		attachmentsPanel.release();
51  		container.removeAttachmentsChangeListener( this );
52  	}
53  
54  	public void locationChanged( XmlLocation location )
55  	{
56  	}
57  
58  	public void propertyChange( PropertyChangeEvent evt )
59  	{
60  		setTitle( "Attachments (" + container.getAttachmentCount() + ")");
61  	}
62  }