FileDocCategorySizeDatePackage
UIFunctionsImpl.javaAPI DocAzureus 3.0.3.420326Sun Sep 23 04:54:08 BST 2007com.aelitis.azureus.ui.swt.shells.main

UIFunctionsImpl

public class UIFunctionsImpl extends Object implements com.aelitis.azureus.ui.swt.UIFunctionsSWT
author
TuxPaper
created
Jul 13, 2006

Fields Summary
private static final org.gudy.azureus2.core3.logging.LogIDs
LOGID
private final com.aelitis.azureus.ui.swt.shells.main.MainWindow
mainWindow
private final Map
mapPluginViews
This isn't presently populated. mapPluginViews stores the plugin views that need to be added once the oldMainWindow is created. Currently, we create the oldMainWindow at startup. Once we swtich to delayed oldMainWindow creation, in theory the code will work.
private final org.gudy.azureus2.core3.util.AEMonitor
pluginViews_mon
Constructors Summary
public UIFunctionsImpl(com.aelitis.azureus.ui.swt.shells.main.MainWindow window)

param
window


	  	 
	 
			  
		this.mainWindow = window;
	
Methods Summary
public voidaddPluginView(org.gudy.azureus2.plugins.PluginView view)

		try {
			UIFunctionsSWT uiFunctions = mainWindow.getOldUIFunctions(true);
			if (uiFunctions == null) {
				pluginViews_mon.enter();
				try {
					mapPluginViews.put(view, null);
				} finally {
					pluginViews_mon.exit();
				}
				return;
			}

			uiFunctions.addPluginView(view);

		} catch (Exception e) {
			Logger.log(new LogEvent(LOGID, "addPluginView", e));
		}

	
public voidaddPluginView(java.lang.String viewID, UISWTViewEventListener l)

		try {
			UIFunctionsSWT uiFunctions = mainWindow.getOldUIFunctions(true);
			if (uiFunctions == null) {
				pluginViews_mon.enter();
				try {
					mapPluginViews.put(viewID, l);
				} finally {
					pluginViews_mon.exit();
				}
				return;
			}

			uiFunctions.addPluginView(viewID, l);

		} catch (Exception e) {
			Logger.log(new LogEvent(LOGID, "addPluginView", e));
		}

	
public voidaddPluginView(UISWTPluginView view)

		try {
			UIFunctionsSWT uiFunctions = mainWindow.getOldUIFunctions(true);
			if (uiFunctions == null) {
				pluginViews_mon.enter();
				try {
					mapPluginViews.put(view, null);
				} finally {
					pluginViews_mon.exit();
				}
				return;
			}

			uiFunctions.addPluginView(view);

		} catch (Exception e) {
			Logger.log(new LogEvent(LOGID, "addPluginView", e));
		}

	
public voidbringToFront()

		bringToFront(true);
	
public voidbringToFront(boolean tryTricks)

		Utils.execSWTThread(new AERunnable() {
			public void runSupport() {
				try {
					// this will force active and set !minimized after PW test
					mainWindow.setVisible(true, tryTricks);

				} catch (Exception e) {
					Logger.log(new LogEvent(LOGID, "bringToFront", e));
				}

			}
		});
	
public voidcloseDownloadBars()

		try {
			UIFunctionsSWT uiFunctions = mainWindow.getOldUIFunctions(false);
			if (uiFunctions == null) {
				return;
			}

			uiFunctions.closeDownloadBars();

		} catch (Exception e) {
			Logger.log(new LogEvent(LOGID, "closeDownloadBars", e));
		}

	
public voidcloseGlobalTransferBar()

		Utils.execSWTThread(new AERunnable() {
			public void runSupport() {
				AllTransfersBar.close(
						AzureusCoreFactory.getSingleton().getGlobalManager());
			}
		});
	
public voidclosePluginView(org.gudy.azureus2.ui.swt.views.IView view)

		try {
			UIFunctionsSWT uiFunctions = mainWindow.getOldUIFunctions(false);
			if (uiFunctions == null) {
				return;
			}

			uiFunctions.closePluginView(view);

		} catch (Exception e) {
			Logger.log(new LogEvent(LOGID, "closePluginView", e));
		}

	
public voidclosePluginViews(java.lang.String sViewID)

		try {
			UIFunctionsSWT uiFunctions = mainWindow.getOldUIFunctions(false);
			if (uiFunctions == null) {
				return;
			}

			uiFunctions.closePluginViews(sViewID);

		} catch (Exception e) {
			Logger.log(new LogEvent(LOGID, "closePluginViews", e));
		}

	
