Search in sources :

Example 6 with SelectedContent

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

the class PiecesView method updateSelectedContent.

protected void updateSelectedContent() {
    Object[] dataSources = tv.getSelectedDataSources(true);
    if (dataSources.length == 0) {
        String id = "DMDetails_Pieces";
        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)

Example 7 with SelectedContent

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

the class TorrentInfoView method eventOccurred.

@Override
public boolean eventOccurred(UISWTViewEvent event) {
    switch(event.getType()) {
        case UISWTViewEvent.TYPE_CREATE:
            swtView = (UISWTView) event.getData();
            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_Info";
            if (download_manager != null) {
                if (download_manager.getTorrent() != null) {
                    id += "." + download_manager.getInternalName();
                } else {
                    id += ":" + download_manager.getSize();
                }
                SelectedContentManager.changeCurrentlySelectedContent(id, new SelectedContent[] { new SelectedContent(download_manager) });
            } else {
                SelectedContentManager.changeCurrentlySelectedContent(id, null);
            }
            break;
        case UISWTViewEvent.TYPE_FOCUSLOST:
            SelectedContentManager.clearCurrentlySelectedContent();
            break;
        case UISWTViewEvent.TYPE_REFRESH:
            refresh();
            break;
    }
    return true;
}
Also used : SelectedContent(com.biglybt.ui.selectedcontent.SelectedContent)

Example 8 with SelectedContent

use of com.biglybt.ui.selectedcontent.SelectedContent 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);
}
Also used : DownloadUrlInfo(com.biglybt.ui.selectedcontent.DownloadUrlInfo) TableViewSWTMenuFillListener(com.biglybt.ui.swt.views.table.TableViewSWTMenuFillListener) TableColumnManager(com.biglybt.ui.common.table.impl.TableColumnManager) UIFunctions(com.biglybt.ui.UIFunctions) SelectedContent(com.biglybt.ui.selectedcontent.SelectedContent) ISelectedContent(com.biglybt.ui.selectedcontent.ISelectedContent) ISelectedContent(com.biglybt.ui.selectedcontent.ISelectedContent)

Example 9 with SelectedContent

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

the class ActivitiesEntry method createSelectedContentObject.

public SelectedContent createSelectedContentObject() throws Exception {
    SelectedContent sc = new SelectedContent();
    if (assetHash == null) {
        // Contains no content
        return sc;
    }
    dm = getDownloadManger();
    if (dm != null) {
        sc.setDisplayName(PlatformTorrentUtils.getContentTitle2(dm));
        sc.setDownloadManager(dm);
        return sc;
    } else {
        if (torrent != null) {
            sc.setTorrent(torrent);
        }
    }
    sc.setDisplayName(getTorrentName());
    if (sc.getDisplayName() == null) {
        TOTorrent torrent = getTorrent();
        if (torrent != null) {
            sc.setDisplayName(TorrentUtils.getLocalisedName(torrent));
            sc.setHash(torrent.getHashWrapper().toBase32String());
        }
    }
    if (sc.getHash() == null) {
        if (assetHash != null) {
            sc.setHash(assetHash);
        }
    }
    return sc;
}
Also used : SelectedContent(com.biglybt.ui.selectedcontent.SelectedContent) TOTorrent(com.biglybt.core.torrent.TOTorrent)

Example 10 with SelectedContent

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

the class TrackerView method updateSelectedContent.

protected void updateSelectedContent() {
    Object[] dataSources = tv.getSelectedDataSources(true);
    if (dataSources.length == 0) {
        String id = "DMDetails_Sources";
        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