Search in sources :

Example 11 with SelectedContent

use of com.biglybt.ui.selectedcontent.SelectedContent 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 12 with SelectedContent

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

the class PeersGraphicView method eventOccurred.

@Override
public boolean eventOccurred(UISWTViewEvent event) {
    switch(event.getType()) {
        case UISWTViewEvent.TYPE_CREATE:
            swtView = event.getView();
            swtView.setTitle(MessageText.getString(getData()));
            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(MessageText.getString(getData()));
            break;
        case UISWTViewEvent.TYPE_DATASOURCE_CHANGED:
            dataSourceChanged(event.getData());
            break;
        case UISWTViewEvent.TYPE_FOCUSGAINED:
            String id = "DMDetails_Swarm";
            // do this before next code as it can pick up the corrent 'manager' ref
            setFocused(true);
            synchronized (dm_data_lock) {
                if (dm_data.length == 0) {
                    SelectedContentManager.changeCurrentlySelectedContent(id, null);
                } else {
                    DownloadManager manager = dm_data[0].manager;
                    if (manager.getTorrent() != null) {
                        id += "." + manager.getInternalName();
                    } else {
                        id += ":" + manager.getSize();
                    }
                    SelectedContentManager.changeCurrentlySelectedContent(id, new SelectedContent[] { new SelectedContent(manager) });
                }
            }
            break;
        case UISWTViewEvent.TYPE_FOCUSLOST:
            setFocused(false);
            SelectedContentManager.clearCurrentlySelectedContent();
            break;
        case UISWTViewEvent.TYPE_REFRESH:
            refresh();
            break;
    }
    return true;
}
Also used : SelectedContent(com.biglybt.ui.selectedcontent.SelectedContent) DownloadManager(com.biglybt.core.download.DownloadManager)

Example 13 with SelectedContent

use of com.biglybt.ui.selectedcontent.SelectedContent 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 14 with SelectedContent

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

the class SBC_SearchResultsView method initTable.

private void initTable(Composite control) {
    tv_subs_results = TableViewFactory.createTableViewSWT(SBC_SearchResult.class, TABLE_SR, TABLE_SR, new TableColumnCore[0], ColumnSearchSubResultName.COLUMN_ID, SWT.MULTI | SWT.FULL_SELECTION | SWT.VIRTUAL);
    TableColumnManager tableManager = TableColumnManager.getInstance();
    tableManager.setDefaultColumnNames(TABLE_SR, new String[] { 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, ColumnSearchResultSite.COLUMN_ID });
    tableManager.setDefaultSortColumnName(TABLE_SR, ColumnSearchSubResultRank.COLUMN_ID);
    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_SearchResult rc = (SBC_SearchResult) rows[0].getDataSource();
                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_SearchResult rc = (SBC_SearchResult) 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.addMenuFillListener(new TableViewSWTMenuFillListener() {

        @Override
        public void fillMenu(String sColumnName, Menu menu) {
            Object[] _related_content = tv_subs_results.getSelectedDataSources().toArray();
            final SBC_SearchResult[] results = new SBC_SearchResult[_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_SearchResult 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);
                }
            }
        }

        @Override
        public void addThisColumnSubMenu(String columnName, Menu menuThisColumn) {
        }
    });
    tv_subs_results.initialize(table_parent);
    control.layout(true);
}
Also used : DownloadUrlInfo(com.biglybt.ui.selectedcontent.DownloadUrlInfo) TableViewSWTMenuFillListener(com.biglybt.ui.swt.views.table.TableViewSWTMenuFillListener) TableColumnManager(com.biglybt.ui.common.table.impl.TableColumnManager) SWTSkinObject(com.biglybt.ui.swt.skin.SWTSkinObject) GridLayout(org.eclipse.swt.layout.GridLayout) SWTSkinObjectContainer(com.biglybt.ui.swt.skin.SWTSkinObjectContainer) UIFunctions(com.biglybt.ui.UIFunctions) Menu(org.eclipse.swt.widgets.Menu) SelectedContent(com.biglybt.ui.selectedcontent.SelectedContent) ISelectedContent(com.biglybt.ui.selectedcontent.ISelectedContent) ISelectedContent(com.biglybt.ui.selectedcontent.ISelectedContent) Composite(org.eclipse.swt.widgets.Composite) MenuItem(org.eclipse.swt.widgets.MenuItem)

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