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

📄 tabletooltips.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:   TableTooltips.java

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

import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.graphics.Rectangle;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.widgets.*;
import org.gudy.azureus2.ui.swt.views.table.TableCellSWT;
import org.gudy.azureus2.ui.swt.views.table.TableViewSWT;

public class TableTooltips
	implements Listener
{

	Shell toolTipShell;
	Shell mainShell;
	Label toolTipLabel;
	private final Composite composite;
	private final TableViewSWT tv;

	public TableTooltips(TableViewSWT tv, Composite composite)
	{
		toolTipShell = null;
		mainShell = null;
		toolTipLabel = null;
		this.tv = tv;
		this.composite = composite;
		mainShell = composite.getShell();
		composite.addListener(12, this);
		composite.addListener(1, this);
		composite.addListener(5, this);
		composite.addListener(32, this);
		mainShell.addListener(27, this);
		tv.getComposite().addListener(27, this);
	}

	public void handleEvent(Event event)
	{
		switch (event.type)
		{
		case 32: // ' '
			if (toolTipShell != null && !toolTipShell.isDisposed())
				toolTipShell.dispose();
			TableCellSWT cell = tv.getTableCell(event.x, event.y);
			if (cell == null)
				return;
			cell.invokeToolTipListeners(0);
			Object oToolTip = cell.getToolTip();
			if (oToolTip == null || !(oToolTip instanceof String))
				return;
			String sToolTip = (String)oToolTip;
			Display d = composite.getDisplay();
			if (d == null)
				return;
			toolTipShell = new Shell(composite.getShell(), 16384);
			FillLayout f = new FillLayout();
			try
			{
				f.marginWidth = 3;
				f.marginHeight = 1;
			}
			catch (NoSuchFieldError e) { }
			toolTipShell.setLayout(f);
			toolTipShell.setBackground(d.getSystemColor(29));
			toolTipLabel = new Label(toolTipShell, 64);
			toolTipLabel.setForeground(d.getSystemColor(28));
			toolTipLabel.setBackground(d.getSystemColor(29));
			toolTipShell.setData("TableCellSWT", cell);
			toolTipLabel.setText(sToolTip.replaceAll("&", "&&"));
			Point size = toolTipLabel.computeSize(-1, -1);
			if (size.x > 600)
				size = toolTipLabel.computeSize(600, -1, true);
			size.x += toolTipShell.getBorderWidth() * 2 + 2;
			size.y += toolTipShell.getBorderWidth() * 2;
			try
			{
				size.x += toolTipShell.getBorderWidth() * 2 + f.marginWidth * 2;
				size.y += toolTipShell.getBorderWidth() * 2 + f.marginHeight * 2;
			}
			catch (NoSuchFieldError e) { }
			Point pt = composite.toDisplay(event.x, event.y);
			Rectangle displayRect;
			try
			{
				displayRect = composite.getMonitor().getClientArea();
			}
			catch (NoSuchMethodError e)
			{
				displayRect = composite.getDisplay().getClientArea();
			}
			if (pt.x + size.x > displayRect.x + displayRect.width)
				pt.x = (displayRect.x + displayRect.width) - size.x;
			if (pt.y + size.y > displayRect.y + displayRect.height)
				pt.y -= size.y + 2;
			else
				pt.y += 21;
			if (pt.y < displayRect.y)
				pt.y = displayRect.y;
			toolTipShell.setBounds(pt.x, pt.y, size.x, size.y);
			toolTipShell.setVisible(true);
			break;

		case 12: // '\f'
			if (mainShell != null && !mainShell.isDisposed())
				mainShell.removeListener(27, this);
			if (tv.getComposite() != null && !tv.getComposite().isDisposed())
				mainShell.removeListener(27, this);
			// fall through

		default:
			if (toolTipShell != null)
			{
				toolTipShell.dispose();
				toolTipShell = null;
				toolTipLabel = null;
			}
			break;
		}
	}
}

⌨️ 快捷键说明

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