Search in sources :

Example 11 with UISWTInstance

use of com.biglybt.ui.swt.pif.UISWTInstance in project BiglyBT by BiglySoftware.

the class PMSWTImpl method initialise.

@Override
public void initialise(final PluginInterface pi, final BooleanParameter icon_enable) {
    final NetworkAdmin na = NetworkAdmin.getSingleton();
    na.addPropertyChangeListener(new NetworkAdminPropertyChangeListener() {

        @Override
        public void propertyChanged(String property) {
            if (property == NetworkAdmin.PR_NETWORK_INTERFACES) {
                updateLocalAddresses(na);
            }
        }
    });
    updateLocalAddresses(na);
    pi.getUIManager().addUIListener(new UIManagerListener() {

        @Override
        public void UIAttached(final UIInstance instance) {
            if (instance instanceof UISWTInstance) {
                UIFunctions uif = UIFunctionsManager.getUIFunctions();
                if (uif != null) {
                    uiUpdaterListener = new UIUpdaterListener() {

                        @Override
                        public void updateComplete(int count) {
                            last_update_count = count;
                            updateStatus(true);
                        }
                    };
                    uif.getUIUpdater().addListener(uiUpdaterListener);
                }
                Utils.execSWTThread(new AERunnable() {

                    @Override
                    public void runSupport() {
                        ImageLoader imageLoader = ImageLoader.getInstance();
                        icon_idle = imageLoader.getImage("pair_sb_idle");
                        icon_green = imageLoader.getImage("pair_sb_green");
                        icon_red = imageLoader.getImage("pair_sb_red");
                        UISWTInstance ui_instance = (UISWTInstance) instance;
                        status = ui_instance.createStatusEntry();
                        last_tooltip_text = MessageText.getString("pairing.ui.icon.tip");
                        status.setTooltipText(last_tooltip_text);
                        status.setImageEnabled(true);
                        status.setImage(icon_idle);
                        last_image = icon_idle;
                        boolean is_visible = icon_enable.getValue();
                        status.setVisible(is_visible);
                        if (is_visible) {
                            updateStatus(false);
                        }
                        final MenuItem mi_show = pi.getUIManager().getMenuManager().addMenuItem(status.getMenuContext(), "pairing.ui.icon.show");
                        mi_show.setStyle(MenuItem.STYLE_CHECK);
                        mi_show.setData(Boolean.valueOf(is_visible));
                        mi_show.addListener(new MenuItemListener() {

                            @Override
                            public void selected(MenuItem menu, Object target) {
                                icon_enable.setValue(false);
                            }
                        });
                        iconEnableListener = new ParameterListener() {

                            @Override
                            public void parameterChanged(Parameter param) {
                                boolean is_visible = icon_enable.getValue();
                                status.setVisible(is_visible);
                                mi_show.setData(Boolean.valueOf(is_visible));
                                if (is_visible) {
                                    updateStatus(false);
                                }
                            }
                        };
                        icon_enable.addListener(iconEnableListener);
                        MenuItem mi_pairing = pi.getUIManager().getMenuManager().addMenuItem(status.getMenuContext(), "MainWindow.menu.pairing");
                        mi_pairing.addListener(new MenuItemListener() {

                            @Override
                            public void selected(MenuItem menu, Object target) {
                                UIFunctions uif = UIFunctionsManager.getUIFunctions();
                                if (uif == null) {
                                    Debug.out("UIFunctions not available, can't open remote pairing window");
                                } else {
                                    uif.openRemotePairingWindow();
                                }
                            }
                        });
                        MenuItem mi_sep = pi.getUIManager().getMenuManager().addMenuItem(status.getMenuContext(), "");
                        mi_sep.setStyle(MenuItem.STYLE_SEPARATOR);
                        MenuItem mi_options = pi.getUIManager().getMenuManager().addMenuItem(status.getMenuContext(), "MainWindow.menu.view.configuration");
                        mi_options.addListener(new MenuItemListener() {

                            @Override
                            public void selected(MenuItem menu, Object target) {
                                UIFunctions uif = UIFunctionsManager.getUIFunctions();
                                if (uif != null) {
                                    uif.getMDI().showEntryByID(MultipleDocumentInterface.SIDEBAR_SECTION_CONFIG, PairingManager.CONFIG_SECTION_ID);
                                }
                            }
                        });
                        UISWTStatusEntryListener click_listener = new UISWTStatusEntryListener() {

                            @Override
                            public void entryClicked(UISWTStatusEntry entry) {
                                UIFunctions uif = UIFunctionsManager.getUIFunctions();
                                if (uif != null) {
                                    uif.getMDI().showEntryByID(MultipleDocumentInterface.SIDEBAR_SECTION_CONFIG, PairingManager.CONFIG_SECTION_ID);
                                }
                            }
                        };
                        status.setListener(click_listener);
                    }
                });
            }
        }

        @Override
        public void UIDetached(UIInstance instance) {
            if (instance instanceof UISWTInstance) {
                UIFunctions uif = UIFunctionsManager.getUIFunctions();
                if (uif != null && uiUpdaterListener != null) {
                    uif.getUIUpdater().removeListener(uiUpdaterListener);
                    uiUpdaterListener = null;
                }
                if (status != null) {
                    // menu items get destroyed with this call
                    status.destroy();
                    status = null;
                }
                if (icon_enable != null && iconEnableListener != null) {
                    icon_enable.removeListener(iconEnableListener);
                    iconEnableListener = null;
                }
            }
        }
    });
}
Also used : UIUpdaterListener(com.biglybt.ui.common.updater.UIUpdater.UIUpdaterListener) UISWTStatusEntryListener(com.biglybt.ui.swt.pif.UISWTStatusEntryListener) MenuItem(com.biglybt.pif.ui.menus.MenuItem) NetworkAdminPropertyChangeListener(com.biglybt.core.networkmanager.admin.NetworkAdminPropertyChangeListener) NetworkAdmin(com.biglybt.core.networkmanager.admin.NetworkAdmin) UIFunctions(com.biglybt.ui.UIFunctions) UISWTStatusEntry(com.biglybt.ui.swt.pif.UISWTStatusEntry) ParameterListener(com.biglybt.pif.ui.config.ParameterListener) BooleanParameter(com.biglybt.pif.ui.config.BooleanParameter) Parameter(com.biglybt.pif.ui.config.Parameter) MenuItemListener(com.biglybt.pif.ui.menus.MenuItemListener) UISWTInstance(com.biglybt.ui.swt.pif.UISWTInstance) UIManagerListener(com.biglybt.pif.ui.UIManagerListener) ImageLoader(com.biglybt.ui.swt.imageloader.ImageLoader) UIInstance(com.biglybt.pif.ui.UIInstance)

