View Javadoc

1   /*
2    *  soapUI, copyright (C) 2004-2007 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.wsdl.WsdlProject;
22  import com.eviware.soapui.impl.wsdl.actions.support.ShowOnlineHelpAction;
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, String targetHost, int sourcePort, boolean addEndpoint, boolean isProxy,
36  				String incomingRequestWss, String incomingResponseWss )
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, targetHost, addEndpoint, isProxy, incomingRequestWss, incomingResponseWss, toolbar );
46  		
47  		tabs.add( soapMonitor, "Traffic Log" );
48  		
49  		toolbar.add( UISupport.createToolbarButton( new ShowOnlineHelpAction( HelpUrls.SOAPMONITOR_HELP_URL ) ) );
50  		
51  		p.add( toolbar, BorderLayout.NORTH );
52  		p.add( UISupport.createTabPanel( tabs, true ), BorderLayout.CENTER );
53  		
54  		p.setPreferredSize( new Dimension( 700, 600 ) );
55  	}
56  	
57  	@Override
58  	public boolean onClose( boolean canCancel )
59  	{
60  		if( soapMonitor.isRunning() && canCancel )
61  		{
62  			if( !UISupport.confirm( "Close and stop SOAP Monitor", "Close SOAP Monitor" ))
63  			{
64  				return false;
65  			}
66  		}
67  		
68  		soapMonitor.stop();
69  		soapMonitor.release();
70  		return true;
71  	}
72  	
73  	@Override
74  	public boolean dependsOn( ModelItem modelItem )
75  	{
76  		return modelItem == project;
77  	}
78  
79  	public WsdlProject getProject()
80  	{
81  		return project;
82  	}
83  }