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

📄 uimanagerimpl.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:   UIManagerImpl.java

package org.gudy.azureus2.pluginsimpl.local.ui;

import com.aelitis.azureus.core.util.CopyOnWriteList;
import com.aelitis.azureus.ui.IUIIntializer;
import java.io.File;
import java.net.URL;
import java.util.*;
import org.gudy.azureus2.core3.internat.MessageText;
import org.gudy.azureus2.core3.util.AEMonitor;
import org.gudy.azureus2.core3.util.Debug;
import org.gudy.azureus2.plugins.*;
import org.gudy.azureus2.plugins.logging.LoggerChannel;
import org.gudy.azureus2.plugins.torrent.Torrent;
import org.gudy.azureus2.plugins.ui.SWT.SWTManager;
import org.gudy.azureus2.plugins.ui.*;
import org.gudy.azureus2.plugins.ui.components.UIProgressBar;
import org.gudy.azureus2.plugins.ui.components.UITextField;
import org.gudy.azureus2.plugins.ui.menus.MenuManager;
import org.gudy.azureus2.plugins.ui.model.*;
import org.gudy.azureus2.plugins.ui.tables.TableManager;
import org.gudy.azureus2.pluginsimpl.local.deprecate.PluginDeprecation;
import org.gudy.azureus2.pluginsimpl.local.ui.SWT.SWTManagerImpl;
import org.gudy.azureus2.pluginsimpl.local.ui.menus.MenuManagerImpl;
import org.gudy.azureus2.pluginsimpl.local.ui.model.BasicPluginConfigModelImpl;
import org.gudy.azureus2.pluginsimpl.local.ui.model.BasicPluginViewModelImpl;
import org.gudy.azureus2.pluginsimpl.local.ui.tables.TableManagerImpl;

// Referenced classes of package org.gudy.azureus2.pluginsimpl.local.ui:
//			UIManagerEventAdapter