Example 12 with UISWTInstance

use of com.biglybt.ui.swt.pif.UISWTInstance in project BiglyBT by BiglySoftware.

the class TrackerView method registerPluginViews.

private void registerPluginViews(final UISWTInstance pluginUI) {
    if (pluginUI == null || registeredCoreSubViews) {
        return;
    }
    pluginUI.addView(TableManager.TABLE_TORRENT_TRACKERS, "ScrapeInfoView", ScrapeInfoView.class, manager);
    registeredCoreSubViews = true;
    final UIManager uiManager = PluginInitializer.getDefaultInterface().getUIManager();
    uiManager.addUIListener(new UIManagerListener() {

        @Override
        public void UIAttached(UIInstance instance) {
        }

        @Override
        public void UIDetached(UIInstance instance) {
            if (!(instance instanceof UISWTInstance)) {
                return;
            }
            registeredCoreSubViews = false;
            pluginUI.removeViews(TableManager.TABLE_TORRENT_TRACKERS, "ScrapeInfoView");
            uiManager.removeUIListener(this);
        }
    });
}
Also used : UIManager(com.biglybt.pif.ui.UIManager) UISWTInstance(com.biglybt.ui.swt.pif.UISWTInstance) UIManagerListener(com.biglybt.pif.ui.UIManagerListener) UIInstance(com.biglybt.pif.ui.UIInstance)

Example 13 with UISWTInstance

use of com.biglybt.ui.swt.pif.UISWTInstance in project BiglyBT by BiglySoftware.

the class MyTorrentsView method createTableView.

protected TableViewSWT<DownloadManager> createTableView(Class<?> forDataSourceType, String tableID, TableColumnCore[] basicItems) {
    int tableExtraStyle = COConfigurationManager.getIntParameter("MyTorrentsView.table.style");
    TableViewSWT<DownloadManager> table = TableViewFactory.createTableViewSWT(forDataSourceType, tableID, getPropertiesPrefix(), basicItems, "#", tableExtraStyle | SWT.MULTI | SWT.FULL_SELECTION | SWT.VIRTUAL | SWT.CASCADE);
    // config??
    boolean enable_tab_views = !Utils.isAZ2UI() && supportsTabs && COConfigurationManager.getBooleanParameter("Library.ShowTabsInTorrentView");
    List<String> restrictTo = new ArrayList<>();
    restrictTo.addAll(Arrays.asList(GeneralView.MSGID_PREFIX, TrackerView.MSGID_PREFIX, PeersView.MSGID_PREFIX, PeersGraphicView.MSGID_PREFIX, PiecesView.MSGID_PREFIX, DownloadActivityView.MSGID_PREFIX, PieceInfoView.MSGID_PREFIX, FilesView.MSGID_PREFIX, TaggingView.MSGID_PREFIX, PrivacyView.MSGID_PREFIX));
    // sub-tab hacks
    restrictTo.add("azbuddy.ui.menu.chat");
    PluginManager pm = CoreFactory.getSingleton().getPluginManager();
    PluginInterface pi = pm.getPluginInterfaceByID("aercm", true);
    if (pi != null) {
        String pluginInfo = pi.getPluginconfig().getPluginStringParameter("plugin.info", "");
        if (pluginInfo.equals("e")) {
            restrictTo.add("rcm.subview.torrentdetails.name");
        }
    }
    pi = pm.getPluginInterfaceByID("3dview", true);
    if (pi != null) {
        restrictTo.add("view3d.subtab.name");
    }
    if (Logger.isEnabled()) {
        restrictTo.add(LoggerView.MSGID_PREFIX);
    }
    table.setEnableTabViews(enable_tab_views, false, restrictTo.toArray(new String[0]));
    UIFunctionsSWT uiFunctions = UIFunctionsManagerSWT.getUIFunctionsSWT();
    if (uiFunctions != null) {
        UISWTInstance pluginUI = uiFunctions.getUISWTInstance();
        registerPluginViews(pluginUI);
    }
    return (table);
}
Also used : PluginManager(com.biglybt.pif.PluginManager) PluginInterface(com.biglybt.pif.PluginInterface) UISWTInstance(com.biglybt.ui.swt.pif.UISWTInstance) DownloadManager(com.biglybt.core.download.DownloadManager)

Example 14 with UISWTInstance

use of com.biglybt.ui.swt.pif.UISWTInstance in project BiglyBT by BiglySoftware.

the class PeersViewBase method registerPluginViews.

protected void registerPluginViews(String table_id, final UISWTInstance pluginUI) {
    final int table_index = table_id == TableManager.TABLE_TORRENT_PEERS ? 0 : 1;
    if (pluginUI == null || registeredCoreSubViews[table_index]) {
        return;
    }
    pluginUI.addView(table_id, "PeerInfoView", PeerInfoView.class, null);
    pluginUI.addView(table_id, "RemotePieceDistributionView", RemotePieceDistributionView.class, null);
    if (table_index == 0) {
        pluginUI.addView(table_id, "PeerFilesView", PeerFilesView.class, null);
    }
    pluginUI.addView(table_id, "LoggerView", LoggerView.class, true);
    registeredCoreSubViews[table_index] = true;
    final UIManager uiManager = PluginInitializer.getDefaultInterface().getUIManager();
    uiManager.addUIListener(new UIManagerListener() {

        @Override
        public void UIAttached(UIInstance instance) {
        }

        @Override
        public void UIDetached(UIInstance instance) {
            if (!(instance instanceof UISWTInstance)) {
                return;
            }
            registeredCoreSubViews[table_index] = false;
            pluginUI.removeViews(table_id, "PeerInfoView");
            pluginUI.removeViews(table_id, "RemotePieceDistributionView");
            if (table_index == 0) {
                pluginUI.removeViews(table_id, "PeerFilesView");
            }
            pluginUI.removeViews(table_id, "LoggerView");
            uiManager.removeUIListener(this);
        }
    });
}
Also used : UIManager(com.biglybt.pif.ui.UIManager) UISWTInstance(com.biglybt.ui.swt.pif.UISWTInstance) UIManagerListener(com.biglybt.pif.ui.UIManagerListener) UIInstance(com.biglybt.pif.ui.UIInstance)

