1
2
3
4
5
6
7
8
9
10
11
12
13 package com.eviware.soapui.ui;
14
15 import java.awt.BorderLayout;
16 import java.lang.reflect.InvocationTargetException;
17
18 import javax.swing.JPanel;
19 import javax.swing.SwingUtilities;
20
21 import com.eviware.soapui.support.StringUtils;
22 import com.eviware.soapui.support.components.BrowserComponent;
23 import com.eviware.soapui.ui.support.DefaultDesktopPanel;
24
25 public class URLDesktopPanel extends DefaultDesktopPanel
26 {
27 private BrowserComponent browser;
28 private boolean closed;
29
30 public URLDesktopPanel( String title, String description, String url ) throws InterruptedException,
31 InvocationTargetException
32 {
33 super( title, description, new JPanel( new BorderLayout() ) );
34
35 JPanel panel = ( JPanel )getComponent();
36
37 browser = new BrowserComponent( true, false );
38 panel.add( browser.getComponent(), BorderLayout.CENTER );
39
40 if( StringUtils.hasContent( url ) )
41 navigate( url, null, true );
42 }
43
44 public void navigate( String url, String errorUrl, boolean async )
45 {
46 if( async )
47 {
48 SwingUtilities.invokeLater( new Navigator( url, errorUrl ) );
49 }
50 else
51 {
52 browser.navigate( url, errorUrl );
53 }
54 }
55
56 public boolean onClose( boolean canCancel )
57 {
58 browser.release();
59 closed = true;
60 return super.onClose( canCancel );
61 }
62
63 public boolean isClosed()
64 {
65 return closed;
66 }
67
68 private class Navigator implements Runnable
69 {
70 private final String url;
71 private final String errorUrl;
72
73 public Navigator( String url, String errorUrl )
74 {
75 this.url = url;
76 this.errorUrl = errorUrl;
77 }
78
79 public void run()
80 {
81
82 browser.navigate( url, errorUrl );
83
84 }
85 }
86 }