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

📄 welcomewindow.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:   WelcomeWindow.java

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

import com.aelitis.azureus.ui.swt.utils.ColorCache;
import java.io.*;
import java.net.URL;
import java.util.Locale;
import org.eclipse.swt.browser.Browser;
import org.eclipse.swt.custom.StyleRange;
import org.eclipse.swt.custom.StyledText;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.Font;
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.utils.resourcedownloader.*;
import org.gudy.azureus2.pluginsimpl.local.utils.resourcedownloader.ResourceDownloaderFactoryImpl;
import org.gudy.azureus2.ui.swt.Utils;
import org.gudy.azureus2.ui.swt.components.shell.ShellFactory;

public class WelcomeWindow
{

	private static final String URL_WHATSNEW = "http://www.vuze.com/releasenotes";
	private static final String lineSeparator = System.getProperty("line.separator");
	Display display;
	Shell shell;
	Color black;
	Color white;
	Color light;
	Color grey;
	Color green;
	Color blue;
	Color fg;
	Color bg;
	String sWhatsNew;
	Font monospace;

	public WelcomeWindow(Shell parentShell)
	{
		try
		{
			init(parentShell);
		}
		catch (Throwable t) { }
	}

	public void init(Shell parentShell)
	{
		shell = ShellFactory.createShell(parentShell, 2160);
		Utils.setShellIcon(shell);
		if (Constants.isOSX)
			monospace = new Font(shell.getDisplay(), "Courier", 12, 0);
		else
			monospace = new Font(shell.getDisplay(), "Courier New", 8, 0);
		shell.setText(MessageText.getString("window.welcome.title", new String[] {
			"4.2.0.0"
		}));
		display = shell.getDisplay();
		GridLayout layout = new GridLayout();
		shell.setLayout(layout);
		Composite cWhatsNew = new Composite(shell, 2048);
		GridData data = new GridData(1808);
		cWhatsNew.setLayoutData(data);
		cWhatsNew.setLayout(new FillLayout());
		Button bClose = new Button(shell, 8);
		bClose.setText(MessageText.getString("Button.close"));
		data = new GridData();
		data.widthHint = 70;
		data.horizontalAlignment = Constants.isOSX ? 0x1000000 : 0x20000;
		bClose.setLayoutData(data);
		Listener closeListener = new Listener() {

			final WelcomeWindow this$0;

			public void handleEvent(Event event)
			{
				close();
			}

			
			{
				this$0 = WelcomeWindow.this;
				super();
			}
		};
		bClose.addListener(13, closeListener);
		shell.addListener(21, closeListener);
		shell.setDefaultButton(bClose);
		shell.addListener(31, new Listener() {

			final WelcomeWindow this$0;

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

			
			{
				this$0 = WelcomeWindow.this;
				super();
			}
		});
		shell.setSize(750, 500);
		Utils.centreWindow(shell);
		shell.layout();
		shell.open();
		fillWhatsNew(cWhatsNew);
	}

	private void fillWhatsNew(Composite cWhatsNew)
	{
		Label label = new Label(cWhatsNew, 0x1000000);
		label.setText(MessageText.getString("installPluginsWizard.details.loading"));
		shell.layout(true, true);
		shell.update();
		String helpFile = MessageText.getString("window.welcome.file");
		if ((sWhatsNew == null || sWhatsNew.length() == 0) && helpFile.toLowerCase().startsWith("http://azureus.sourceforge.net/"))
		{
			sWhatsNew = getWhatsNew(helpFile);
			if (shell.isDisposed())
				return;
		}
		if (sWhatsNew == null || sWhatsNew.length() == 0)
		{
			helpFile = (new StringBuilder()).append("http://www.vuze.com/releasenotes?version=4.2.0.0&locale=").append(Locale.getDefault().toString()).append("&ui=").append(COConfigurationManager.getStringParameter("ui")).toString();
			sWhatsNew = getWhatsNew(helpFile);
			if (shell.isDisposed())
				return;
		}
		if (sWhatsNew == null || sWhatsNew.length() == 0)
		{
			InputStream stream = getClass().getResourceAsStream(helpFile);
			if (stream == null)
			{
				String helpFullPath = (new StringBuilder()).append("/org/gudy/azureus2/internat/whatsnew/").append(helpFile).toString();
				stream = getClass().getResourceAsStream(helpFullPath);
			}
			if (stream == null)
				stream = getClass().getResourceAsStream("/ChangeLog.txt");
			if (stream == null)
				sWhatsNew = (new StringBuilder()).append("Welcome Window: Error loading resource: ").append(helpFile).toString();
			else
				try
				{
					sWhatsNew = FileUtil.readInputStreamAsString(stream, 65535, "utf8");
					stream.close();
				}
				catch (IOException e)
				{
					Debug.out(e);
				}
		}
		if (sWhatsNew.indexOf("<html") >= 0 || sWhatsNew.indexOf("<HTML") >= 0)
		{
			try
			{
				Browser browser = new Browser(cWhatsNew, Utils.getInitialBrowserStyle(0));
				browser.setText(sWhatsNew);
			}
			catch (Throwable t)
			{
				try
				{
					File tempFile = File.createTempFile("AZU", ".html");
					tempFile.deleteOnExit();
					FileUtil.writeBytesAsFile(tempFile.getAbsolutePath(), sWhatsNew.getBytes("utf8"));
					Utils.launch(tempFile.getAbsolutePath());
					shell.dispose();
					return;
				}
				catch (IOException e) { }
			}
		} else
		{
			StyledText helpPanel = new StyledText(cWhatsNew, 768);
			helpPanel.setEditable(false);
			try
			{
				helpPanel.setRedraw(false);
				helpPanel.setWordWrap(false);
				helpPanel.setFont(monospace);
				black = ColorCache.getColor(display, 0, 0, 0);
				white = ColorCache.getColor(display, 255, 255, 255);
				light = ColorCache.getColor(display, 200, 200, 200);
				grey = ColorCache.getColor(display, 50, 50, 50);
				green = ColorCache.getColor(display, 30, 80, 30);
				blue = ColorCache.getColor(display, 20, 20, 80);
				helpPanel.setForeground(grey);
				String lines[] = sWhatsNew.split("\\r?\\n");
				for (int i = 0; i < lines.length; i++)
				{
					String line = lines[i];
					boolean setStyle = false;
					fg = grey;
					bg = white;
					int style = 0;
					char styleChar;
					String text;
					if (line.length() < 2)
					{
						styleChar = ' ';
						text = (new StringBuilder()).append(" ").append(lineSeparator).toString();
					} else
					{
						styleChar = line.charAt(0);
						text = (new StringBuilder()).append(line.substring(1)).append(lineSeparator).toString();
					}
					switch (styleChar)
					{
					case 42: // '*'
						text = (new StringBuilder()).append("  * ").append(text).toString();
						fg = green;
						setStyle = true;
						break;

					case 43: // '+'
						text = (new StringBuilder()).append("     ").append(text).toString();
						fg = black;
						bg = light;
						style = 1;
						setStyle = true;
						break;

					case 33: // '!'
						style = 1;
						setStyle = true;
						break;

					case 64: // '@'
						fg = blue;
						setStyle = true;
						break;

					case 36: // '$'
						bg = blue;
						fg = white;
						style = 1;
						setStyle = true;
						break;

					case 32: // ' '
						text = (new StringBuilder()).append("  ").append(text).toString();
						break;

					default:
						text = (new StringBuilder()).append(styleChar).append(text).toString();
						break;
					}
					helpPanel.append(text);
					if (setStyle)
					{
						int lineCount = helpPanel.getLineCount() - 1;
						int charCount = helpPanel.getCharCount();
						int lineOfs = helpPanel.getOffsetAtLine(lineCount - 1);
						int lineLen = charCount - lineOfs;
						helpPanel.setStyleRange(new StyleRange(lineOfs, lineLen, fg, bg, style));
						helpPanel.setLineBackground(lineCount - 1, 1, bg);
					}
				}

				helpPanel.setRedraw(true);
			}
			catch (Exception e)
			{
				System.out.println((new StringBuilder()).append("Unable to load help contents because:").append(e).toString());
			}
		}
		label.dispose();
		shell.layout(true, true);
	}

	private String getWhatsNew(String url)
	{
		String s[] = new String[1];
		(new AEThread(url, s) {

			final String val$url;
			final String val$s[];
			final WelcomeWindow this$0;

			public void runSupport()
			{
				ResourceDownloaderFactory rdf = ResourceDownloaderFactoryImpl.getSingleton();
				try
				{
					ResourceDownloader rd = rdf.create(new URL(url));
					InputStream is = rd.download();
					int length = is.available();
					byte data[] = new byte[length];
					is.read(data);
					is.close();
					s[0] = new String(data);
				}
				catch (ResourceDownloaderException rde)
				{
					s[0] = "";
				}
				catch (Exception e)
				{
					Debug.out(e);
					s[0] = "";
				}
				if (!shell.isDisposed())
					shell.getDisplay().wake();
			}

			
			{
				this$0 = WelcomeWindow.this;
				url = s1;
				s = as;
				super(x0, x1);
			}
		}).start();
		do
		{
			if (shell.isDisposed() || s[0] != null)
				break;
			if (!shell.getDisplay().readAndDispatch())
				shell.getDisplay().sleep();
		} while (true);
		return s[0];
	}

	private void close()
	{
		monospace.dispose();
		shell.dispose();
	}

	public static void main(String args[])
	{
		System.out.println(Locale.getDefault().getCountry());
		new WelcomeWindow(null);
		do
		{
			Display display;
			for (display = Display.getDefault(); display.readAndDispatch(););
			display.sleep();
		} while (true);
	}


}

⌨️ 快捷键说明

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