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

📄 progressreporterpanel.java

📁 java 文件下载器。可自定义
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
				{
					if (null != nameLabel && !nameLabel.isDisposed())
						nameLabel.setText(pReport.getName());
					if (pReport.isIndeterminate())
						updateStatusLabel("∞", false);
					else
						updateStatusLabel((new StringBuilder()).append(pReport.getPercentage()).append("%").toString(), false);
					appendToDetail(pReport.getMessage(), false);
					appendToDetail(pReport.getDetailMessage(), false);
					synchProgressBar(pReport);
					synchActionLabels(pReport);
					resizeContent();
				}

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

		case 1: // '\001'
			getDisplay().asyncExec(new Runnable() {

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

				public void run()
				{
					synchProgressBar(pReport);
					updateStatusLabel(MessageText.getString("Progress.reporting.status.canceled"), false);
					appendToDetail(pReport.getMessage(), false);
					synchActionLabels(pReport);
					resizeContent();
				}

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

		case 2: // '\002'
			getDisplay().asyncExec(new Runnable() {

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

				public void run()
				{
					if ((style & 2) != 0)
					{
						dispose();
					} else
					{
						synchProgressBar(pReport);
						updateStatusLabel(MessageText.getString("Progress.reporting.status.finished"), false);
						appendToDetail(MessageText.getString("Progress.reporting.status.finished"), false);
						synchActionLabels(pReport);
						resizeContent();
					}
				}

			
			{
				this$0 = ProgressReporterPanel.this;
				pReport = iprogressreport;
				Object();
			}
			});
			return 1;

		case 3: // '\003'
			getDisplay().asyncExec(new Runnable() {

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

				public void run()
				{
					if (null != pBar && !pBar.isDisposed())
						pBar.setIndeterminate(pReport.isIndeterminate());
				}

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

		case 4: // '\004'
			getDisplay().asyncExec(new Runnable() {

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

				public void run()
				{
					updateStatusLabel(MessageText.getString("Progress.reporting.default.error"), true);
					appendToDetail(pReport.getErrorMessage(), true);
					synchActionLabels(pReport);
					synchProgressBar(pReport);
					resizeContent();
				}

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

		case 5: // '\005'
			getDisplay().asyncExec(new Runnable() {

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

				public void run()
				{
					updateStatusLabel(pReport.getMessage(), false);
					appendToDetail(MessageText.getString("Progress.reporting.status.retrying"), false);
					synchActionLabels(pReport);
					synchProgressBar(pReport);
					resizeContent();
				}

			
			{
				this$0 = ProgressReporterPanel.this;
				pReport = iprogressreport;
				Object();
			}
			});
			break;
		}
		return 0;
	}

	private void synchProgressBar(IProgressReport pReport)
	{
		if (null == pBar || pBar.isDisposed() || null == pReport)
			return;
		if (pReport.isInErrorState())
		{
			pBar.setIndeterminate(false);
			pBar.setSelection(pReport.getMinimum());
		} else
		{
			pBar.setIndeterminate(pReport.isIndeterminate());
			if (!pReport.isIndeterminate())
			{
				pBar.setMinimum(pReport.getMinimum());
				pBar.setMaximum(pReport.getMaximum());
			}
			pBar.setSelection(pReport.getSelection());
		}
	}

	private void updateStatusLabel(String text, boolean showAsError)
	{
		if (null == statusLabel || statusLabel.isDisposed())
			return;
		if (showAsError)
			lastStatusError = text;
		if (lastStatusError != null)
		{
			showAsError = true;
			text = lastStatusError;
		}
		statusLabel.setText(formatForDisplay(text));
		if (!showAsError)
			statusLabel.setForeground(normalColor);
		else
			statusLabel.setForeground(errorColor);
		statusLabel.update();
	}

	private void synchActionLabels(IProgressReport pReport)
	{
		if (null == actionLabel_remove || null == actionLabel_cancel || null == actionLabel_retry || actionLabel_remove.isDisposed() || actionLabel_cancel.isDisposed() || actionLabel_retry.isDisposed())
			return;
		showActionLabel(actionLabel_cancel, false);
		showActionLabel(actionLabel_remove, false);
		showActionLabel(actionLabel_retry, false);
		if (pReport.isDone())
			showActionLabel(actionLabel_remove, true);
		else
		if (pReport.isInErrorState())
		{
			if (pReport.isRetryAllowed())
			{
				showActionLabel(actionLabel_retry, true);
				showActionLabel(actionLabel_remove, true);
			} else
			{
				showActionLabel(actionLabel_remove, true);
			}
		} else
		if (pReport.isCanceled())
		{
			if (pReport.isRetryAllowed())
			{
				showActionLabel(actionLabel_retry, true);
				showActionLabel(actionLabel_remove, true);
			} else
			{
				showActionLabel(actionLabel_remove, true);
			}
		} else
		{
			showActionLabel(actionLabel_cancel, true);
			actionLabel_cancel.setEnabled(pReport.isCancelAllowed());
		}
	}

	private void showActionLabel(Label label, boolean showIt)
	{
		((GridData)label.getLayoutData()).widthHint = !showIt ? 0 : 16;
	}

	public void resizeContent()
	{
		if (!isDisposed())
			layout(true, true);
	}

	private String formatForDisplay(String string)
	{
		string = null != string ? string : "";
		return string.replaceAll("&", "&&");
	}

	public void addTwistieListener(ITwistieListener listener)
	{
		detailSection.addTwistieListener(listener);
	}

	public void removeTwistieListener(ITwistieListener listener)
	{
		detailSection.removeTwistieListener(listener);
	}

	private void appendToDetail(String value, boolean isError)
	{
		if (null == value || value.length() < 1)
			return;
		if (null == detailListWidget || detailListWidget.isDisposed())
			return;
		int charCount = detailListWidget.getCharCount();
		detailListWidget.append((new StringBuilder()).append(value).append("\n").toString());
		if (isError)
		{
			StyleRange style2 = new StyleRange();
			style2.start = charCount;
			style2.length = value.length();
			style2.foreground = errorColor;
			detailListWidget.setStyleRange(style2);
		}
		detailSection.setEnabled(true);
	}

	public IProgressReporter getProgressReporter()
	{
		return pReporter;
	}

	public int getStyle()
	{
		return style;
	}








}

⌨️ 快捷键说明

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