if ( subs_man == null ){
return;
}
Download dl = (Download)cell.getDataSource();
if ( dl == null ){
return;
}
Torrent torrent = dl.getTorrent();
if ( torrent != null ){
Subscription[] subs = subs_man.getKnownSubscriptions( torrent.getHash());
int num_subscribed = 0;
int num_unsubscribed = 0;
for (int i=0;i<subs.length;i++){
if ( subs[i].isSubscribed()){
num_subscribed++;
}else{
num_unsubscribed++;
}
}
Graphic graphic;
String tooltip;
int height = cell.getHeight();
int sort_order = 0;
if ( subs.length == 0 ){
graphic = null;
tooltip = null;
}else{
if ( num_subscribed == subs.length ){
graphic = height >= 22?icon_rss_all_add_big:icon_rss_all_add_small;
tooltip = MessageText.getString( "subscript.all.subscribed" );
}else if ( num_subscribed > 0 ){
graphic = height >= 22?icon_rss_some_add_big:icon_rss_some_add_small;
tooltip = MessageText.getString( "subscript.some.subscribed" );
sort_order = 10000;
}else{
graphic = height >= 22?icon_rss_big:icon_rss_small;
tooltip = MessageText.getString( "subscript.none.subscribed" );
sort_order = 1000000;
}
}
sort_order += 1000*num_unsubscribed + num_subscribed;
cell.setMarginHeight(0);
cell.setGraphic( graphic );
cell.setToolTip( tooltip );
cell.setSortValue( sort_order );
cell.setCursorID( graphic==null?SWT.CURSOR_ARROW:SWT.CURSOR_HAND );
}else{
cell.setCursorID( SWT.CURSOR_ARROW );
cell.setSortValue( 0 );
}
}
};
final TableCellMouseListener subs_mouse_listener =
new TableCellMouseListener()
{
public void
cellMouseTrigger(
TableCellMouseEvent event )
{
if ( event.eventType == TableCellMouseEvent.EVENT_MOUSEDOWN ){
TableCell cell = event.cell;
Download dl = (Download)cell.getDataSource();
Torrent torrent = dl.getTorrent();
if ( torrent != null ){
SubscriptionManager subs_man = SubscriptionManagerFactory.getSingleton();
Subscription[] subs = subs_man.getKnownSubscriptions( torrent.getHash());
if ( subs.length > 0 ){
event.skipCoreFunctionality = true;
new SubscriptionWizard(PluginCoreUtils.unwrap(dl));
COConfigurationManager.setParameter( "subscriptions.wizard.shown", true );
refreshTitles( mdiEntryOverview );
//new SubscriptionListWindow(PluginCoreUtils.unwrap(dl),true);
}
}
}
}
};
table_manager.registerColumn(
Download.class,
"azsubs.ui.column.subs",
new TableColumnCreationListener()
{
public void tableColumnCreated(TableColumn result) {
result.setAlignment(TableColumn.ALIGN_CENTER);
result.setPosition(TableColumn.POSITION_LAST);
result.setWidth(32);
result.setRefreshInterval(TableColumn.INTERVAL_INVALID_ONLY);
result.setType(TableColumn.TYPE_GRAPHIC);
result.addCellRefreshListener( subs_refresh_listener );
result.addCellMouseListener( subs_mouse_listener );
result.setIconReference("image.subscription.column", true);
synchronized (columns) {
columns.add(result);
}
}
});
final TableCellRefreshListener link_refresh_listener =
new TableCellRefreshListener()
{
public void
refresh(
TableCell _cell )
{
TableCellSWT cell = (TableCellSWT)_cell;
SubscriptionManager subs_man = SubscriptionManagerFactory.getSingleton();
if ( subs_man == null ){
return;
}
Download dl = (Download)cell.getDataSource();
if ( dl == null ){
return;
}
String str = "";
Torrent torrent = dl.getTorrent();
if ( torrent != null ){
byte[] hash = torrent.getHash();
Subscription[] subs = subs_man.getKnownSubscriptions( hash );
for (int i=0;i<subs.length;i++){
Subscription sub = subs[i];
if ( sub.hasAssociation( hash )){
str += (str.length()==0?"":"; ") + sub.getName();
}
}
}
cell.setCursorID( str.length() > 0?SWT.CURSOR_HAND:SWT.CURSOR_ARROW );
cell.setText( str );
}
};
final TableCellMouseListener link_mouse_listener =
new TableCellMouseListener()
{
public void
cellMouseTrigger(
TableCellMouseEvent event )
{
if ( event.eventType == TableCellMouseEvent.EVENT_MOUSEDOWN ){
TableCell cell = event.cell;
Download dl = (Download)cell.getDataSource();
Torrent torrent = dl.getTorrent();
SubscriptionManager subs_man = SubscriptionManagerFactory.getSingleton();
if ( torrent != null && subs_man != null ){