1
2
3
4
5
6
7
8
9
10
11
12
13 package com.eviware.soapui.support.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.support.editor.EditorView;
22 import com.eviware.soapui.support.editor.inspectors.AbstractXmlInspector;
23 import com.eviware.soapui.support.editor.views.xml.raw.RawXmlEditorFactory;
24 import com.eviware.soapui.support.editor.xml.XmlDocument;
25
26 public class AttachmentsInspector extends AbstractXmlInspector implements PropertyChangeListener
27 {
28 private AttachmentContainer container;
29 private AttachmentsPanel attachmentsPanel;
30
31 public AttachmentsInspector( AttachmentContainer container )
32 {
33 super( "Attachments (" + container.getAttachmentCount() + ")", "Files attached to this message", true,
34 AttachmentsInspectorFactory.INSPECTOR_ID );
35 this.container = container;
36
37 container.addAttachmentsChangeListener( this );
38 }
39
40 public JComponent getComponent()
41 {
42 if( attachmentsPanel == null )
43 {
44 attachmentsPanel = new AttachmentsPanel( container );
45 }
46
47 return attachmentsPanel;
48 }
49
50 @Override
51 public void release()
52 {
53 super.release();
54 attachmentsPanel.release();
55 container.removeAttachmentsChangeListener( this );
56 }
57
58 public void propertyChange( PropertyChangeEvent evt )
59 {
60 setTitle( "Attachments (" + container.getAttachmentCount() + ")" );
61 }
62
63 @Override
64 public boolean isEnabledFor( EditorView<XmlDocument> view )
65 {
66 return !view.getViewId().equals( RawXmlEditorFactory.VIEW_ID );
67 }
68 }