Search in sources :

Example 1 with SelectedContent

use of com.biglybt.ui.selectedcontent.SelectedContent in project BiglyBT by BiglySoftware.

the class SBC_DevicesView method updateSelectedContent.

public void updateSelectedContent() {
    TableView tv = tvFiles != null ? tvFiles : tvDevices;
    Object[] dataSources = tv.getSelectedDataSources(true);
    List<SelectedContent> listSelected = new ArrayList<>(dataSources.length);
    for (Object ds : dataSources) {
        if (ds instanceof DiskManagerFileInfo) {
            DiskManagerFileInfo fileInfo = (DiskManagerFileInfo) ds;
            listSelected.add(new SelectedContent(fileInfo.getDownloadManager(), fileInfo.getIndex()));
        }
    }
    SelectedContent[] sc = listSelected.toArray(new SelectedContent[0]);
    SelectedContentManager.changeCurrentlySelectedContent(tv.getTableID(), null, tv);
}
Also used : SelectedContent(com.biglybt.ui.selectedcontent.SelectedContent) DiskManagerFileInfo(com.biglybt.core.disk.DiskManagerFileInfo) SWTSkinObject(com.biglybt.ui.swt.skin.SWTSkinObject)

Example 2 with SelectedContent

use of com.biglybt.ui.selectedcontent.SelectedContent in project BiglyBT by BiglySoftware.

the class TorrentUtil method toDMS.

private static DownloadManager[] toDMS(Object[] objects) {
    int count = 0;
    DownloadManager[] result = new DownloadManager[objects.length];
    for (Object object : objects) {
        if (object instanceof DownloadManager) {
            DownloadManager dm = (DownloadManager) object;
            result[count++] = dm;
        } else if (object instanceof SelectedContent) {
            SelectedContent sc = (SelectedContent) object;
            if (sc.getFileIndex() == -1 && sc.getDownloadManager() != null) {
                result[count++] = sc.getDownloadManager();
            }
        }
    }
    DownloadManager[] resultTrim = new DownloadManager[count];
    System.arraycopy(result, 0, resultTrim, 0, count);
    return resultTrim;
}
Also used : SelectedContent(com.biglybt.ui.selectedcontent.SelectedContent) ISelectedContent(com.biglybt.ui.selectedcontent.ISelectedContent) DownloadManager(com.biglybt.core.download.DownloadManager)

Example 3 with SelectedContent

use of com.biglybt.ui.selectedcontent.SelectedContent in project BiglyBT by BiglySoftware.

the class TorrentUtil method toDMFI.

private static DiskManagerFileInfo[] toDMFI(Object[] objects) {
    int count = 0;
    DiskManagerFileInfo[] result = new DiskManagerFileInfo[objects.length];
    for (Object object : objects) {
        if (object instanceof DiskManagerFileInfo) {
            DiskManagerFileInfo fileInfo = (DiskManagerFileInfo) object;
            result[count++] = fileInfo;
        } else if (object instanceof SelectedContent) {
            SelectedContent sc = (SelectedContent) object;
            int fileIndex = sc.getFileIndex();
            if (fileIndex >= 0 && sc.getDownloadManager() != null) {
                DownloadManager dm = sc.getDownloadManager();
                if (dm != null) {
                    DiskManagerFileInfo[] infos = dm.getDiskManagerFileInfo();
                    if (fileIndex < infos.length) {
                        result[count++] = infos[fileIndex];
                    }
                }
            }
        }
    }
    DiskManagerFileInfo[] resultTrim = new DiskManagerFileInfo[count];
    System.arraycopy(result, 0, resultTrim, 0, count);
    return resultTrim;
}
Also used : SelectedContent(com.biglybt.ui.selectedcontent.SelectedContent) ISelectedContent(com.biglybt.ui.selectedcontent.ISelectedContent) DiskManagerFileInfo(com.biglybt.core.disk.DiskManagerFileInfo) DownloadManager(com.biglybt.core.download.DownloadManager)

Example 4 with SelectedContent

use of com.biglybt.ui.selectedcontent.SelectedContent in project BiglyBT by BiglySoftware.

the class GeneralView method eventOccurred.

