use of com.biglybt.ui.selectedcontent.ISelectedContent in project BiglyBT by BiglySoftware.
the class ToolBarView method _refreshCoreToolBarItems.
public void _refreshCoreToolBarItems() {
if (DEBUG && !isVisible()) {
Debug.out("Trying to refresh core toolbar items when toolbar is not visible " + this + getMainSkinObject());
}
UIFunctionsSWT uiFunctionsSWT = UIFunctionsManagerSWT.getUIFunctionsSWT();
MultipleDocumentInterfaceSWT mdi = uiFunctionsSWT != null ? uiFunctionsSWT.getMDISWT() : null;
if (mdi != null) {
UIToolBarItem[] allToolBarItems = tbm.getAllToolBarItems();
MdiEntrySWT entry = mdi.getCurrentEntrySWT();
Map<String, Long> mapStates = new HashMap<>();
if (entry != null) {
UIToolBarEnablerBase[] enablers = entry.getToolbarEnablers();
for (UIToolBarEnablerBase enabler : enablers) {
if (enabler instanceof UIPluginViewToolBarListener) {
try {
((UIPluginViewToolBarListener) enabler).refreshToolBarItems(mapStates);
} catch (Throwable e) {
// don't trust them plugins
Debug.out(e);
}
}
}
}
ISelectedContent[] currentContent = SelectedContentManager.getCurrentlySelectedContent();
synchronized (dm_listener_map) {
Map<DownloadManager, DownloadManagerListener> copy = new IdentityHashMap<>(dm_listener_map);
for (ISelectedContent content : currentContent) {
DownloadManager dm = content.getDownloadManager();
if (dm != null) {
copy.remove(dm);
if (!dm_listener_map.containsKey(dm)) {
DownloadManagerListener l = new DownloadManagerListener() {
@Override
public void stateChanged(DownloadManager manager, int state) {
refreshCoreToolBarItems();
}
@Override
public void downloadComplete(DownloadManager manager) {
refreshCoreToolBarItems();
}
@Override
public void completionChanged(DownloadManager manager, boolean bCompleted) {
refreshCoreToolBarItems();
}
@Override
public void positionChanged(DownloadManager download, int oldPosition, int newPosition) {
refreshCoreToolBarItems();
}
@Override
public void filePriorityChanged(DownloadManager download, DiskManagerFileInfo file) {
refreshCoreToolBarItems();
}
};
dm.addListener(l, false);
dm_listener_map.put(dm, l);
// System.out.println( "Added " + dm.getDisplayName() + " - size=" + dm_listener_map.size());
}
}
}
for (Map.Entry<DownloadManager, DownloadManagerListener> e : copy.entrySet()) {
DownloadManager dm = e.getKey();
dm.removeListener(e.getValue());
dm_listener_map.remove(dm);
// System.out.println( "Removed " + dm.getDisplayName() + " - size=" + dm_listener_map.size());
}
}
boolean has1Selection = currentContent.length == 1;
boolean can_play = false;
boolean can_stream = false;
boolean stream_permitted = false;
if (has1Selection) {
if (!(currentContent[0] instanceof ISelectedVuzeFileContent)) {
can_play = PlayUtils.canPlayDS(currentContent[0], currentContent[0].getFileIndex(), false);
can_stream = PlayUtils.canStreamDS(currentContent[0], currentContent[0].getFileIndex(), false);
if (can_stream) {
stream_permitted = PlayUtils.isStreamPermitted();
}
}
}
if (mapStates.containsKey("play")) {
can_play |= (mapStates.get("play") & UIToolBarItem.STATE_ENABLED) > 0;
}
if (mapStates.containsKey("stream")) {
can_stream |= (mapStates.get("stream") & UIToolBarItem.STATE_ENABLED) > 0;
}
mapStates.put("play", can_play | can_stream ? UIToolBarItem.STATE_ENABLED : 0);
UIToolBarItem pitem = tbm.getToolBarItem("play");
if (pitem != null) {
if (can_stream) {
pitem.setImageID(stream_permitted ? "image.button.stream" : "image.button.pstream");
pitem.setTextID(stream_permitted ? "iconBar.stream" : "iconBar.pstream");
} else {
pitem.setImageID("image.button.play");
pitem.setTextID("iconBar.play");
}
}
UIToolBarItem ssItem = tbm.getToolBarItem("startstop");
if (ssItem != null) {
boolean shouldStopGroup;
if (currentContent.length == 0 && mapStates.containsKey("start") && (!mapStates.containsKey("stop") || (mapStates.get("stop") & UIToolBarItem.STATE_ENABLED) == 0) && (mapStates.get("start") & UIToolBarItem.STATE_ENABLED) > 0) {
shouldStopGroup = false;
} else {
shouldStopGroup = TorrentUtil.shouldStopGroup(currentContent);
}
ssItem.setTextID(shouldStopGroup ? "iconBar.stop" : "iconBar.start");
ssItem.setImageID("image.toolbar.startstop." + (shouldStopGroup ? "stop" : "start"));
if (currentContent.length == 0 && !mapStates.containsKey("startstop")) {
boolean can_stop = mapStates.containsKey("stop") && (mapStates.get("stop") & UIToolBarItem.STATE_ENABLED) > 0;
boolean can_start = mapStates.containsKey("start") && (mapStates.get("start") & UIToolBarItem.STATE_ENABLED) > 0;
if (can_start && can_stop) {
can_stop = false;
}
if (can_start || can_stop) {
ssItem.setTextID(can_stop ? "iconBar.stop" : "iconBar.start");
ssItem.setImageID("image.toolbar.startstop." + (can_stop ? "stop" : "start"));
mapStates.put("startstop", UIToolBarItem.STATE_ENABLED);
}
}
}
Map<String, Long> fallBackStates = TorrentUtil.calculateToolbarStates(currentContent, null);
for (String key : fallBackStates.keySet()) {
if (!mapStates.containsKey(key)) {
mapStates.put(key, fallBackStates.get(key));
}
}
final String[] TBKEYS = new String[] { "play", "run", "top", "up", "down", "bottom", "start", "stop", "startstop", "remove" };
for (String key : TBKEYS) {
if (!mapStates.containsKey(key)) {
mapStates.put(key, 0L);
}
}
for (int i = 0; i < allToolBarItems.length; i++) {
UIToolBarItem toolBarItem = allToolBarItems[i];
Long state = mapStates.get(toolBarItem.getID());
if (state != null) {
toolBarItem.setState(state);
}
}
}
}
use of com.biglybt.ui.selectedcontent.ISelectedContent in project BiglyBT by BiglySoftware.
the class DataSourceUtils method getTorrent.
public static TOTorrent getTorrent(Object ds) {
if (ds instanceof TOTorrent) {
return (TOTorrent) ds;
}
if (ds instanceof DownloadManager) {
TOTorrent torrent = ((DownloadManager) ds).getTorrent();
if (torrent != null) {
return torrent;
}
}
if (ds instanceof ActivitiesEntry) {
TOTorrent torrent = ((ActivitiesEntry) ds).getTorrent();
if (torrent == null) {
// getDM will check hash as well
DownloadManager dm = getDM(ds);
if (dm != null) {
torrent = dm.getTorrent();
}
}
return torrent;
}
if (ds instanceof TranscodeFile) {
TranscodeFile tf = (TranscodeFile) ds;
try {
DiskManagerFileInfo file = tf.getSourceFile();
if (file != null) {
Download download = file.getDownload();
if (download != null) {
Torrent torrent = download.getTorrent();
if (torrent != null) {
return PluginCoreUtils.unwrap(torrent);
}
}
}
} catch (Throwable e) {
}
}
if (ds instanceof TranscodeJob) {
TranscodeJob tj = (TranscodeJob) ds;
try {
DiskManagerFileInfo file = tj.getFile();
if (file != null) {
Download download = tj.getFile().getDownload();
if (download != null) {
Torrent torrent = download.getTorrent();
if (torrent != null) {
return PluginCoreUtils.unwrap(torrent);
}
}
}
} catch (DownloadException e) {
}
}
if (ds instanceof ISelectedContent) {
return ((ISelectedContent) ds).getTorrent();
}
if (ds instanceof String) {
String hash = (String) ds;
try {
GlobalManager gm = CoreFactory.getSingleton().getGlobalManager();
DownloadManager dm = gm.getDownloadManager(new HashWrapper(Base32.decode(hash)));
if (dm != null) {
return dm.getTorrent();
}
} catch (Exception e) {
// ignore
}
}
DownloadManager dm = getDM(ds);
if (dm != null) {
return dm.getTorrent();
}
return null;
}
use of com.biglybt.ui.selectedcontent.ISelectedContent in project BiglyBT by BiglySoftware.
the class TorrentUtil method calculateToolbarStates.
// XXX Don't think *View's need this call anymore. ToolBarView does it fo them
public static Map<String, Long> calculateToolbarStates(ISelectedContent[] currentContent, String viewID_unused) {
// System.out.println("calculateToolbarStates(" + currentContent.length + ", " + viewID_unused + " via " + Debug.getCompressedStackTrace());
/*
String[] TBKEYS = new String[] {
"download",
"play",
"stream",
"run",
"top",
"up",
"down",
"bottom",
"start",
"stop",
"remove"
};
*/
Map<String, Long> mapNewToolbarStates = new HashMap<>();
String[] itemsNeedingSelection = {};
String[] itemsNeedingRealDMSelection = { "remove", "top", "bottom", "transcode", "startstop" };
String[] itemsRequiring1DMwithHash = { "details", "comment", "up", "down" };
String[] itemsRequiring1DMSelection = {};
int numSelection = currentContent.length;
boolean hasSelection = numSelection > 0;
boolean has1Selection = numSelection == 1;
for (int i = 0; i < itemsNeedingSelection.length; i++) {
String itemID = itemsNeedingSelection[i];
mapNewToolbarStates.put(itemID, hasSelection ? UIToolBarItem.STATE_ENABLED : 0);
}
TableView tv = SelectedContentManager.getCurrentlySelectedTableView();
// not sure why we assume that the existance of any table view
boolean hasRealDM = tv != null;
if (!hasRealDM && numSelection > 0) {
hasRealDM = true;
for (int i = 0; i < currentContent.length; i++) {
ISelectedContent content = currentContent[i];
DownloadManager dm = content.getDownloadManager();
if (dm == null) {
hasRealDM = false;
break;
}
}
}
if (!hasRealDM) {
MultipleDocumentInterfaceSWT mdi = UIFunctionsManagerSWT.getUIFunctionsSWT().getMDISWT();
if (mdi != null) {
MdiEntrySWT entry = mdi.getCurrentEntrySWT();
if (entry != null) {
if (entry.getDatasource() instanceof DownloadManager) {
hasRealDM = true;
} else if ((entry instanceof UIPluginView) && (((UIPluginView) entry).getDataSource() instanceof DownloadManager)) {
hasRealDM = true;
}
}
}
}
boolean canStart = false;
boolean canStop = false;
boolean canRemoveFileInfo = false;
boolean canRunFileInfo = false;
boolean canCheckExist = false;
boolean hasDM = false;
boolean canRecheck = false;
if (currentContent.length > 0 && hasRealDM) {
// well, in fact, we can have hasRealDM set to true here (because tv isn't null) and actually not have a real dm.
// fancy that - protect against null DownloadManagers...
boolean canMoveUp = false;
boolean canMoveDown = false;
boolean canDownload = false;
canCheckExist = true;
GlobalManager gm = null;
for (int i = 0; i < currentContent.length; i++) {
ISelectedContent content = currentContent[i];
DownloadManager dm = content.getDownloadManager();
if (dm == null) {
if (!canDownload && content.getDownloadInfo() != null) {
canDownload = true;
}
continue;
}
if (gm == null) {
gm = dm.getGlobalManager();
}
int state = dm.getState();
canCheckExist &= (state == DownloadManager.STATE_ERROR || state == DownloadManager.STATE_STOPPED || state == DownloadManager.STATE_QUEUED);
int fileIndex = content.getFileIndex();
if (fileIndex == -1) {
if (!canMoveUp && gm.isMoveableUp(dm)) {
canMoveUp = true;
}
if (!canMoveDown && gm.isMoveableDown(dm)) {
canMoveDown = true;
}
hasDM = true;
if (!canStart && ManagerUtils.isStartable(dm)) {
canStart = true;
}
if (!canStop && ManagerUtils.isStopable(dm)) {
canStop = true;
}
} else {
DiskManagerFileInfoSet fileInfos = dm.getDiskManagerFileInfoSet();
if (fileIndex < fileInfos.nbFiles()) {
DiskManagerFileInfo fileInfo = fileInfos.getFiles()[fileIndex];
if (!canStart && (fileInfo.isSkipped())) {
canStart = true;
}
if (!canStop && !fileInfo.isSkipped()) {
canStop = true;
}
if (!canRemoveFileInfo && !fileInfo.isSkipped()) {
int storageType = fileInfo.getStorageType();
if (storageType == DiskManagerFileInfo.ST_LINEAR || storageType == DiskManagerFileInfo.ST_COMPACT) {
canRemoveFileInfo = true;
}
}
if (!canRunFileInfo && fileInfo.getAccessMode() == DiskManagerFileInfo.READ && fileInfo.getDownloaded() == fileInfo.getLength() && fileInfo.getFile(true).exists()) {
canRunFileInfo = true;
}
}
}
canRecheck = canRecheck || dm.canForceRecheck();
}
boolean canRemove = hasDM || canRemoveFileInfo;
mapNewToolbarStates.put("remove", canRemove ? UIToolBarItem.STATE_ENABLED : 0);
mapNewToolbarStates.put("download", canDownload ? UIToolBarItem.STATE_ENABLED : 0);
if (currentContent.length == 1) {
mapNewToolbarStates.put("up", canMoveUp ? UIToolBarItem.STATE_ENABLED : 0);
mapNewToolbarStates.put("down", canMoveDown ? UIToolBarItem.STATE_ENABLED : 0);
}
}
boolean canRun = has1Selection && ((hasDM && !canRunFileInfo) || (!hasDM && canRunFileInfo));
if (canRun) {
ISelectedContent content = currentContent[0];
DownloadManager dm = content.getDownloadManager();
if (dm == null) {
canRun = false;
} else {
TOTorrent torrent = dm.getTorrent();
if (torrent == null) {
canRun = false;
} else if (!dm.getAssumedComplete() && torrent.isSimpleTorrent()) {
canRun = false;
/*
} else if (PlatformTorrentUtils.useEMP(torrent)
&& PlatformTorrentUtils.embeddedPlayerAvail()
&& PlayUtils.canProgressiveOrIsComplete(torrent)) {
// play button enabled and not UMP.. don't need launch
canRun = false;
}
*/
}
}
}
mapNewToolbarStates.put("run", canRun ? UIToolBarItem.STATE_ENABLED : 0);
mapNewToolbarStates.put("start", canStart ? UIToolBarItem.STATE_ENABLED : 0);
mapNewToolbarStates.put("stop", canStop ? UIToolBarItem.STATE_ENABLED : 0);
mapNewToolbarStates.put("startstop", canStart || canStop ? UIToolBarItem.STATE_ENABLED : 0);
for (int i = 0; i < itemsNeedingRealDMSelection.length; i++) {
String itemID = itemsNeedingRealDMSelection[i];
if (!mapNewToolbarStates.containsKey(itemID)) {
mapNewToolbarStates.put(itemID, hasSelection && hasDM && hasRealDM ? UIToolBarItem.STATE_ENABLED : 0);
}
}
for (int i = 0; i < itemsRequiring1DMSelection.length; i++) {
String itemID = itemsRequiring1DMSelection[i];
if (!mapNewToolbarStates.containsKey(itemID)) {
mapNewToolbarStates.put(itemID, has1Selection && hasDM ? UIToolBarItem.STATE_ENABLED : 0);
}
}
for (int i = 0; i < itemsRequiring1DMwithHash.length; i++) {
String itemID = itemsRequiring1DMwithHash[i];
if (!mapNewToolbarStates.containsKey(itemID)) {
mapNewToolbarStates.put(itemID, hasDM ? UIToolBarItem.STATE_ENABLED : 0);
}
}
mapNewToolbarStates.put("download", has1Selection && (!(currentContent[0] instanceof ISelectedVuzeFileContent)) && currentContent[0].getDownloadManager() == null && (currentContent[0].getHash() != null || currentContent[0].getDownloadInfo() != null) ? UIToolBarItem.STATE_ENABLED : 0);
if (tv != null) {
TableColumn tc = tv.getTableColumn(RankItem.COLUMN_ID);
if (tc != null && !tc.isVisible()) {
mapNewToolbarStates.put("up", 0L);
mapNewToolbarStates.put("down", 0L);
}
}
mapNewToolbarStates.put(TU_ITEM_RECHECK, canRecheck ? UIToolBarItem.STATE_ENABLED : 0);
mapNewToolbarStates.put(TU_ITEM_CHECK_FILES, canCheckExist ? UIToolBarItem.STATE_ENABLED : 0);
return mapNewToolbarStates;
}
use of com.biglybt.ui.selectedcontent.ISelectedContent in project BiglyBT by BiglySoftware.
the class SBC_SubscriptionResultsView method initTable.
private void initTable(Composite control) {
tv_subs_results = TableViewFactory.createTableViewSWT(SBC_SubscriptionResult.class, TABLE_SR, TABLE_SR, new TableColumnCore[0], ColumnSearchSubResultAge.COLUMN_ID, SWT.MULTI | SWT.FULL_SELECTION | SWT.VIRTUAL);
TableColumnManager tableManager = TableColumnManager.getInstance();
tableManager.setDefaultColumnNames(TABLE_SR, new String[] { ColumnSubResultNew.COLUMN_ID, ColumnSearchSubResultType.COLUMN_ID, ColumnSearchSubResultName.COLUMN_ID, ColumnSearchSubResultActions.COLUMN_ID, ColumnSearchSubResultSize.COLUMN_ID, ColumnSearchSubResultSeedsPeers.COLUMN_ID, ColumnSearchSubResultRatings.COLUMN_ID, ColumnSearchSubResultAge.COLUMN_ID, ColumnSearchSubResultRank.COLUMN_ID, ColumnSearchSubResultCategory.COLUMN_ID });
tableManager.setDefaultSortColumnName(TABLE_SR, ColumnSearchSubResultAge.COLUMN_ID);
TableColumnCore tcc = tableManager.getTableColumnCore(TABLE_SR, ColumnSearchSubResultAge.COLUMN_ID);
if (tcc != null) {
tcc.setDefaultSortAscending(true);
}
if (txtFilter != null) {
tv_subs_results.enableFilterCheck(txtFilter, this);
}
tv_subs_results.setRowDefaultHeight(COConfigurationManager.getIntParameter("Search Subs Row Height"));
SWTSkinObject soSizeSlider = getSkinObject("table-size-slider");
if (soSizeSlider instanceof SWTSkinObjectContainer) {
SWTSkinObjectContainer so = (SWTSkinObjectContainer) soSizeSlider;
if (!tv_subs_results.enableSizeSlider(so.getComposite(), 16, 100)) {
so.setVisible(false);
}
}
table_parent = new Composite(control, SWT.NONE);
table_parent.setLayoutData(Utils.getFilledFormData());
GridLayout layout = new GridLayout();
layout.marginHeight = layout.marginWidth = layout.verticalSpacing = layout.horizontalSpacing = 0;
table_parent.setLayout(layout);
tv_subs_results.addSelectionListener(new TableSelectionListener() {
@Override
public void selected(TableRowCore[] _rows) {
updateSelectedContent();
}
@Override
public void mouseExit(TableRowCore row) {
}
@Override
public void mouseEnter(TableRowCore row) {
}
@Override
public void focusChanged(TableRowCore focus) {
UIFunctions uiFunctions = UIFunctionsManager.getUIFunctions();
if (uiFunctions != null) {
uiFunctions.refreshIconBar();
}
}
@Override
public void deselected(TableRowCore[] rows) {
updateSelectedContent();
}
@Override
public void defaultSelected(TableRowCore[] rows, int stateMask) {
if (rows.length == 1) {
SBC_SubscriptionResult rc = (SBC_SubscriptionResult) rows[0].getDataSource();
SBC_SearchResultsView.downloadAction(rc);
}
}
private void updateSelectedContent() {
TableRowCore[] rows = tv_subs_results.getSelectedRows();
ArrayList<ISelectedContent> valid = new ArrayList<>();
last_selected_content.clear();
for (int i = 0; i < rows.length; i++) {
SBC_SubscriptionResult rc = (SBC_SubscriptionResult) rows[i].getDataSource();
last_selected_content.add(rc);
byte[] hash = rc.getHash();
if (hash != null && hash.length > 0) {
SelectedContent sc = new SelectedContent(Base32.encode(hash), rc.getName());
sc.setDownloadInfo(new DownloadUrlInfo(getDownloadURI(rc)));
valid.add(sc);
}
}
ISelectedContent[] sels = valid.toArray(new ISelectedContent[valid.size()]);
SelectedContentManager.changeCurrentlySelectedContent("IconBarEnabler", sels, tv_subs_results);
UIFunctions uiFunctions = UIFunctionsManager.getUIFunctions();
if (uiFunctions != null) {
uiFunctions.refreshIconBar();
}
}
}, false);
tv_subs_results.addLifeCycleListener(new TableLifeCycleListener() {
@Override
public void tableLifeCycleEventOccurred(TableView tv, int eventType, Map<String, Object> data) {
if (eventType == TableLifeCycleListener.EVENT_TABLELIFECYCLE_INITIALIZED) {
reconcileResults(ds);
}
}
});
tv_subs_results.addMenuFillListener(new TableViewSWTMenuFillListener() {
@Override
public void fillMenu(String sColumnName, Menu menu) {
Object[] _related_content = tv_subs_results.getSelectedDataSources().toArray();
final SBC_SubscriptionResult[] results = new SBC_SubscriptionResult[_related_content.length];
System.arraycopy(_related_content, 0, results, 0, results.length);
MenuItem item = new MenuItem(menu, SWT.PUSH);
item.setText(MessageText.getString("label.copy.url.to.clip"));
item.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
StringBuffer buffer = new StringBuffer(1024);
for (SBC_SubscriptionResult result : results) {
if (buffer.length() > 0) {
buffer.append("\r\n");
}
buffer.append(getDownloadURI(result));
}
ClipboardCopy.copyToClipBoard(buffer.toString());
}
});
item.setEnabled(results.length > 0);
SearchSubsUtils.addMenu(results, menu);
new MenuItem(menu, SWT.SEPARATOR);
if (results.length == 1) {
if (SearchSubsUtils.addMenu(results[0], menu)) {
new MenuItem(menu, SWT.SEPARATOR);
}
}
final MenuItem remove_item = new MenuItem(menu, SWT.PUSH);
remove_item.setText(MessageText.getString("azbuddy.ui.menu.remove"));
Utils.setMenuItemImage(remove_item, "delete");
remove_item.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
userDelete(results);
}
});
remove_item.setEnabled(results.length > 0);
new MenuItem(menu, SWT.SEPARATOR);
}
@Override
public void addThisColumnSubMenu(String columnName, Menu menuThisColumn) {
}
});
tv_subs_results.addKeyListener(new KeyListener() {
@Override
public void keyPressed(KeyEvent e) {
if (e.stateMask == 0 && e.keyCode == SWT.DEL) {
Object[] selected;
synchronized (this) {
if (tv_subs_results == null) {
selected = new Object[0];
} else {
selected = tv_subs_results.getSelectedDataSources().toArray();
}
}
SBC_SubscriptionResult[] content = new SBC_SubscriptionResult[selected.length];
for (int i = 0; i < content.length; i++) {
content[i] = (SBC_SubscriptionResult) selected[i];
}
userDelete(content);
e.doit = false;
}
}
@Override
public void keyReleased(KeyEvent arg0) {
}
});
/*
if (ds instanceof RCMItemSubView) {
tv_related_content.addCountChangeListener(new TableCountChangeListener() {
public void rowRemoved(TableRowCore row) {
updateCount();
}
public void rowAdded(TableRowCore row) {
updateCount();
}
private void updateCount() {
int size = tv_related_content == null ? 0 : tv_related_content.size(false);
((RCMItemSubView) ds).setCount(size);
}
});
((RCMItemSubView) ds).setCount(0);
}
*/
tv_subs_results.initialize(table_parent);
control.layout(true);
}
use of com.biglybt.ui.selectedcontent.ISelectedContent in project BiglyBT by BiglySoftware.
the class MyTorrentsSuperView method initializeWithCore.
private void initializeWithCore(Core core, Composite parent) {
torrentview = createTorrentView(core, TableManager.TABLE_MYTORRENTS_INCOMPLETE, false, getIncompleteColumns(), child1);
seedingview = createTorrentView(core, TableManager.TABLE_MYTORRENTS_COMPLETE, true, getCompleteColumns(), child2);
torrentview.getComposite().addListener(SWT.FocusIn, new Listener() {
@Override
public void handleEvent(Event event) {
seedingview.getTableView().getTabsCommon().setTvOverride(torrentview.getTableView());
}
});
seedingview.getComposite().addListener(SWT.FocusIn, new Listener() {
@Override
public void handleEvent(Event event) {
seedingview.getTableView().getTabsCommon().setTvOverride(null);
}
});
// delegate selections from the incomplete view to the sub-tabs owned by the seeding view
SelectedContentManager.addCurrentlySelectedContentListener(new SelectedContentListener() {
@Override
public void currentlySelectedContentChanged(ISelectedContent[] currentContent, String viewId) {
if (form.isDisposed() || torrentview == null || seedingview == null) {
SelectedContentManager.removeCurrentlySelectedContentListener(this);
} else {
TableView<?> selected_tv = SelectedContentManager.getCurrentlySelectedTableView();
TableViewSWT<?> incomp_tv = torrentview.getTableView();
TableViewSWT<?> comp_tv = seedingview.getTableView();
if (incomp_tv != null && comp_tv != null && (selected_tv == incomp_tv || selected_tv == comp_tv)) {
TableViewSWT_TabsCommon tabs = comp_tv.getTabsCommon();
if (tabs != null) {
Utils.execSWTThread(new Runnable() {
public void run() {
tabs.triggerTabViewsDataSourceChanged(selected_tv);
}
});
}
}
}
}
});
initializeDone();
}
Aggregations