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

📄 uiswtinstanceimpl.java

📁 java 文件下载器。可自定义
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
// 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:   UISWTInstanceImpl.java

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

import com.aelitis.azureus.core.AzureusCore;
import com.aelitis.azureus.ui.IUIIntializer;
import com.aelitis.azureus.ui.UIFunctionsManager;
import com.aelitis.azureus.ui.common.table.TableColumnCore;
import com.aelitis.azureus.ui.common.table.TableStructureEventDispatcher;
import com.aelitis.azureus.ui.common.table.impl.TableColumnImpl;
import com.aelitis.azureus.ui.swt.UIFunctionsManagerSWT;
import com.aelitis.azureus.ui.swt.UIFunctionsSWT;
import java.awt.*;
import java.io.File;
import java.lang.ref.WeakReference;
import java.net.URL;
import java.util.*;
import org.eclipse.swt.awt.SWT_AWT;
import org.eclipse.swt.custom.CLabel;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.graphics.ImageData;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.widgets.*;
import org.gudy.azureus2.core3.config.COConfigurationManager;
import org.gudy.azureus2.core3.download.DownloadManager;
import org.gudy.azureus2.core3.internat.MessageText;
import org.gudy.azureus2.core3.util.*;
import org.gudy.azureus2.plugins.PluginInterface;
import org.gudy.azureus2.plugins.PluginManager;
import org.gudy.azureus2.plugins.download.Download;
import org.gudy.azureus2.plugins.torrent.Torrent;
import org.gudy.azureus2.plugins.ui.*;
import org.gudy.azureus2.plugins.ui.menus.MenuItem;
import org.gudy.azureus2.plugins.ui.model.BasicPluginConfigModel;
import org.gudy.azureus2.plugins.ui.model.BasicPluginViewModel;
import org.gudy.azureus2.plugins.ui.tables.*;
import org.gudy.azureus2.pluginsimpl.local.download.DownloadImpl;
import org.gudy.azureus2.pluginsimpl.local.ui.UIManagerImpl;
import org.gudy.azureus2.ui.common.util.MenuItemManager;
import org.gudy.azureus2.ui.swt.*;
import org.gudy.azureus2.ui.swt.mainwindow.*;
import org.gudy.azureus2.ui.swt.minibar.AllTransfersBar;
import org.gudy.azureus2.ui.swt.minibar.DownloadBar;
import org.gudy.azureus2.ui.swt.plugins.*;
import org.gudy.azureus2.ui.swt.shells.MessageBoxShell;
import org.gudy.azureus2.ui.swt.views.table.utils.TableColumnManager;
import org.gudy.azureus2.ui.swt.views.table.utils.TableContextMenuManager;
import org.gudy.azureus2.ui.swt.views.utils.ManagerUtils;

// Referenced classes of package org.gudy.azureus2.ui.swt.pluginsimpl:
//			BasicPluginConfigImpl, BasicPluginViewImpl, UIMessageImpl, UISWTGraphicImpl, 
//			UISWTStatusEntryImpl