Example 15 with UISWTInstance

use of com.biglybt.ui.swt.pif.UISWTInstance in project BiglyBT by BiglySoftware.

the class PeersViewBase method initYourTableView.

protected TableViewSWT<PEPeer> initYourTableView(String table_id, boolean enable_tabs) {
    if (table_id == TableManager.TABLE_TORRENT_PEERS) {
        tv = TableViewFactory.createTableViewSWT(Peer.class, TableManager.TABLE_TORRENT_PEERS, getPropertiesPrefix(), basicItems, "pieces", SWT.MULTI | SWT.FULL_SELECTION | SWT.VIRTUAL);
    } else {
        TableColumnCore[] items = PeersView.getBasicColumnItems(TableManager.TABLE_ALL_PEERS);
        TableColumnCore[] basicItems = new TableColumnCore[items.length + 1];
        System.arraycopy(items, 0, basicItems, 0, items.length);
        basicItems[items.length] = new DownloadNameItem(TableManager.TABLE_ALL_PEERS);
        TableColumnManager tcManager = TableColumnManager.getInstance();
        tcManager.setDefaultColumnNames(TableManager.TABLE_ALL_PEERS, basicItems);
        tv = TableViewFactory.createTableViewSWT(Peer.class, TableManager.TABLE_ALL_PEERS, getPropertiesPrefix(), basicItems, "connected_time", SWT.MULTI | SWT.FULL_SELECTION | SWT.VIRTUAL);
    }
    tv.setRowDefaultHeightEM(1);
    tv.setEnableTabViews(enable_tabs, true, null);
    UIFunctionsSWT uiFunctions = UIFunctionsManagerSWT.getUIFunctionsSWT();
    if (uiFunctions != null) {
        UISWTInstance pluginUI = uiFunctions.getUISWTInstance();
        registerPluginViews(table_id, pluginUI);
    }
    tv.addLifeCycleListener(this);
    tv.addMenuFillListener(this);
    tv.addSelectionListener(this, false);
    return tv;
}
Also used : Peer(com.biglybt.pif.peers.Peer) PEPeer(com.biglybt.core.peer.PEPeer) DownloadNameItem(com.biglybt.ui.swt.views.tableitems.peers.DownloadNameItem) UIFunctionsSWT(com.biglybt.ui.swt.UIFunctionsSWT) TableColumnCore(com.biglybt.ui.common.table.TableColumnCore) UISWTInstance(com.biglybt.ui.swt.pif.UISWTInstance) TableColumnManager(com.biglybt.ui.common.table.impl.TableColumnManager)

Aggregations

UISWTInstance (com.biglybt.ui.swt.pif.UISWTInstance)22 UIManagerListener (com.biglybt.pif.ui.UIManagerListener)12 UIInstance (com.biglybt.pif.ui.UIInstance)10 UIManager (com.biglybt.pif.ui.UIManager)10 UIFunctionsSWT (com.biglybt.ui.swt.UIFunctionsSWT)10 DownloadManager (com.biglybt.core.download.DownloadManager)5 PluginInterface (com.biglybt.pif.PluginInterface)4 UISWTViewEventListenerWrapper (com.biglybt.ui.swt.pif.UISWTInstance.UISWTViewEventListenerWrapper)3 GridLayout (org.eclipse.swt.layout.GridLayout)3 Composite (org.eclipse.swt.widgets.Composite)3 DiskManagerFileInfo (com.biglybt.core.disk.DiskManagerFileInfo)2 PEPeer (com.biglybt.core.peer.PEPeer)2 MenuItem (com.biglybt.pif.ui.menus.MenuItem)2 MenuItemListener (com.biglybt.pif.ui.menus.MenuItemListener)2 UIFunctions (com.biglybt.ui.UIFunctions)2 UserPrompterResultListener (com.biglybt.ui.UserPrompterResultListener)2 SelectedContentListener (com.biglybt.ui.selectedcontent.SelectedContentListener)2 TabbedMdiMaximizeListener (com.biglybt.ui.swt.mdi.TabbedMdiMaximizeListener)2 SelectionEvent (org.eclipse.swt.events.SelectionEvent)2 Core (com.biglybt.core.Core)1