📄 mysharesview.java
字号:
private void addCategory()
{
CategoryAdderWindow adderWindow = new CategoryAdderWindow(Display.getDefault());
Category newCategory = adderWindow.getNewCategory();
if (newCategory != null)
assignSelectedToCategory(newCategory);
}
private void assignSelectedToCategory(final Category category)
{
tv.runForSelectedRows(new TableGroupRowRunner() {
final Category val$category;
final MySharesView this$0;
public void run(TableRowCore row)
{
String value;
if (category == null)
value = null;
else
if (category == CategoryManager.getCategory(2))
value = null;
else
value = category.getName();
((ShareResource)row.getDataSource(true)).setAttribute(MySharesView.category_attribute, value);
}
{
this$0 = MySharesView.this;
category = category1;
super();
}
});
}
private void computePossibleActions()
{
List items;
org.gudy.azureus2.plugins.download.DownloadManager dm;
int i;
start = stop = remove = false;
items = getSelectedItems();
if (items.size() <= 0)
break MISSING_BLOCK_LABEL_163;
PluginInterface pi = azureus_core.getPluginManager().getDefaultPluginInterface();
dm = pi.getDownloadManager();
remove = true;
i = 0;
_L3:
if (i >= items.size()) goto _L2; else goto _L1
_L1:
ShareItem item = (ShareItem)items.get(i);
Torrent t = item.getTorrent();
Download download = dm.getDownload(t);
if (download == null)
continue; /* Loop/switch isn't completed */
try
{
int dl_state = download.getState();
if (dl_state == 8)
continue; /* Loop/switch isn't completed */
if (dl_state != 7)
stop = true;
else
start = true;
}
catch (Throwable e)
{
Debug.printStackTrace(e);
}
i++;
goto _L3
_L2:
}
public boolean isEnabled(String itemKey)
{
if (itemKey.equals("start"))
return start;
if (itemKey.equals("stop"))
return stop;
if (itemKey.equals("remove"))
return remove;
else
return super.isEnabled(itemKey);
}
public void itemActivated(String itemKey)
{
if (itemKey.equals("remove"))
{
removeSelectedShares();
return;
}
if (itemKey.equals("stop"))
{
stopSelectedShares();
return;
}
if (itemKey.equals("start"))
{
startSelectedShares();
return;
} else
{
super.itemActivated(itemKey);
return;
}
}
private List getSelectedItems()
{
Object shares[] = tv.getSelectedDataSources().toArray();
List items = new ArrayList();
if (shares.length > 0)
{
for (int i = 0; i < shares.length; i++)
{
ShareResource share = (ShareResource)shares[i];
int type = share.getType();
if (type == 2)
{
ShareResourceDir sr = (ShareResourceDir)share;
items.add(sr.getItem());
continue;
}
if (type == 1)
{
ShareResourceFile sr = (ShareResourceFile)share;
items.add(sr.getItem());
continue;
}
ShareResourceDirContents cont = (ShareResourceDirContents)share;
List entries = new ArrayList();
getEntries(entries, cont);
for (int j = 0; j < entries.size(); j++)
{
share = (ShareResource)entries.get(j);
type = share.getType();
if (type == 2)
{
ShareResourceDir sr = (ShareResourceDir)share;
items.add(sr.getItem());
continue;
}
if (type == 1)
{
ShareResourceFile sr = (ShareResourceFile)share;
items.add(sr.getItem());
}
}
}
}
return items;
}
private void getEntries(List entries, ShareResourceDirContents cont)
{
ShareResource kids[] = cont.getChildren();
for (int i = 0; i < kids.length; i++)
{
ShareResource share = kids[i];
int type = share.getType();
if (type == 3)
getEntries(entries, (ShareResourceDirContents)share);
else
entries.add(share);
}
}
private void startStopSelectedShares(boolean do_stop)
{
List items;
org.gudy.azureus2.plugins.download.DownloadManager dm;
Tracker tracker;
int i;
items = getSelectedItems();
PluginInterface pi = azureus_core.getPluginManager().getDefaultPluginInterface();
dm = pi.getDownloadManager();
tracker = pi.getTracker();
i = 0;
_L3:
if (i >= items.size()) goto _L2; else goto _L1
_L1:
ShareItem item = (ShareItem)items.get(i);
Torrent t = item.getTorrent();
TrackerTorrent tracker_torrent = tracker.getTorrent(t);
Download download = dm.getDownload(t);
if (tracker_torrent == null || download == null)
continue; /* Loop/switch isn't completed */
try
{
int dl_state = download.getState();
if (dl_state == 8)
continue; /* Loop/switch isn't completed */
if (dl_state != 7)
{
if (!do_stop)
continue; /* Loop/switch isn't completed */
try
{
download.stop();
}
catch (Throwable e) { }
try
{
tracker_torrent.stop();
}
catch (Throwable e) { }
continue; /* Loop/switch isn't completed */
}
if (do_stop)
continue; /* Loop/switch isn't completed */
try
{
download.restart();
}
catch (Throwable e) { }
try
{
tracker_torrent.start();
}
catch (Throwable e) { }
}
catch (Throwable e)
{
Debug.printStackTrace(e);
}
i++;
goto _L3
_L2:
}
private void startSelectedShares()
{
startStopSelectedShares(false);
}
private void stopSelectedShares()
{
startStopSelectedShares(true);
}
private void removeSelectedShares()
{
stopSelectedShares();
Object shares[] = tv.getSelectedDataSources().toArray();
for (int i = 0; i < shares.length; i++)
try
{
((ShareResource)shares[i]).delete();
}
catch (Throwable e)
{
Alerts.showErrorMessageBoxUsingResourceString(new Object[] {
shares[i]
}, "globalmanager.download.remove.veto", e, 0);
}
}
public void addThisColumnSubMenu(String s, Menu menu)
{
}
public void defaultSelected(TableRowCore atablerowcore[], int i)
{
}
public void deselected(TableRowCore rows[])
{
computePossibleActions();
UIFunctions uiFunctions = UIFunctionsManager.getUIFunctions();
if (uiFunctions != null)
uiFunctions.refreshIconBar();
}
public void focusChanged(TableRowCore focus)
{
computePossibleActions();
UIFunctions uiFunctions = UIFunctionsManager.getUIFunctions();
if (uiFunctions != null)
uiFunctions.refreshIconBar();
}
public void mouseEnter(TableRowCore tablerowcore)
{
}
public void mouseExit(TableRowCore tablerowcore)
{
}
public void selected(TableRowCore row[])
{
computePossibleActions();
UIFunctions uiFunctions = UIFunctionsManager.getUIFunctions();
if (uiFunctions != null)
uiFunctions.refreshIconBar();
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -