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