public class UISWTInstanceImpl
	implements UIInstanceFactory, UISWTInstance, UIManagerEventListener
{
	protected static class instanceWrapper
		implements UISWTInstance
	{

		private WeakReference pi_ref;
		private UISWTInstanceImpl delegate;

		public void detach()
			throws UIException
		{
			delegate.detach();
		}

		public Display getDisplay()
		{
			return delegate.getDisplay();
		}

		public Image loadImage(String resource)
		{
			PluginInterface pi = (PluginInterface)pi_ref.get();
			if (pi == null)
				return null;
			else
				return delegate.loadImage(pi, resource);
		}

		public UISWTGraphic createGraphic(Image img)
		{
			return delegate.createGraphic(img);
		}

		public void addView(String sParentID, String sViewID, UISWTViewEventListener l)
		{
			delegate.addView(sParentID, sViewID, l);
		}

		public void openMainView(String sViewID, UISWTViewEventListener l, Object dataSource)
		{
			delegate.openMainView(sViewID, l, dataSource);
		}

		public void openMainView(String sViewID, UISWTViewEventListener l, Object dataSource, boolean setfocus)
		{
			delegate.openMainView(sViewID, l, dataSource, setfocus);
		}

		public void removeViews(String sParentID, String sViewID)
		{
			delegate.removeViews(sParentID, sViewID);
		}

		public UISWTView[] getOpenViews(String sParentID)
		{
			return delegate.getOpenViews(sParentID);
		}

		public void addView(UISWTPluginView view, boolean autoOpen)
		{
			delegate.addView(view, autoOpen);
		}

		public void removeView(UISWTPluginView view)
		{
			delegate.removeView(view);
		}

		public void addView(UISWTAWTPluginView view, boolean auto_open)
		{
			delegate.addView(view, auto_open);
		}

		public void removeView(UISWTAWTPluginView view)
		{
			delegate.removeView(view);
		}

		public int promptUser(String title, String text, String options[], int defaultOption)
		{
			return delegate.promptUser(title, text, options, defaultOption);
		}

		public boolean openView(String sParentID, String sViewID, Object dataSource)
		{
			return delegate.openView(sParentID, sViewID, dataSource);
		}

		public boolean openView(String sParentID, String sViewID, Object dataSource, boolean setfocus)
		{
			return delegate.openView(sParentID, sViewID, dataSource, setfocus);
		}

		public UIInputReceiver getInputReceiver()
		{
			return delegate.getInputReceiver();
		}

		public UIMessage createMessage()
		{
			return delegate.createMessage();
		}

		public void showDownloadBar(Download download, boolean display)
		{
			delegate.showDownloadBar(download, display);
		}

		public void showTransfersBar(boolean display)
		{
			delegate.showTransfersBar(display);
		}

		public UISWTStatusEntry createStatusEntry()
		{
			return delegate.createStatusEntry();
		}

		public boolean openView(BasicPluginViewModel model)
		{
			return delegate.openView(model);
		}

		public void openConfig(BasicPluginConfigModel model)
		{
			delegate.openConfig(model);
		}

		protected instanceWrapper(PluginInterface _pi, UISWTInstanceImpl _delegate)
		{
			pi_ref = new WeakReference(_pi);
			delegate = _delegate;
		}
	}


	private AzureusCore core;
	private Map awt_view_map;
	private Map config_view_map;
	private Map views;
	private Map plugin_map;
	private boolean bUIAttaching;
	private final UIFunctionsSWT uiFunctions = (UIFunctionsSWT)UIFunctionsManager.getUIFunctions();

	public UISWTInstanceImpl(AzureusCore _core)
	{
		awt_view_map = new WeakHashMap();
		config_view_map = new WeakHashMap();
		views = new HashMap();
		plugin_map = new WeakHashMap();
		core = _core;
	}

	public void init(IUIIntializer init)
	{
		UIManager ui_manager = core.getPluginManager().getDefaultPluginInterface().getUIManager();
		ui_manager.addUIEventListener(this);
		bUIAttaching = true;
		((UIManagerImpl)ui_manager).attachUI(this, init);
		bUIAttaching = false;
	}

	public UIInstance getInstance(PluginInterface plugin_interface)
	{
		UIInstance instance = (UIInstance)plugin_map.get(plugin_interface);
		if (instance == null)
		{
			instance = new instanceWrapper(plugin_interface, this);
			plugin_map.put(plugin_interface, instance);
		}
		return instance;
	}

	public boolean eventOccurred(UIManagerEvent event)
	{
		boolean done = true;
		final Object data = event.getData();
label0:
		switch (event.getType())
		{
		case 1: // '\001'
		{
			Utils.execSWTThread(new Runnable() {

				final Object val$data;
				final UISWTInstanceImpl this$0;

				public void run()
				{
					String params[] = (String[])(String[])data;
					new TextViewerWindow(params[0], params[1], params[2]);
				}

			
			{
				this$0 = UISWTInstanceImpl.this;
				data = obj;
				super();
			}
			});
			break;
		}

		case 21: // '\025'
		{
			final int result[] = {
				0
			};
			Utils.execSWTThread(new Runnable() {

				final Object val$data;
				final int val$result[];
				final UISWTInstanceImpl this$0;

				public void run()
				{
					UIFunctionsManagerSWT.getUIFunctionsSWT().bringToFront();
					Object params[] = (Object[])(Object[])data;
					long _styles = ((Long)(Long)params[2]).longValue();
					int styles = 0;
					if ((_styles & 4L) != 0L)
						styles |= 0x40;
					if ((_styles & 8L) != 0L)
						styles |= 0x80;
					if ((_styles & 1L) != 0L)
						styles |= 0x20;
					if ((_styles & 2L) != 0L)
						styles |= 0x100;
					org.eclipse.swt.widgets.Shell shell = uiFunctions.getMainShell();
					if (shell != null)
					{
						int _r = Utils.openMessageBox(shell, styles, MessageText.getString((String)params[0]), MessageText.getString((String)params[1]));
						int r = 0;
						if ((_r & 0x40) != 0)
							r |= 4;
						if ((_r & 0x80) != 0)
							r |= 8;
						if ((_r & 0x20) != 0)
							r |= 1;
						if ((_r & 0x100) != 0)
							r |= 2;
						result[0] = r;
					}
				}

			
			{
				this$0 = UISWTInstanceImpl.this;
				data = obj;
				result = ai;
				super();
			}
			}, false);
			event.setResult(new Long(result[0]));
			break;
		}

		case 2: // '\002'
		{
			TorrentOpener.openTorrent(((File)data).toString());
			break;
		}

		case 22: // '\026'
		{
			Torrent t = (Torrent)data;
			try
			{
				File f = AETemporaryFileHandler.createTempFile();
				t.writeToFile(f);
				TorrentOpener.openTorrent(f.toString());
			}
			catch (Throwable e)
			{
				Debug.printStackTrace(e);
			}
			break;
		}

		case 3: // '\003'
		{
			Display display = SWTThread.getInstance().getDisplay();
			display.syncExec(new AERunnable() {

				final Object val$data;
				final UISWTInstanceImpl this$0;

				public void runSupport()
				{
					Object params[] = (Object[])(Object[])data;
					URL target = (URL)params[0];
					URL referrer = (URL)params[1];
					boolean auto_download = ((Boolean)params[2]).booleanValue();
					Map request_properties = (Map)params[3];
					if (!COConfigurationManager.getBooleanParameter("add_torrents_silently"))
						uiFunctions.bringToFront();
					if (auto_download)
					{
						org.eclipse.swt.widgets.Shell shell = uiFunctions.getMainShell();
						if (shell != null)
							new FileDownloadWindow(core, shell, target.toString(), referrer != null ? referrer.toString() : null, request_properties);
					} else
					{
						TorrentOpener.openTorrent(target.toString());
					}
				}

			
			{
				this$0 = UISWTInstanceImpl.this;
				data = obj;
				super();
			}
			});
			break;
		}

		case 4: // '\004'
		{
			if (data instanceof BasicPluginViewModel)
			{
				BasicPluginViewModel model = (BasicPluginViewModel)data;
				String sViewID = model.getName().replaceAll(" ", ".");
				BasicPluginViewImpl view = new BasicPluginViewImpl(model);
				addView("Main", sViewID, view);
			}
			break;
		}

		case 7: // '\007'
		{
			if (data instanceof BasicPluginViewModel)
			{
				BasicPluginViewModel model = (BasicPluginViewModel)data;
				String sViewID = model.getName().replaceAll(" ", ".");
				removeViews("Main", sViewID);
			}
			break;
		}

		case 5: // '\005'
		{
			if (data instanceof BasicPluginConfigModel)
			{
				BasicPluginConfigModel model = (BasicPluginConfigModel)data;
				BasicPluginConfigImpl view = new BasicPluginConfigImpl(new WeakReference(model));
				config_view_map.put(model, view);
				model.getPluginInterface().addConfigSection(view);
			}
			break;
		}

		case 8: // '\b'
		{
			if (!(data instanceof BasicPluginConfigModel))
				break;
			BasicPluginConfigModel model = (BasicPluginConfigModel)data;
			BasicPluginConfigImpl view = (BasicPluginConfigImpl)config_view_map.get(model);
			if (view != null)
				model.getPluginInterface().removeConfigSection(view);
			break;
		}

		case 6: // '\006'
		{
			ClipboardCopy.copyToClipBoard((String)data);
			break;
		}

		case 9: // '\t'
		{
			Utils.launch(((URL)data).toExternalForm());
			break;
		}

		case 10: // '\n'
		{
			if (data instanceof TableColumn)
			{
				event.setResult((TableColumn)data);
			} else
			{
				String args[] = (String[])(String[])data;
				event.setResult(new TableColumnImpl(args[0], args[1]));
			}
			break;
		}

		case 11: // '\013'
		{
			TableColumn _col = (TableColumn)data;
			if (_col instanceof TableColumnImpl)
			{
				TableColumnManager.getInstance().addColumns(new TableColumnCore[] {
					(TableColumnCore)_col
				});
				TableStructureEventDispatcher tsed = TableStructureEventDispatcher.getInstance(_col.getTableID());
				tsed.tableStructureChangedSWTThread(true);
			} else
			{
				throw new UIRuntimeException("TableManager.addColumn(..) can only add columns created by createColumn(..)");
			}
			break;
		}

		case 25: // '\031'
		{
			Object params[] = (Object[])(Object[])data;
			TableColumnManager tcManager = TableColumnManager.getInstance();
			Class dataSource = (Class)params[0];
			String columnName = (String)params[1];
			tcManager.registerColumn(dataSource, columnName, (TableColumnCreationListener)params[2]);
			String tables[] = tcManager.getTableIDs();
			String arr$[] = tables;
			int len$ = arr$.length;
			for (int i$ = 0; i$ < len$; i$++)
			{
				String tid = arr$[i$];
				TableStructureEventDispatcher tsed = TableStructureEventDispatcher.getInstance(tid);
				tsed.tableStructureChangedSWTThread(true);
			}

			break;
		}

		case 26: // '\032'
		{
			Object params[] = (Object[])(Object[])data;
			TableColumnManager tcManager = TableColumnManager.getInstance();
			Class dataSource = (Class)params[0];
			String columnName = (String)params[1];
			tcManager.unregisterColumn(dataSource, columnName, (TableColumnCreationListener)params[2]);
			String tables[] = tcManager.getTableIDs();
			String arr$[] = tables;
			int len$ = arr$.length;
			int i$ = 0;
			do
			{
				if (i$ >= len$)
					break label0;
				String tid = arr$[i$];
				TableColumnCore col = tcManager.getTableColumnCore(tid, columnName);
				if (col != null)
					col.remove();
				i$++;
			} while (true);
		}

		case 12: // '\f'
		{
			TableContextMenuItem item = (TableContextMenuItem)data;
			TableContextMenuManager.getInstance().addContextMenuItem(item);
			break;
		}

		case 15: // '\017'
		{
			MenuItem item = (MenuItem)data;
			MenuItemManager.getInstance().addMenuItem(item);
			break;
		}

		case 17: // '\021'
		{
			TableContextMenuItem item = (TableContextMenuItem)data;
			TableContextMenuManager.getInstance().removeContextMenuItem(item);
			break;
		}

⌨️ 快捷键说明

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