public booleandispose(boolean for_restart, boolean close_already_in_progress)

		try {
			return mainWindow.dispose(for_restart, close_already_in_progress);
		} catch (Exception e) {
			Logger.log(new LogEvent(LOGID, "Disposing MainWindow", e));
		}
		return false;
	
public org.eclipse.swt.widgets.ShellgetMainShell()

		return mainWindow.shell;
	
public org.eclipse.swt.widgets.MenugetMenu(int id)

		// TODO Auto-generated method stub
		// XXX Don't use oldMainWindow, menu is global and oldMainWindow
		//     shouldn't need to be initialized
		return null;
	
public UISWTView[]getPluginViews()

		try {
			UIFunctionsSWT uiFunctions = mainWindow.getOldUIFunctions(true);
			if (uiFunctions == null) {
				return new UISWTView[0];
			}

			return uiFunctions.getPluginViews();

		} catch (Exception e) {
			Logger.log(new LogEvent(LOGID, "getPluginViews", e));
		}

		return new UISWTView[0];
	
public org.gudy.azureus2.ui.swt.pluginsimpl.UISWTInstanceImplgetSWTPluginInstanceImpl()

		try {
			return (UISWTInstanceImpl) mainWindow.getUISWTInstanceImpl();
		} catch (Exception e) {
			Logger.log(new LogEvent(LOGID, "getSWTPluginInstanceImpl", e));
		}

		return null;
	
public UISWTInstancegetUISWTInstance()

		return mainWindow.getUISWTInstanceImpl();
	
public com.aelitis.azureus.ui.UIFunctionsUserPromptergetUserPrompter(java.lang.String title, java.lang.String text, java.lang.String[] buttons, int defaultOption)


		MessageBoxShell mb = new MessageBoxShell(getMainShell(), title, text,
				buttons, defaultOption);
		return mb;
	
public booleanisGlobalTransferBarShown()

		return AllTransfersBar.getManager().isOpen(
				AzureusCoreFactory.getSingleton().getGlobalManager());
	
protected voidoldMainWindowInitialized(org.gudy.azureus2.ui.swt.mainwindow.MainWindow oldMainWindow)

		UIFunctionsSWT uiFunctions = mainWindow.getOldUIFunctions(true);
		if (uiFunctions == null) {
			return;
		}

		pluginViews_mon.enter();
		try {
			for (Iterator iterator = mapPluginViews.keySet().iterator(); iterator.hasNext();) {
				Object key = iterator.next();
				if (key instanceof PluginView) {
					uiFunctions.addPluginView((PluginView) key);
				} else if (key instanceof UISWTPluginView) {
					uiFunctions.addPluginView((UISWTPluginView) key);
				} else if (key instanceof String) {
					UISWTViewEventListener value = (UISWTViewEventListener) mapPluginViews.get(key);
					uiFunctions.addPluginView((String) key, value);
				}
			}
			mapPluginViews.clear();
		} finally {
			pluginViews_mon.exit();
		}
	
public voidopenManagerView(org.gudy.azureus2.core3.download.DownloadManager dm)

		try {
			UIFunctionsSWT uiFunctions = mainWindow.getOldUIFunctions(true);
			if (uiFunctions == null) {
				return;
			}

			mainWindow.switchToAdvancedTab();
			uiFunctions.openManagerView(dm);

		} catch (Exception e) {
			Logger.log(new LogEvent(LOGID, "openManagerView", e));
		}

	
public voidopenPluginView(org.gudy.azureus2.ui.swt.views.AbstractIView view, java.lang.String name)

		try {
			UIFunctionsSWT uiFunctions = mainWindow.getOldUIFunctions(true);
			if (uiFunctions == null) {
				return;
			}

			mainWindow.switchToAdvancedTab();
			uiFunctions.openPluginView(view, name);

		} catch (Exception e) {
			Logger.log(new LogEvent(LOGID, "openPluginView", e));
		}

	
public voidopenPluginView(org.gudy.azureus2.plugins.PluginView view)

		try {
			UIFunctionsSWT uiFunctions = mainWindow.getOldUIFunctions(true);
			if (uiFunctions == null) {
				return;
			}

			mainWindow.switchToAdvancedTab();
			uiFunctions.openPluginView(view);

		} catch (Exception e) {
			Logger.log(new LogEvent(LOGID, "openPluginView", e));
		}

	
