Search in sources :

Example 71 with DiskManagerFileInfo

use of com.biglybt.core.disk.DiskManagerFileInfo in project BiglyBT by BiglySoftware.

the class TaggingView method dataSourceChanged.

private void dataSourceChanged(Object ds) {
    boolean wasNull = taggables == null;
    if (ds instanceof Taggable) {
        taggables = new ArrayList<>();
        taggables.add((Taggable) ds);
    } else if (ds instanceof Taggable[]) {
        taggables = new ArrayList<>();
        taggables.addAll(Arrays.asList((Taggable[]) ds));
    } else if (ds instanceof Object[]) {
        taggables = new ArrayList<>();
        Object[] objects = (Object[]) ds;
        for (Object o : objects) {
            if (o instanceof Taggable) {
                Taggable taggable = (Taggable) o;
                if (!taggables.contains(taggable)) {
                    taggables.add(taggable);
                }
            } else if (o instanceof DiskManagerFileInfo) {
                DownloadManager temp = ((DiskManagerFileInfo) o).getDownloadManager();
                if (temp != null) {
                    if (!taggables.contains(temp)) {
                        taggables.add(temp);
                    }
                }
            }
        }
        if (taggables.size() == 0) {
            taggables = null;
        }
    } else {
        taggables = null;
    }
    boolean isNull = taggables == null;
    if (isNull != wasNull) {
        TagManager tm = TagManagerFactory.getTagManager();
        TagType tagType;
        /*
			tagType = tm.getTagType(TagType.TT_DOWNLOAD_CATEGORY);
			if (isNull) {
				tagType.removeTagTypeListener(this);
			} else {
				tagType.addTagTypeListener(this, false);
			}
			*/
        tagType = tm.getTagType(TagType.TT_DOWNLOAD_MANUAL);
        if (isNull) {
            tagType.removeTagTypeListener(this);
        } else {
            tagType.addTagTypeListener(this, false);
        }
    }
    Utils.execSWTThread(new AERunnable() {

        @Override
        public void runSupport() {
            swt_updateFields();
        }
    });
}
Also used : AERunnable(com.biglybt.core.util.AERunnable) DiskManagerFileInfo(com.biglybt.core.disk.DiskManagerFileInfo) ArrayList(java.util.ArrayList) DownloadManager(com.biglybt.core.download.DownloadManager)

Example 72 with DiskManagerFileInfo

use of com.biglybt.core.disk.DiskManagerFileInfo in project BiglyBT by BiglySoftware.

the class MyTorrentsView method updateSelectedContent.

public void updateSelectedContent(boolean force) {
    if (cTablePanel == null || cTablePanel.isDisposed()) {
        return;
    }
    if (!isTableFocus()) {
        if (!force) {
            return;
        }
    }
    Object[] dataSources = tv.getSelectedDataSources(true);
    List<SelectedContent> listSelected = new ArrayList<>(dataSources.length);
    for (Object ds : dataSources) {
        if (ds instanceof DownloadManager) {
            listSelected.add(new SelectedContent((DownloadManager) ds));
        } else if (ds instanceof DiskManagerFileInfo) {
            DiskManagerFileInfo fileInfo = (DiskManagerFileInfo) ds;
            listSelected.add(new SelectedContent(fileInfo.getDownloadManager(), fileInfo.getIndex()));
        }
    }
    SelectedContent[] content = listSelected.toArray(new SelectedContent[0]);
    SelectedContentManager.changeCurrentlySelectedContent(tv.getTableID(), content, tv);
}
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 73 with DiskManagerFileInfo

use of com.biglybt.core.disk.DiskManagerFileInfo in project BiglyBT by BiglySoftware.

the class FilesView method updateSelectedContent.

public void updateSelectedContent() {
    long total_size = 0;
    long total_dnd = 0;
    long total_done = 0;
    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()));
            if (fileInfo.isSkipped()) {
                total_dnd += fileInfo.getLength();
            } else {
                total_size += fileInfo.getLength();
                total_done += fileInfo.getDownloaded();
            }
        }
    }
    selection_size = total_size;
    selection_size_with_dnd = total_dnd + total_size;
    selection_done = total_done;
    updateHeader();
    SelectedContent[] sc = listSelected.toArray(new SelectedContent[0]);
    SelectedContentManager.changeCurrentlySelectedContent(tv.getTableID(), sc, tv);
}
Also used : SelectedContent(com.biglybt.ui.selectedcontent.SelectedContent) DiskManagerFileInfo(com.biglybt.core.disk.DiskManagerFileInfo)

Example 74 with DiskManagerFileInfo

use of com.biglybt.core.disk.DiskManagerFileInfo in project BiglyBT by BiglySoftware.

the class FilesView method updateFlatView.

