FileDocCategorySizeDatePackage
SimpleBrowserWindow.javaAPI DocAzureus 3.0.3.43706Wed Jul 18 14:50:30 BST 2007org.gudy.azureus2.ui.swt.shells

SimpleBrowserWindow

public class SimpleBrowserWindow extends Object
author
TuxPaper
created
Jul 18, 2007

Fields Summary
private org.eclipse.swt.widgets.Shell
shell
Constructors Summary
public SimpleBrowserWindow(org.eclipse.swt.widgets.Shell parent, String url, double wPct, double hPct, boolean allowResize, boolean isModal)

		if (parent == null) {
			init(parent, url, 0, 0, allowResize, isModal);
		} else {
			Rectangle clientArea = parent.getClientArea();
			init(parent, url, (int) (clientArea.width * wPct),
					(int) (clientArea.height * hPct), allowResize, isModal);
		}
	
public SimpleBrowserWindow(org.eclipse.swt.widgets.Shell parent, String url, int w, int h, boolean allowResize, boolean isModal)

		init(parent, url, w, h, allowResize, isModal);
	
Methods Summary
private voidinit(org.eclipse.swt.widgets.Shell parent, java.lang.String url, int w, int h, boolean allowResize, boolean isModal)

		if (parent == null) {
			parent = Utils.findAnyShell();
		}

		int style = SWT.DIALOG_TRIM;
		if (allowResize) {
			style |= SWT.RESIZE;
		}
		if (isModal) {
			style |= SWT.APPLICATION_MODAL;
		}
		shell = ShellFactory.createShell(parent, style);

		shell.setLayout(new FillLayout());

		Utils.setShellIcon(shell);

		Browser browser = null;
		
		try {
			browser = new Browser(shell, SWT.None);
		} catch (Throwable t) {
			shell.dispose();
			return;
		}
		
		if (browser == null) {
			shell.dispose();
			return;
		}

		browser.addProgressListener(new ProgressListener() {
			public void completed(ProgressEvent event) {
				shell.open();
			}

			public void changed(ProgressEvent event) {
			}
		});

		browser.addCloseWindowListener(new CloseWindowListener() {
			public void close(WindowEvent event) {
				shell.dispose();
			}
		});

		browser.addTitleListener(new TitleListener() {

			public void changed(TitleEvent event) {
				shell.setText(event.title);
			}

		});

		if (w > 0 && h > 0) {
			shell.setSize(w, h);
		}

		Utils.centerWindowRelativeTo(shell, parent);
		browser.setUrl(url);
		browser.setData("StartURL", url);
	
public static voidmain(java.lang.String[] args)

		Display display = new Display();
		Shell shell = new Shell(display, SWT.DIALOG_TRIM);
		shell.setSize(800, 600);

		new SimpleBrowserWindow(shell, "http://google.com", 0.8, 0.5, true, false);

		shell.open();

		while (!shell.isDisposed()) {
			if (!display.readAndDispatch()) {
				display.sleep();
			}
		}
	
public voidwaitUntilClosed()

		Display display = shell.getDisplay();
		while (!shell.isDisposed()) {
			if (!display.readAndDispatch()) {
				display.sleep();
			}
		}