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

📄 basicpluginviewimpl.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:   BasicPluginViewImpl.java

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

import com.aelitis.azureus.ui.UIFunctions;
import com.aelitis.azureus.ui.UIFunctionsManager;
import java.util.regex.*;
import org.eclipse.swt.custom.StyledText;
import org.eclipse.swt.events.*;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.*;
import org.gudy.azureus2.core3.util.AERunnable;
import org.gudy.azureus2.plugins.ui.components.*;
import org.gudy.azureus2.plugins.ui.model.BasicPluginViewModel;
import org.gudy.azureus2.ui.swt.Messages;
import org.gudy.azureus2.ui.swt.components.BufferedLabel;
import org.gudy.azureus2.ui.swt.mainwindow.Colors;
import org.gudy.azureus2.ui.swt.plugins.UISWTViewEvent;
import org.gudy.azureus2.ui.swt.plugins.UISWTViewEventListener;

public class BasicPluginViewImpl
	implements UISWTViewEventListener, UIPropertyChangeListener
{

	BasicPluginViewModel model;
	Display display;
	Composite panel;
	ProgressBar progress;
	BufferedLabel status;
	BufferedLabel task;
	StyledText log;
	Pattern inclusionFilter;
	Pattern exclusionFilter;
	boolean paused;
	boolean isCreated;

	public BasicPluginViewImpl(BasicPluginViewModel model)
	{
		this.model = model;
		isCreated = false;
	}

	public boolean eventOccurred(UISWTViewEvent event)
	{
		switch (event.getType())
		{
		case 1: // '\001'
		case 3: // '\003'
		case 4: // '\004'
		case 6: // '\006'
		default:
			break;

		case 0: // '\0'
			if (isCreated)
				return false;
			isCreated = true;
			break;

		case 2: // '\002'
			initialize((Composite)event.getData());
			break;

		case 5: // '\005'
			refresh();
			break;

		case 7: // '\007'
			delete();
			isCreated = false;
			break;
		}
		return true;
	}

	private void initialize(Composite composite)
	{
		String sConfigSectionID = model.getConfigSectionID();
		display = composite.getDisplay();
		panel = new Composite(composite, 0);
		GridLayout gridLayout = new GridLayout();
		gridLayout.numColumns = 2;
		panel.setLayout(gridLayout);
		GridData gridData = new GridData(1808);
		panel.setLayoutData(gridData);
		Composite topSection = new Composite(panel, 0);
		gridLayout = new GridLayout();
		gridLayout.numColumns = 2;
		gridLayout.marginHeight = 0;
		gridLayout.marginWidth = 0;
		topSection.setLayout(gridLayout);
		gridData = new GridData(768);
		if (sConfigSectionID == null)
			gridData.horizontalSpan = 2;
		topSection.setLayoutData(gridData);
		if (model.getStatus().getVisible())
		{
			Label statusTitle = new Label(topSection, 0);
			Messages.setLanguageText(statusTitle, "plugins.basicview.status");
			status = new BufferedLabel(topSection, 0);
			gridData = new GridData(768);
			status.setLayoutData(gridData);
		}
		if (model.getActivity().getVisible())
		{
			Label activityTitle = new Label(topSection, 0);
			Messages.setLanguageText(activityTitle, "plugins.basicview.activity");
			task = new BufferedLabel(topSection, 0);
			gridData = new GridData(768);
			task.setLayoutData(gridData);
		}
		if (model.getProgress().getVisible())
		{
			Label progressTitle = new Label(topSection, 0);
			Messages.setLanguageText(progressTitle, "plugins.basicview.progress");
			progress = new ProgressBar(topSection, 0);
			progress.setMaximum(100);
			progress.setMinimum(0);
			gridData = new GridData(768);
			progress.setLayoutData(gridData);
		}
		if (sConfigSectionID != null)
		{
			Composite configSection = new Composite(panel, 0);
			gridLayout = new GridLayout();
			gridLayout.numColumns = 1;
			gridLayout.marginHeight = 0;
			gridLayout.marginWidth = 2;
			configSection.setLayout(gridLayout);
			gridData = new GridData(11);
			configSection.setLayoutData(gridData);
			Button btnConfig = new Button(configSection, 8);
			Messages.setLanguageText(btnConfig, "plugins.basicview.config");
			btnConfig.addSelectionListener(new SelectionAdapter() {

				final BasicPluginViewImpl this$0;

				public void widgetSelected(SelectionEvent e)
				{
					UIFunctions uiFunctions = UIFunctionsManager.getUIFunctions();
					if (uiFunctions != null)
						uiFunctions.openView(4, model.getConfigSectionID());
				}

			
			{
				this$0 = BasicPluginViewImpl.this;
				super();
			}
			});
			btnConfig.setLayoutData(new GridData());
		}
		if (model.getLogArea().getVisible())
		{
			Label logTitle = new Label(topSection, 0);
			Messages.setLanguageText(logTitle, "plugins.basicview.log");
			Button button = new Button(topSection, 8);
			Messages.setLanguageText(button, "plugins.basicview.clear");
			button.addListener(13, new Listener() {

				final BasicPluginViewImpl this$0;

				public void handleEvent(Event event)
				{
					model.getLogArea().setText("");
				}

			
			{
				this$0 = BasicPluginViewImpl.this;
				super();
			}
			});
			log = new StyledText(panel, 2824);
			gridData = new GridData(1808);
			gridData.horizontalSpan = 2;
			log.setLayoutData(gridData);
			model.getLogArea().addPropertyChangeListener(this);
			Composite bottomSection = new Composite(panel, 0);
			gridLayout = new GridLayout();
			gridLayout.numColumns = 3;
			gridLayout.marginHeight = 0;
			gridLayout.marginWidth = 0;
			bottomSection.setLayout(gridLayout);
			gridData = new GridData(768);
			gridData.horizontalSpan = 2;
			bottomSection.setLayoutData(gridData);
			Label label = new Label(bottomSection, 0);
			label.setLayoutData(new GridData());
			Messages.setLanguageText(label, "LoggerView.includeOnly");
			final Text inclText = new Text(bottomSection, 2048);
			gridData = new GridData();
			gridData.widthHint = 200;
			inclText.setLayoutData(gridData);
			inclText.addModifyListener(new ModifyListener() {

				final Text val$inclText;
				final BasicPluginViewImpl this$0;

				public void modifyText(ModifyEvent e)
				{
					String newExpression = inclText.getText();
					if (newExpression.length() == 0)
						inclusionFilter = null;
					else
						try
						{
							inclusionFilter = Pattern.compile(newExpression, 2);
							inclText.setBackground(null);
						}
						catch (PatternSyntaxException e1)
						{
							inclText.setBackground(Colors.colorErrorBG);
						}
				}

			
			{
				this$0 = BasicPluginViewImpl.this;
				inclText = text;
				super();
			}
			});
			label = new Label(bottomSection, 0);
			label = new Label(bottomSection, 0);
			label.setLayoutData(new GridData());
			Messages.setLanguageText(label, "LoggerView.excludeAll");
			final Text exclText = new Text(bottomSection, 2048);
			gridData = new GridData();
			gridData.widthHint = 200;
			exclText.setLayoutData(gridData);
			exclText.addModifyListener(new ModifyListener() {

				final Text val$exclText;
				final BasicPluginViewImpl this$0;

				public void modifyText(ModifyEvent e)
				{
					String newExpression = exclText.getText();
					if (newExpression.length() == 0)
						exclusionFilter = null;
					else
						try
						{
							exclusionFilter = Pattern.compile(newExpression, 2);
							exclText.setBackground(null);
						}
						catch (PatternSyntaxException e1)
						{
							exclText.setBackground(Colors.colorErrorBG);
						}
				}

			
			{
				this$0 = BasicPluginViewImpl.this;
				exclText = text;
				super();
			}
			});
			label = new Label(bottomSection, 0);
			Button buttonPause = new Button(bottomSection, 32);
			Messages.setLanguageText(buttonPause, "LoggerView.pause");
			gridData = new GridData();
			buttonPause.setLayoutData(gridData);
			buttonPause.addSelectionListener(new SelectionAdapter() {

				final BasicPluginViewImpl this$0;

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

			
			{
				this$0 = BasicPluginViewImpl.this;
				super();
			}
			});
		}
		composite.addListener(23, new Listener() {

			final BasicPluginViewImpl this$0;

			public void handleEvent(Event arg0)
			{
				log.setText("");
			}

			
			{
				this$0 = BasicPluginViewImpl.this;
				super();
			}
		});
		composite.addListener(22, new Listener() {

			final BasicPluginViewImpl this$0;

			public void handleEvent(Event arg0)
			{
				String text = model.getLogArea().getText().trim();
				log.setText(text);
				log.setTopIndex(log.getLineCount());
			}

			
			{
				this$0 = BasicPluginViewImpl.this;
				super();
			}
		});
	}

	private void refresh()
	{
		if (status != null)
			status.setText(model.getStatus().getText());
		if (task != null)
			task.setText(model.getActivity().getText());
		if (progress != null)
			progress.setSelection(model.getProgress().getPercentageComplete());
	}

	public void propertyChanged(final UIPropertyChangeEvent ev)
	{
		if (ev.getSource() != model.getLogArea())
			return;
		if (display == null || display.isDisposed() || log == null || paused)
		{
			return;
		} else
		{
			display.asyncExec(new AERunnable() {

				final UIPropertyChangeEvent val$ev;
				final BasicPluginViewImpl this$0;

				public void runSupport()
				{
					if (log.isDisposed())
						return;
					if (!log.isVisible())
						return;
					String old_value = (String)ev.getOldPropertyValue();
					String new_value = (String)ev.getNewPropertyValue();
					ScrollBar bar = log.getVerticalBar();
					boolean max = bar.getSelection() == bar.getMaximum() - bar.getThumb();
					int lineOffset = log.getLineCount() - log.getTopIndex();
					if (new_value.startsWith(old_value))
					{
						String toAppend = new_value.substring(old_value.length());
						if (toAppend.length() == 0)
							return;
						StringBuffer builder = new StringBuffer(toAppend.length());
						String lines[] = toAppend.split("\n");
						for (int i = 0; i < lines.length; i++)
						{
							String line = lines[i];
							if ((inclusionFilter == null || inclusionFilter.matcher(line).find()) && (exclusionFilter == null || !exclusionFilter.matcher(line).find()))
							{
								builder.append("\n");
								builder.append(line);
							}
						}

						log.append(builder.toString());
					} else
					{
						StringBuffer builder = new StringBuffer(new_value.length());
						String lines[] = new_value.split("\n");
						for (int i = 0; i < lines.length; i++)
						{
							String line = lines[i];
							if (inclusionFilter != null && !inclusionFilter.matcher(line).find() || exclusionFilter != null && exclusionFilter.matcher(line).find())
								continue;
							if (line != lines[0])
								builder.append("\n");
							builder.append(line);
						}

						log.setText(builder.toString());
					}
					if (max)
					{
						bar.setSelection(bar.getMaximum() - bar.getThumb());
						log.setTopIndex(log.getLineCount() - lineOffset);
						log.redraw();
					}
				}

			
			{
				this$0 = BasicPluginViewImpl.this;
				ev = uipropertychangeevent;
				super();
			}
			});
			return;
		}
	}

	private void delete()
	{
		model.getLogArea().removePropertyChangeListener(this);
	}
}

⌨️ 快捷键说明

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