📄 torrentinfoview.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: TorrentInfoView.java
package org.gudy.azureus2.ui.swt.views;
import com.aelitis.azureus.ui.common.table.TableCellCore;
import com.aelitis.azureus.ui.common.table.TableColumnCore;
import java.net.URL;
import java.util.*;
import org.eclipse.swt.custom.ScrolledComposite;
import org.eclipse.swt.graphics.Font;
import org.eclipse.swt.graphics.FontData;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.*;
import org.gudy.azureus2.core3.download.DownloadManager;
import org.gudy.azureus2.core3.internat.LocaleTorrentUtil;
import org.gudy.azureus2.core3.internat.MessageText;
import org.gudy.azureus2.core3.torrent.*;
import org.gudy.azureus2.core3.tracker.client.TRTrackerAnnouncer;
import org.gudy.azureus2.core3.tracker.client.TRTrackerScraperResponse;
import org.gudy.azureus2.core3.util.Debug;
import org.gudy.azureus2.plugins.download.DownloadTypeComplete;
import org.gudy.azureus2.plugins.download.DownloadTypeIncomplete;
import org.gudy.azureus2.plugins.ui.tables.TableColumn;
import org.gudy.azureus2.ui.swt.Messages;
import org.gudy.azureus2.ui.swt.components.BufferedLabel;
import org.gudy.azureus2.ui.swt.views.table.impl.FakeTableCell;
import org.gudy.azureus2.ui.swt.views.table.utils.TableColumnManager;
// Referenced classes of package org.gudy.azureus2.ui.swt.views:
// AbstractIView
public class TorrentInfoView extends AbstractIView
{
private static final String TEXT_PREFIX = "TorrentInfoView.";
private DownloadManager download_manager;
private Composite outer_panel;
private Font headerFont;
private FakeTableCell cells[];
private ScrolledComposite sc;
private Composite parent;
protected TorrentInfoView()
{
}
public void initialize(Composite composite)
{
parent = composite;
if (download_manager == null)
return;
if (sc != null && !sc.isDisposed())
sc.dispose();
sc = new ScrolledComposite(composite, 768);
sc.setExpandHorizontal(true);
sc.setExpandVertical(true);
GridData gridData = new GridData(4, 4, true, true, 2, 1);
sc.setLayoutData(gridData);
outer_panel = sc;
Composite panel = new Composite(sc, 0);
sc.setContent(panel);
GridLayout layout = new GridLayout();
layout.marginHeight = 0;
layout.marginWidth = 0;
layout.numColumns = 1;
panel.setLayout(layout);
Composite cHeader = new Composite(panel, 2048);
GridLayout configLayout = new GridLayout();
configLayout.marginHeight = 3;
configLayout.marginWidth = 0;
cHeader.setLayout(configLayout);
gridData = new GridData(772);
cHeader.setLayoutData(gridData);
Display d = panel.getDisplay();
cHeader.setBackground(d.getSystemColor(26));
cHeader.setForeground(d.getSystemColor(27));
Label lHeader = new Label(cHeader, 0);
lHeader.setBackground(d.getSystemColor(26));
lHeader.setForeground(d.getSystemColor(27));
FontData fontData[] = lHeader.getFont().getFontData();
fontData[0].setStyle(1);
int fontHeight = (int)((double)fontData[0].getHeight() * 1.2D);
fontData[0].setHeight(fontHeight);
headerFont = new Font(d, fontData);
lHeader.setFont(headerFont);
lHeader.setText((new StringBuilder()).append(" ").append(MessageText.getString("authenticator.torrent")).append(" : ").append(download_manager.getDisplayName().replaceAll("&", "&&")).toString());
gridData = new GridData(772);
lHeader.setLayoutData(gridData);
Composite gTorrentInfo = new Composite(panel, 0);
gridData = new GridData(272);
gTorrentInfo.setLayoutData(gridData);
layout = new GridLayout();
layout.numColumns = 2;
gTorrentInfo.setLayout(layout);
Label label = new Label(gTorrentInfo, 0);
gridData = new GridData();
label.setLayoutData(gridData);
label.setText((new StringBuilder()).append(MessageText.getString("TorrentInfoView.torrent.encoding")).append(": ").toString());
TOTorrent torrent = download_manager.getTorrent();
BufferedLabel blabel = new BufferedLabel(gTorrentInfo, 0);
gridData = new GridData();
blabel.setLayoutData(gridData);
blabel.setText(torrent != null ? LocaleTorrentUtil.getCurrentTorrentEncoding(torrent) : "");
label = new Label(gTorrentInfo, 0);
gridData = new GridData();
label.setLayoutData(gridData);
label.setText((new StringBuilder()).append(MessageText.getString("MyTrackerView.tracker")).append(": ").toString());
String trackers = "";
if (torrent != null)
{
TOTorrentAnnounceURLGroup group = torrent.getAnnounceURLGroup();
TOTorrentAnnounceURLSet sets[] = group.getAnnounceURLSets();
List tracker_list = new ArrayList();
URL url = torrent.getAnnounceURL();
tracker_list.add((new StringBuilder()).append(url.getHost()).append(url.getPort() != -1 ? (new StringBuilder()).append(":").append(url.getPort()).toString() : "").toString());
for (int i = 0; i < sets.length; i++)
{
TOTorrentAnnounceURLSet set = sets[i];
URL urls[] = set.getAnnounceURLs();
for (int j = 0; j < urls.length; j++)
{
url = urls[j];
String str = (new StringBuilder()).append(url.getHost()).append(url.getPort() != -1 ? (new StringBuilder()).append(":").append(url.getPort()).toString() : "").toString();
if (!tracker_list.contains(str))
tracker_list.add(str);
}
}
TRTrackerAnnouncer announcer = download_manager.getTrackerClient();
URL active_url = null;
if (announcer != null)
{
active_url = announcer.getTrackerUrl();
} else
{
TRTrackerScraperResponse scrape = download_manager.getTrackerScrapeResponse();
if (scrape != null)
active_url = scrape.getURL();
}
if (active_url == null)
active_url = torrent.getAnnounceURL();
trackers = (new StringBuilder()).append(active_url.getHost()).append(active_url.getPort() != -1 ? (new StringBuilder()).append(":").append(active_url.getPort()).toString() : "").toString();
tracker_list.remove(trackers);
if (tracker_list.size() > 0)
{
trackers = (new StringBuilder()).append(trackers).append(" (").toString();
for (int i = 0; i < tracker_list.size(); i++)
trackers = (new StringBuilder()).append(trackers).append(i != 0 ? ", " : "").append(tracker_list.get(i)).toString();
trackers = (new StringBuilder()).append(trackers).append(")").toString();
}
}
blabel = new BufferedLabel(gTorrentInfo, 0);
gridData = new GridData();
blabel.setLayoutData(gridData);
blabel.setText(trackers);
Group gColumns = new Group(panel, 0);
Messages.setLanguageText(gColumns, "TorrentInfoView.columns");
gridData = new GridData(272);
gColumns.setLayoutData(gridData);
layout = new GridLayout();
layout.numColumns = 4;
gColumns.setLayout(layout);
Map usable_cols = new HashMap();
TableColumnManager col_man = TableColumnManager.getInstance();
TableColumnCore cols_sets[][] = {
col_man.getAllTableColumnCoreAsArray(org/gudy/azureus2/plugins/download/DownloadTypeIncomplete, "MyTorrents"), col_man.getAllTableColumnCoreAsArray(org/gudy/azureus2/plugins/download/DownloadTypeComplete, "MySeeders")
};
for (int i = 0; i < cols_sets.length; i++)
{
TableColumnCore cols[] = cols_sets[i];
for (int j = 0; j < cols.length; j++)
{
TableColumnCore col = cols[j];
String id = col.getName();
if (usable_cols.containsKey(id))
continue;
FakeTableCell fakeTableCell = null;
try
{
fakeTableCell = new FakeTableCell(col);
fakeTableCell.setOrentation(16384);
fakeTableCell.setDataSource(download_manager);
col.invokeCellAddedListeners(fakeTableCell);
fakeTableCell.refresh();
usable_cols.put(id, fakeTableCell);
continue;
}
catch (Throwable t) { }
try
{
if (fakeTableCell != null)
fakeTableCell.dispose();
}
catch (Throwable t2) { }
}
}
Collection values = usable_cols.values();
cells = new FakeTableCell[values.size()];
values.toArray(cells);
Arrays.sort(cells, new Comparator() {
final TorrentInfoView this$0;
public int compare(Object o1, Object o2)
{
TableColumnCore c1 = (TableColumnCore)((TableCellCore)o1).getTableColumn();
TableColumnCore c2 = (TableColumnCore)((TableCellCore)o2).getTableColumn();
String key1 = MessageText.getString(c1.getTitleLanguageKey());
String key2 = MessageText.getString(c2.getTitleLanguageKey());
return key1.compareToIgnoreCase(key2);
}
{
this$0 = TorrentInfoView.this;
super();
}
});
for (int i = 0; i < cells.length; i++)
{
final FakeTableCell cell = cells[i];
label = new Label(gColumns, 0);
gridData = new GridData();
if (i % 2 == 1)
gridData.horizontalIndent = 16;
label.setLayoutData(gridData);
String key = ((TableColumnCore)cell.getTableColumn()).getTitleLanguageKey();
label.setText((new StringBuilder()).append(MessageText.getString(key)).append(": ").toString());
label.setToolTipText(MessageText.getString((new StringBuilder()).append(key).append(".info").toString(), ""));
final Composite c = new Composite(gColumns, 0);
gridData = new GridData(768);
gridData.heightHint = 16;
c.setLayoutData(gridData);
cell.setControl(c);
cell.invalidate();
cell.refresh();
c.addListener(32, new Listener() {
final FakeTableCell val$cell;
final Composite val$c;
final TorrentInfoView this$0;
public void handleEvent(Event event)
{
Object toolTip = cell.getToolTip();
if (toolTip instanceof String)
{
String s = (String)toolTip;
c.setToolTipText(s);
}
}
{
this$0 = TorrentInfoView.this;
cell = faketablecell;
c = composite;
super();
}
});
}
refresh();
sc.setMinSize(panel.computeSize(-1, -1));
}
public void refresh()
{
if (cells != null)
{
for (int i = 0; i < cells.length; i++)
{
TableCellCore cell = cells[i];
try
{
cell.refresh();
}
catch (Exception e)
{
Debug.printStackTrace(e, (new StringBuilder()).append("Error refreshing cell: ").append(cells[i].getTableColumn().getName()).toString());
}
}
}
}
public Composite getComposite()
{
return outer_panel;
}
public String getFullTitle()
{
return MessageText.getString("GeneralView.section.info");
}
public String getData()
{
return "GeneralView.section.info";
}
public void delete()
{
super.delete();
if (headerFont != null)
headerFont.dispose();
if (cells != null)
{
for (int i = 0; i < cells.length; i++)
{
TableCellCore cell = cells[i];
cell.dispose();
}
}
}
public void dataSourceChanged(Object newDataSource)
{
if (newDataSource instanceof DownloadManager)
download_manager = (DownloadManager)newDataSource;
if (parent != null)
initialize(parent);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -