Search in sources :

Example 1 with UISWTViewCore

use of com.biglybt.ui.swt.pifimpl.UISWTViewCore in project BiglyBT by BiglySoftware.

the class SBC_TagsOverview method toolBarItemActivated.

// @see com.biglybt.pif.ui.toolbar.UIToolBarActivationListener#toolBarItemActivated(ToolBarItem, long, java.lang.Object)
@Override
public boolean toolBarItemActivated(ToolBarItem item, long activationType, Object datasource) {
    // Send to active view.  mostly works
    // except MyTorrentsSubView always takes focus after tag is selected..
    boolean isTableSelected = false;
    if (tv instanceof TableViewImpl) {
        isTableSelected = ((TableViewImpl) tv).isTableSelected();
    }
    if (!isTableSelected) {
        UISWTViewCore active_view = getActiveView();
        if (active_view != null) {
            UIPluginViewToolBarListener l = active_view.getToolBarListener();
            if (l != null && l.toolBarItemActivated(item, activationType, datasource)) {
                return true;
            }
        }
        return false;
    }
    if (tv == null || !tv.isVisible()) {
        return (false);
    }
    if (item.getID().equals("remove")) {
        Object[] datasources = tv.getSelectedDataSources().toArray();
        if (datasources.length > 0) {
            for (Object object : datasources) {
                if (object instanceof Tag) {
                    final Tag tag = (Tag) object;
                    if (tag.getTagType().getTagType() != TagType.TT_DOWNLOAD_MANUAL) {
                        continue;
                    }
                    MessageBoxShell mb = new MessageBoxShell(MessageText.getString("message.confirm.delete.title"), MessageText.getString("message.confirm.delete.text", new String[] { tag.getTagName(true) }), new String[] { MessageText.getString("Button.yes"), MessageText.getString("Button.no") }, 1);
                    mb.open(new UserPrompterResultListener() {

                        @Override
                        public void prompterClosed(int result) {
                            if (result == 0) {
                                tag.removeTag();
                            }
                        }
                    });
                }
            }
            return true;
        }
    }
    return false;
}
Also used : TableViewImpl(com.biglybt.ui.common.table.impl.TableViewImpl) UserPrompterResultListener(com.biglybt.ui.UserPrompterResultListener) UISWTViewCore(com.biglybt.ui.swt.pifimpl.UISWTViewCore) MessageBoxShell(com.biglybt.ui.swt.shells.MessageBoxShell) SWTSkinObject(com.biglybt.ui.swt.skin.SWTSkinObject) UIPluginViewToolBarListener(com.biglybt.pif.ui.UIPluginViewToolBarListener)

Example 2 with UISWTViewCore

use of com.biglybt.ui.swt.pifimpl.UISWTViewCore in project BiglyBT by BiglySoftware.

the class SideBar method updateUI.

// @see com.biglybt.ui.swt.utils.UIUpdatable#updateUI()
@Override
public void updateUI() {
    Object[] views = pluginViews.toArray();
    for (int i = 0; i < views.length; i++) {
        try {
            UISWTViewCore view = (UISWTViewCore) views[i];
            Composite composite = view.getComposite();
            if (composite == null) {
                continue;
            }
            if (composite.isDisposed()) {
                pluginViews.remove(view);
                continue;
            }
            if (composite.isVisible()) {
                view.triggerEvent(UISWTViewEvent.TYPE_REFRESH, null);
            }
        } catch (Exception e) {
            Debug.out(e);
        }
    }
    if (tree.getSelectionCount() == 0) {
        return;
    }
    super.updateUI();
}
Also used : UISWTViewCore(com.biglybt.ui.swt.pifimpl.UISWTViewCore) PluginUISWTSkinObject(com.biglybt.ui.swt.pif.PluginUISWTSkinObject)

Example 3 with UISWTViewCore

use of com.biglybt.ui.swt.pifimpl.UISWTViewCore in project BiglyBT by BiglySoftware.

the class MyTorrentsView method refreshToolBarItems.

@Override
public void refreshToolBarItems(Map<String, Long> list) {
    ISelectedContent[] datasource = SelectedContentManager.getCurrentlySelectedContent();
    if (!isTableFocus()) {
        UISWTViewCore active_view = getActiveView();
        if (active_view != null) {
            UIPluginViewToolBarListener l = active_view.getToolBarListener();
            if (l != null) {
                Map<String, Long> activeViewList = new HashMap<>();
                l.refreshToolBarItems(activeViewList);
                if (activeViewList.size() > 0) {
                    list.putAll(activeViewList);
                    return;
                }
            }
        }
    }
}
Also used : ISelectedContent(com.biglybt.ui.selectedcontent.ISelectedContent) UISWTViewCore(com.biglybt.ui.swt.pifimpl.UISWTViewCore)

