FileDocCategorySizeDatePackage
Browse.javaAPI DocAzureus 3.0.3.45530Tue Sep 04 21:04:24 BST 2007com.aelitis.azureus.ui.swt.views.skin

Browse

public class Browse extends SkinView
author
TuxPaper
created
Sep 30, 2006

Fields Summary
public static boolean
PULL_TABS
private SWTSkinObjectBrowser
browserSkinObject
Constructors Summary
Methods Summary
private voidcreateBrowseArea(SWTSkinObjectBrowser browserSkinObject)

		this.browserSkinObject = browserSkinObject;

		browserSkinObject.setURL(Constants.URL_PREFIX + Constants.URL_BIG_BROWSE
				+ "?" + Constants.URL_SUFFIX);
		browserSkinObject.layout();
	
protected voidcreateBrowseTabs(SWTSkinObject skinObject, java.util.Map[] browseSections)

param
browseSections

		SWTSkin skin = skinObject.getSkin();
		AzureusCore core = AzureusCoreFactory.getSingleton();

		FormData formData;
		Composite cArea = (Composite) skinObject.getControl();

		final Browser browser = new Browser(cArea, SWT.NONE);
		final ClientMessageContext context = new BrowserContext("big", browser,
				null, true);
		context.addMessageListener(new TorrentListener(core));

		formData = new FormData();
		formData.top = new FormAttachment(0, 0);
		formData.left = new FormAttachment(0, 0);
		formData.right = new FormAttachment(100, 0);
		formData.bottom = new FormAttachment(100, 0);
		browser.setLayoutData(formData);

		skinObject = skin.getSkinObject("browse-tabs");
		if (skinObject == null) {
			return;
		}

		Control previousControl = null;
		SWTSkinTabSet tabSet = null;
		for (int i = 0; i < browseSections.length; i++) {
			String sTabName = (String) browseSections[i].get("title");
			String sTabID = "internal.browse.tab." + i;
			SWTSkinObject skinTab = skin.createTab(sTabID, "tab", skinObject);

			if (skinTab == null) {
				continue;
			}

			if (tabSet == null) {
				tabSet = skin.getTabSet(skinTab);
			}

			Control currentControl = skinTab.getControl();
			if (previousControl != null) {
				formData = (FormData) skinTab.getControl().getLayoutData();
				if (formData == null) {
					formData = new FormData();
				}
				formData.left = new FormAttachment(previousControl, 1);
				currentControl.setLayoutData(formData);
			}

			previousControl = currentControl;

			SWTSkinObject tabText = skin.getSkinObject("browse-tab-text", skinTab);
			if (tabText instanceof SWTSkinObjectText) {
				((SWTSkinObjectText) tabText).setText(sTabName);
			}

			if (i == 0) {
				tabSet.addListener(new SWTSkinTabSetListener() {
					public void tabChanged(SWTSkinTabSet tabSet, String oldTabID,
							String newTabID) {
						System.out.println(newTabID);
						browser.stop();
						browser.execute("document.clear(); document.write('Loading..');");

						char c = newTabID.charAt(newTabID.length() - 1);
						int i = c - '0";
						if (i >= 0 && i < browseSections.length) {
							browser.setUrl((String) browseSections[i].get("url"));
							System.out.println(browser.getUrl());
						}
					}
				});
				tabSet.setActiveTab(sTabID);
			}
		}
		cArea.getParent().layout(true);
	
public voidrestart()

		browserSkinObject.restart();
	
public java.lang.ObjectshowSupport(SWTSkinObject skinObject, java.lang.Object params)


	/* (non-Javadoc)
	 * @see com.aelitis.azureus.ui.swt.views.SkinView#showSupport(com.aelitis.azureus.ui.swt.skin.SWTSkinObject, java.lang.Object)
	 */
	      
		browserSkinObject = (SWTSkinObjectBrowser) skinObject;
		if (PULL_TABS) {
			PlatformConfigMessenger.getBrowseSections(
					PlatformConfigMessenger.SECTION_TYPE_BIGBROWSE, 0,
					new PlatformConfigMessenger.GetBrowseSectionsReplyListener() {

						public void replyReceived(final Map[] browseSections) {
							Utils.execSWTThread(new AERunnable() {
								public void runSupport() {
									createBrowseTabs(browserSkinObject, browseSections);
								}
							});
						}

						public void messageSent() {
						}

					});
		} else {
			createBrowseArea(browserSkinObject);
		}
		return null;