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

📄 progressreporter.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:   ProgressReporter.java

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

import com.aelitis.azureus.core.util.CopyOnWriteList;
import java.util.*;
import org.eclipse.swt.graphics.Image;
import org.gudy.azureus2.core3.internat.MessageText;
import org.gudy.azureus2.core3.util.Debug;

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

public class ProgressReporter
	implements IProgressReporter, IProgressReportConstants
{
	public class ProgressReport
		implements IProgressReport
	{

		private final String reporterType;
		private final int reporterID;
		private final int minimum;
		private final int maximum;
		private final int selection;
		private final int percentage;
		private final boolean isActive;
		private final boolean isIndeterminate;
		private final boolean isDone;
		private final boolean isPercentageInUse;
		private final boolean isCancelAllowed;
		public final boolean isCanceled;
		private final boolean isRetryAllowed;
		private final boolean isInErrorState;
		private final boolean isDisposed;
		private final String title;
		private final String message;
		private final String detailMessage;
		private final String errorMessage;
		private final String name;
		private final Image image;
		private final Object objectData;
		private final int REPORT_TYPE;
		final ProgressReporter this$0;

		public String getReporterType()
		{
			return reporterType;
		}

		public int getReporterID()
		{
			return reporterID;
		}

		public int getMinimum()
		{
			return minimum;
		}

		public int getMaximum()
		{
			return maximum;
		}

		public int getSelection()
		{
			return selection;
		}

		public int getPercentage()
		{
			return percentage;
		}

		public boolean isActive()
		{
			return isActive;
		}

		public boolean isIndeterminate()
		{
			return isIndeterminate;
		}

		public boolean isDone()
		{
			return isDone;
		}

		public boolean isPercentageInUse()
		{
			return isPercentageInUse;
		}

		public boolean isCancelAllowed()
		{
			return isCancelAllowed;
		}

		public boolean isCanceled()
		{
			return isCanceled;
		}

		public boolean isRetryAllowed()
		{
			return isRetryAllowed;
		}

		public boolean isInErrorState()
		{
			return isInErrorState;
		}

		public boolean isDisposed()
		{
			return isDisposed;
		}

		public String getTitle()
		{
			return title;
		}

		public String getMessage()
		{
			return message;
		}

		public String getDetailMessage()
		{
			return detailMessage;
		}

		public String getErrorMessage()
		{
			return errorMessage;
		}

		public String getName()
		{
			return name;
		}

		public Image getImage()
		{
			return image;
		}

		public Object getObjectData()
		{
			return objectData;
		}

		public int getReportType()
		{
			return REPORT_TYPE;
		}

		private ProgressReport()
		{
			this$0 = ProgressReporter.this;
			Object();
			reporterType = ProgressReporter.this.reporterType;
			reporterID = ID;
			minimum = ProgressReporter.this.minimum;
			maximum = ProgressReporter.this.maximum;
			selection = ProgressReporter.this.selection;
			percentage = ProgressReporter.this.percentage;
			isActive = ProgressReporter.this.isActive;
			isIndeterminate = ProgressReporter.this.isIndeterminate;
			isDone = ProgressReporter.this.isDone;
			isPercentageInUse = ProgressReporter.this.isPercentageInUse;
			isCancelAllowed = ProgressReporter.this.isCancelAllowed;
			isCanceled = ProgressReporter.this.isCanceled;
			isRetryAllowed = ProgressReporter.this.isRetryAllowed;
			isInErrorState = ProgressReporter.this.isInErrorState;
			isDisposed = ProgressReporter.this.isDisposed;
			title = ProgressReporter.this.title;
			message = ProgressReporter.this.message;
			detailMessage = ProgressReporter.this.detailMessage;
			errorMessage = ProgressReporter.this.errorMessage;
			name = ProgressReporter.this.name;
			image = ProgressReporter.this.image;
			objectData = ProgressReporter.this.objectData;
			REPORT_TYPE = latestReportType;
		}

	}


	private ProgressReportingManager manager;
	private transient int ID;
	private int minimum;
	private int maximum;
	private int selection;
	private int percentage;
	private int latestReportType;
	private boolean isIndeterminate;
	private boolean isDone;
	private boolean isPercentageInUse;
	private boolean isCancelAllowed;
	private boolean isCanceled;
	private boolean isRetryAllowed;
	private boolean isInErrorState;
	private boolean isDisposed;
	private String title;
	private String message;
	private CopyOnWriteList messageHistory;
	private String detailMessage;
	private String errorMessage;
	private String name;
	private Image image;
	private String reporterType;
	private IProgressReport latestProgressReport;
	private CopyOnWriteList reporterListeners;
	private Object objectData;
	private int messageHistoryLimit;
	private boolean isActive;

	protected ProgressReporter(ProgressReportingManager manager)
	{
		ProgressReporter(manager, null);
	}

	protected ProgressReporter(ProgressReportingManager _manager, String name)
	{
		manager = null;
		latestReportType = 0;
		title = "";
		message = "";
		messageHistory = new CopyOnWriteList();
		detailMessage = "";
		errorMessage = "";
		this.name = "";
		image = null;
		reporterType = "default.reporter.type";
		latestProgressReport = null;
		reporterListeners = null;
		objectData = null;
		messageHistoryLimit = 1000;
		isActive = true;
		manager = _manager;
		this.name = name;
		ID = manager.getNextAvailableID();
	}

	public void setReporterType(String reporterType)
	{
		this.reporterType = reporterType;
	}

	public void dispose()
	{
label0:
		{
			synchronized (this)
			{
				if (!isDisposed)
					break label0;
			}
			return;
		}
		isDisposed = true;
		isActive = false;
		progressreporter;
		JVM INSTR monitorexit ;
		  goto _L1
		exception;
		throw exception;
_L1:
		latestReportType = 7;
		notifyListeners();
		if (null != reporterListeners)
			reporterListeners.clear();
		manager.notifyManager(this);
		return;
	}

	private void reInit()
	{
		isActive = true;
		isCanceled = false;
		isDone = false;
		isInErrorState = false;
		errorMessage = "";
		message = "";
		detailMessage = "";
		messageHistory.clear();
	}

	private void notifyListeners()
	{
		if (null == reporterListeners || reporterListeners.size() < 1)
			return;
		List removalList = new ArrayList();
		Iterator iterator = reporterListeners.iterator();
		do
		{
			if (!iterator.hasNext())
				break;
			IProgressReporterListener listener = (IProgressReporterListener)iterator.next();
			try
			{
				if (1 == listener.report(getProgressReport()))
					removalList.add(listener);
			}
			catch (Throwable e)
			{
				Debug.out(e);
			}
		} while (true);
		for (iterator = removalList.iterator(); iterator.hasNext(); reporterListeners.remove(iterator.next()));
	}

	private void updateAndNotify(int eventType)
	{
		latestReportType = eventType;
		latestProgressReport = new ProgressReport();
		manager.notifyManager(this);
		if (eventType == 6 && isCanceled)
		{
			return;
		} else
		{
			notifyListeners();
			return;
		}
	}

	public void setSelection(int selection, String message)
	{
		if (shouldIgnore())
			return;
		this.message = message;
		if (selection >= maximum)
		{
			setDone();
			return;
		}
		if (selection < minimum)
		{
			percentage = 0;
			selection = minimum;
			isIndeterminate = true;
			return;
		}
		this.selection = selection;
		percentage = (selection * 100) / (maximum - minimum);
		isDone = false;
		isPercentageInUse = false;
		isIndeterminate = false;
		if (null != message && message.length() > 0)
			addToMessageHistory(message, 2);
		updateAndNotify(6);
	}

	public void setPercentage(int percentage, String message)
	{
		if (shouldIgnore())
			return;
		this.message = message;
		if (percentage >= 100)
		{
			setDone();
			return;
		}
		if (percentage < 0)
		{
			percentage = 0;
			selection = minimum;
			isIndeterminate = true;
			return;
		}
		minimum = 0;
		maximum = 100;
		this.percentage = percentage;
		selection = percentage;
		isDone = false;
		isPercentageInUse = true;
		isIndeterminate = false;
		if (null != message && message.length() > 0)
			addToMessageHistory(message, 2);
		updateAndNotify(6);
	}

	public void setIndeterminate(boolean isIndeterminate)
	{
		if (shouldIgnore())
			return;
		this.isIndeterminate = isIndeterminate;
		if (isIndeterminate)
		{
			minimum = 0;
			maximum = 0;
		}
		updateAndNotify(3);
	}

	public void setDone()
	{
label0:
		{
			synchronized (this)
			{
				if (!shouldIgnore())
					break label0;
			}
			return;
		}
		isDone = true;
		isActive = false;
		progressreporter;
		JVM INSTR monitorexit ;
		  goto _L1
		exception;
		throw exception;
_L1:
		selection = maximum;
		percentage = 100;
		isIndeterminate = false;
		message = MessageText.getString("Progress.reporting.status.finished");
		addToMessageHistory(message, 8);
		updateAndNotify(2);
		return;
	}

	public void setMessage(String message)
	{
		if (shouldIgnore())
		{
			return;
		} else
		{
			this.message = message;
			addToMessageHistory(message, 2);
			updateAndNotify(6);
			return;
		}
	}

	public void appendDetailMessage(String detailMessage)
	{
		if (shouldIgnore())
		{
			return;
		} else
		{
			this.detailMessage = detailMessage;
			addToMessageHistory(detailMessage, 8);
			updateAndNotify(6);
			this.detailMessage = "";
			return;
		}
	}

	public void setMinimum(int min)
	{
		if (shouldIgnore())
		{
			return;
		} else
		{
			minimum = min;
			updateAndNotify(6);
			return;
		}
	}

	public void setMaximum(int max)
	{
		if (shouldIgnore())
		{
			return;
		} else
		{
			maximum = max;
			updateAndNotify(6);
			return;
		}
	}

	public void cancel()
	{
label0:
		{
			synchronized (this)
			{
				if (!isCanceled && !shouldIgnore())
					break label0;
			}
			return;
		}
		isCanceled = true;
		isActive = false;
		progressreporter;
		JVM INSTR monitorexit ;
		  goto _L1
		exception;
		throw exception;
_L1:
		message = MessageText.getString("Progress.reporting.status.canceled");
		addToMessageHistory(message, 8);
		updateAndNotify(1);
		return;
	}

	public void retry()
	{
label0:
		{
			synchronized (this)
			{
				if (!shouldIgnore())
					break label0;
			}
			return;
		}
		reInit();
		progressreporter;
		JVM INSTR monitorexit ;
		  goto _L1
		exception;
		throw exception;
_L1:
		message = MessageText.getString("Progress.reporting.status.retrying");
		addToMessageHistory(message, 8);
		updateAndNotify(5);
		return;
	}

	public void setCancelAllowed(boolean cancelAllowed)
	{
		if (shouldIgnore())
		{
			return;
		} else
		{
			isCancelAllowed = cancelAllowed;
			updateAndNotify(6);
			return;
		}
	}

	public void setName(String name)
	{
		if (shouldIgnore())
		{
			return;
		} else
		{
			this.name = (new StringBuilder()).append(name).append("").toString();
			updateAndNotify(6);
			return;
		}
	}

	public void setTitle(String title)
	{
		if (shouldIgnore())
		{
			return;
		} else
		{
			this.title = title;
			updateAndNotify(6);
			return;
		}
	}

	public void setImage(Image image)
	{
		if (shouldIgnore())
		{
			return;
		} else
		{
			this.image = image;
			updateAndNotify(6);
			return;
		}
	}

	public void setErrorMessage(String errorMessage)
	{
		if (shouldIgnore())
			return;
		if (null != this.errorMessage && this.errorMessage.equals(errorMessage))
			return;
		if (null == errorMessage || errorMessage.length() < 1)
			this.errorMessage = MessageText.getString("Progress.reporting.default.error");
		else
			this.errorMessage = errorMessage;
		isInErrorState = true;
		isActive = false;
		addToMessageHistory(this.errorMessage, 4);
		updateAndNotify(4);
	}

	public void setRetryAllowed(boolean retryOnError)
	{
		if (shouldIgnore())
		{
			return;
		} else
		{
			isRetryAllowed = retryOnError;
			return;
		}
	}

	private boolean shouldIgnore()
	{
		return isDisposed || isDone;
	}

	private void addToMessageHistory(String value, int type)
	{
		if (messageHistory.size() >= messageHistoryLimit)
			return;
		if (messageHistory.size() < messageHistoryLimit)
			messageHistory.add(new ProgressReportMessage(value, type));
		if (messageHistory.size() == messageHistoryLimit)
			Debug.out(MessageText.getString("Progress.reporting.detail.history.limit", new String[] {
				(new StringBuilder()).append(messageHistoryLimit).append("").toString()
			}));
	}

	public void setObjectData(Object objectData)
	{
		if (shouldIgnore())
		{
			return;
		} else
		{
			this.objectData = objectData;
			return;
		}
	}

	public IMessage[] getMessageHistory()
	{
		List tmp = messageHistory.getList();
		return (IMessage[])(IMessage[])tmp.toArray(new IMessage[tmp.size()]);
	}

	public void addListener(IProgressReporterListener listener)
	{
		if (shouldIgnore())
			return;
		if (null != listener)
			if (null == reporterListeners)
			{
				reporterListeners = new CopyOnWriteList();
				reporterListeners.add(listener);
			} else
			if (!reporterListeners.contains(listener))
				reporterListeners.add(listener);
	}

	public void removeListener(IProgressReporterListener listener)
	{
		if (null == reporterListeners)
		{
			return;
		} else
		{
			reporterListeners.remove(listener);
			return;
		}
	}

	public int compareTo(Object obj)
	{
		if (obj instanceof IProgressReporter)
			return ID >= obj.hashCode() ? ((int) (ID != obj.hashCode() ? 1 : 0)) : -1;
		else
			return 0;
	}

	public boolean equals(Object obj)
	{
		if (obj instanceof IProgressReporter)
			return ID == obj.hashCode();
		else
			return false;
	}

	public int hashCode()
	{
		return ID;
	}

	public IProgressReport getProgressReport()
	{
		if (null == latestProgressReport)
			latestProgressReport = new ProgressReport();
		return latestProgressReport;
	}























}

⌨️ 快捷键说明

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