Search in sources :

Example 1 with DiskManagerFileInfo

use of com.biglybt.core.disk.DiskManagerFileInfo 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);
            }
        }
    }
}
Also used : DownloadManagerListener(com.biglybt.core.download.DownloadManagerListener) DownloadManager(com.biglybt.core.download.DownloadManager) MultipleDocumentInterfaceSWT(com.biglybt.ui.swt.mdi.MultipleDocumentInterfaceSWT) ISelectedVuzeFileContent(com.biglybt.ui.selectedcontent.ISelectedVuzeFileContent) DiskManagerFileInfo(com.biglybt.core.disk.DiskManagerFileInfo) ISelectedContent(com.biglybt.ui.selectedcontent.ISelectedContent) UIFunctionsSWT(com.biglybt.ui.swt.UIFunctionsSWT) MdiEntrySWT(com.biglybt.ui.swt.mdi.MdiEntrySWT) UIPluginViewToolBarListener(com.biglybt.pif.ui.UIPluginViewToolBarListener)

Example 2 with DiskManagerFileInfo

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

the class PeerFilesView method tableRefresh.

@Override
public void tableRefresh() {
    synchronized (this) {
        if (refreshing) {
            return;
        }
        refreshing = true;
    }
    try {
        PEPeer peer = current_peer;
        if (peer == null) {
            tv.removeAllTableRows();
        } else {
            if (tv.getRowCount() == 0) {
                DiskManagerFileInfo[] files = peer.getManager().getDiskManager().getFiles();
                PeersFilesViewRow[] rows = new PeersFilesViewRow[files.length];
                for (int i = 0; i < files.length; i++) {
                    rows[i] = new PeersFilesViewRow(files[i], peer);
                }
                tv.addDataSources(rows);
                tv.processDataSourceQueueSync();
            } else {
                TableRowCore[] rows = tv.getRows();
                for (TableRowCore row : rows) {
                    ((PeersFilesViewRow) row.getDataSource()).setPeer(peer);
                }
            }
        }
    } finally {
        synchronized (this) {
            refreshing = false;
        }
    }
}
Also used : PEPeer(com.biglybt.core.peer.PEPeer) DiskManagerFileInfo(com.biglybt.core.disk.DiskManagerFileInfo)

Example 3 with DiskManagerFileInfo

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

the class PieceInfoView method createPeerInfoPanel.

