⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 initializer.java

📁 java 文件下载器。可自定义
💻 JAVA
字号:
// Decompiled by Jad v1.5.8e2. Copyright 2001 Pavel Kouznetsov.
// Jad home page: http://kpdus.tripod.com/jad.html
// Decompiler options: packimports(3) fieldsfirst ansi space 
// Source File Name:   Initializer.java

package org.gudy.azureus2.ui.swt.mainwindow;

import com.aelitis.azureus.core.*;
import com.aelitis.azureus.core.util.CopyOnWriteList;
import com.aelitis.azureus.launcher.Launcher;
import com.aelitis.azureus.ui.IUIIntializer;
import com.aelitis.azureus.ui.InitializerListener;
import com.aelitis.azureus.ui.swt.UIFunctionsManagerSWT;
import com.aelitis.azureus.ui.swt.UIFunctionsSWT;
import com.aelitis.azureus.ui.swt.utils.UIMagnetHandler;
import java.io.PrintStream;
import java.lang.reflect.Constructor;
import java.util.ArrayList;
import java.util.Iterator;
import org.gudy.azureus2.core3.config.COConfigurationManager;
import org.gudy.azureus2.core3.global.GlobalManager;
import org.gudy.azureus2.core3.internat.MessageText;
import org.gudy.azureus2.core3.ipfilter.IpFilterManager;
import org.gudy.azureus2.core3.logging.*;
import org.gudy.azureus2.core3.util.*;
import org.gudy.azureus2.plugins.PluginManager;
import org.gudy.azureus2.plugins.utils.DelayedTask;
import org.gudy.azureus2.pluginsimpl.local.utils.UtilitiesImpl;
import org.gudy.azureus2.ui.common.util.UserAlerts;
import org.gudy.azureus2.ui.swt.*;
import org.gudy.azureus2.ui.swt.auth.*;
import org.gudy.azureus2.ui.swt.networks.SWTNetworkSelection;
import org.gudy.azureus2.ui.swt.pluginsinstaller.InstallPluginWizard;
import org.gudy.azureus2.ui.swt.progress.ProgressWindow;
import org.gudy.azureus2.ui.swt.update.UpdateMonitor;
import org.gudy.azureus2.ui.swt.updater2.PreUpdateChecker;
import org.gudy.azureus2.ui.swt.updater2.SWTUpdateChecker;

// Referenced classes of package org.gudy.azureus2.ui.swt.mainwindow:
//			Cursors, SWTThread, SWTThreadAlreadyInstanciatedException, SplashWindow, 
//			Colors, MainWindow, TorrentOpener

