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

📄 updatewindow.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:   UpdateWindow.java

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

import com.aelitis.azureus.core.AzureusCore;
import com.aelitis.azureus.ui.swt.UIFunctionsManagerSWT;
import com.aelitis.azureus.ui.swt.UIFunctionsSWT;
import java.io.InputStream;
import java.util.*;
import org.eclipse.swt.browser.Browser;
import org.eclipse.swt.custom.SashForm;
import org.eclipse.swt.layout.*;
import org.eclipse.swt.widgets.*;
import org.gudy.azureus2.core3.config.COConfigurationManager;
import org.gudy.azureus2.core3.internat.MessageText;
import org.gudy.azureus2.core3.util.*;
import org.gudy.azureus2.plugins.update.*;
import org.gudy.azureus2.plugins.utils.resourcedownloader.*;
import org.gudy.azureus2.ui.swt.Messages;
import org.gudy.azureus2.ui.swt.Utils;
import org.gudy.azureus2.ui.swt.components.LinkArea;
import org.gudy.azureus2.ui.swt.components.StringListChooser;
import org.gudy.azureus2.ui.swt.components.shell.ShellFactory;
import org.gudy.azureus2.ui.swt.mainwindow.MainStatusBar;
import org.gudy.azureus2.ui.swt.mainwindow.SWTThread;

// Referenced classes of package org.gudy.azureus2.ui.swt.update:
//			UpdateMonitor

