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

📄 loggerview.java

📁 java 文件下载器。可自定义
💻 JAVA
📖 第 1 页 / 共 2 页
字号:

			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(false);
						ignoredComponents[index].add(ID);
					}
				}

			}

			
			{
				this$0 = LoggerView.this;
				listLogTypes = list;
				cChecks = composite;
				super();
			}
		});
		Composite cBottom = new Composite(panel, 0);
		gd = new GridData(4, 4, true, false);
		gd.horizontalSpan = 2;
		cBottom.setLayoutData(gd);
		cBottom.setLayout(new GridLayout(2, false));
		label = new Label(cBottom, 0);
		label.setLayoutData(new GridData());
		Messages.setLanguageText(label, "LoggerView.includeOnly");
		final Text inclText = new Text(cBottom, 2048);
		gd = new GridData();
		gd.widthHint = 200;
		inclText.setLayoutData(gd);
		inclText.addModifyListener(new ModifyListener() {

			final Text val$inclText;
			final LoggerView 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 = LoggerView.this;
				inclText = text;
				super();
			}
		});
		label = new Label(cBottom, 0);
		label.setLayoutData(new GridData());
		Messages.setLanguageText(label, "LoggerView.excludeAll");
		final Text exclText = new Text(cBottom, 2048);
		gd = new GridData();
		gd.widthHint = 200;
		exclText.setLayoutData(gd);
		exclText.addModifyListener(new ModifyListener() {

			final Text val$exclText;
			final LoggerView 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 = LoggerView.this;
				exclText = text;
				super();
			}
		});
		if (!Logger.isEnabled())
			consoleText.setText((new StringBuilder()).append(MessageText.getString("LoggerView.loggingDisabled")).append("\n").toString());
	}

	public Composite getComposite()
	{
		return panel;
	}

	public void refresh()
	{
label0:
		{
			if (bPaused)
				return;
			synchronized (buffer)
			{
				if (consoleText != null && !consoleText.isDisposed())
					break label0;
			}
			return;
		}
		int i = 0;
_L3:
		if (i >= buffer.size()) goto _L2; else goto _L1
_L1:
		LogEvent event;
		int nbLinesBefore;
		String toAppend;
		event = (LogEvent)buffer.get(i);
		nbLinesBefore = consoleText.getLineCount();
		if (nbLinesBefore > 1280)
		{
			consoleText.replaceTextRange(0, consoleText.getOffsetAtLine(256), "");
			nbLinesBefore = consoleText.getLineCount();
		}
		StringBuffer buf = new StringBuffer();
		buf.append('\n');
		dateFormatter.format(event.timeStamp, buf, formatPos);
		buf.append("{").append(event.logID).append("} ");
		buf.append(event.text);
		if (event.relatedTo != null)
		{
			buf.append("; \t| ");
			for (int j = 0; j < event.relatedTo.length; j++)
			{
				Object obj = event.relatedTo[j];
				if (j > 0)
					buf.append("; ");
				if (obj instanceof LogRelation)
				{
					buf.append(((LogRelation)obj).getRelationText());
					continue;
				}
				if (obj != null)
					buf.append(obj.getClass().getName()).append(": '").append(obj.toString()).append("'");
			}

		}
		toAppend = buf.toString();
		if (inclusionFilter != null && !inclusionFilter.matcher(toAppend).find() || exclusionFilter != null && exclusionFilter.matcher(toAppend).find())
			continue; /* Loop/switch isn't completed */
		try
		{
			consoleText.append(toAppend);
			int nbLinesNow = consoleText.getLineCount();
			int colorIdx = -1;
			if (event.entryType == 0)
				colorIdx = 0;
			else
			if (event.entryType == 1)
				colorIdx = 1;
			else
			if (event.entryType == 3)
				colorIdx = 2;
			if (colors != null && colorIdx >= 0)
				consoleText.setLineBackground(nbLinesBefore, nbLinesNow - nbLinesBefore, colors[colorIdx]);
			continue; /* Loop/switch isn't completed */
		}
		catch (Exception e)
		{
			PrintStream ps = Logger.getOldStdErr();
			if (ps != null)
			{
				ps.println("Error writing event to console:");
				e.printStackTrace(ps);
			}
			i++;
		}
		  goto _L3
_L2:
		buffer.clear();
		if (bAutoScroll)
			consoleText.setTopIndex(consoleText.getLineCount());
		linkedlist;
		JVM INSTR monitorexit ;
		  goto _L4
		exception;
		throw exception;
_L4:
	}

	public void delete()
	{
		Logger.removeListener(this);
		if (panel != null && !panel.isDisposed())
			panel.dispose();
		Colors.getInstance().removeColorsChangedListener(this);
	}

	public String getFullTitle()
	{
		return MessageText.getString("ConsoleView.title.full");
	}

	public String getData()
	{
		return "ConsoleView.title.short";
	}

	public synchronized void log(LogEvent event)
	{
		if (display == null || display.isDisposed())
			return;
		if (ignoredComponents[logTypeToIndex(event.entryType)].contains(event.logID))
			return;
		boolean bMatch = event.logID == LogIDs.STDERR || filter == null;
		if (!bMatch && event.relatedTo != null)
		{
			for (int i = 0; !bMatch && i < event.relatedTo.length; i++)
			{
				Object obj = event.relatedTo[i];
				if (obj == null)
					continue;
				for (int j = 0; !bMatch && j < filter.length; j++)
				{
					if (obj instanceof LogRelation)
					{
						Object newObj = ((LogRelation)obj).queryForClass(filter[j].getClass());
						if (newObj != null)
							obj = newObj;
					}
					if (obj == filter[j])
						bMatch = true;
				}

			}

		}
		if (bMatch)
		{
			synchronized (buffer)
			{
				if (buffer.size() >= 200)
					buffer.removeFirst();
				buffer.add(event);
			}
			if (bRealtime && !bPaused)
				Utils.execSWTThread(new AERunnable() {

					final LoggerView this$0;

					public void runSupport()
					{
						refresh();
					}

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

	public void setFilter(Object _filter[])
	{
		filter = _filter;
		clearConsole();
	}

	private void clearConsole()
	{
		if (display == null || display.isDisposed())
		{
			return;
		} else
		{
			Utils.execSWTThread(new AERunnable() {

				final LoggerView this$0;

				public void runSupport()
				{
					consoleText.setText("");
				}

			
			{
				this$0 = LoggerView.this;
				super();
			}
			});
			return;
		}
	}

	public void setEnabled(boolean on)
	{
		if (bEnabled == on)
			return;
		bEnabled = on;
		if (on)
			Logger.addListener(this);
		else
			Logger.removeListener(this);
	}

	public String getPluginViewName()
	{
		return "Console";
	}

	public void dataSourceChanged(Object newDataSource)
	{
		if (newDataSource == null)
		{
			if (stopOnNull)
			{
				setEnabled(false);
				return;
			}
			setFilter(null);
		} else
		if (newDataSource instanceof Object[])
			setFilter((Object[])(Object[])newDataSource);
		else
			setFilter(new Object[] {
				newDataSource
			});
		setEnabled(true);
	}

	private int logTypeToIndex(int entryType)
	{
		switch (entryType)
		{
		case 0: // '\0'
			return 0;

		case 1: // '\001'
			return 1;

		case 3: // '\003'
			return 2;

		case 2: // '\002'
		default:
			return 0;
		}
	}

	private int indexToLogType(int index)
	{
		switch (index)
		{
		case 0: // '\0'
			return 0;

		case 1: // '\001'
			return 1;

		case 2: // '\002'
			return 3;
		}
		return 0;
	}

	public void parameterChanged(String parameterName)
	{
		if (parameterName.startsWith("Color"))
			Utils.execSWTThread(new AERunnable() {

				final LoggerView this$0;

				public void runSupport()
				{
					if (display == null || display.isDisposed())
						return;
					if (LoggerView.colors == null)
						LoggerView.colors = new Color[3];
					Color newColors[] = {
						Colors.blues[2], Colors.colorWarning, Colors.red_ConsoleView
					};
					boolean bColorChanged = false;
					for (int i = 0; i < newColors.length; i++)
						if (LoggerView.colors[i] == null || LoggerView.colors[i].isDisposed())
						{
							LoggerView.colors[i] = newColors[i];
							bColorChanged = true;
						}

					if (bColorChanged && consoleText != null)
					{
						String text = consoleText.getText();
						consoleText.setText(text);
					}
				}

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














}

⌨️ 快捷键说明

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