FileDocCategorySizeDatePackage
SWTSkinObjectBrowser.javaAPI DocAzureus 3.0.3.45162Sat Sep 08 14:43:40 BST 2007com.aelitis.azureus.ui.swt.skin

SWTSkinObjectBrowser

public class SWTSkinObjectBrowser extends SWTSkinObjectBasic implements com.aelitis.azureus.ui.swt.browser.listener.publish.LocalHoster
author
TuxPaper
created
Oct 9, 2006

Fields Summary
private org.eclipse.swt.browser.Browser
browser
private org.eclipse.swt.widgets.Composite
cArea
private String
sStartURL
private com.aelitis.azureus.util.LocalResourceHTTPServer
local_publisher
private com.aelitis.azureus.ui.swt.browser.BrowserContext
context
Constructors Summary
public SWTSkinObjectBrowser(SWTSkin skin, SWTSkinProperties properties, String sID, String sConfigID, SWTSkinObject parent)

param
skin
param
properties
param
sID
param
sConfigID
param
type
param
parent

		super(skin, properties, sID, sConfigID, "browser", parent);

		AzureusCore core = AzureusCoreFactory.getSingleton();

		cArea = parent == null ? skin.getShell() : (Composite) parent.getControl();


		try {
			browser = new Browser(cArea, SWT.NONE);
		} catch (SWTError e) {
			System.err.println("Browser: " + e.toString());
			return;
		}

		Control widgetIndicator = null;
		String sIndicatorWidgetID = properties.getStringValue(sConfigID
				+ ".indicator");
		if (sIndicatorWidgetID != null) {
			SWTSkinObject skinObjectIndicator = skin.getSkinObjectByID(sIndicatorWidgetID);
			if (skinObjectIndicator != null) {
				widgetIndicator = skinObjectIndicator.getControl();
			}
		}

		String browserID = properties.getStringValue(sConfigID + ".view");
		if (browserID == null) {
			browserID = sID;
		}
		
		context = new BrowserContext(browserID, browser, widgetIndicator,
				properties.getBooleanValue(sConfigID + ".forceVisibleAfterLoad", true));
		context.addMessageListener(new TorrentListener(core));
		context.addMessageListener(new DisplayListener(browser));
		context.addMessageListener(new ConfigListener(browser));
		context.addMessageListener(new PublishListener(skin.getShell(), this));
		PublishUtils.setupContext(context);

		
		setControl(browser);
	
Methods Summary
public org.eclipse.swt.browser.BrowsergetBrowser()

		return browser;
	
public com.aelitis.azureus.ui.swt.browser.BrowserContextgetContext()

		return context;
	
public java.net.URLhostFile(java.io.File f)

		if (local_publisher == null) {
			try {
				PluginInterface pi = AzureusCoreFactory.getSingleton().getPluginManager().getDefaultPluginInterface();
				local_publisher = new LocalResourceHTTPServer(pi, null);
			} catch (Throwable e) {
				Debug.out("Failed to create local resource publisher", e);
				return null;
			}
		}
		try {
			return local_publisher.publishResource(f);
		} catch (Exception e) {
			e.printStackTrace();
			return null;
		}
	
public voidlayout()

		cArea.layout();
	
public voidrestart()

		// TODO: Replace the existing rand
		setURL(sStartURL + (sStartURL.indexOf('?") > 0 ? "&" : "?") + "rand=" + SystemTime.getCurrentTime());
	
public voidsetURL(java.lang.String url)

		Utils.execSWTThread(new AERunnable() {
			public void runSupport() {
				if (url == null) {
					browser.setText("");
				} else {
					browser.setUrl(url);
				}
				if (sStartURL == null) {
					sStartURL = url;
					browser.setData("StartURL", url);
				}
				//System.out.println(SystemTime.getCurrentTime() + "] Set URL: " + url);
			}
		});