Example 4 with UISWTViewCore

use of com.biglybt.ui.swt.pifimpl.UISWTViewCore in project BiglyBT by BiglySoftware.

the class MyTorrentsView method toolBarItemActivated.

@Override
public boolean toolBarItemActivated(ToolBarItem item, long activationType, Object datasource) {
    boolean isTableSelected = false;
    if (tv instanceof TableViewImpl) {
        isTableSelected = ((TableViewImpl) tv).isTableSelected();
    }
    if (!isTableSelected) {
        UISWTViewCore active_view = getActiveView();
        if (active_view != null) {
            UIPluginViewToolBarListener l = active_view.getToolBarListener();
            if (l != null && l.toolBarItemActivated(item, activationType, datasource)) {
                return true;
            }
        }
        return false;
    }
    String itemKey = item.getID();
    if (activationType == UIToolBarActivationListener.ACTIVATIONTYPE_HELD) {
        if (itemKey.equals("up")) {
            moveSelectedTorrentsTop();
            return true;
        }
        if (itemKey.equals("down")) {
            moveSelectedTorrentsEnd();
            return true;
        }
        return false;
    }
    if (activationType != UIToolBarActivationListener.ACTIVATIONTYPE_NORMAL) {
        return false;
    }
    if (itemKey.equals("top")) {
        moveSelectedTorrentsTop();
        return true;
    }
    if (itemKey.equals("bottom")) {
        moveSelectedTorrentsEnd();
        return true;
    }
    if (itemKey.equals("up")) {
        moveSelectedTorrentsUp();
        return true;
    }
    if (itemKey.equals("down")) {
        moveSelectedTorrentsDown();
        return true;
    }
    if (itemKey.equals("run")) {
        TorrentUtil.runDataSources(tv.getSelectedDataSources().toArray());
        return true;
    }
    if (itemKey.equals("start")) {
        TorrentUtil.queueDataSources(tv.getSelectedDataSources().toArray(), true);
        return true;
    }
    if (itemKey.equals("stop")) {
        TorrentUtil.stopDataSources(tv.getSelectedDataSources().toArray());
        return true;
    }
    if (itemKey.equals("startstop")) {
        TorrentUtil.stopOrStartDataSources(tv.getSelectedDataSources().toArray());
        return true;
    }
    if (itemKey.equals("remove")) {
        TorrentUtil.removeDataSources(tv.getSelectedDataSources().toArray());
        return true;
    }
    return false;
}
Also used : TableViewImpl(com.biglybt.ui.common.table.impl.TableViewImpl) UISWTViewCore(com.biglybt.ui.swt.pifimpl.UISWTViewCore)

Example 5 with UISWTViewCore

use of com.biglybt.ui.swt.pifimpl.UISWTViewCore in project BiglyBT by BiglySoftware.

the class PeersGraphicView method initialize.

