SWTSkinObjectBrowserpublic class SWTSkinObjectBrowser extends SWTSkinObjectBasic implements com.aelitis.azureus.ui.swt.browser.listener.publish.LocalHoster
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)
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.Browser | getBrowser()
return browser;
| public com.aelitis.azureus.ui.swt.browser.BrowserContext | getContext()
return context;
| public java.net.URL | hostFile(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 void | layout()
cArea.layout();
| public void | restart()
// TODO: Replace the existing rand
setURL(sStartURL + (sStartURL.indexOf('?") > 0 ? "&" : "?") + "rand=" + SystemTime.getCurrentTime());
| public void | setURL(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);
}
});
|
|