View Javadoc

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