private void updateFlatView() {
    DiskManagerFileInfo[] files = getFileInfo();
    if (files != null && (this.force_refresh || !doAllExist(files))) {
        this.force_refresh = false;
        List<DiskManagerFileInfo> datasources = tv.getDataSources();
        if (datasources.size() == files.length) {
            // check if we actually have to replace anything
            ArrayList<DiskManagerFileInfo> toAdd = new ArrayList<>(Arrays.asList(files));
            ArrayList<DiskManagerFileInfo> toRemove = new ArrayList<>();
            for (DiskManagerFileInfo info : datasources) {
                if (info.getIndex() != -1 && files[info.getIndex()] == info)
                    toAdd.set(info.getIndex(), null);
                else
                    toRemove.add(info);
            }
            tv.removeDataSources(toRemove.toArray(new DiskManagerFileInfo[toRemove.size()]));
            tv.addDataSources(toAdd.toArray(new DiskManagerFileInfo[toAdd.size()]));
            tv.tableInvalidate();
        } else {
            tv.removeAllTableRows();
            DiskManagerFileInfo[] filesCopy = new DiskManagerFileInfo[files.length];
            System.arraycopy(files, 0, filesCopy, 0, files.length);
            tv.addDataSources(filesCopy);
        }
        tv.processDataSourceQueue();
    }
}
Also used : DiskManagerFileInfo(com.biglybt.core.disk.DiskManagerFileInfo)

Example 75 with DiskManagerFileInfo

use of com.biglybt.core.disk.DiskManagerFileInfo in project BiglyBT by BiglySoftware.

the class FilesView method defaultSelected.

// @see TableSelectionListener#defaultSelected(TableRowCore[])
@Override
public void defaultSelected(TableRowCore[] rows, int stateMask, int origin) {
    DiskManagerFileInfo fileInfo = (DiskManagerFileInfo) tv.getFirstSelectedDataSource();
    if (fileInfo == null) {
        return;
    }
    boolean webInBrowser = COConfigurationManager.getBooleanParameter("Library.LaunchWebsiteInBrowser");
    if (webInBrowser) {
        if (ManagerUtils.browseWebsite(fileInfo)) {
            return;
        }
    }
    String mode = COConfigurationManager.getStringParameter("list.dm.dblclick");
    if (origin == 1) {
        String enter_mode = COConfigurationManager.getStringParameter("list.dm.enteraction");
        if (!enter_mode.equals("-1")) {
            mode = enter_mode;
        }
    }
    switch(mode) {
        case "1":
            {
                DownloadManager dm = fileInfo.getDownloadManager();
                if (dm != null) {
                    UIFunctionsManager.getUIFunctions().getMDI().showEntryByID(MultipleDocumentInterface.SIDEBAR_SECTION_TORRENT_DETAILS, dm);
                }
                break;
            }
        case "2":
            boolean openMode = COConfigurationManager.getBooleanParameter("MyTorrentsView.menu.show_parent_folder_enabled");
            ManagerUtils.open(fileInfo, openMode);
            break;
        case "3":
        case "4":
            if (fileInfo.getAccessMode() == DiskManagerFileInfo.READ) {
                if (mode.equals("4") && fileInfo.getDownloaded() == fileInfo.getLength() && Utils.isQuickViewSupported(fileInfo)) {
                    Utils.setQuickViewActive(fileInfo, true);
                } else {
                    Utils.launch(fileInfo);
                }
            }
            break;
        case "5":
            ManagerUtils.browse(fileInfo);
            break;
        default:
            int file_index = fileInfo.getIndex();
            DownloadManager dm = fileInfo.getDownloadManager();
            boolean canPlay = PlayUtils.canPlayDS(dm, file_index, true) || PlayUtils.canStreamDS(dm, file_index, true);
            UIFunctions uif = UIFunctionsManager.getUIFunctions();
            if (uif != null) {
                uif.playOrStreamDataSource(fileInfo, DLReferals.DL_REFERAL_PLAYDM, false, false);
                return;
            }
            if (fileInfo.getAccessMode() == DiskManagerFileInfo.READ) {
                Utils.launch(fileInfo);
            }
            break;
    }
}
Also used : DiskManagerFileInfo(com.biglybt.core.disk.DiskManagerFileInfo) UIFunctions(com.biglybt.ui.UIFunctions) DownloadManager(com.biglybt.core.download.DownloadManager)

Aggregations

DiskManagerFileInfo (com.biglybt.core.disk.DiskManagerFileInfo)107 DownloadManager (com.biglybt.core.download.DownloadManager)54 File (java.io.File)16 TOTorrent (com.biglybt.core.torrent.TOTorrent)15 PEPeerManager (com.biglybt.core.peer.PEPeerManager)9 DiskManagerFileInfoSet (com.biglybt.core.disk.DiskManagerFileInfoSet)8 TableRowCore (com.biglybt.ui.common.table.TableRowCore)8 DiskManager (com.biglybt.core.disk.DiskManager)7 IOException (java.io.IOException)7 Point (org.eclipse.swt.graphics.Point)7 DownloadManagerState (com.biglybt.core.download.DownloadManagerState)6 MessageBoxShell (com.biglybt.ui.swt.shells.MessageBoxShell)6 FilesView (com.biglybt.ui.swt.views.FilesView)6 List (java.util.List)6 Image (org.eclipse.swt.graphics.Image)6 DiskManagerPiece (com.biglybt.core.disk.DiskManagerPiece)5 PEPeer (com.biglybt.core.peer.PEPeer)5 TOTorrentException (com.biglybt.core.torrent.TOTorrentException)5 UIFunctions (com.biglybt.ui.UIFunctions)5 ISelectedContent (com.biglybt.ui.selectedcontent.ISelectedContent)5