private void createPeerInfoPanel(Composite parent) {
    GridLayout layout;
    GridData gridData;
    // Peer Info section contains
    // - Peer's Block display
    // - Peer's Datarate
    pieceInfoComposite = new Composite(parent, SWT.NONE);
    layout = new GridLayout();
    layout.numColumns = 2;
    layout.horizontalSpacing = 0;
    layout.verticalSpacing = 0;
    layout.marginHeight = 0;
    layout.marginWidth = 0;
    pieceInfoComposite.setLayout(layout);
    gridData = new GridData(GridData.FILL, GridData.FILL, true, true);
    pieceInfoComposite.setLayoutData(gridData);
    imageLabel = new Label(pieceInfoComposite, SWT.NULL);
    gridData = new GridData();
    imageLabel.setLayoutData(gridData);
    topLabel = new Label(pieceInfoComposite, SWT.NULL);
    topLabel.setBackground(Colors.white);
    gridData = new GridData(SWT.FILL, SWT.DEFAULT, false, false);
    topLabel.setLayoutData(gridData);
    sc = new ScrolledComposite(pieceInfoComposite, SWT.V_SCROLL);
    sc.setExpandHorizontal(true);
    sc.setExpandVertical(true);
    layout = new GridLayout();
    layout.horizontalSpacing = 0;
    layout.verticalSpacing = 0;
    layout.marginHeight = 0;
    layout.marginWidth = 0;
    sc.setLayout(layout);
    gridData = new GridData(GridData.FILL, GridData.FILL, true, true, 2, 1);
    sc.setLayoutData(gridData);
    sc.getVerticalBar().setIncrement(BLOCK_SIZE);
    pieceInfoCanvas = new Canvas(sc, SWT.NO_REDRAW_RESIZE | SWT.NO_BACKGROUND);
    gridData = new GridData(GridData.FILL, SWT.DEFAULT, true, false);
    pieceInfoCanvas.setLayoutData(gridData);
    pieceInfoCanvas.addPaintListener(new PaintListener() {

        @Override
        public void paintControl(PaintEvent e) {
            if (e.width <= 0 || e.height <= 0)
                return;
            try {
                Rectangle bounds = (img == null) ? null : img.getBounds();
                if (bounds == null || dlm == null || dlm.getPeerManager() == null) {
                    e.gc.fillRectangle(e.x, e.y, e.width, e.height);
                } else {
                    if (e.x + e.width > bounds.width)
                        e.gc.fillRectangle(bounds.width, e.y, e.x + e.width - bounds.width + 1, e.height);
                    if (e.y + e.height > bounds.height)
                        e.gc.fillRectangle(e.x, bounds.height, e.width, e.y + e.height - bounds.height + 1);
                    int width = Math.min(e.width, bounds.width - e.x);
                    int height = Math.min(e.height, bounds.height - e.y);
                    e.gc.drawImage(img, e.x, e.y, width, height, e.x, e.y, width, height);
                }
            } catch (Exception ex) {
            }
        }
    });
    pieceInfoCanvas.addListener(SWT.KeyDown, new DoNothingListener());
    pieceInfoCanvas.addListener(SWT.Resize, new Listener() {

        @Override
        public void handleEvent(Event e) {
            synchronized (PieceInfoView.this) {
                if (alreadyFilling) {
                    return;
                }
                alreadyFilling = true;
            }
            // wrap in asyncexec because sc.setMinWidth (called later) doesn't work
            // too well inside a resize (the canvas won't size isn't always updated)
            Utils.execSWTThreadLater(0, new AERunnable() {

                @Override
                public void runSupport() {
                    if (img != null) {
                        int iOldColCount = img.getBounds().width / BLOCK_SIZE;
                        int iNewColCount = pieceInfoCanvas.getClientArea().width / BLOCK_SIZE;
                        if (iOldColCount != iNewColCount)
                            refreshInfoCanvas();
                    }
                    synchronized (PieceInfoView.this) {
                        alreadyFilling = false;
                    }
                }
            });
        }
    });
    sc.setContent(pieceInfoCanvas);
    pieceInfoCanvas.addMouseMoveListener(new MouseMoveListener() {

        @Override
        public void mouseMove(MouseEvent event) {
            int piece_number = getPieceNumber(event.x, event.y);
            if (piece_number != selectedPiece) {
                selectedPieceShowFilePending = -1;
            }
        }
    });
    pieceInfoCanvas.addMouseTrackListener(new MouseTrackAdapter() {

        @Override
        public void mouseHover(MouseEvent event) {
            int piece_number = getPieceNumber(event.x, event.y);
            if (piece_number >= 0) {
                selectedPiece = piece_number;
                selectedPieceShowFilePending = piece_number;
                SimpleTimer.addEvent("ShowFile", SystemTime.getOffsetTime(1000), new TimerEventPerformer() {

                    @Override
                    public void perform(TimerEvent event) {
                        Utils.execSWTThread(new Runnable() {

                            @Override
                            public void run() {
                                if (selectedPieceShowFilePending == piece_number) {
                                    selectedPieceShowFile = true;
                                    refreshInfoCanvas();
                                }
                            }
                        });
                    }
                });
                refreshInfoCanvas();
                DiskManager disk_manager = dlm.getDiskManager();
                PEPeerManager pm = dlm.getPeerManager();
                DiskManagerPiece dm_piece = disk_manager.getPiece(piece_number);
                PEPiece pm_piece = pm.getPiece(piece_number);
                String text = "Piece " + piece_number + ": " + dm_piece.getString();
                if (pm_piece != null) {
                    text += ", active: " + pm_piece.getString();
                } else {
                    if (dm_piece.isNeeded() && !dm_piece.isDone()) {
                        text += ", inactive: " + pm.getPiecePicker().getPieceString(piece_number);
                    }
                }
                text += " - ";
                DMPieceList l = disk_manager.getPieceList(piece_number);
                for (int i = 0; i < l.size(); i++) {
                    DMPieceMapEntry entry = l.get(i);
                    DiskManagerFileInfo info = entry.getFile();
                    text += (i == 0 ? "" : "; ") + info.getFile(true).getName();
                }
                topLabelRHS = text;
            } else {
                topLabelRHS = "";
            }
            updateTopLabel();
        }

        @Override
        public void mouseExit(MouseEvent e) {
            selectedPiece = -1;
            selectedPieceShowFile = false;
            refreshInfoCanvas();
        }
    });
    final Menu menu = new Menu(pieceInfoCanvas.getShell(), SWT.POP_UP);
    pieceInfoCanvas.setMenu(menu);
    pieceInfoCanvas.addListener(SWT.MenuDetect, new Listener() {

        @Override
        public void handleEvent(Event event) {
            Point pt = pieceInfoCanvas.toControl(event.x, event.y);
            int piece_number = getPieceNumber(pt.x, pt.y);
            menu.setData("pieceNumber", piece_number);
        }
    });
    MenuBuildUtils.addMaintenanceListenerForMenu(menu, new MenuBuildUtils.MenuBuilder() {

        @Override
        public void buildMenu(Menu menu, MenuEvent event) {
            Integer pn = (Integer) menu.getData("pieceNumber");
            if (pn != null && pn != -1) {
                DownloadManager download_manager = dlm;
                if (download_manager == null) {
                    return;
                }
                DiskManager disk_manager = download_manager.getDiskManager();
                PEPeerManager peer_manager = download_manager.getPeerManager();
                if (disk_manager == null || peer_manager == null) {
                    return;
                }
                final PiecePicker picker = peer_manager.getPiecePicker();
                DiskManagerPiece[] dm_pieces = disk_manager.getPieces();
                PEPiece[] pe_pieces = peer_manager.getPieces();
                final int piece_number = pn;
                final DiskManagerPiece dm_piece = dm_pieces[piece_number];
                final PEPiece pm_piece = pe_pieces[piece_number];
                final MenuItem force_piece = new MenuItem(menu, SWT.CHECK);
                Messages.setLanguageText(force_piece, "label.force.piece");
                boolean done = dm_piece.isDone();
                force_piece.setEnabled(!done);
                if (!done) {
                    force_piece.setSelection(picker.isForcePiece(piece_number));
                    force_piece.addSelectionListener(new SelectionListenerForcePiece(picker, piece_number, force_piece));
                }
                final MenuItem reset_piece = new MenuItem(menu, SWT.PUSH);
                Messages.setLanguageText(reset_piece, "label.reset.piece");
                boolean can_reset = dm_piece.isDone() || dm_piece.getNbWritten() > 0;
                reset_piece.setEnabled(can_reset);
                reset_piece.addSelectionListener(new SelectionListenerResetPiece(dm_piece, pm_piece));
                new MenuItem(menu, SWT.SEPARATOR);
                final MenuItem seq_asc = new MenuItem(menu, SWT.PUSH);
                Messages.setLanguageText(seq_asc, "label.seq.asc.from", new String[] { String.valueOf(piece_number) });
                seq_asc.addSelectionListener(new SelectionAdapter() {

                    @Override
                    public void widgetSelected(SelectionEvent e) {
                        download_manager.getDownloadState().setFlag(DownloadManagerState.FLAG_SEQUENTIAL_DOWNLOAD, false);
                        picker.setReverseBlockOrder(false);
                        picker.setSequentialAscendingFrom(piece_number);
                    }
                });
                final MenuItem seq_desc = new MenuItem(menu, SWT.PUSH);
                Messages.setLanguageText(seq_desc, "label.seq.desc.from", new String[] { String.valueOf(piece_number) });
                seq_desc.addSelectionListener(new SelectionAdapter() {

                    @Override
                    public void widgetSelected(SelectionEvent e) {
                        download_manager.getDownloadState().setFlag(DownloadManagerState.FLAG_SEQUENTIAL_DOWNLOAD, false);
                        picker.setReverseBlockOrder(true);
                        picker.setSequentialDescendingFrom(piece_number);
                    }
                });
                final MenuItem seq_clear = new MenuItem(menu, SWT.PUSH);
                Messages.setLanguageText(seq_clear, "label.seq.clear", new String[] { String.valueOf(piece_number) });
                seq_clear.addSelectionListener(new SelectionAdapter() {

                    @Override
                    public void widgetSelected(SelectionEvent e) {
                        download_manager.getDownloadState().setFlag(DownloadManagerState.FLAG_SEQUENTIAL_DOWNLOAD, false);
                        picker.setReverseBlockOrder(false);
                        picker.clearSequential();
                    }
                });
            }
        }
    });
    Legend.createLegendComposite(pieceInfoComposite, blockColors, new String[] { "PiecesView.BlockView.Have", "PiecesView.BlockView.NoHave", "PeersView.BlockView.Transfer", "PeersView.BlockView.NextRequest", "PeersView.BlockView.AvailCount", "PeersView.BlockView.ShowFile" }, new GridData(SWT.FILL, SWT.DEFAULT, true, false, 2, 1));
    int iFontPixelsHeight = 10;
    int iFontPointHeight = (iFontPixelsHeight * 72) / Utils.getDPIRaw(pieceInfoCanvas.getDisplay()).y;
    Font f = pieceInfoCanvas.getFont();
    FontData[] fontData = f.getFontData();
    fontData[0].setHeight(iFontPointHeight);
    font = new Font(pieceInfoCanvas.getDisplay(), fontData);
}
Also used : AERunnable(com.biglybt.core.util.AERunnable) DownloadManagerPieceListener(com.biglybt.core.download.DownloadManagerPieceListener) PiecePicker(com.biglybt.core.peermanager.piecepicker.PiecePicker) DiskManager(com.biglybt.core.disk.DiskManager) DownloadManager(com.biglybt.core.download.DownloadManager) GridLayout(org.eclipse.swt.layout.GridLayout) TimerEventPerformer(com.biglybt.core.util.TimerEventPerformer) ScrolledComposite(org.eclipse.swt.custom.ScrolledComposite) TimerEvent(com.biglybt.core.util.TimerEvent) DiskManagerPiece(com.biglybt.core.disk.DiskManagerPiece) DiskManagerFileInfo(com.biglybt.core.disk.DiskManagerFileInfo) ScrolledComposite(org.eclipse.swt.custom.ScrolledComposite) DMPieceList(com.biglybt.core.disk.impl.piecemapper.DMPieceList) PEPiece(com.biglybt.core.peer.PEPiece) AERunnable(com.biglybt.core.util.AERunnable) GridData(org.eclipse.swt.layout.GridData) DMPieceMapEntry(com.biglybt.core.disk.impl.piecemapper.DMPieceMapEntry) UISWTViewEvent(com.biglybt.ui.swt.pif.UISWTViewEvent) LogEvent(com.biglybt.core.logging.LogEvent) TimerEvent(com.biglybt.core.util.TimerEvent) PEPeerManager(com.biglybt.core.peer.PEPeerManager) MenuBuildUtils(com.biglybt.ui.swt.MenuBuildUtils)