public class UpdateWindow
	implements ResourceDownloaderListener
{

	private UpdateMonitor update_monitor;
	private UpdateCheckInstance check_instance;
	private int check_type;
	Display display;
	Shell updateWindow;
	Table table;
	LinkArea link_area;
	ProgressBar progress;
	Label status;
	Button btnOk;
	Listener lOk;
	Button btnCancel;
	Listener lCancel;
	boolean hasMandatoryUpdates;
	boolean restartRequired;
	private long totalDownloadSize;
	private List downloaders;
	private Iterator iterDownloaders;
	private Browser browser;
	private static final int COL_NAME = 0;
	private static final int COL_VERSION = 1;
	private static final int COL_SIZE = 2;
	private Map downloadersToData;

	public UpdateWindow(UpdateMonitor _update_monitor, AzureusCore _azureus_core, UpdateCheckInstance _check_instance)
	{
		update_monitor = _update_monitor;
		check_instance = _check_instance;
		check_type = check_instance.getType();
		check_instance.addDecisionListener(new UpdateManagerDecisionListener() {

			final UpdateWindow this$0;

			public Object decide(Update update, int decision_type, String decision_name, String decision_description, Object decision_data)
			{
				if (decision_type == 0)
				{
					String options[] = (String[])(String[])decision_data;
					Shell shell = updateWindow;
					if (shell == null)
					{
						Debug.out("Shell doesn't exist");
						return null;
					}
					StringListChooser chooser = new StringListChooser(shell);
					chooser.setTitle(decision_name);
					chooser.setText(decision_description);
					for (int i = 0; i < options.length; i++)
						chooser.addOption(options[i]);

					String result = chooser.open();
					return result;
				} else
				{
					return null;
				}
			}

			
			{
				this$0 = UpdateWindow.this;
				super();
			}
		});
		updateWindow = null;
		display = SWTThread.getInstance().getDisplay();
		Utils.execSWTThreadWithBool("UpdateWindow", new AERunnableBoolean() {

			final UpdateWindow this$0;

			public boolean runSupport()
			{
				buildWindow();
				return true;
			}

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

	public void buildWindow()
	{
		if (display == null || display.isDisposed())
			return;
		Utils.waitForModals();
		updateWindow = ShellFactory.createMainShell(2160);
		updateWindow.addListener(21, new Listener() {

			final UpdateWindow this$0;

			public void handleEvent(Event e)
			{
				dispose();
			}

			
			{
				this$0 = UpdateWindow.this;
				super();
			}
		});
		Utils.setShellIcon(updateWindow);
		String res_prefix = "swt.";
		if (check_type == 1)
			res_prefix = (new StringBuilder()).append(res_prefix).append("install.window").toString();
		else
		if (check_type == 3)
			res_prefix = (new StringBuilder()).append(res_prefix).append("uninstall.window").toString();
		else
			res_prefix = "UpdateWindow";
		Messages.setLanguageText(updateWindow, (new StringBuilder()).append(res_prefix).append(".title").toString());
		FormLayout layout = new FormLayout();
		try
		{
			layout.spacing = 5;
		}
		catch (NoSuchFieldError e) { }
		layout.marginHeight = 10;
		layout.marginWidth = 10;
		updateWindow.setLayout(layout);
		Label lHeaderText = new Label(updateWindow, 64);
		Messages.setLanguageText(lHeaderText, (new StringBuilder()).append(res_prefix).append(".header").toString());
		FormData formData = new FormData();
		formData.left = new FormAttachment(0, 0);
		formData.right = new FormAttachment(100, 0);
		formData.top = new FormAttachment(0, 0);
		lHeaderText.setLayoutData(formData);
		SashForm sash = new SashForm(updateWindow, 512);
		table = new Table(sash, 0x10824);
		String names[] = {
			"name", "version", "size"
		};
		int sizes[] = {
			350, 100, 100
		};
		for (int i = 0; i < names.length; i++)
		{
			TableColumn column = new TableColumn(table, i != 0 ? 0x20000 : 16384);
			Messages.setLanguageText(column, (new StringBuilder()).append("UpdateWindow.columns.").append(names[i]).toString());
			column.setWidth(sizes[i]);
		}

		table.setHeaderVisible(true);
		table.addListener(13, new Listener() {

			final UpdateWindow this$0;

			public void handleEvent(Event e)
			{
				rowSelected();
			}

			
			{
				this$0 = UpdateWindow.this;
				super();
			}
		});
		Composite cInfoArea = new Composite(sash, 0);
		cInfoArea.setLayout(new FormLayout());
		link_area = new LinkArea(cInfoArea);
		FormData fd = new FormData();
		fd.top = new FormAttachment(0, 0);
		fd.bottom = new FormAttachment(100, 0);
		fd.right = new FormAttachment(100, 0);
		fd.left = new FormAttachment(0, 0);
		link_area.getComponent().setLayoutData(fd);
		try
		{
			browser = new Browser(cInfoArea, Utils.getInitialBrowserStyle(2048));
			fd = new FormData();
			fd.top = new FormAttachment(0, 0);
			fd.bottom = new FormAttachment(100, 0);
			fd.right = new FormAttachment(100, 0);
			fd.left = new FormAttachment(0, 0);
			browser.setLayoutData(fd);
		}
		catch (Throwable t) { }
		progress = new ProgressBar(updateWindow, 0);
		progress.setMinimum(0);
		progress.setMaximum(100);
		progress.setSelection(0);
		status = new Label(updateWindow, 0);
		Composite cButtons = new Composite(updateWindow, 0);
		FillLayout fl = new FillLayout(256);
		fl.spacing = 3;
		cButtons.setLayout(fl);
		btnOk = new Button(cButtons, 8);
		Messages.setLanguageText(btnOk, (new StringBuilder()).append(res_prefix).append(".ok").toString());
		updateWindow.setDefaultButton(btnOk);
		lOk = new Listener() {

			final UpdateWindow this$0;

			public void handleEvent(Event e)
			{
				update();
			}

			
			{
				this$0 = UpdateWindow.this;
				super();
			}
		};
		btnOk.addListener(13, lOk);
		btnOk.setEnabled(false);
		btnCancel = new Button(cButtons, 8);
		Messages.setLanguageText(btnCancel, "UpdateWindow.cancel");
		lCancel = new Listener() {

			final UpdateWindow this$0;

			public void handleEvent(Event e)
			{
				dispose();
				check_instance.cancel();
			}

			
			{
				this$0 = UpdateWindow.this;
				super();
			}
		};
		btnCancel.addListener(13, lCancel);
		updateWindow.addListener(31, new Listener() {

			final UpdateWindow this$0;

			public void handleEvent(Event e)
			{
				if (e.character == '\033')
				{
					dispose();
					check_instance.cancel();
				}
			}

			
			{
				this$0 = UpdateWindow.this;
				super();
			}
		});
		formData = new FormData();
		formData.left = new FormAttachment(0, 0);
		formData.right = new FormAttachment(100, 0);
		formData.top = new FormAttachment(lHeaderText);
		formData.bottom = new FormAttachment(progress);
		sash.setLayoutData(formData);
		formData = new FormData();
		formData.left = new FormAttachment(0, 0);
		formData.right = new FormAttachment(100, 0);
		formData.bottom = new FormAttachment(status);
		progress.setLayoutData(formData);
		formData = new FormData();
		formData.left = new FormAttachment(0, 0);
		formData.right = new FormAttachment(100, 0);
		formData.bottom = new FormAttachment(cButtons);
		status.setLayoutData(formData);
		formData = new FormData();
		formData.right = new FormAttachment(100, 0);
		formData.bottom = new FormAttachment(100, 0);
		cButtons.setLayoutData(formData);
		sash.setWeights(new int[] {
			25, 75
		});
		updateWindow.setSize(600, 450);
	}

	protected void rowSelected()
	{
		checkMandatory();
		checkRestartNeeded();
		TableItem items[] = table.getSelection();
		if (items.length == 0)
			return;
		Update update = (Update)items[0].getData();
		String desciptionURL = update.getDesciptionURL();
		if (desciptionURL != null && browser != null)
		{
			browser.setUrl(desciptionURL);
			browser.setVisible(true);
			link_area.getComponent().setVisible(false);
		} else
		{
			if (browser != null)
				browser.setVisible(false);
			link_area.getComponent().setVisible(true);
			String descriptions[] = update.getDescription();
			link_area.reset();
			link_area.setRelativeURLBase(update.getRelativeURLBase());
			for (int i = 0; i < descriptions.length; i++)
				link_area.addLine(descriptions[i]);

		}
	}

	public Shell getShell()
	{
		return updateWindow;
	}

	public void dispose()
	{
		Utils.execSWTThread(new AERunnable() {

			final UpdateWindow this$0;

			public void runSupport()
			{
				updateWindow.dispose();
				UIFunctionsSWT functionsSWT = UIFunctionsManagerSWT.getUIFunctionsSWT();
				if (functionsSWT != null)
				{
					MainStatusBar mainStatusBar = functionsSWT.getMainStatusBar();
					if (mainStatusBar != null)
						mainStatusBar.setUpdateNeeded(null);
				}
			}

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

	public void addUpdate(final Update update)
	{
		if (display == null || display.isDisposed())
			return;
		if (update.isMandatory())
			hasMandatoryUpdates = true;
		display.asyncExec(new AERunnable() {

			final Update val$update;
			final UpdateWindow this$0;

			public void runSupport()
			{
				if (table == null || table.isDisposed())
					return;
				TableItem item = new TableItem(table, 0);
				item.setData(update);
				item.setText(0, update.getName() != null ? update.getName() : "Unknown");
				item.setText(1, update.getNewVersion() != null ? update.getNewVersion() : "Unknown");
				ResourceDownloader rds[] = update.getDownloaders();
				long totalLength = 0L;
				for (int i = 0; i < rds.length; i++)
					try
					{
						totalLength += rds[i].getSize();
					}
					catch (Exception e) { }

⌨️ 快捷键说明

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