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.impl.wsdl.panels.monitor;
14  
15  import com.eviware.soapui.impl.support.actions.ShowOnlineHelpAction;
16  import com.eviware.soapui.impl.wsdl.WsdlProject;
17  import com.eviware.soapui.impl.wsdl.monitor.SoapMonitor;
18  import com.eviware.soapui.impl.wsdl.support.HelpUrls;
19  import com.eviware.soapui.model.ModelItem;
20  import com.eviware.soapui.support.UISupport;
21  import com.eviware.soapui.support.components.JXToolBar;
22  import com.eviware.soapui.ui.support.DefaultDesktopPanel;
23  
24  import javax.swing.*;
25  import java.awt.*;
26  
27  public class SoapMonitorDesktopPanel extends DefaultDesktopPanel
28  {
29  	private SoapMonitor soapMonitor;
30  	private final WsdlProject project;
31  
32  	public SoapMonitorDesktopPanel( WsdlProject project, int sourcePort, String incomingRequestWss, String incomingResponseWss, boolean setAsProxy, String sslEndpoint )
33  	{
34  		super( "SOAP Monitor [" + project.getName() + "]", null, new JPanel( new BorderLayout() ) );
35  		this.project = project;
36  
37  		JPanel p = ( JPanel ) getComponent();
38  		JTabbedPane tabs = new JTabbedPane();
39  
40  		JXToolBar toolbar = UISupport.createToolbar();
41  		soapMonitor = new SoapMonitor( project, sourcePort, incomingRequestWss, incomingResponseWss, toolbar, setAsProxy, sslEndpoint );
42  		
43  		
44  		tabs.add( soapMonitor, "Traffic Log" );
45  		
46  		toolbar.add( UISupport.createToolbarButton( new ShowOnlineHelpAction( HelpUrls.SOAPMONITOR_HELP_URL ) ) );
47  		
48  		p.add( toolbar, BorderLayout.NORTH );
49  		p.add( UISupport.createTabPanel( tabs, true ), BorderLayout.CENTER );
50  		
51  		p.setPreferredSize( new Dimension( 700, 600 ) );
52  	}
53  	
54  	@Override
55  	public boolean onClose( boolean canCancel )
56  	{
57  		if( soapMonitor.isRunning() && canCancel )
58  		{
59  			if( !UISupport.confirm( "Close and stop SOAP Monitor", "Close SOAP Monitor" ))
60  			{
61  				return false;
62  			}
63  		}
64  		
65  		soapMonitor.stop();
66  		soapMonitor.release();
67  		return true;
68  	}
69  	
70  	@Override
71  	public boolean dependsOn( ModelItem modelItem )
72  	{
73  		return modelItem == project;
74  	}
75  
76  	public WsdlProject getProject()
77  	{
78  		return project;
79  	}
80  }