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

📄 messagepopupshell.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:   MessagePopupShell.java

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

import com.aelitis.azureus.ui.swt.UIFunctionsManagerSWT;
import com.aelitis.azureus.ui.swt.UIFunctionsSWT;
import com.aelitis.azureus.ui.swt.imageloader.ImageLoader;
import java.lang.ref.WeakReference;
import java.util.*;
import org.eclipse.swt.custom.StyledText;
import org.eclipse.swt.graphics.*;
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.AERunnable;
import org.gudy.azureus2.core3.util.Constants;
import org.gudy.azureus2.ui.swt.Messages;
import org.gudy.azureus2.ui.swt.Utils;
import org.gudy.azureus2.ui.swt.animations.Animator;
import org.gudy.azureus2.ui.swt.animations.shell.AnimableShell;
import org.gudy.azureus2.ui.swt.animations.shell.LinearAnimator;

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

public class MessagePopupShell
	implements AnimableShell
{

	private Shell shell;
	private Shell detailsShell;
	Image shellImg;
	private Display display;
	public static final String ICON_ERROR = "error";
	public static final String ICON_WARNING = "warning";
	public static final String ICON_INFO = "info";
	private static LinkedList viewStack = new LinkedList();
	private Timer closeTimer;
	private String icon;
	private Animator currentAnimator;
	private boolean closeAfterAnimation;
	int x0;
	int y0;
	int x1;
	int y1;

	public MessagePopupShell(String icon, String keyPrefix, String details, String textParams[], Display display)
	{
		this(display, icon, MessageText.getString((new StringBuilder()).append(keyPrefix).append(".title").toString()), MessageText.getString((new StringBuilder()).append(keyPrefix).append(".text").toString(), textParams), details);
	}

	public MessagePopupShell(Display display, String icon, String title, String errorMessage, String details)
	{
		closeTimer = new Timer(true);
		this.display = display;
		this.icon = icon;
		detailsShell = new Shell(display, 18432);
		Utils.setShellIcon(detailsShell);
		detailsShell.setLayout(new FillLayout());
		StyledText textDetails = new StyledText(detailsShell, 2824);
		textDetails.setBackground(display.getSystemColor(1));
		textDetails.setWordWrap(true);
		detailsShell.layout();
		detailsShell.setSize(550, 300);
		int popupWidth = 280;
		int popupHeight = 170;
		shell = new Shell(display, 16384);
		Utils.setShellIcon(shell);
		FormLayout layout = new FormLayout();
		layout.marginHeight = 0;
		layout.marginWidth = 0;
		try
		{
			layout.spacing = 0;
		}
		catch (NoSuchFieldError e) { }
		shell.setLayout(layout);
		ImageLoader imageLoader = ImageLoader.getInstance();
		Image popup_image = imageLoader.getImage("popup");
		GC gcImage = null;
		if (ImageLoader.isRealImage(popup_image))
		{
			shellImg = new Image(display, popup_image, 0);
			popupWidth = popup_image.getBounds().width;
			popupHeight = popup_image.getBounds().height;
		} else
		{
			shellImg = new Image(display, new Rectangle(0, 0, popupWidth, popupHeight));
		}
		imageLoader.releaseImage("popup");
		shell.setSize(popupWidth, popupHeight);
		gcImage = new GC(shellImg);
		Image imgIcon = imageLoader.getImage(icon);
		int iconWidth = 0;
		int iconHeight = 15;
		if (ImageLoader.isRealImage(imgIcon))
		{
			gcImage.drawImage(imgIcon, 5, 5);
			iconWidth = imgIcon.getBounds().width;
			iconHeight = imgIcon.getBounds().height;
		}
		imageLoader.releaseImage(icon);
		Font tempFont = shell.getFont();
		FontData fontDataMain[] = tempFont.getFontData();
		for (int i = 0; i < fontDataMain.length; i++)
		{
			fontDataMain[i].setStyle(1);
			fontDataMain[i].setHeight((int)((double)fontDataMain[i].getHeight() * 1.2D));
		}

		Font fontTitle = new Font(display, fontDataMain);
		gcImage.setFont(fontTitle);
		Rectangle rect = new Rectangle(iconWidth + 10, 5, popupWidth - iconWidth - 15, iconHeight);
		GCStringPrinter.printString(gcImage, title, rect);
		gcImage.setFont(tempFont);
		fontTitle.dispose();
		rect = new Rectangle(5, iconHeight + 5, popupWidth - 10, popupHeight - iconHeight - 60);
		boolean bItFit = GCStringPrinter.printString(gcImage, errorMessage, rect);
		gcImage.dispose();
		if (!bItFit && details == null)
			details = errorMessage;
		if (details != null)
			textDetails.setText(details);
		final Button btnDetails = new Button(shell, 2);
		Messages.setLanguageText(btnDetails, "popup.error.details");
		btnDetails.setEnabled(details != null);
		final Button btnHide = new Button(shell, 8);
		Messages.setLanguageText(btnHide, "popup.error.hide");
		Label lblImage = new Label(shell, 0);
		if (shellImg != null)
			lblImage.setImage(shellImg);
		FormData formData = new FormData();
		formData.right = new FormAttachment(btnHide, -5);
		formData.bottom = new FormAttachment(100, -5);
		btnDetails.setLayoutData(formData);
		formData = new FormData();
		formData.right = new FormAttachment(100, -5);
		formData.bottom = new FormAttachment(100, -5);
		btnHide.setLayoutData(formData);
		formData = new FormData();
		formData.left = new FormAttachment(0, 0);
		formData.top = new FormAttachment(0, 0);
		lblImage.setLayoutData(formData);
		Button btnHideAll = null;
		if (viewStack.size() > 0)
		{
			btnHideAll = new Button(shell, 8);
			btnHideAll.moveAbove(btnDetails);
			Messages.setLanguageText(btnHideAll, "popup.error.hideall");
			formData = new FormData();
			formData.right = new FormAttachment(btnDetails, -5);
			formData.bottom = new FormAttachment(100, -5);
			btnHideAll.setLayoutData(formData);
			btnHideAll.addListener(4, new Listener() {

				final Button val$btnHide;
				final Button val$btnDetails;
				final MessagePopupShell this$0;

				public void handleEvent(Event event)
				{
					btnHide.setEnabled(false);
					btnDetails.setEnabled(false);
					Iterator iter = MessagePopupShell.viewStack.iterator();
					do
					{
						if (!iter.hasNext())
							break;
						WeakReference wr = (WeakReference)iter.next();
						MessagePopupShell popup = (MessagePopupShell)wr.get();
						iter.remove();
						if (popup == null)
							return;
						popup.shell.dispose();
						popup.detailsShell.dispose();
						if (popup.shellImg != null)
							popup.shellImg.dispose();
					} while (true);
				}

			
			{
				this$0 = MessagePopupShell.this;
				btnHide = button;
				btnDetails = button1;
				super();
			}
			});
		}
		shell.layout();
		shell.setTabList(new Control[] {
			btnDetails, btnHide
		});
		btnHide.addListener(4, new Listener() {

			final Button val$btnHide;
			final Button val$btnDetails;
			final MessagePopupShell this$0;

			public void handleEvent(Event arg0)
			{
				btnHide.setEnabled(false);
				btnDetails.setEnabled(false);
				hideShell();
			}

			
			{
				this$0 = MessagePopupShell.this;
				btnHide = button;
				btnDetails = button1;
				super();
			}
		});
		btnDetails.addListener(4, new Listener() {

			final Button val$btnDetails;
			final MessagePopupShell this$0;

			public void handleEvent(Event arg0)
			{
				detailsShell.setVisible(btnDetails.getSelection());
			}

			
			{
				this$0 = MessagePopupShell.this;
				btnDetails = button;
				super();
			}
		});
		Rectangle bounds = null;
		try
		{
			UIFunctionsSWT uiFunctions = UIFunctionsManagerSWT.getUIFunctionsSWT();
			if (uiFunctions != null)
			{
				Shell mainShell = uiFunctions.getMainShell();
				bounds = mainShell.getMonitor().getClientArea();
			}
		}
		catch (Exception e) { }
		if (bounds == null)
			bounds = display.getClientArea();
		x0 = (bounds.x + bounds.width) - popupWidth - 5;
		x1 = bounds.x + bounds.width;
		y0 = bounds.y + bounds.height;
		y1 = (bounds.y + bounds.height) - popupHeight - 5;
		shell.setLocation(x0, y0);
		viewStack.addFirst(new WeakReference(this));
		detailsShell.setLocation(x1 - detailsShell.getSize().x, y1 - detailsShell.getSize().y);
		currentAnimator = new LinearAnimator(this, new Point(x0, y0), new Point(x0, y1), 20, 30);
		currentAnimator.start();
		shell.open();
	}

	private void hideShell()
	{
		try
		{
			if (currentAnimator == null)
			{
				closeTimer.cancel();
				detailsShell.setVisible(false);
				detailsShell.forceActive();
				if (!Constants.isOSX)
					detailsShell.forceFocus();
				currentAnimator = new LinearAnimator(this, new Point(x0, y1), new Point(x1, y1), 20, 30);
				currentAnimator.start();
				closeAfterAnimation = true;
			}
		}
		catch (Exception e)
		{
			closeAfterAnimation = true;
			animationEnded(null);
		}
	}

	public void animationEnded(Animator source)
	{
		if (source == currentAnimator)
			currentAnimator = null;
		if (closeAfterAnimation)
		{
			if (display == null || display.isDisposed())
				return;
			display.asyncExec(new AERunnable() {

				final MessagePopupShell this$0;

				public void runSupport()
				{
					MessagePopupShell.viewStack.removeFirst();
					shell.dispose();
					detailsShell.dispose();
					if (shellImg != null)
						shellImg.dispose();
				}

			
			{
				this$0 = MessagePopupShell.this;
				super();
			}
			});
		} else
		{
			scheduleAutocloseTask();
		}
	}

	private void scheduleAutocloseTask()
	{
		int delay = COConfigurationManager.getIntParameter("Message Popup Autoclose in Seconds") * 1000;
		if (delay < 1000)
		{
			return;
		} else
		{
			closeTimer.scheduleAtFixedRate(new TimerTask() {

				final MessagePopupShell this$0;

				public void run()
				{
					display.syncExec(new AERunnable() {

						final 5 this$1;

						public void runSupport()
						{
							if (shell.isDisposed())
							{
								closeTimer.cancel();
								return;
							}
							boolean notInfoType = icon != "info";
							if (notInfoType)
							{
								closeTimer.cancel();
								return;
							}
							boolean notTopWindow = ((WeakReference)MessagePopupShell.viewStack.getFirst()).get() != 0;
							boolean animationInProgress = currentAnimator != null;
							boolean detailsOpen = !detailsShell.isDisposed() && detailsShell.isVisible();
							Control cc = display.getCursorControl();
							boolean mouseOver = cc == shell;
							if (!mouseOver)
							{
								Control childControls[] = shell.getChildren();
								int i = 0;
								do
								{
									if (i >= childControls.length)
										break;
									if (childControls[i] == cc)
									{
										mouseOver = true;
										break;
									}
									i++;
								} while (true);
							}
							if (notTopWindow || mouseOver || animationInProgress || detailsOpen)
							{
								return;
							} else
							{
								hideShell();
								return;
							}
						}

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

			
			{
				this$0 = MessagePopupShell.this;
				super();
			}
			}, delay, delay);
			return;
		}
	}

	public void animationStarted(Animator animator)
	{
	}

	public Shell getShell()
	{
		return shell;
	}

	public void reportPercent(int i)
	{
	}









}

⌨️ 快捷键说明

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