public class UIManagerImpl
	implements UIManager
{

	protected static AEMonitor class_mon = new AEMonitor("UIManager:class");
	protected static boolean initialisation_complete;
	protected static CopyOnWriteList ui_listeners = new CopyOnWriteList();
	protected static CopyOnWriteList ui_event_listeners = new CopyOnWriteList();
	protected static List ui_factories = new ArrayList();
	protected static List ui_event_history = new ArrayList();
	protected static List configModels = new ArrayList();
	protected PluginInterface pi;
	protected PluginConfig plugin_config;
	protected String key_prefix;
	protected TableManager table_manager;
	protected MenuManager menu_manager;

	public UIManagerImpl(PluginInterface _pi)
	{
		pi = _pi;
		plugin_config = pi.getPluginconfig();
		key_prefix = plugin_config.getPluginConfigKeyPrefix();
		table_manager = new TableManagerImpl(this);
		menu_manager = new MenuManagerImpl(this);
	}

	public PluginInterface getPluginInterface()
	{
		return pi;
	}

	public BasicPluginViewModel getBasicPluginViewModel(String name)
	{
		return createBasicPluginViewModel(name);
	}

	public PluginView createPluginView(PluginViewModel model)
	{
		return SWTManagerImpl.getSingleton().createPluginView(model);
		Throwable e;
		e;
		e.printStackTrace();
		return null;
	}

	public BasicPluginViewModel createBasicPluginViewModel(String name)
	{
		BasicPluginViewModel model = new BasicPluginViewModelImpl(this, name);
		fireEvent(pi, 4, model);
		return model;
	}

	public void destroy(BasicPluginViewModel model)
	{
		fireEvent(pi, 7, model);
	}

	public BasicPluginConfigModel createBasicPluginConfigModel(String section_name)
	{
		return createBasicPluginConfigModel("plugins", section_name);
	}

	public BasicPluginConfigModel createBasicPluginConfigModel(String parent_section, String section_name)
	{
		BasicPluginConfigModel model = new BasicPluginConfigModelImpl(this, parent_section, section_name);
		class_mon.enter();
		configModels.add(model);
		class_mon.exit();
		break MISSING_BLOCK_LABEL_47;
		Exception exception;
		exception;
		class_mon.exit();
		throw exception;
		fireEvent(pi, 5, model);
		return model;
	}

	public void destroy(BasicPluginConfigModel model)
	{
		class_mon.enter();
		configModels.remove(model);
		class_mon.exit();
		break MISSING_BLOCK_LABEL_34;
		Exception exception;
		exception;
		class_mon.exit();
		throw exception;
		fireEvent(pi, 8, model);
		return;
	}

	public PluginConfigModel[] getPluginConfigModels()
	{
		PluginConfigModel apluginconfigmodel[];
		class_mon.enter();
		apluginconfigmodel = (PluginConfigModel[])(PluginConfigModel[])configModels.toArray(new PluginConfigModel[0]);
		class_mon.exit();
		return apluginconfigmodel;
		Exception exception;
		exception;
		class_mon.exit();
		throw exception;
	}

	public void copyToClipBoard(String data)
		throws UIException
	{
		boolean ok = fireEvent(pi, 6, data);
		if (!ok)
			throw new UIException("Failed to deliver request to UI");
		else
			return;
	}

	public void openURL(URL url)
		throws UIException
	{
		boolean ok = fireEvent(pi, 9, url);
		if (!ok)
			throw new UIException("Failed to deliver request to UI");
		else
			return;
	}

	public TableManager getTableManager()
	{
		return table_manager;
	}

	public MenuManager getMenuManager()
	{
		return menu_manager;
	}

	public SWTManager getSWTManager()
	{
		PluginDeprecation.call("getSWTManager", pi.getPluginID());
		return SWTManagerImpl.getSingleton();
	}

	public static void initialisationComplete()
	{
		class_mon.enter();
		initialisation_complete = true;
		for (int j = 0; j < ui_factories.size(); j++)
		{
			UIInstanceFactory instance = (UIInstanceFactory)ui_factories.get(j);
			for (Iterator it = ui_listeners.iterator(); it.hasNext();)
			{
				Object entry[] = (Object[])(Object[])it.next();
				try
				{
					((UIManagerListener)entry[0]).UIAttached(instance.getInstance((PluginInterface)entry[1]));
				}
				catch (Throwable e)
				{
					Debug.printStackTrace(e);
				}
			}

		}

		class_mon.exit();
		break MISSING_BLOCK_LABEL_128;
		Exception exception;
		exception;
		class_mon.exit();
		throw exception;
	}

	public void attachUI(UIInstanceFactory factory)
		throws UIException
	{
		attachUI(factory, null);
	}

	public void attachUI(UIInstanceFactory factory, IUIIntializer init)
	{
		class_mon.enter();
		ui_factories.add(factory);
		if (initialisation_complete)
		{
			for (Iterator it = ui_listeners.iterator(); it.hasNext();)
			{
				Object entry[] = (Object[])(Object[])it.next();
				PluginInterface pi = (PluginInterface)entry[1];
				String name = pi.getPluginName();
				if (init != null)
				{
					init.reportCurrentTask(MessageText.getString("splash.plugin.UIinit", new String[] {
						name
					}));
					init.increaseProgress();
				}
				try
				{
					((UIManagerListener)entry[0]).UIAttached(factory.getInstance(pi));
				}
				catch (Throwable e)
				{
					Debug.printStackTrace(e);
				}
			}

		}
		class_mon.exit();
		break MISSING_BLOCK_LABEL_153;
		Exception exception;
		exception;
		class_mon.exit();
		throw exception;
	}

	public void detachUI(UIInstanceFactory instance)
		throws UIException
	{
		class_mon.enter();
		instance.detach();
		ui_factories.remove(instance);
		if (initialisation_complete)
		{
			for (Iterator it = ui_listeners.iterator(); it.hasNext();)
			{
				Object entry[] = (Object[])(Object[])it.next();
				try
				{
					((UIManagerListener)entry[0]).UIDetached(instance.getInstance((PluginInterface)entry[1]));
				}
				catch (Throwable e)
				{
					Debug.printStackTrace(e);
				}
			}

		}
		class_mon.exit();
		break MISSING_BLOCK_LABEL_113;
		Exception exception;
		exception;
		class_mon.exit();
		throw exception;
	}

	public void addUIListener(UIManagerListener listener)
	{
		class_mon.enter();
		ui_listeners.add(((Object) (new Object[] {
			listener, pi
		})));
		if (initialisation_complete)
		{
			for (int i = 0; i < ui_factories.size(); i++)
			{
				UIInstanceFactory instance = (UIInstanceFactory)ui_factories.get(i);
				try
				{
					listener.UIAttached(instance.getInstance(pi));
				}
				catch (Throwable e)
				{
					Debug.printStackTrace(e);
				}
			}

		}
		class_mon.exit();
		break MISSING_BLOCK_LABEL_112;
		Exception exception;
		exception;
		class_mon.exit();
		throw exception;
	}

	public void removeUIListener(UIManagerListener listener)
	{
		class_mon.enter();
		Iterator it = ui_listeners.iterator();
		do
		{
			if (!it.hasNext())
				break;
			Object entry[] = (Object[])(Object[])it.next();
			if (entry[0] == listener)
				it.remove();
		} while (true);
		class_mon.exit();
		break MISSING_BLOCK_LABEL_71;
		Exception exception;
		exception;
		class_mon.exit();
		throw exception;
	}

	public void addUIEventListener(UIManagerEventListener listener)
	{
		List ui_event_history_copy;
		class_mon.enter();
		ui_event_listeners.add(listener);
		ui_event_history_copy = new ArrayList(ui_event_history);
		class_mon.exit();
		break MISSING_BLOCK_LABEL_42;
		Exception exception;
		exception;
		class_mon.exit();
		throw exception;
		for (int i = 0; i < ui_event_history_copy.size(); i++)
			try
			{
				listener.eventOccurred((UIManagerEvent)ui_event_history_copy.get(i));
			}
			catch (Throwable e)
			{
				Debug.printStackTrace(e);
			}

		return;
	}

	public void removeUIEventListener(UIManagerEventListener listener)
	{
		class_mon.enter();
		ui_event_listeners.remove(listener);
		class_mon.exit();
		break MISSING_BLOCK_LABEL_32;
		Exception exception;
		exception;
		class_mon.exit();
		throw exception;
	}

	public boolean hasUIInstances()
	{
		return !ui_factories.isEmpty();
	}

	public UIInstance[] getUIInstances()
	{
		UIInstance auiinstance[];
		class_mon.enter();
		ArrayList result = new ArrayList(ui_factories.size());
		for (int i = 0; i < ui_factories.size(); i++)
		{
			UIInstanceFactory instance = (UIInstanceFactory)ui_factories.get(i);
			result.add(instance.getInstance(pi));
		}

		auiinstance = (UIInstance[])(UIInstance[])result.toArray(new UIInstance[result.size()]);
		class_mon.exit();
		return auiinstance;
		Exception exception;
		exception;
		class_mon.exit();
		throw exception;
	}

	public static boolean fireEvent(PluginInterface pi, int type, Object data)
	{
		return fireEvent(new UIManagerEventAdapter(pi, type, data));
	}

	public static boolean fireEvent(UIManagerEventAdapter event)
	{
		boolean delivered;
		int type;
		delivered = false;
		Iterator event_it = ui_event_listeners.iterator();
		do
		{
			if (!event_it.hasNext())
				break;
			try
			{
				if (!((UIManagerEventListener)event_it.next()).eventOccurred(event))
					continue;
				delivered = true;
				break;
			}
			catch (Throwable e)
			{
				e.printStackTrace();
			}
		} while (true);
		type = event.getType();
		if (type != 4 && type != 5 && type != 12 && type != 15 && type != 17 && type != 19)
			break MISSING_BLOCK_LABEL_132;
		delivered = true;
		class_mon.enter();
		ui_event_history.add(event);
		class_mon.exit();
		break MISSING_BLOCK_LABEL_252;
		Exception exception;
		exception;
		class_mon.exit();
		throw exception;
		if (type != 7 && type != 8)
			break MISSING_BLOCK_LABEL_252;
		delivered = true;
		class_mon.enter();
		Iterator history_it = ui_event_history.iterator();
		do
		{
			if (!history_it.hasNext())
				break;
			UIManagerEvent e = (UIManagerEvent)history_it.next();
			int e_type = e.getType();
			if (e_type != 4 && e_type != 5 || e.getData() != event.getData())
				continue;
			history_it.remove();
			break;
		} while (true);
		class_mon.exit();
		break MISSING_BLOCK_LABEL_252;
		Exception exception1;
		exception1;
		class_mon.exit();
		throw exception1;
		return delivered;
	}

	public void showTextMessage(String title_resource, String message_resource, String contents)
	{
		fireEvent(pi, 1, new String[] {
			title_resource, message_resource, contents
		});
	}

	public long showMessageBox(String title_resource, String message_resource, long message_map)
	{
		UIManagerEventAdapter event = new UIManagerEventAdapter(pi, 21, ((Object) (new Object[] {
			title_resource, message_resource, new Long(message_map)
		})));
		if (!fireEvent(event))
			return 0L;
		else
			return ((Long)event.getResult()).longValue();
	}

	public void openTorrent(Torrent torrent)
	{
		fireEvent(pi, 22, torrent);
	}

	public void openFile(File file)
	{
		fireEvent(pi, 24, file);
	}

	public void showFile(File file)
	{
		fireEvent(pi, 23, file);
	}

	public boolean showConfigSection(String sectionID)
	{
		UIManagerEventAdapter event = new UIManagerEventAdapter(pi, 13, sectionID);
		if (!fireEvent(event))
			return false;
		if (event.getResult() instanceof Boolean)
			return false;
		else
			return ((Boolean)event.getResult()).booleanValue();
	}

	public UIInputReceiver getInputReceiver()
	{
		UIInstance instances[] = getUIInstances();
		UIInputReceiver r = null;
		for (int i = 0; i < instances.length; i++)
		{
			r = instances[i].getInputReceiver();
			if (r != null)
				return r;
		}

		return null;
	}

	public UIMessage createMessage()
	{
		UIInstance instances[] = getUIInstances();
		UIMessage r = null;
		for (int i = 0; i < instances.length; i++)
		{
			r = instances[i].createMessage();
			if (r != null)
				return r;
		}

		return null;
	}

	public BasicPluginViewModel createLoggingViewModel(LoggerChannel channel, boolean use_plugin_name)
	{
		String log_view_name = use_plugin_name ? pi.getPluginName() : channel.getName();
		BasicPluginViewModel model = createBasicPluginViewModel(log_view_name);
		model.getActivity().setVisible(false);
		model.getProgress().setVisible(false);
		model.getStatus().setVisible(false);
		model.attachLoggerChannel(channel);
		return model;
	}

	public static void unload(PluginInterface pi)
	{
		class_mon.enter();
		Iterator it = ui_listeners.iterator();
		do
		{
			if (!it.hasNext())
				break;
			Object entry[] = (Object[])(Object[])it.next();
			if (pi == (PluginInterface)entry[1])
				it.remove();
		} while (true);
		Iterator ev_it = ui_event_history.iterator();
		do
		{
			if (!ev_it.hasNext())
				break;
			UIManagerEventAdapter event = (UIManagerEventAdapter)ev_it.next();
			if (event.getPluginInterface() == pi)
				ev_it.remove();
		} while (true);
		class_mon.exit();
		break MISSING_BLOCK_LABEL_119;
		Exception exception;
		exception;
		class_mon.exit();
		throw exception;
	}

}

⌨️ 快捷键说明

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