Example 4 with DiskManagerFileInfo

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

the class SBC_LibraryTableView method doDefaultClick.

public static void doDefaultClick(final TableRowCore[] rows, final int stateMask, final boolean neverPlay, int origin) {
    if (rows == null || rows.length != 1) {
        return;
    }
    final Object ds = rows[0].getDataSource(true);
    boolean webInBrowser = COConfigurationManager.getBooleanParameter("Library.LaunchWebsiteInBrowser");
    if (webInBrowser) {
        DiskManagerFileInfo fileInfo = DataSourceUtils.getFileInfo(ds);
        if (fileInfo != null) {
            if (ManagerUtils.browseWebsite(fileInfo)) {
                return;
            }
        } else {
            DownloadManager dm = DataSourceUtils.getDM(ds);
            if (dm != null) {
                if (ManagerUtils.browseWebsite(dm)) {
                    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;
        }
    }
    if (mode.equals("1")) {
        if (UIFunctionsManager.getUIFunctions().getMDI().showEntryByID(MultipleDocumentInterface.SIDEBAR_SECTION_TORRENT_DETAILS, ds)) {
            return;
        }
    } else if (mode.equals("2")) {
        // Show in explorer
        boolean openMode = COConfigurationManager.getBooleanParameter("MyTorrentsView.menu.show_parent_folder_enabled");
        DiskManagerFileInfo file = DataSourceUtils.getFileInfo(ds);
        if (file != null) {
            ManagerUtils.open(file, openMode);
            return;
        }
        DownloadManager dm = DataSourceUtils.getDM(ds);
        if (dm != null) {
            ManagerUtils.open(dm, openMode);
            return;
        }
    } else if (mode.equals("3") || mode.equals("4")) {
        // Launch
        DiskManagerFileInfo file = DataSourceUtils.getFileInfo(ds);
        if (file != null) {
            if (mode.equals("4") && file.getDownloaded() == file.getLength() && Utils.isQuickViewSupported(file)) {
                Utils.setQuickViewActive(file, true);
            } else {
                TorrentUtil.runDataSources(new Object[] { file });
            }
            return;
        }
        DownloadManager dm = DataSourceUtils.getDM(ds);
        if (dm != null) {
            TorrentUtil.runDataSources(new Object[] { dm });
            return;
        }
    } else if (mode.equals("5")) {
        DiskManagerFileInfo fileInfo = DataSourceUtils.getFileInfo(ds);
        if (fileInfo != null) {
            ManagerUtils.browse(fileInfo);
            return;
        }
        DownloadManager dm = DataSourceUtils.getDM(ds);
        if (dm != null) {
            ManagerUtils.browse(dm);
            return;
        }
    }
    if (neverPlay) {
        return;
    }
    if (PlayUtils.canPlayDS(ds, -1, true) || (stateMask & SWT.CONTROL) != 0) {
        TorrentListViewsUtils.playOrStreamDataSource(ds, DLReferals.DL_REFERAL_DBLCLICK, false, true);
        return;
    }
    if (PlayUtils.canStreamDS(ds, -1, true)) {
        TorrentListViewsUtils.playOrStreamDataSource(ds, DLReferals.DL_REFERAL_DBLCLICK, true, false);
        return;
    }
    DownloadManager dm = DataSourceUtils.getDM(ds);
    DiskManagerFileInfo file = DataSourceUtils.getFileInfo(ds);
    TOTorrent torrent = DataSourceUtils.getTorrent(ds);
    if (torrent == null && file != null) {
        DownloadManager dmFile = file.getDownloadManager();
        if (dmFile != null) {
            torrent = dmFile.getTorrent();
        }
    }
    if (file != null && file.getDownloaded() == file.getLength()) {
        TorrentUtil.runDataSources(new Object[] { file });
    } else if (dm != null) {
        TorrentUtil.runDataSources(new Object[] { dm });
    }
}
Also used : DiskManagerFileInfo(com.biglybt.core.disk.DiskManagerFileInfo) TOTorrent(com.biglybt.core.torrent.TOTorrent) SWTSkinObject(com.biglybt.ui.swt.skin.SWTSkinObject) DownloadManager(com.biglybt.core.download.DownloadManager)

Example 5 with DiskManagerFileInfo

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

the class ColumnSizeWithDND method refresh.

@Override
public void refresh(TableCell cell) {
    long value = 0;
    Object ds = cell.getDataSource();
    if (ds instanceof DownloadManager) {
        DownloadManager dm = (DownloadManager) ds;
        value = dm.getSize();
    } else if (ds instanceof DiskManagerFileInfo) {
        DiskManagerFileInfo fileInfo = (DiskManagerFileInfo) ds;
        value = fileInfo.getLength();
    }
    if (!cell.setSortValue(value) && cell.isValid())
        return;
    cell.setText(DisplayFormatters.formatByteCountToKiBEtc(value));
}
Also used : DiskManagerFileInfo(com.biglybt.core.disk.DiskManagerFileInfo) 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