public voidopenPluginView(java.lang.String sParentID, java.lang.String sViewID, UISWTViewEventListener l, java.lang.Object dataSource, boolean bSetFocus)

		try {
			UIFunctionsSWT uiFunctions = mainWindow.getOldUIFunctions(true);
			if (uiFunctions == null) {
				return;
			}

			mainWindow.switchToAdvancedTab();
			uiFunctions.openPluginView(sParentID, sViewID, l, dataSource, bSetFocus);

		} catch (Exception e) {
			Logger.log(new LogEvent(LOGID, "openPluginView", e));
		}

	
public voidopenPluginView(UISWTPluginView view)

		try {
			UIFunctionsSWT uiFunctions = mainWindow.getOldUIFunctions(true);
			if (uiFunctions == null) {
				return;
			}

			mainWindow.switchToAdvancedTab();
			uiFunctions.openPluginView(view);

		} catch (Exception e) {
			Logger.log(new LogEvent(LOGID, "openPluginView", e));
		}

	
public intpromptUser(java.lang.String title, java.lang.String text, java.lang.String[] buttons, int defaultOption, java.lang.String rememberID, java.lang.String rememberText, boolean rememberByDefault, int autoCloseInMS)

		return MessageBoxShell.open(getMainShell(), title, text, buttons,
				defaultOption, rememberID, rememberText, rememberByDefault,
				autoCloseInMS);
	
public voidrefreshIconBar()

		try {
			UIFunctionsSWT uiFunctions = mainWindow.getOldUIFunctions(true);
			if (uiFunctions == null) {
				return;
			}

			uiFunctions.refreshIconBar();

		} catch (Exception e) {
			Logger.log(new LogEvent(LOGID, "refreshIconBar", e));
		}

	
public voidrefreshLanguage()

		try {
			UIFunctionsSWT uiFunctions = mainWindow.getOldUIFunctions(true);
			if (uiFunctions == null) {
				return;
			}

			uiFunctions.refreshLanguage();

		} catch (Exception e) {
			Logger.log(new LogEvent(LOGID, "refreshLanguage", e));
		}

	
public voidrefreshTorrentMenu()

		try {
			UIFunctionsSWT uiFunctions = mainWindow.getOldUIFunctions(true);
			if (uiFunctions == null) {
				return;
			}

			uiFunctions.refreshTorrentMenu();

		} catch (Exception e) {
			Logger.log(new LogEvent(LOGID, "refreshTorrentMenu", e));
		}
	
public voidremoveManagerView(org.gudy.azureus2.core3.download.DownloadManager dm)

		try {
			UIFunctionsSWT uiFunctions = mainWindow.getOldUIFunctions(true);
			if (uiFunctions == null) {
				return;
			}

			uiFunctions.removeManagerView(dm);

		} catch (Exception e) {
			Logger.log(new LogEvent(LOGID, "removeManagerView", e));
		}

	
public voidremovePluginView(java.lang.String viewID)

		try {
			UIFunctionsSWT uiFunctions = mainWindow.getOldUIFunctions(true);
			if (uiFunctions == null) {
				pluginViews_mon.enter();
				try {
					mapPluginViews.remove(viewID);
				} finally {
					pluginViews_mon.exit();
				}
				return;
			}

			uiFunctions.removePluginView(viewID);

		} catch (Exception e) {
			Logger.log(new LogEvent(LOGID, "removePluginView", e));
		}

	
public voidremovePluginView(UISWTPluginView view)

		try {
			UIFunctionsSWT uiFunctions = mainWindow.getOldUIFunctions(true);
			if (uiFunctions == null) {
				pluginViews_mon.enter();
				try {
					mapPluginViews.remove(view);
				} finally {
					pluginViews_mon.exit();
				}
				return;
			}

			uiFunctions.removePluginView(view);

		} catch (Exception e) {
			Logger.log(new LogEvent(LOGID, "removePluginView", e));
		}

	
public booleanrequestShutdown()

		try {
			UIFunctionsSWT uiFunctions = mainWindow.getOldUIFunctions(true);
			if (uiFunctions == null) {
				return true;
			}

			return uiFunctions.requestShutdown();

		} catch (Exception e) {
			Logger.log(new LogEvent(LOGID, "requestShutdown", e));
		}

		return false;
	
public voidsetStatusText(java.lang.String string)

		// TODO Auto-generated method stub

		// XXX Don't use oldMainWindow, status bar is global and oldMainWindow
		//     shouldn't need to be initialized
	
public voidsetStatusText(int statustype, java.lang.String string, com.aelitis.azureus.ui.UIStatusTextClickListener l)

		// TODO Auto-generated method stub

	