protected void initialize(Composite composite) {
    display = composite.getDisplay();
    panel = new Canvas(composite, SWT.NO_BACKGROUND);
    panel.addListener(SWT.MouseHover, new Listener() {

        @Override
        public void handleEvent(Event event) {
            int x = event.x;
            int y = event.y;
            String tt = "";
            synchronized (dm_data_lock) {
                for (ManagerData data : dm_data) {
                    DownloadManager manager = data.manager;
                    if (x >= data.me_hit_x && x <= data.me_hit_x + OWN_SIZE && y >= data.me_hit_y && y <= data.me_hit_y + OWN_SIZE) {
                        if (dm_data.length > 1) {
                            tt = manager.getDisplayName() + "\r\n";
                        }
                        tt += DisplayFormatters.formatDownloadStatus(manager) + ", " + DisplayFormatters.formatPercentFromThousands(manager.getStats().getCompleted());
                        break;
                    } else {
                        PEPeer target = null;
                        for (Map.Entry<PEPeer, int[]> entry : data.peer_hit_map.entrySet()) {
                            int[] loc = entry.getValue();
                            int loc_x = loc[0];
                            int loc_y = loc[1];
                            if (x >= loc_x && x <= loc_x + PEER_SIZE && y >= loc_y && y <= loc_y + PEER_SIZE) {
                                target = entry.getKey();
                                break;
                            }
                        }
                        if (target != null) {
                            PEPeerStats stats = target.getStats();
                            String[] details = PeerUtils.getCountryDetails(target);
                            String dstr = (details == null || details.length < 2) ? "" : (" - " + details[0] + "/" + details[1]);
                            /*
							if ( dm_map.size() > 1 ){

								tt = manager.getDisplayName() + "\r\n";
							}
							*/
                            tt = target.getIp() + dstr + ", " + DisplayFormatters.formatPercentFromThousands(target.getPercentDoneInThousandNotation()) + "\r\n" + "Up=" + DisplayFormatters.formatByteCountToKiBEtcPerSec(stats.getDataSendRate() + stats.getProtocolSendRate()) + ", " + "Down=" + DisplayFormatters.formatByteCountToKiBEtcPerSec(stats.getDataReceiveRate() + stats.getProtocolReceiveRate());
                            break;
                        }
                    }
                }
            }
            panel.setToolTipText(tt);
        }
    });
    panel.addMouseListener(new MouseAdapter() {

        @Override
        public void mouseUp(MouseEvent event) {
            if (event.button == 3) {
                int x = event.x;
                int y = event.y;
                PEPeer target = null;
                DownloadManager target_manager = null;
                synchronized (dm_data_lock) {
                    for (ManagerData data : dm_data) {
                        DownloadManager manager = data.manager;
                        for (Map.Entry<PEPeer, int[]> entry : data.peer_hit_map.entrySet()) {
                            int[] loc = entry.getValue();
                            int loc_x = loc[0];
                            int loc_y = loc[1];
                            if (x >= loc_x && x <= loc_x + PEER_SIZE && y >= loc_y && y <= loc_y + PEER_SIZE) {
                                target = entry.getKey();
                                target_manager = manager;
                                break;
                            }
                        }
                        if (target != null) {
                            break;
                        }
                    }
                }
                if (target == null) {
                    return;
                }
                Menu menu = panel.getMenu();
                if (menu != null && !menu.isDisposed()) {
                    menu.dispose();
                }
                menu = new Menu(panel);
                PeersViewBase.fillMenu(menu, target, target_manager);
                final Point cursorLocation = Display.getCurrent().getCursorLocation();
                menu.setLocation(cursorLocation.x, cursorLocation.y);
                menu.setVisible(true);
            }
        }

        @Override
        public void mouseDoubleClick(MouseEvent event) {
            int x = event.x;
            int y = event.y;
            synchronized (dm_data_lock) {
                for (ManagerData data : dm_data) {
                    DownloadManager manager = data.manager;
                    if (x >= data.me_hit_x && x <= data.me_hit_x + OWN_SIZE && y >= data.me_hit_y && y <= data.me_hit_y + OWN_SIZE) {
                        UIFunctions uiFunctions = UIFunctionsManager.getUIFunctions();
                        if (uiFunctions != null) {
                            uiFunctions.getMDI().showEntryByID(MultipleDocumentInterface.SIDEBAR_SECTION_TORRENT_DETAILS, manager);
                        }
                    } else {
                        for (Map.Entry<PEPeer, int[]> entry : data.peer_hit_map.entrySet()) {
                            int[] loc = entry.getValue();
                            int loc_x = loc[0];
                            int loc_y = loc[1];
                            if (x >= loc_x && x <= loc_x + PEER_SIZE && y >= loc_y && y <= loc_y + PEER_SIZE) {
                                PEPeer target = entry.getKey();
                                try {
                                    String dm_id = "DMDetails_" + Base32.encode(manager.getTorrent().getHash());
                                    MdiEntry mdi_entry = UIFunctionsManager.getUIFunctions().getMDI().getEntry(dm_id);
                                    if (mdi_entry != null) {
                                        mdi_entry.setDatasource(new Object[] { manager, target });
                                    }
                                    Composite comp = panel.getParent();
                                    while (comp != null) {
                                        if (comp instanceof CTabFolder) {
                                            CTabFolder tf = (CTabFolder) comp;
                                            CTabItem[] items = tf.getItems();
                                            for (CTabItem item : items) {
                                                UISWTViewCore view = (UISWTViewCore) item.getData("TabbedEntry");
                                                UISWTViewEventListener listener = view.getEventListener();
                                                if (listener instanceof UISWTViewEventListenerHolder) {
                                                    listener = ((UISWTViewEventListenerHolder) listener).getDelegatedEventListener(view);
                                                }
                                                if (listener instanceof PeersView) {
                                                    tf.setSelection(item);
                                                    Event ev = new Event();
                                                    ev.item = item;
                                                    // manual setSelection doesn't file selection event - derp
                                                    tf.notifyListeners(SWT.Selection, ev);
                                                    ((PeersView) listener).selectPeer(target);
                                                    return;
                                                }
                                            }
                                        }
                                        comp = comp.getParent();
                                    }
                                } catch (Throwable e) {
                                }
                                break;
                            }
                        }
                    }
                }
            }
        }
    });
    // without this we get a transient blank when mousing in and out of the tab folder on OSX :(
    panel.addPaintListener(new PaintListener() {

        @Override
        public void paintControl(PaintEvent e) {
            doRefresh();
        }
    });
}
Also used : PEPeer(com.biglybt.core.peer.PEPeer) UIPluginViewToolBarListener(com.biglybt.pif.ui.UIPluginViewToolBarListener) PaintListener(org.eclipse.swt.events.PaintListener) UISWTViewEventListener(com.biglybt.ui.swt.pif.UISWTViewEventListener) Listener(org.eclipse.swt.widgets.Listener) DownloadManagerPeerListener(com.biglybt.core.download.DownloadManagerPeerListener) CTabFolder(org.eclipse.swt.custom.CTabFolder) PEPeerStats(com.biglybt.core.peer.PEPeerStats) DownloadManager(com.biglybt.core.download.DownloadManager) CTabItem(org.eclipse.swt.custom.CTabItem) MdiEntry(com.biglybt.ui.mdi.MdiEntry) UIFunctions(com.biglybt.ui.UIFunctions) MdiEntry(com.biglybt.ui.mdi.MdiEntry) Menu(org.eclipse.swt.widgets.Menu) MouseEvent(org.eclipse.swt.events.MouseEvent) PaintEvent(org.eclipse.swt.events.PaintEvent) Composite(org.eclipse.swt.widgets.Composite) PaintListener(org.eclipse.swt.events.PaintListener) Canvas(org.eclipse.swt.widgets.Canvas) MouseAdapter(org.eclipse.swt.events.MouseAdapter) Point(org.eclipse.swt.graphics.Point) UISWTViewEventListener(com.biglybt.ui.swt.pif.UISWTViewEventListener) UISWTViewEventListenerHolder(com.biglybt.ui.swt.pifimpl.UISWTViewEventListenerHolder) UISWTViewCore(com.biglybt.ui.swt.pifimpl.UISWTViewCore) PaintEvent(org.eclipse.swt.events.PaintEvent) MouseEvent(org.eclipse.swt.events.MouseEvent) Event(org.eclipse.swt.widgets.Event) UISWTViewEvent(com.biglybt.ui.swt.pif.UISWTViewEvent)