@Override
public boolean eventOccurred(UISWTViewEvent event) {
    switch(event.getType()) {
        case UISWTViewEvent.TYPE_CREATE:
            swtView = event.getView();
            swtView.setTitle(getFullTitle());
            swtView.setToolBarListener(this);
            break;
        case UISWTViewEvent.TYPE_DESTROY:
            delete();
            break;
        case UISWTViewEvent.TYPE_INITIALIZE:
            initialize((Composite) event.getData());
            break;
        case UISWTViewEvent.TYPE_LANGUAGEUPDATE:
            Messages.updateLanguageForControl(getComposite());
            swtView.setTitle(getFullTitle());
            break;
        case UISWTViewEvent.TYPE_DATASOURCE_CHANGED:
            dataSourceChanged(event.getData());
            break;
        case UISWTViewEvent.TYPE_FOCUSGAINED:
            String id = "DMDetails_General";
            if (manager != null) {
                if (manager.getTorrent() != null) {
                    id += "." + manager.getInternalName();
                } else {
                    id += ":" + manager.getSize();
                }
                SelectedContentManager.changeCurrentlySelectedContent(id, new SelectedContent[] { new SelectedContent(manager) });
            } else {
                SelectedContentManager.changeCurrentlySelectedContent(id, null);
            }
            break;
        case UISWTViewEvent.TYPE_FOCUSLOST:
            SelectedContentManager.clearCurrentlySelectedContent();
            break;
        case UISWTViewEvent.TYPE_REFRESH:
            refresh();
            break;
        case UISWTViewEvent.TYPE_OBFUSCATE:
            Object data = event.getData();
            if (data instanceof Map) {
                obfuscatedImage((Image) MapUtils.getMapObject((Map) data, "image", null, Image.class));
            }
            break;
    }
    return true;
}
Also used : SelectedContent(com.biglybt.ui.selectedcontent.SelectedContent) Map(java.util.Map)

Example 5 with SelectedContent

use of com.biglybt.ui.selectedcontent.SelectedContent in project BiglyBT by BiglySoftware.

the class PeersView method updateSelectedContent.

protected void updateSelectedContent() {
    Object[] dataSources = tv.getSelectedDataSources(true);
    if (dataSources.length == 0) {
        String id = "DMDetails_Peers";
        // do this here to pick up correct manager before rest of code
        setFocused(true);
        if (manager != null) {
            if (manager.getTorrent() != null) {
                id += "." + manager.getInternalName();
            } else {
                id += ":" + manager.getSize();
            }
            SelectedContentManager.changeCurrentlySelectedContent(id, new SelectedContent[] { new SelectedContent(manager) });
        } else {
            SelectedContentManager.changeCurrentlySelectedContent(id, null);
        }
    } else {
        SelectedContent[] sc = new SelectedContent[dataSources.length];
        for (int i = 0; i < sc.length; i++) {
            sc[i] = new SelectedContent();
        }
        SelectedContentManager.changeCurrentlySelectedContent(tv.getTableID(), sc, tv);
    }
}
Also used : SelectedContent(com.biglybt.ui.selectedcontent.SelectedContent)

Aggregations

SelectedContent (com.biglybt.ui.selectedcontent.SelectedContent)14 ISelectedContent (com.biglybt.ui.selectedcontent.ISelectedContent)5 DiskManagerFileInfo (com.biglybt.core.disk.DiskManagerFileInfo)4 DownloadManager (com.biglybt.core.download.DownloadManager)4 UIFunctions (com.biglybt.ui.UIFunctions)2 TableColumnManager (com.biglybt.ui.common.table.impl.TableColumnManager)2 DownloadUrlInfo (com.biglybt.ui.selectedcontent.DownloadUrlInfo)2 SWTSkinObject (com.biglybt.ui.swt.skin.SWTSkinObject)2 TableViewSWTMenuFillListener (com.biglybt.ui.swt.views.table.TableViewSWTMenuFillListener)2 TOTorrent (com.biglybt.core.torrent.TOTorrent)1 SWTSkinObjectContainer (com.biglybt.ui.swt.skin.SWTSkinObjectContainer)1 Map (java.util.Map)1 GridLayout (org.eclipse.swt.layout.GridLayout)1 Composite (org.eclipse.swt.widgets.Composite)1 Menu (org.eclipse.swt.widgets.Menu)1 MenuItem (org.eclipse.swt.widgets.MenuItem)1