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

📄 loggerview.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:   LoggerView.java

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

import java.io.PrintStream;
import java.text.FieldPosition;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.regex.PatternSyntaxException;
import org.eclipse.swt.custom.StyledText;
import org.eclipse.swt.events.ModifyEvent;
import org.eclipse.swt.events.ModifyListener;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.FontMetrics;
import org.eclipse.swt.graphics.GC;
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.graphics.Rectangle;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.layout.RowLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Event;
import org.eclipse.swt.widgets.Group;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.List;
import org.eclipse.swt.widgets.Listener;
import org.eclipse.swt.widgets.ScrollBar;
import org.eclipse.swt.widgets.Text;
import org.gudy.azureus2.core3.config.ParameterListener;
import org.gudy.azureus2.core3.internat.MessageText;
import org.gudy.azureus2.core3.logging.ILogEventListener;
import org.gudy.azureus2.core3.logging.LogEvent;
import org.gudy.azureus2.core3.logging.LogIDs;
import org.gudy.azureus2.core3.logging.LogRelation;
import org.gudy.azureus2.core3.logging.Logger;
import org.gudy.azureus2.core3.logging.impl.FileLogging;
import org.gudy.azureus2.core3.util.AERunnable;
import org.gudy.azureus2.ui.swt.Messages;
import org.gudy.azureus2.ui.swt.Utils;
import org.gudy.azureus2.ui.swt.mainwindow.Colors;

// Referenced classes of package org.gudy.azureus2.ui.swt.views:
//			AbstractIView

