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

📄 progressreporterpanel.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:   ProgressReporterPanel.java

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

import com.aelitis.azureus.ui.swt.imageloader.ImageLoader;
import org.eclipse.swt.custom.StyleRange;
import org.eclipse.swt.custom.StyledText;
import org.eclipse.swt.events.MouseAdapter;
import org.eclipse.swt.events.MouseEvent;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.*;
import org.gudy.azureus2.core3.internat.MessageText;
import org.gudy.azureus2.ui.swt.*;
import org.gudy.azureus2.ui.swt.mainwindow.Colors;

// Referenced classes of package org.gudy.azureus2.ui.swt.progress:
//			IMessage, IProgressReport, IProgressReportConstants, IProgressReporter, 
//			IProgressReporterListener, ProgressReportingManager

public class ProgressReporterPanel extends Composite
	implements IProgressReportConstants, IProgressReporterListener
{

	private Color normalColor;
	private Color errorColor;
	public IProgressReporter pReporter;
	private Label imageLabel;
	private Label nameLabel;
	private Label statusLabel;
	private StyledText detailListWidget;
	private GridData detailSectionData;
	private AZProgressBar pBar;
	private Composite progressPanel;
	private TwistieSection detailSection;
	private int style;
	private Label actionLabel_cancel;
	private Label actionLabel_remove;
	private Label actionLabel_retry;
	private int maxPreferredDetailPanelHeight;
	private int maxPreferredDetailPanelHeight_Standalone;
	private int maxPreferredWidth;
	private String lastStatusError;

	public ProgressReporterPanel(Composite parent, IProgressReporter reporter, int style)
	{
		Composite(parent, (style & 0x10) == 0 ? 0 : 2048);
		normalColor = null;
		errorColor = null;
		pReporter = null;
		imageLabel = null;
		nameLabel = null;
		statusLabel = null;
		detailListWidget = null;
		detailSectionData = null;
		pBar = null;
		progressPanel = null;
		detailSection = null;
		actionLabel_cancel = null;
		actionLabel_remove = null;
		actionLabel_retry = null;
		maxPreferredDetailPanelHeight = 200;
		maxPreferredDetailPanelHeight_Standalone = 600;
		maxPreferredWidth = 900;
		lastStatusError = null;
		if (null == reporter)
		{
			throw new NullPointerException("IProgressReporter can not be null");
		} else
		{
			pReporter = reporter;
			this.style = style;
			normalColor = Colors.blue;
			errorColor = Colors.colorError;
			setLayoutData(new GridData(4, 128, true, false));
			GridLayout gLayout = new GridLayout(2, false);
			gLayout.marginWidth = 25;
			gLayout.marginTop = 15;
			gLayout.marginBottom = 10;
			setLayout(gLayout);
			createControls(pReporter.getProgressReport());
			addListener(11, new Listener() {

				final ProgressReporterPanel this$0;

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

			
			{
				this$0 = ProgressReporterPanel.this;
				Object();
			}
			});
			pReporter.addListener(this);
			return;
		}
	}

	public int report(IProgressReport pReport)
	{
		return handleEvents(pReport);
	}

	private void createControls(IProgressReport pReport)
	{
		imageLabel = new Label(this, 0);
		imageLabel.setLayoutData(new GridData(1, 128, false, false, 1, 3));
		progressPanel = new Composite(this, 0);
		progressPanel.setLayoutData(new GridData(4, 4, true, false));
		GridLayout rightLayout = new GridLayout(4, false);
		rightLayout.marginHeight = 0;
		rightLayout.marginWidth = 0;
		progressPanel.setLayout(rightLayout);
		nameLabel = new Label(progressPanel, 64);
		nameLabel.setLayoutData(new GridData(4, 0x1000000, true, false, 4, 1));
		pBar = new AZProgressBar(progressPanel, pReport.isIndeterminate());
		pBar.setLayoutData(new GridData(4, 0x1000000, true, false));
		actionLabel_cancel = new Label(progressPanel, 0);
		actionLabel_cancel.setLayoutData(new GridData(0x1000008, 0x1000000, false, false));
		actionLabel_remove = new Label(progressPanel, 0);
		actionLabel_remove.setLayoutData(new GridData(0x1000008, 0x1000000, false, false));
		actionLabel_retry = new Label(progressPanel, 0);
		actionLabel_retry.setLayoutData(new GridData(0x1000008, 0x1000000, false, false));
		statusLabel = new Label(progressPanel, 0);
		statusLabel.setLayoutData(new GridData(1, 0x1000000, true, false, 2, 1));
		createDetailSection(pReport);
		initControls(pReport);
		actionLabel_cancel.addMouseListener(new MouseAdapter() {

			final ProgressReporterPanel this$0;

			public void mouseDown(MouseEvent e)
			{
				pReporter.cancel();
			}

			
			{
				this$0 = ProgressReporterPanel.this;
				MouseAdapter();
			}
		});
		actionLabel_retry.addMouseListener(new MouseAdapter() {

			final ProgressReporterPanel this$0;

			public void mouseDown(MouseEvent e)
			{
				pReporter.retry();
			}

			
			{
				this$0 = ProgressReporterPanel.this;
				MouseAdapter();
			}
		});
		actionLabel_remove.addMouseListener(new MouseAdapter() {

			final ProgressReporterPanel this$0;

			public void mouseDown(MouseEvent e)
			{
				ProgressReportingManager.getInstance().remove(pReporter);
				dispose();
			}

			
			{
				this$0 = ProgressReporterPanel.this;
				MouseAdapter();
			}
		});
	}

	private void initControls(IProgressReport pReport)
	{
		if (null != pReport.getImage())
			imageLabel.setImage(pReport.getImage());
		else
			imageLabel.setImage(getDisplay().getSystemImage(2));
		nameLabel.setText(formatForDisplay(pReport.getName()));
		ImageLoader imageLoader = ImageLoader.getInstance();
		imageLoader.setLabelImage(actionLabel_cancel, "progress_cancel");
		imageLoader.setLabelImage(actionLabel_remove, "progress_remove");
		imageLoader.setLabelImage(actionLabel_retry, "progress_retry");
		actionLabel_cancel.setToolTipText(MessageText.getString("Progress.reporting.action.label.cancel.tooltip"));
		actionLabel_remove.setToolTipText(MessageText.getString("Progress.reporting.action.label.remove.tooltip"));
		actionLabel_retry.setToolTipText(MessageText.getString("Progress.reporting.action.label.retry.tooltip"));
		if (pReport.isInErrorState())
			updateStatusLabel(MessageText.getString("Progress.reporting.default.error"), true);
		else
		if (pReport.isDone())
			updateStatusLabel(MessageText.getString("Progress.reporting.status.finished"), false);
		else
		if (pReport.isCanceled())
			updateStatusLabel(MessageText.getString("Progress.reporting.status.canceled"), false);
		else
		if (pReport.isIndeterminate())
			updateStatusLabel("∞", false);
		else
			updateStatusLabel((new StringBuilder()).append(pReport.getPercentage()).append("%").toString(), false);
		synchProgressBar(pReport);
		synchActionLabels(pReport);
	}

	private void createDetailSection(IProgressReport pReport)
	{
		Label separator = new Label(this, 258);
		separator.setLayoutData(new GridData(4, 128, true, false));
		detailSection = new TwistieSection(this, 2);
		detailSection.setTitle(MessageText.getString("Progress.reporting.action.label.detail"));
		Composite sectionContent = detailSection.getContent();
		detailSectionData = new GridData(4, 4, true, true);
		detailSection.setLayoutData(detailSectionData);
		GridLayout sectionLayout = new GridLayout();
		sectionLayout.marginHeight = 0;
		sectionLayout.marginWidth = 0;
		sectionContent.setLayout(sectionLayout);
		detailSection.setEnabled(false);
		detailListWidget = new StyledText(sectionContent, 2624);
		detailListWidget.setLayoutData(new GridData(4, 4, true, true));
		IMessage messages[] = pReporter.getMessageHistory();
		for (int i = 0; i < messages.length; i++)
			if (messages[i].getType() == 4)
				appendToDetail(formatForDisplay(messages[i].getValue()), true);
			else
				appendToDetail(formatForDisplay(messages[i].getValue()), false);

		resizeDetailSection();
		detailSection.addTwistieListener(new ITwistieListener() {

			final ProgressReporterPanel this$0;

			public void isCollapsed(boolean value)
			{
				resizeDetailSection();
				layout(true, true);
			}

			
			{
				this$0 = ProgressReporterPanel.this;
				Object();
			}
		});
	}

	private void resizeDetailSection()
	{
		Point computedSize = detailSection.computeSize(-1, -1);
		detailSectionData.heightHint = computedSize.y;
		if ((8 & style) != 0)
		{
			if (computedSize.y > maxPreferredDetailPanelHeight_Standalone)
				detailSectionData.heightHint = maxPreferredDetailPanelHeight_Standalone;
		} else
		if (computedSize.y > maxPreferredDetailPanelHeight)
			detailSectionData.heightHint = maxPreferredDetailPanelHeight;
		if (computedSize.x > maxPreferredWidth)
			detailSectionData.widthHint = maxPreferredWidth;
	}

	public Point computeSize(int hint, int hint2, boolean changed)
	{
		Point newSize = super.computeSize(hint, hint2, changed);
		if (newSize.x > maxPreferredWidth)
			newSize.x = maxPreferredWidth;
		return newSize;
	}

	private int handleEvents(final IProgressReport pReport)
	{
		if (null == pReport || isDisposed() || null == getDisplay())
			return 0;
		switch (pReport.getReportType())
		{
		case 6: // '\006'
			getDisplay().asyncExec(new Runnable() {

				final IProgressReport val$pReport;
				final ProgressReporterPanel this$0;

				public void run()

⌨️ 快捷键说明

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