Search in sources :

Example 11 with DownloadHistory

use of com.biglybt.core.history.DownloadHistory in project BiglyBT by BiglySoftware.

the class SBC_DownloadHistoryView method fillMenu.

@Override
public void fillMenu(String sColumnName, Menu menu) {
    if (dh_manager != null) {
        if (dh_manager.isEnabled()) {
            List<Object> ds = tv.getSelectedDataSources();
            final List<DownloadHistory> dms = new ArrayList<>(ds.size());
            for (Object o : ds) {
                dms.add((DownloadHistory) o);
            }
            boolean hasSelection = dms.size() > 0;
            // Explore (or open containing folder)
            final boolean use_open_containing_folder = COConfigurationManager.getBooleanParameter("MyTorrentsView.menu.show_parent_folder_enabled");
            MenuItem itemExplore = new MenuItem(menu, SWT.PUSH);
            Messages.setLanguageText(itemExplore, "MyTorrentsView.menu." + (use_open_containing_folder ? "open_parent_folder" : "explore"));
            itemExplore.addListener(SWT.Selection, new Listener() {

                @Override
                public void handleEvent(Event event) {
                    for (DownloadHistory download : dms) {
                        ManagerUtils.open(new File(download.getSaveLocation()), use_open_containing_folder);
                    }
                }
            });
            itemExplore.setEnabled(hasSelection);
            // redownload
            MenuItem itemRedownload = new MenuItem(menu, SWT.PUSH);
            Messages.setLanguageText(itemRedownload, "label.redownload");
            itemRedownload.addListener(SWT.Selection, new Listener() {

                @Override
                public void handleEvent(Event event) {
                    for (DownloadHistory download : dms) {
                        download.setRedownloading();
                        String magnet = UrlUtils.getMagnetURI(download.getTorrentHash(), download.getName(), null);
                        TorrentOpener.openTorrent(magnet);
                    }
                }
            });
            itemExplore.setEnabled(hasSelection);
            // remove
            MenuItem itemRemove = new MenuItem(menu, SWT.PUSH);
            Utils.setMenuItemImage(itemRemove, "delete");
            Messages.setLanguageText(itemRemove, "MySharesView.menu.remove");
            itemRemove.addListener(SWT.Selection, new Listener() {

                @Override
                public void handleEvent(Event event) {
                    dh_manager.removeHistory(dms);
                }
            });
            itemRemove.setEnabled(hasSelection);
            new MenuItem(menu, SWT.SEPARATOR);
            // reset
            MenuItem itemReset = new MenuItem(menu, SWT.PUSH);
            Messages.setLanguageText(itemReset, "label.reset.history");
            itemReset.addListener(SWT.Selection, new Listener() {

                @Override
                public void handleEvent(Event event) {
                    resetHistory();
                }
            });
            // disable
            MenuItem itemDisable = new MenuItem(menu, SWT.PUSH);
            Messages.setLanguageText(itemDisable, "label.disable.history");
            itemDisable.addListener(SWT.Selection, new Listener() {

                @Override
                public void handleEvent(Event event) {
                    dh_manager.setEnabled(false);
                }
            });
            new MenuItem(menu, SWT.SEPARATOR);
        }
    }
}
Also used : DownloadHistory(com.biglybt.core.history.DownloadHistory) TableViewSWTMenuFillListener(com.biglybt.ui.swt.views.table.TableViewSWTMenuFillListener) UserPrompterResultListener(com.biglybt.ui.UserPrompterResultListener) TableColumnCreationListener(com.biglybt.pif.ui.tables.TableColumnCreationListener) Listener(org.eclipse.swt.widgets.Listener) UIPluginViewToolBarListener(com.biglybt.pif.ui.UIPluginViewToolBarListener) DownloadHistoryListener(com.biglybt.core.history.DownloadHistoryListener) Event(org.eclipse.swt.widgets.Event) DownloadHistoryEvent(com.biglybt.core.history.DownloadHistoryEvent) SWTSkinObject(com.biglybt.ui.swt.skin.SWTSkinObject) MenuItem(org.eclipse.swt.widgets.MenuItem) File(java.io.File)

Aggregations

DownloadHistory (com.biglybt.core.history.DownloadHistory)11 TableColumn (com.biglybt.pif.ui.tables.TableColumn)3 ColumnDateSizer (com.biglybt.ui.swt.views.tableitems.ColumnDateSizer)3 SWTSkinObject (com.biglybt.ui.swt.skin.SWTSkinObject)2 DownloadHistoryEvent (com.biglybt.core.history.DownloadHistoryEvent)1 DownloadHistoryListener (com.biglybt.core.history.DownloadHistoryListener)1 UIPluginViewToolBarListener (com.biglybt.pif.ui.UIPluginViewToolBarListener)1 TableColumnCreationListener (com.biglybt.pif.ui.tables.TableColumnCreationListener)1 UserPrompterResultListener (com.biglybt.ui.UserPrompterResultListener)1 TableViewSWTMenuFillListener (com.biglybt.ui.swt.views.table.TableViewSWTMenuFillListener)1 File (java.io.File)1 Event (org.eclipse.swt.widgets.Event)1 Listener (org.eclipse.swt.widgets.Listener)1 MenuItem (org.eclipse.swt.widgets.MenuItem)1