public class LoggerView extends AbstractIView
	implements ILogEventListener, ParameterListener
{

	private static final int COLOR_INFO = 0;
	private static final int COLOR_WARN = 1;
	private static final int COLOR_ERR = 2;
	private static Color colors[] = null;
	private static final int PREFERRED_LINES = 256;
	private static final int MAX_LINES = 1280;
	private static final SimpleDateFormat dateFormatter = new SimpleDateFormat("[HH:mm:ss.SSS] ");
	private static final FieldPosition formatPos = new FieldPosition(0);
	private Display display;
	private Composite panel;
	private StyledText consoleText;
	private Button buttonAutoScroll;
	private Object filter[];
	private LinkedList buffer;
	private boolean bPaused;
	private boolean bRealtime;
	private boolean bEnabled;
	private boolean bAutoScroll;
	private Pattern inclusionFilter;
	private Pattern exclusionFilter;
	private ArrayList ignoredComponents[];
	private boolean stopOnNull;

	public LoggerView()
	{
		this(false);
		setEnabled(true);
	}

	public LoggerView(boolean stopOnNull)
	{
		consoleText = null;
		buttonAutoScroll = null;
		filter = null;
		buffer = new LinkedList();
		bPaused = false;
		bRealtime = false;
		bEnabled = false;
		bAutoScroll = true;
		ignoredComponents = new ArrayList[3];
		this.stopOnNull = false;
		for (int i = 0; i < ignoredComponents.length; i++)
			ignoredComponents[i] = new ArrayList();

		this.stopOnNull = stopOnNull;
	}

	public LoggerView(java.util.List initialList)
	{
		this();
		if (initialList != null)
			buffer.addAll(initialList);
		setEnabled(true);
	}

	public void initialize(Composite composite)
	{
		display = composite.getDisplay();
		Colors.getInstance().addColorsChangedListener(this);
		parameterChanged("Color");
		panel = new Composite(composite, 0);
		GridLayout layout = new GridLayout();
		layout.marginHeight = 0;
		layout.marginWidth = 0;
		layout.verticalSpacing = 2;
		layout.numColumns = 2;
		panel.setLayout(layout);
		consoleText = new StyledText(panel, 776);
		GridData gd = new GridData(1808);
		gd.horizontalSpan = 2;
		consoleText.setLayoutData(gd);
		consoleText.addListener(11, new Listener() {

			final LoggerView this$0;

			public void handleEvent(Event event)
			{
				GC gc = new GC(consoleText);
				int charWidth = gc.getFontMetrics().getAverageCharWidth();
				gc.dispose();
				int areaWidth = consoleText.getBounds().width;
				consoleText.setTabs(areaWidth / 6 / charWidth);
			}

			
			{
				this$0 = LoggerView.this;
				super();
			}
		});
		ScrollBar sb = consoleText.getVerticalBar();
		sb.addSelectionListener(new SelectionAdapter() {

			final LoggerView this$0;

			public void widgetSelected(SelectionEvent e)
			{
				bAutoScroll = false;
				if (buttonAutoScroll != null && !buttonAutoScroll.isDisposed())
					buttonAutoScroll.setSelection(false);
			}

			
			{
				this$0 = LoggerView.this;
				super();
			}
		});
		Composite cLeft = new Composite(panel, 0);
		layout = new GridLayout();
		layout.marginHeight = 0;
		layout.marginWidth = 0;
		layout.verticalSpacing = 1;
		cLeft.setLayout(layout);
		gd = new GridData(128, 16384, false, false);
		cLeft.setLayoutData(gd);
		Button buttonPause = new Button(cLeft, 32);
		Messages.setLanguageText(buttonPause, "LoggerView.pause");
		gd = new GridData();
		buttonPause.setLayoutData(gd);
		buttonPause.addSelectionListener(new SelectionAdapter() {

			final LoggerView this$0;

			public void widgetSelected(SelectionEvent e)
			{
				if (e.widget == null || !(e.widget instanceof Button))
					return;
				Button btn = (Button)e.widget;
				bPaused = btn.getSelection();
				if (!bPaused && buffer != null)
					refresh();
			}

			
			{
				this$0 = LoggerView.this;
				super();
			}
		});
		Button buttonRealtime = new Button(cLeft, 32);
		Messages.setLanguageText(buttonRealtime, "LoggerView.realtime");
		gd = new GridData();
		buttonRealtime.setLayoutData(gd);
		buttonRealtime.addSelectionListener(new SelectionAdapter() {

			final LoggerView this$0;

			public void widgetSelected(SelectionEvent e)
			{
				if (e.widget == null || !(e.widget instanceof Button))
				{
					return;
				} else
				{
					Button btn = (Button)e.widget;
					bRealtime = btn.getSelection();
					return;
				}
			}

			
			{
				this$0 = LoggerView.this;
				super();
			}
		});
		buttonAutoScroll = new Button(cLeft, 32);
		Messages.setLanguageText(buttonAutoScroll, "LoggerView.autoscroll");
		gd = new GridData();
		buttonAutoScroll.setLayoutData(gd);
		buttonAutoScroll.addSelectionListener(new SelectionAdapter() {

			final LoggerView this$0;

			public void widgetSelected(SelectionEvent e)
			{
				if (e.widget == null || !(e.widget instanceof Button))
				{
					return;
				} else
				{
					Button btn = (Button)e.widget;
					bAutoScroll = btn.getSelection();
					return;
				}
			}

			
			{
				this$0 = LoggerView.this;
				super();
			}
		});
		buttonAutoScroll.setSelection(true);
		Button buttonClear = new Button(cLeft, 8);
		Messages.setLanguageText(buttonClear, "LoggerView.clear");
		gd = new GridData();
		buttonClear.setLayoutData(gd);
		buttonClear.addSelectionListener(new SelectionAdapter() {

			final LoggerView this$0;

			public void widgetSelected(SelectionEvent e)
			{
				consoleText.setText("");
			}

			
			{
				this$0 = LoggerView.this;
				super();
			}
		});
		String sFilterPrefix = "ConfigView.section.logging.filter";
		Group gLogIDs = new Group(panel, 0);
		Messages.setLanguageText(gLogIDs, "LoggerView.filter");
		layout = new GridLayout();
		layout.marginHeight = 0;
		layout.numColumns = 2;
		gLogIDs.setLayout(layout);
		gd = new GridData();
		gLogIDs.setLayoutData(gd);
		Label label = new Label(gLogIDs, 0);
		Messages.setLanguageText(label, "ConfigView.section.logging.level");
		label.setLayoutData(new GridData());
		final Label labelCatFilter = new Label(gLogIDs, 0);
		labelCatFilter.setLayoutData(new GridData(256));
		final List listLogTypes = new List(gLogIDs, 2564);
		gd = new GridData(0, 1, false, false);
		listLogTypes.setLayoutData(gd);
		final int logTypes[] = {
			0, 1, 3
		};
		for (int i = 0; i < logTypes.length; i++)
			listLogTypes.add(MessageText.getString((new StringBuilder()).append("ConfigView.section.logging.log").append(i).append("type").toString()));

		listLogTypes.select(0);
		LogIDs logIDs[] = FileLogging.configurableLOGIDs;
		Composite cChecksAndButtons = new Composite(gLogIDs, 0);
		layout = new GridLayout(2, false);
		layout.marginHeight = 0;
		layout.marginWidth = 0;
		cChecksAndButtons.setLayout(layout);
		cChecksAndButtons.setLayoutData(new GridData());
		final Composite cChecks = new Composite(cChecksAndButtons, 0);
		RowLayout rowLayout = new RowLayout(512);
		rowLayout.wrap = true;
		rowLayout.marginLeft = 0;
		rowLayout.marginRight = 0;
		rowLayout.marginTop = 0;
		rowLayout.marginBottom = 0;
		cChecks.setLayout(rowLayout);
		SelectionAdapter buttonClickListener = new SelectionAdapter() {

			final List val$listLogTypes;
			final int val$logTypes[];
			final LoggerView this$0;

			public void widgetSelected(SelectionEvent e)
			{
				int index = listLogTypes.getSelectionIndex();
				if (index < 0 || index >= logTypes.length)
					return;
				Button item = (Button)e.widget;
				if (item.getSelection())
					ignoredComponents[index].remove(item.getData("LOGID"));
				else
					ignoredComponents[index].add(item.getData("LOGID"));
			}

			
			{
				this$0 = LoggerView.this;
				listLogTypes = list;
				logTypes = ai;
				super();
			}
		};
		for (int i = 0; i < logIDs.length; i++)
		{
			Button btn = new Button(cChecks, 32);
			btn.setText(MessageText.getString((new StringBuilder()).append("ConfigView.section.logging.filter.").append(logIDs[i]).toString(), logIDs[i].toString()));
			btn.setData("LOGID", logIDs[i]);
			btn.addSelectionListener(buttonClickListener);
			if (i == 0)
			{
				gd = new GridData(4, 4, false, false, 1, 2);
				gd.heightHint = (btn.computeSize(-1, -1).y + 2) * 3;
				cChecks.setLayoutData(gd);
			}
		}

		listLogTypes.addSelectionListener(new SelectionAdapter() {

			final List val$listLogTypes;
			final int val$logTypes[];
			final Label val$labelCatFilter;
			final Composite val$cChecks;
			final LoggerView this$0;

			public void widgetSelected(SelectionEvent e)
			{
				int index = listLogTypes.getSelectionIndex();
				if (index < 0 || index >= logTypes.length)
					return;
				labelCatFilter.setText(MessageText.getString("ConfigView.section.logging.showLogsFor", listLogTypes.getSelection()));
				Control items[] = cChecks.getChildren();
				for (int i = 0; i < items.length; i++)
				{
					if (!(items[i] instanceof Button))
						continue;
					LogIDs ID = (LogIDs)items[i].getData("LOGID");
					if (ID != null)
					{
						boolean checked = !ignoredComponents[index].contains(ID);
						((Button)items[i]).setSelection(checked);
					}
				}

			}

			
			{
				this$0 = LoggerView.this;
				listLogTypes = list;
				logTypes = ai;
				labelCatFilter = label;
				cChecks = composite;
				super();
			}
		});
		listLogTypes.notifyListeners(13, null);
		Button btn = new Button(cChecksAndButtons, 8);
		gd = new GridData();
		btn.setLayoutData(gd);
		Messages.setLanguageText(btn, "LoggerView.filter.checkAll");
		btn.addSelectionListener(new SelectionAdapter() {

			final List val$listLogTypes;
			final Composite val$cChecks;
			final LoggerView this$0;

			public void widgetSelected(SelectionEvent e)
			{
				int index = listLogTypes.getSelectionIndex();
				Control items[] = cChecks.getChildren();
				for (int i = 0; i < items.length; i++)
				{
					if (!(items[i] instanceof Button))
						continue;
					LogIDs ID = (LogIDs)items[i].getData("LOGID");
					if (ID != null && ignoredComponents[index].contains(ID))
					{
						((Button)items[i]).setSelection(true);
						ignoredComponents[index].remove(ID);
					}
				}

			}

			
			{
				this$0 = LoggerView.this;
				listLogTypes = list;
				cChecks = composite;
				super();
			}
		});
		btn = new Button(cChecksAndButtons, 8);
		gd = new GridData();
		btn.setLayoutData(gd);
		Messages.setLanguageText(btn, "LoggerView.filter.uncheckAll");
		btn.addSelectionListener(new SelectionAdapter() {

			final List val$listLogTypes;
			final Composite val$cChecks;
			final LoggerView this$0;

⌨️ 快捷键说明

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