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 )
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 );
42  		
43  		tabs.add( soapMonitor, "Traffic Log" );
44  		
45  		toolbar.add( UISupport.createToolbarButton( new ShowOnlineHelpAction( HelpUrls.SOAPMONITOR_HELP_URL ) ) );
46  		
47  		p.add( toolbar, BorderLayout.NORTH );
48  		p.add( UISupport.createTabPanel( tabs, true ), BorderLayout.CENTER );
49  		
50  		p.setPreferredSize( new Dimension( 700, 600 ) );
51  	}
52  	
53  	@Override
54  	public boolean onClose( boolean canCancel )
55  	{
56  		if( soapMonitor.isRunning() && canCancel )
57  		{
58  			if( !UISupport.confirm( "Close and stop SOAP Monitor", "Close SOAP Monitor" ))
59  			{
60  				return false;
61  			}
62  		}
63  		
64  		soapMonitor.stop();
65  		soapMonitor.release();
66  		return true;
67  	}
68  	
69  	@Override
70  	public boolean dependsOn( ModelItem modelItem )
71  	{
72  		return modelItem == project;
73  	}
74  
75  	public WsdlProject getProject()
76  	{
77  		return project;
78  	}
79  }