public voidshowAllPeersView()

		try {
			UIFunctionsSWT uiFunctions = mainWindow.getOldUIFunctions(true);
			if (uiFunctions == null) {
				return;
			}

			uiFunctions.showAllPeersView();

		} catch (Exception e) {
			Logger.log(new LogEvent(LOGID, "showAllPeersView", e));
		}
	
public booleanshowConfig(java.lang.String string)

		try {
			UIFunctionsSWT uiFunctions = mainWindow.getOldUIFunctions(true);
			if (uiFunctions == null) {
				return false;
			}

			mainWindow.switchToAdvancedTab();
			return uiFunctions.showConfig(string);

		} catch (Exception e) {
			Logger.log(new LogEvent(LOGID, "showConfig", e));
		}

		return false;
	
public voidshowConsole()

		try {
			UIFunctionsSWT uiFunctions = mainWindow.getOldUIFunctions(true);
			if (uiFunctions == null) {
				return;
			}

			mainWindow.switchToAdvancedTab();
			uiFunctions.showConsole();
		} catch (Exception e) {
			Logger.log(new LogEvent(LOGID, "ShowConsole", e));
		}
	
public voidshowGlobalTransferBar()

		Utils.execSWTThread(new AERunnable() {
			public void runSupport() {
				AllTransfersBar.open(
						AzureusCoreFactory.getSingleton().getGlobalManager(),
						getMainShell());
			}
		});
	
public voidshowMyShares()

		try {
			UIFunctionsSWT uiFunctions = mainWindow.getOldUIFunctions(true);
			if (uiFunctions == null) {
				return;
			}

			mainWindow.switchToAdvancedTab();
			uiFunctions.showMyShares();

		} catch (Exception e) {
			Logger.log(new LogEvent(LOGID, "showMyShares", e));
		}

	
public voidshowMyTorrents()

		try {
			UIFunctionsSWT uiFunctions = mainWindow.getOldUIFunctions(true);
			if (uiFunctions == null) {
				return;
			}

			mainWindow.switchToAdvancedTab();
			uiFunctions.showMyTorrents();

		} catch (Exception e) {
			Logger.log(new LogEvent(LOGID, "showMyTorrents", e));
		}

	
public voidshowMyTracker()

		try {
			UIFunctionsSWT uiFunctions = mainWindow.getOldUIFunctions(true);
			if (uiFunctions == null) {
				return;
			}

			mainWindow.switchToAdvancedTab();
			uiFunctions.showMyTracker();

		} catch (Exception e) {
			Logger.log(new LogEvent(LOGID, "showMyTracker", e));
		}

	
public voidshowStats()

		try {
			UIFunctionsSWT uiFunctions = mainWindow.getOldUIFunctions(true);
			if (uiFunctions == null) {
				return;
			}

			mainWindow.switchToAdvancedTab();
			uiFunctions.showStats();

		} catch (Exception e) {
			Logger.log(new LogEvent(LOGID, "showStats", e));
		}

	
public voidshowStatsDHT()

		try {
			UIFunctionsSWT uiFunctions = mainWindow.getOldUIFunctions(true);
			if (uiFunctions == null) {
				return;
			}

			mainWindow.switchToAdvancedTab();
			uiFunctions.showStatsDHT();

		} catch (Exception e) {
			Logger.log(new LogEvent(LOGID, "showStatsDHT", e));
		}
	
public voidshowStatsTransfers()

		try {
			UIFunctionsSWT uiFunctions = mainWindow.getOldUIFunctions(true);
			if (uiFunctions == null) {
				return;
			}

			mainWindow.switchToAdvancedTab();
			uiFunctions.showStatsTransfers();
		} catch (Exception e) {
			Logger.log(new LogEvent(LOGID, "", e));
		}
	
public booleanviewURL(java.lang.String url, java.lang.String target, int w, int h, boolean allowResize, boolean isModal)


		mainWindow.shell.getDisplay().syncExec(new AERunnable() {
			public void runSupport() {
				if (target == null) {
					BrowserWindow window = new BrowserWindow(mainWindow.shell, url, w, h,
							allowResize, isModal);
					window.waitUntilClosed();
				} else {
					mainWindow.showURL(url, target);
				}
			}
		});
		return true;
	
public booleanviewURL(java.lang.String url, java.lang.String target, double w, double h, boolean allowResize, boolean isModal)


		mainWindow.shell.getDisplay().syncExec(new AERunnable() {
			public void runSupport() {
				if (target == null) {
					BrowserWindow window = new BrowserWindow(mainWindow.shell, url, w, h,
							allowResize, isModal);
					window.waitUntilClosed();
				} else {
					mainWindow.showURL(url, target);
				}
			}
		});
		return true;