public class Initializer
	implements AzureusCoreListener, IUIIntializer
{

	private static final LogIDs LOGID;
	private AzureusCore azureus_core;
	private GlobalManager gm;
	private StartServer startServer;
	private CopyOnWriteList listeners;
	private AEMonitor listeners_mon;
	private String args[];
	private AESemaphore semFilterLoader;
	private AESemaphore init_task;
	private int nbTasks;
	private int currentTask;
	private int currentPercent;
	private int lastTaskPercent;

	public Initializer(AzureusCore _azureus_core, StartServer _server, String _args[])
	{
		listeners = new CopyOnWriteList();
		listeners_mon = new AEMonitor("Initializer:l");
		semFilterLoader = new AESemaphore("filter loader");
		init_task = new AESemaphore("delayed init");
		nbTasks = 1;
		currentTask = 0;
		currentPercent = 0;
		lastTaskPercent = 0;
		azureus_core = _azureus_core;
		startServer = _server;
		args = _args;
		Thread filterLoaderThread = new AEThread("filter loader", true) {

			final Initializer this$0;

			public void runSupport()
			{
				azureus_core.getIpFilterManager().getIPFilter();
				semFilterLoader.releaseForever();
				break MISSING_BLOCK_LABEL_44;
				Exception exception;
				exception;
				semFilterLoader.releaseForever();
				throw exception;
			}

			
			{
				this$0 = Initializer.this;
				super(x0, x1);
			}
		};
		filterLoaderThread.setPriority(1);
		filterLoaderThread.start();
		try
		{
			SWTThread.createInstance(this);
		}
		catch (SWTThreadAlreadyInstanciatedException e)
		{
			Debug.printStackTrace(e);
		}
	}

	public static boolean handleStopRestart(boolean restart)
	{
		UIFunctionsSWT functionsSWT = UIFunctionsManagerSWT.getUIFunctionsSWT();
		if (functionsSWT != null)
			return functionsSWT.dispose(restart, true);
		else
			return false;
	}

	public void run()
	{
		try
		{
			String uiMode = UISwitcherUtil.openSwitcherWindow(false);
			if (uiMode.equals("az3"))
				try
				{
					Class az3Class = Class.forName("com.aelitis.azureus.ui.swt.Initializer");
					Constructor constructor = az3Class.getConstructor(new Class[] {
						com/aelitis/azureus/core/AzureusCore, Boolean.TYPE, [Ljava/lang/String;
					});
					IUIIntializer initializer = (IUIIntializer)constructor.newInstance(new Object[] {
						azureus_core, new Boolean(false), args
					});
					initializer.run();
					return;
				}
				catch (Throwable t)
				{
					t.printStackTrace();
				}
			DelayedTask delayed_task = UtilitiesImpl.addDelayedTask("SWT Initialisation", new Runnable() {

				final Initializer this$0;

				public void run()
				{
					init_task.reserve();
				}

			
			{
				this$0 = Initializer.this;
				super();
			}
			});
			delayed_task.queue();
			new LocaleUtilSWT(azureus_core);
			org.eclipse.swt.widgets.Display display = SWTThread.getInstance().getDisplay();
			new UIMagnetHandler(azureus_core);
			UIConfigDefaultsSWT.initialize();
			if (COConfigurationManager.getBooleanParameter("Show Splash", true))
				SplashWindow.create(display, this);
			setNbTasks(6);
			nextTask();
			reportCurrentTaskByKey("splash.firstMessageNoI18N");
			Alerts.init();
			final ArrayList logEvents = new ArrayList();
			ILogEventListener logListener = null;
			if (COConfigurationManager.getBooleanParameter("Open Console", false))
			{
				logListener = new ILogEventListener() {

					final ArrayList val$logEvents;
					final Initializer this$0;

					public void log(LogEvent event)
					{
						logEvents.add(event);
					}

			
			{
				this$0 = Initializer.this;
				logEvents = arraylist;
				super();
			}
				};
				Logger.addListener(logListener);
			}
			final ILogEventListener finalLogListener = logListener;
			ProgressWindow.register(azureus_core);
			new SWTNetworkSelection();
			new AuthenticatorWindow();
			new CryptoWindow();
			new CertificateTrustWindow();
			InstallPluginWizard.register(azureus_core, display);
			nextTask();
			reportCurrentTaskByKey("splash.initializeGM");
			azureus_core.addListener(this);
			azureus_core.addLifecycleListener(new AzureusCoreLifecycleAdapter() {

				final ArrayList val$logEvents;
				final ILogEventListener val$finalLogListener;
				final Initializer this$0;

				public void componentCreated(AzureusCore core, AzureusCoreComponent comp)
				{
					if (comp instanceof GlobalManager)
					{
						gm = (GlobalManager)comp;
						nextTask();
						reportCurrentTask(MessageText.getString("splash.initializePlugins"));
					}
				}

				public void started(AzureusCore core)
				{
					boolean main_window_will_report_complete = false;
					if (gm == null)
					{
						if (!main_window_will_report_complete)
							init_task.release();
						return;
					}
					new UserAlerts(gm);
					nextTask();
					IpFilterManager ipFilterManager = azureus_core.getIpFilterManager();
					if (ipFilterManager != null)
					{
						String s = MessageText.getString("splash.loadIpFilters");
						do
						{
							reportCurrentTask(s);
							s = (new StringBuilder()).append(s).append(".").toString();
						} while (!semFilterLoader.reserve(3000L));
					}
					nextTask();
					reportCurrentTaskByKey("splash.initializeGui");
					Colors.getInstance();
					Cursors.init();
					main_window_will_report_complete = true;
					new MainWindow(core, Initializer.this, logEvents);
					if (finalLogListener != null)
						Logger.removeListener(finalLogListener);
					SWTUpdateChecker.initialize();
					PreUpdateChecker.initialize(core, COConfigurationManager.getStringParameter("ui"));
					UpdateMonitor.getSingleton(core);
					Alerts.initComplete();
					for (int i = 0; i < args.length; i++)
						try
						{
							TorrentOpener.openTorrent(args[i]);
						}
						catch (Throwable e)
						{
							Debug.printStackTrace(e);
						}

					if (!main_window_will_report_complete)
						init_task.release();
					break MISSING_BLOCK_LABEL_277;
					Exception exception;
					exception;
					if (!main_window_will_report_complete)
						init_task.release();
					throw exception;
				}

				public void stopping(AzureusCore core)
				{
					Alerts.stopInitiated();
				}

				public void stopped(AzureusCore azureuscore)
				{
				}

				public boolean syncInvokeRequired()
				{
					return true;
				}

				public boolean requiresPluginInitCompleteBeforeStartedEvent()
				{
					return false;
				}

				public boolean stopRequested(AzureusCore _core)
					throws AzureusCoreException
				{
					return Initializer.handleStopRestart(false);
				}

				public boolean restartRequested(AzureusCore core)
				{
					return Initializer.handleStopRestart(true);
				}

			
			{
				this$0 = Initializer.this;
				logEvents = arraylist;
				finalLogListener = ilogeventlistener;
				super();
			}
			});
			azureus_core.start();
		}
		catch (Throwable e)
		{
			Logger.log(new LogEvent(LOGID, "Initialization fails:", e));
			init_task.release();
		}
	}

	public void addListener(InitializerListener listener)
	{
		listeners_mon.enter();
		listeners.add(listener);
		listeners_mon.exit();
		break MISSING_BLOCK_LABEL_35;
		Exception exception;
		exception;
		listeners_mon.exit();
		throw exception;
	}

	public void removeListener(InitializerListener listener)
	{
		listeners_mon.enter();
		listeners.remove(listener);
		listeners_mon.exit();
		break MISSING_BLOCK_LABEL_36;
		Exception exception;
		exception;
		listeners_mon.exit();
		throw exception;
	}

	public void reportCurrentTask(AzureusCoreOperation operation, String currentTask)
	{
		if (operation.getOperationType() == 1)
			reportCurrentTask(currentTask);
	}

	public void reportPercent(AzureusCoreOperation operation, int percent)
	{
		if (operation.getOperationType() == 1)
			reportPercent(percent);
	}

	public void reportCurrentTask(String currentTaskString)
	{
		listeners_mon.enter();
		for (Iterator iter = listeners.iterator(); iter.hasNext();)
			try
			{
				InitializerListener listener = (InitializerListener)iter.next();
				listener.reportCurrentTask(currentTaskString);
			}
			catch (Throwable e)
			{
				Debug.printStackTrace(e);
			}

		listeners_mon.exit();
		break MISSING_BLOCK_LABEL_74;
		Exception exception;
		exception;
		listeners_mon.exit();
		throw exception;
	}

	public void initializationComplete()
	{
		azureus_core.getPluginManager().firePluginEvent(6);
		new DelayedEvent("SWTInitComplete:delay", 8500L, new AERunnable() {

			final Initializer this$0;

			public void runSupport()
			{
				init_task.release();
			}

			
			{
				this$0 = Initializer.this;
				super();
			}
		});
	}

	public void reportPercent(int percent)
	{
		int overallPercent = overallPercent(percent);
		listeners_mon.enter();
		for (Iterator iter = listeners.iterator(); iter.hasNext();)
			try
			{
				InitializerListener listener = (InitializerListener)iter.next();
				listener.reportPercent(overallPercent);
			}
			catch (Throwable e)
			{
				Debug.printStackTrace(e);
			}

		if (overallPercent > 100)
			listeners.clear();
		listeners_mon.exit();
		break MISSING_BLOCK_LABEL_97;
		Exception exception;
		exception;
		listeners_mon.exit();
		throw exception;
	}

	public void stopIt(boolean for_restart, boolean close_already_in_progress)
		throws AzureusCoreException
	{
		if (azureus_core != null && !close_already_in_progress && for_restart)
			azureus_core.checkRestartSupported();
		Cursors.dispose();
		SWTThread.getInstance().terminate();
		if (azureus_core != null && !close_already_in_progress)
			try
			{
				if (for_restart)
					azureus_core.restart();
				else
					azureus_core.stop();
			}
			catch (Throwable e)
			{
				Debug.out(e);
			}
		if (startServer != null)
			startServer.stopIt();
		break MISSING_BLOCK_LABEL_203;
		Exception exception;
		exception;
		if (startServer != null)
			startServer.stopIt();
		throw exception;
		Exception exception1;
		exception1;
		if (azureus_core != null && !close_already_in_progress)
			try
			{
				if (for_restart)
					azureus_core.restart();
				else
					azureus_core.stop();
			}
			catch (Throwable e)
			{
				Debug.out(e);
			}
		if (startServer != null)
			startServer.stopIt();
		break MISSING_BLOCK_LABEL_200;
		Exception exception2;
		exception2;
		if (startServer != null)
			startServer.stopIt();
		throw exception2;
		throw exception1;
	}

	private void setNbTasks(int _nbTasks)
	{
		currentTask = 0;
		nbTasks = _nbTasks;
	}

	public void nextTask()
	{
		currentTask++;
		currentPercent = (100 * currentTask) / nbTasks;
		reportPercent(0);
	}

	private int overallPercent(int taskPercent)
	{
		lastTaskPercent = taskPercent;
		return currentPercent + taskPercent / nbTasks;
	}

	private void reportCurrentTaskByKey(String key)
	{
		reportCurrentTask(MessageText.getString(key));
	}

	public void increaseProgress()
	{
		if (lastTaskPercent < 100)
			reportPercent(lastTaskPercent + 1);
	}

	public void abortProgress()
	{
		currentTask = nbTasks;
		nextTask();
		reportPercent(101);
	}

	public static void main(String args[])
	{
		if (Launcher.checkAndLaunch(org/gudy/azureus2/ui/swt/mainwindow/Initializer, args))
		{
			return;
		} else
		{
			System.err.println("Shouldn't you be starting with org.gudy.azureus2.ui.swt.Main?");
			AzureusCore core = AzureusCoreFactory.create();
			new Initializer(core, null, args);
			return;
		}
	}

	static 
	{
		LOGID = LogIDs.GUI;
	}







}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -