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

📄 messageboxshell.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:   MessageBoxShell.java

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

import com.aelitis.azureus.ui.UIFunctionsUserPrompter;
import com.aelitis.azureus.ui.common.RememberedDecisionsManager;
import com.aelitis.azureus.ui.swt.UISkinnableManagerSWT;
import com.aelitis.azureus.ui.swt.UISkinnableSWTListener;
import com.aelitis.azureus.ui.swt.imageloader.ImageLoader;
import com.aelitis.azureus.ui.swt.utils.ColorCache;
import java.io.PrintStream;
import org.eclipse.swt.browser.*;
import org.eclipse.swt.events.*;
import org.eclipse.swt.graphics.*;
import org.eclipse.swt.layout.*;
import org.eclipse.swt.widgets.*;
import org.gudy.azureus2.core3.internat.MessageText;
import org.gudy.azureus2.core3.util.*;
import org.gudy.azureus2.ui.swt.Utils;
import org.gudy.azureus2.ui.swt.components.shell.ShellFactory;
import org.gudy.azureus2.ui.swt.mainwindow.ClipboardCopy;

// Referenced classes of package org.gudy.azureus2.ui.swt.shells:
//			GCStringPrinter

public class MessageBoxShell
	implements UIFunctionsUserPrompter
{

	public static final String STATUS_TEXT_CLOSE = "__VUZE__MessageBoxShell__CLOSE";
	private static final int MIN_SIZE_X_DEFAULT = 300;
	private static final int MIN_SIZE_Y_DEFAULT = 120;
	private static final int MAX_SIZE_X_DEFAULT = 500;
	private static final int MIN_BUTTON_SIZE = 70;
	private static int numOpen = 0;
	private Shell parent;
	private int min_size_x;
	private int min_size_y;
	private int max_size_x;
	private final String title;
	private final String text;
	private final String buttons[];
	private final int defaultOption;
	private String rememberID;
	private String rememberText;
	private boolean rememberByDefault;
	private int rememberOnlyIfButton;
	private int autoCloseInMS;
	private String html;
	private String url;
	private boolean squish;
	private boolean autoClosed;
	private Object relatedObjects[];
	private Image imgLeft;
	protected Color urlColor;
	private boolean handleHTML;
	private Image iconImage;
	private Browser shell_browser;
	private boolean browser_follow_links;
	protected boolean isRemembered;
	private String iconImageID;

	public static int open(Shell parent, String title, String text, String buttons[], int defaultOption)
	{
		return open(parent, title, text, buttons, defaultOption, null, false, -1);
	}

	public static int open(Shell parent, String title, String text, String buttons[], int defaultOption, String rememberID, boolean bRememberByDefault, int autoCloseInMS)
	{
		return open(parent, title, text, buttons, defaultOption, rememberID, MessageText.getString("MessageBoxWindow.rememberdecision"), bRememberByDefault, autoCloseInMS);
	}

	public static int open(Shell parent, String title, String text, String buttons[], int defaultOption, String rememberID, String rememberText, boolean bRememberByDefault, 
			int autoCloseInMS)
	{
		MessageBoxShell messageBoxShell = new MessageBoxShell(parent, title, text, buttons, defaultOption, rememberID, rememberText, bRememberByDefault, autoCloseInMS);
		return messageBoxShell.open();
	}

	public static boolean isOpen()
	{
		return numOpen > 0;
	}

	public MessageBoxShell(Shell parent, String title, String text, String buttons[], int defaultOption, String rememberID, String rememberText, 
			boolean bRememberByDefault, int autoCloseInMS)
	{
		min_size_x = 300;
		min_size_y = 120;
		max_size_x = 500;
		rememberOnlyIfButton = -1;
		autoClosed = false;
		handleHTML = true;
		this.parent = parent;
		this.title = title;
		this.text = text;
		this.buttons = buttons;
		this.defaultOption = defaultOption;
		this.rememberID = rememberID;
		this.rememberText = rememberText;
		rememberByDefault = bRememberByDefault;
		this.autoCloseInMS = autoCloseInMS;
	}

	public MessageBoxShell(Shell parent, String title, String text, String buttons[], int defaultOption)
	{
		MessageBoxShell(parent, title, text, buttons, defaultOption, null, null, false, -1);
	}

	public int open()
	{
		return open(false);
	}

	private int open(boolean useCustomShell)
	{
		if (rememberID != null)
		{
			int rememberedDecision = RememberedDecisionsManager.getRememberedDecision(rememberID);
			if (rememberedDecision >= 0)
				return rememberedDecision;
		}
		numOpen++;
		final int result[] = new int[1];
		result[0] = -1;
		Utils.execSWTThread(new AERunnable() {

			final int val$result[];
			final MessageBoxShell this$0;

			public void runSupport()
			{
				result[0] = _open();
			}

			
			{
				this$0 = MessageBoxShell.this;
				result = ai;
				AERunnable();
			}
		}, false);
		numOpen--;
		return result[0];
	}

	private int _open()
	{
		final int result[] = {
			-1
		};
		if (parent == null || parent.isDisposed())
		{
			parent = Utils.findAnyShell();
			if (parent == null || parent.isDisposed())
				return result[0];
		}
		org.eclipse.swt.events.MouseTrackAdapter mouseAdapter = null;
		Display display = parent.getDisplay();
		final Shell shell = ShellFactory.createShell(parent, 0x10870);
		if (title != null)
			shell.setText(title);
		shell.setBackgroundMode(1);
		shell.addListener(21, new Listener() {

			final MessageBoxShell this$0;

			public void handleEvent(Event arg0)
			{
				try
				{
					if (shell_browser != null)
					{
						shell_browser.setUrl("about:blank");
						shell_browser.setVisible(false);
					}
				}
				catch (Throwable e) { }
			}

			
			{
				this$0 = MessageBoxShell.this;
				Object();
			}
		});
		shell.addListener(12, new Listener() {

			final MessageBoxShell this$0;

			public void handleEvent(Event event)
			{
				if (iconImageID != null)
					ImageLoader.getInstance().releaseImage(iconImageID);
			}

			
			{
				this$0 = MessageBoxShell.this;
				Object();
			}
		});
		GridLayout gridLayout = new GridLayout();
		if (squish)
		{
			gridLayout.verticalSpacing = 0;
			gridLayout.horizontalSpacing = 0;
			gridLayout.marginLeft = 0;
			gridLayout.marginRight = 0;
			gridLayout.marginTop = 0;
			gridLayout.marginBottom = 0;
			gridLayout.marginWidth = 0;
			gridLayout.marginHeight = 0;
		}
		shell.setLayout(gridLayout);
		Utils.setShellIcon(shell);
		UISkinnableSWTListener listeners[] = UISkinnableManagerSWT.getInstance().getSkinnableListeners(org/gudy/azureus2/ui/swt/shells/MessageBoxShell.toString());
		for (int i = 0; i < listeners.length; i++)
			listeners[i].skinBeforeComponents(shell, this, relatedObjects);

		Composite textComposite = shell;
		if (imgLeft != null)
		{
			textComposite = new Composite(shell, 0);
			textComposite.setForeground(shell.getForeground());
			GridLayout gl = new GridLayout(2, false);
			gl.horizontalSpacing = 10;
			textComposite.setLayout(gl);
			textComposite.setLayoutData(new GridData(1808));
			Label lblImage = new Label(textComposite, 0);
			lblImage.setImage(imgLeft);
			lblImage.setLayoutData(new GridData(2));
		}
		Control linkControl;
		if (this.text != null && this.text.length() > 0)
			linkControl = createLinkLabel(textComposite, this.text);
		else
			linkControl = null;
		if (html != null && html.length() > 0 || url != null && url.length() > 0)
		{
			try
			{
				final Browser browser = shell_browser = new Browser(shell, Utils.getInitialBrowserStyle(0));
				if (url != null && url.length() > 0)
					browser.setUrl(url);
				else
					browser.setText(html);
				GridData gd = new GridData(1808);
				gd.heightHint = 200;
				browser.setLayoutData(gd);
				browser.addProgressListener(new ProgressListener() {

					final Browser val$browser;
					final MessageBoxShell this$0;

					public void completed(ProgressEvent event)
					{
						browser.addLocationListener(new LocationListener() {

							final 4 this$1;

							public void changing(LocationEvent event)
							{
								event.doit = browser_follow_links;
							}

							public void changed(LocationEvent locationevent)
							{
							}

					
					{
						this$1 = 4.this;
						Object();
					}
						});
						browser.addOpenWindowListener(new OpenWindowListener() {

							final 4 this$1;

							public void open(WindowEvent event)
							{
								event.required = true;
							}

					
					{
						this$1 = 4.this;
						Object();
					}
						});
					}

					public void changed(ProgressEvent progressevent)
					{
					}

			
			{
				this$0 = MessageBoxShell.this;
				browser = browser1;
				Object();
			}
				});
				browser.addStatusTextListener(new StatusTextListener() {

					final Browser val$browser;
					final Shell val$shell;
					final MessageBoxShell this$0;

					public void changed(StatusTextEvent event)
					{
						if ("__VUZE__MessageBoxShell__CLOSE".equals(event.text))
							Utils.execSWTThreadLater(0, new Runnable() {

								final 5 this$1;

								public void run()
								{
									if (!browser.isDisposed() && !shell.isDisposed())
										shell.close();
								}

					
					{
						this$1 = 5.this;
						Object();
					}
							});
					}

			
			{
				this$0 = MessageBoxShell.this;
				browser = browser1;
				shell = shell1;
				Object();
			}
				});
			}
			catch (Exception e)
			{
				Debug.out(e);
				if (html != null)
				{
					Text text = new Text(shell, 2120);
					text.setText(html);
					GridData gd = new GridData(1808);
					gd.heightHint = 200;
					text.setLayoutData(gd);
				}
			}
			if (linkControl != null)
			{
				GridData gridData = new GridData(768);
				linkControl.setLayoutData(gridData);
			}
		} else
		if (linkControl != null)
		{
			GridData gridData = new GridData(1808);
			linkControl.setLayoutData(gridData);
		}
		if (!squish && (autoCloseInMS > 0 || rememberID != null))
		{
			Label lblPadding = new Label(shell, 0);
			lblPadding.setLayoutData(new GridData(768));
		}
		if (autoCloseInMS > 0)
		{
			final Label lblCloseIn = new Label(shell, 64);
			lblCloseIn.setForeground(shell.getForeground());
			lblCloseIn.setLayoutData(new GridData(768));
			long endOn = SystemTime.getCurrentTime() + (long)autoCloseInMS;
			lblCloseIn.setData("CloseOn", new Long(endOn));
			SimpleTimer.addPeriodicEvent("autoclose", 500L, new TimerEventPerformer() {

				final Shell val$shell;
				final Label val$lblCloseIn;
				final int val$result[];
				final MessageBoxShell this$0;

				public void perform(TimerEvent event)
				{
					if (shell.isDisposed())
					{
						event.cancel();
						return;
					} else
					{
						Utils.execSWTThread(new AERunnable() {

							final 6 this$1;

							public void runSupport()
							{
								if (!shell.isDisposed())
								{
									boolean bDelayPaused = lblCloseIn.getData("DelayPaused") != null;
									if (bDelayPaused)
										return;
									long endOn = ((Long)lblCloseIn.getData("CloseOn")).longValue();
									if (SystemTime.getCurrentTime() > endOn)
									{
										result[0] = defaultOption;
										autoClosed = true;
										shell.dispose();
									} else
									{
										String sText = "";
										if (lblCloseIn.isDisposed())
											return;
										if (!bDelayPaused)
										{
											long delaySecs = (endOn - SystemTime.getCurrentTime()) / 1000L;
											sText = MessageText.getString("popup.closing.in", new String[] {
												String.valueOf(delaySecs)
											});
										}
										lblCloseIn.setText(sText);
									}
								}
							}

					
					{
						this$1 = 6.this;
						AERunnable();
					}
						});
						return;
					}
				}

			
			{
				this$0 = MessageBoxShell.this;
				shell = shell1;
				lblCloseIn = label;
				result = ai;
				Object();
			}
			});
			SimpleTimer.addPeriodicEvent("OverPopup", 100L, new TimerEventPerformer() {

				boolean wasOver;
				long lEnterOn;
				final Shell val$shell;
				final Label val$lblCloseIn;
				final MessageBoxShell this$0;

				public void perform(final TimerEvent event)
				{
					if (shell.isDisposed())
					{
						event.cancel();
						return;
					} else
					{
						Utils.execSWTThread(new AERunnable() {

							final TimerEvent val$event;
							final 7 this$1;

							public void runSupport()
							{
								if (shell.isDisposed())
								{
									event.cancel();
									return;
								}
								boolean isOver = shell.getBounds().contains(shell.getDisplay().getCursorLocation());
								if (isOver != wasOver)
								{
									wasOver = isOver;
									if (isOver)
									{
										lblCloseIn.setData("DelayPaused", "");
										lEnterOn = SystemTime.getCurrentTime();
										lblCloseIn.setText("");
									} else
									{
										lblCloseIn.setData("DelayPaused", null);
										if (lEnterOn > 0L)
										{
											long diff = SystemTime.getCurrentTime() - lEnterOn;
											long endOn = ((Long)lblCloseIn.getData("CloseOn")).longValue() + diff;
											lblCloseIn.setData("CloseOn", new Long(endOn));
										}
									}
								}
							}

					
					{
						this$1 = 7.this;
						event = timerevent;
						AERunnable();
					}
						});
						return;
					}
				}

			

⌨️ 快捷键说明

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