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.ui;
14  
15  import com.eviware.soapui.support.components.BrowserComponent;
16  import com.eviware.soapui.ui.support.DefaultDesktopPanel;
17  
18  import javax.swing.*;
19  import java.awt.*;
20  
21  public class URLDesktopPanel extends DefaultDesktopPanel
22  {
23     private BrowserComponent browser;
24  
25     public URLDesktopPanel( String title, String description, final String url )
26     {
27        super( title, description, new JPanel( new BorderLayout() ) );
28  
29        JPanel panel = (JPanel) getComponent();
30  
31        browser = new BrowserComponent();
32        panel.add( browser.getComponent(), BorderLayout.CENTER );
33  
34        navigate( url, true );
35     }
36  
37     public void navigate( final String url, boolean async )
38     {
39        if( async )
40        {
41           new Thread( new Runnable()
42           {
43              public void run()
44              {
45                 browser.navigate( url );
46              }
47           } ).start();
48        }
49        else
50        {
51           browser.navigate( url );
52        }
53     }
54  
55     public boolean onClose( boolean canCancel )
56     {
57        browser.release();
58        return super.onClose( canCancel );
59     }
60  }