Aggregations

UISWTViewCore (com.biglybt.ui.swt.pifimpl.UISWTViewCore)7 UIPluginViewToolBarListener (com.biglybt.pif.ui.UIPluginViewToolBarListener)2 TableViewImpl (com.biglybt.ui.common.table.impl.TableViewImpl)2 UISWTViewEventListener (com.biglybt.ui.swt.pif.UISWTViewEventListener)2 UISWTViewEventListenerHolder (com.biglybt.ui.swt.pifimpl.UISWTViewEventListenerHolder)2 DownloadManager (com.biglybt.core.download.DownloadManager)1 DownloadManagerPeerListener (com.biglybt.core.download.DownloadManagerPeerListener)1 PEPeer (com.biglybt.core.peer.PEPeer)1 PEPeerStats (com.biglybt.core.peer.PEPeerStats)1 UIFunctions (com.biglybt.ui.UIFunctions)1 UserPrompterResultListener (com.biglybt.ui.UserPrompterResultListener)1 MdiEntry (com.biglybt.ui.mdi.MdiEntry)1 ISelectedContent (com.biglybt.ui.selectedcontent.ISelectedContent)1 MdiEntrySWT (com.biglybt.ui.swt.mdi.MdiEntrySWT)1 PluginUISWTSkinObject (com.biglybt.ui.swt.pif.PluginUISWTSkinObject)1 UISWTViewEvent (com.biglybt.ui.swt.pif.UISWTViewEvent)1 UISWTInstanceImpl (com.biglybt.ui.swt.pifimpl.UISWTInstanceImpl)1 SWTViewListener (com.biglybt.ui.swt.pifimpl.UISWTInstanceImpl.SWTViewListener)1 UISWTViewImpl (com.biglybt.ui.swt.pifimpl.UISWTViewImpl)1 MessageBoxShell (com.biglybt.ui.swt.shells.MessageBoxShell)1