1 /*
2  * Copyright (C) Azureus Software, Inc, All Rights Reserved.
3  *
4  * This program is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation; either version 2 of the License, or
7  * (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  * GNU General Public License for more details ( see the LICENSE file ).
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
17  */
18 
19 package com.aelitis.azureus.ui.swt.views.skin;
20 
21 import org.eclipse.swt.widgets.Composite;
22 import org.eclipse.swt.widgets.Text;
23 
24 import org.gudy.azureus2.core3.download.DownloadManager;
25 import org.gudy.azureus2.plugins.download.Download;
26 import org.gudy.azureus2.plugins.download.DownloadTypeComplete;
27 import org.gudy.azureus2.plugins.download.DownloadTypeIncomplete;
28 import org.gudy.azureus2.ui.swt.Utils;
29 import org.gudy.azureus2.ui.swt.views.MyTorrentsView;
30 
31 import com.aelitis.azureus.core.AzureusCore;
32 import com.aelitis.azureus.core.torrent.PlatformTorrentUtils;
33 import com.aelitis.azureus.ui.common.table.TableColumnCore;
34 import com.aelitis.azureus.ui.common.table.TableRowCore;
35 
36 public class MyTorrentsView_Big
37 	extends MyTorrentsView
38 {
39 	private final int torrentFilterMode;
40 	private int defaultRowHeight;
41 
MyTorrentsView_Big(AzureusCore _azureus_core, int torrentFilterMode, TableColumnCore[] basicItems, Text txtFilter, Composite cCatsTags)42 	public MyTorrentsView_Big(AzureusCore _azureus_core, int torrentFilterMode,
43 			TableColumnCore[] basicItems, Text txtFilter, Composite cCatsTags) {
44 		super( true );
45 		defaultRowHeight = Utils.adjustPXForDPI(40);
46 		this.torrentFilterMode = torrentFilterMode;
47 		this.txtFilter = txtFilter;
48 		this.cCategoriesAndTags = cCatsTags;
49 		Class<?> forDataSourceType;
50 		switch (torrentFilterMode) {
51 			case SBC_LibraryView.TORRENTS_COMPLETE:
52 			case SBC_LibraryView.TORRENTS_UNOPENED:
53 				forDataSourceType = DownloadTypeComplete.class;
54 				break;
55 
56 			case SBC_LibraryView.TORRENTS_INCOMPLETE:
57 				forDataSourceType = DownloadTypeIncomplete.class;
58 				break;
59 
60 			default:
61 				forDataSourceType = Download.class;
62 				break;
63 		}
64 		init(
65 				_azureus_core,
66 				SB_Transfers.getTableIdFromFilterMode(torrentFilterMode, true),
67 				forDataSourceType, basicItems);
68 		//setForceHeaderVisible(true);
69 	}
70 
71 
isOurDownloadManager(DownloadManager dm)72 	public boolean isOurDownloadManager(DownloadManager dm) {
73 		if (PlatformTorrentUtils.isAdvancedViewOnly(dm)) {
74 			return false;
75 		}
76 
77 		if (torrentFilterMode == SBC_LibraryView.TORRENTS_UNOPENED) {
78 			if (PlatformTorrentUtils.getHasBeenOpened(dm)) {
79 				return false;
80 			}
81 		} else if (torrentFilterMode == SBC_LibraryView.TORRENTS_ALL) {
82 			if ( !isInCurrentTag(dm)){
83 				return(false );
84 			}
85 			return( isInCurrentTag(dm));
86 		}
87 
88 		return super.isOurDownloadManager(dm);
89 	}
90 
91 	// @see org.gudy.azureus2.ui.swt.views.MyTorrentsView#defaultSelected(com.aelitis.azureus.ui.common.table.TableRowCore[])
defaultSelected(TableRowCore[] rows, int stateMask)92 	public void defaultSelected(TableRowCore[] rows, int stateMask) {
93 		boolean neverPlay = DownloadTypeIncomplete.class.equals(getForDataSourceType());
94 		SBC_LibraryTableView.doDefaultClick(rows, stateMask, neverPlay);
95 	}
96 
getRowDefaultHeight()97 	protected int getRowDefaultHeight() {
98 		return defaultRowHeight;
99 	}
100 
101 }
102