Search in sources :

Example 1 with UIManager

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

the class SBC_TagsOverview method registerPluginViews.

private void registerPluginViews(final UISWTInstance pluginUI) {
    if (registeredCoreSubViews) {
        return;
    }
    pluginUI.addView(TABLE_TAGS, "TagSettingsView", TagSettingsView.class, null);
    pluginUI.addView(TABLE_TAGS, "MyTorrentsSubView", MyTorrentsSubView.class, null);
    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(TABLE_TAGS, "TagSettingsView");
            pluginUI.removeViews(TABLE_TAGS, "MyTorrentsSubView");
            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 2 with UIManager

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

the class SB_Transfers method addHeaderMenu.

protected void addHeaderMenu() {
    PluginInterface pi = PluginInitializer.getDefaultInterface();
    UIManager uim = pi.getUIManager();
    assert uim != null;
    final MenuManager menuManager = uim.getMenuManager();
    MenuItem menuItem;
    menuItem = menuManager.addMenuItem("sidebar." + MultipleDocumentInterface.SIDEBAR_HEADER_TRANSFERS, "MyTorrentsView.menu.setCategory.add");
    menuItem.setDisposeWithUIDetach(UIInstance.UIT_SWT);
    menuItem.addListener(new MenuItemListener() {

        @Override
        public void selected(MenuItem menu, Object target) {
            CategoryUIUtils.showCreateCategoryDialog(null);
        }
    });
    // cats in sidebar
    menuItem.addFillListener(new MenuItemFillListener() {

        @Override
        public void menuWillBeShown(MenuItem menu, Object data) {
            menu.setVisible(COConfigurationManager.getBooleanParameter("Library.CatInSideBar"));
        }
    });
    menuItem = menuManager.addMenuItem("sidebar." + MultipleDocumentInterface.SIDEBAR_HEADER_TRANSFERS, "ConfigView.section.style.CatInSidebar");
    menuItem.setDisposeWithUIDetach(UIInstance.UIT_SWT);
    menuItem.setStyle(MenuItem.STYLE_CHECK);
    menuItem.addListener(new MenuItemListener() {

        @Override
        public void selected(MenuItem menu, Object target) {
            boolean b = COConfigurationManager.getBooleanParameter("Library.CatInSideBar");
            COConfigurationManager.setParameter("Library.CatInSideBar", !b);
        }
    });
    menuItem.addFillListener(new MenuItemFillListener() {

        @Override
        public void menuWillBeShown(MenuItem menu, Object data) {
            menu.setVisible(CategoryManager.getCategories().length > 0);
            menu.setData(COConfigurationManager.getBooleanParameter("Library.CatInSideBar"));
        }
    });
    // show tags in sidebar
    TagUIUtils.setupSideBarMenus(menuManager);
}
Also used : MenuItemFillListener(com.biglybt.pif.ui.menus.MenuItemFillListener) PluginInterface(com.biglybt.pif.PluginInterface) MenuManager(com.biglybt.pif.ui.menus.MenuManager) UIManager(com.biglybt.pif.ui.UIManager) MenuItem(com.biglybt.pif.ui.menus.MenuItem) MenuItemListener(com.biglybt.pif.ui.menus.MenuItemListener)

Example 3 with UIManager

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

the class SideBar method addGeneralMenus.

/**
 * @since 3.1.0.1
 */
private void addGeneralMenus() {
    PluginManager pm = CoreFactory.getSingleton().getPluginManager();
    PluginInterface pi = pm.getDefaultPluginInterface();
    UIManager uim = pi.getUIManager();
    MenuManager menuManager = uim.getMenuManager();
    {
        MenuItem menuItem = menuManager.addMenuItem("sidebar._end_", "menu.add.to.dashboard");
        menuItem.setDisposeWithUIDetach(UIInstance.UIT_SWT);
        menuItem.addFillListener(new MenuItemFillListener() {

            @Override
            public void menuWillBeShown(MenuItem menu, Object data) {
                SideBarEntrySWT sbe = (SideBarEntrySWT) currentEntry;
                if (sbe != null && sbe.getId().equals(MultipleDocumentInterface.SIDEBAR_HEADER_DASHBOARD)) {
                    menu.setVisible(false);
                } else {
                    menu.setVisible(sbe != null && sbe.canBuildStandAlone());
                }
            }
        });
        menuItem.addListener(new MenuItemListener() {

            @Override
            public void selected(MenuItem menu, Object target) {
                SideBarEntrySWT sbe = (SideBarEntrySWT) currentEntry;
                if (sbe != null) {
                    MainMDISetup.getSb_dashboard().addItem(sbe);
                }
            }
        });
    }
    {
        MenuItem menuItem = menuManager.addMenuItem("sidebar._end_", "menu.pop.out");
        menuItem.setDisposeWithUIDetach(UIInstance.UIT_SWT);
        menuItem.addFillListener(new MenuItemFillListener() {

            @Override
            public void menuWillBeShown(MenuItem menu, Object data) {
                SideBarEntrySWT sbe = (SideBarEntrySWT) currentEntry;
                menu.setVisible(sbe != null && sbe.canBuildStandAlone());
            }
        });
        menuItem.addListener(new MenuItemListener() {

            @Override
            public void selected(MenuItem menu, Object target) {
                SideBarEntrySWT sbe = (SideBarEntrySWT) currentEntry;
                if (sbe != null) {
                    SkinnedDialog skinnedDialog = new SkinnedDialog("skin3_dlg_sidebar_popout", "shell", // standalone
                    null, SWT.RESIZE | SWT.MAX | SWT.DIALOG_TRIM);
                    SWTSkin skin = skinnedDialog.getSkin();
                    SWTSkinObjectContainer cont = sbe.buildStandAlone((SWTSkinObjectContainer) skin.getSkinObject("content-area"));
                    if (cont != null) {
                        skinnedDialog.setTitle(sbe.getTitle());
                        skinnedDialog.open();
                    } else {
                        skinnedDialog.close();
                    }
                }
            }
        });
    }
}
Also used : PluginManager(com.biglybt.pif.PluginManager) MenuItemFillListener(com.biglybt.pif.ui.menus.MenuItemFillListener) PluginInterface(com.biglybt.pif.PluginInterface) MenuManager(com.biglybt.pif.ui.menus.MenuManager) UIManager(com.biglybt.pif.ui.UIManager) MenuItem(com.biglybt.pif.ui.menus.MenuItem) PluginUISWTSkinObject(com.biglybt.ui.swt.pif.PluginUISWTSkinObject) MenuItemListener(com.biglybt.pif.ui.menus.MenuItemListener) SkinnedDialog(com.biglybt.ui.swt.views.skin.SkinnedDialog)

Example 4 with UIManager

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

the class StatsView method registerPluginViews.

private void registerPluginViews(final UISWTInstance pluginUI) {
    if (pluginUI == null || registeredCoreSubViews) {
        return;
    }
    pluginUI.addView(UISWTInstance.VIEW_STATISTICS, ActivityView.MSGID_PREFIX, ActivityView.class, null);
    pluginUI.addView(UISWTInstance.VIEW_STATISTICS, TransferStatsView.MSGID_PREFIX, TransferStatsView.class, null);
    pluginUI.addView(UISWTInstance.VIEW_STATISTICS, CacheView.MSGID_PREFIX, CacheView.class, null);
    pluginUI.addView(UISWTInstance.VIEW_STATISTICS, DHTView.MSGID_PREFIX, DHTView.class, DHTView.DHT_TYPE_MAIN);
    pluginUI.addView(UISWTInstance.VIEW_STATISTICS, DHTOpsView.MSGID_PREFIX, DHTOpsView.class, DHTOpsView.DHT_TYPE_MAIN);
    pluginUI.addView(UISWTInstance.VIEW_STATISTICS, VivaldiView.MSGID_PREFIX, VivaldiView.class, VivaldiView.DHT_TYPE_MAIN);
    if (NetworkAdmin.getSingleton().hasDHTIPV6()) {
        pluginUI.addView(UISWTInstance.VIEW_STATISTICS, DHTView.MSGID_PREFIX + ".6", DHTView.class, DHTView.DHT_TYPE_MAIN_V6);
        pluginUI.addView(UISWTInstance.VIEW_STATISTICS, VivaldiView.MSGID_PREFIX + ".6", VivaldiView.class, VivaldiView.DHT_TYPE_MAIN_V6);
    }
    if (Constants.isCVSVersion()) {
        pluginUI.addView(UISWTInstance.VIEW_STATISTICS, DHTView.MSGID_PREFIX + ".cvs", DHTView.class, DHTView.DHT_TYPE_CVS);
        pluginUI.addView(UISWTInstance.VIEW_STATISTICS, VivaldiView.MSGID_PREFIX + ".cvs", VivaldiView.class, VivaldiView.DHT_TYPE_CVS);
        pluginUI.addView(UISWTInstance.VIEW_STATISTICS, DHTView.MSGID_PREFIX + ".biglybt", DHTView.class, DHTView.DHT_TYPE_BIGLYBT);
        pluginUI.addView(UISWTInstance.VIEW_STATISTICS, VivaldiView.MSGID_PREFIX + ".biglybt", VivaldiView.class, VivaldiView.DHT_TYPE_BIGLYBT);
    }
    pluginUI.addView(UISWTInstance.VIEW_STATISTICS, TagStatsView.MSGID_PREFIX, TagStatsView.class, null);
    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(UISWTInstance.VIEW_STATISTICS, ActivityView.MSGID_PREFIX);
            pluginUI.removeViews(UISWTInstance.VIEW_STATISTICS, TransferStatsView.MSGID_PREFIX);
            pluginUI.removeViews(UISWTInstance.VIEW_STATISTICS, CacheView.MSGID_PREFIX);
            pluginUI.removeViews(UISWTInstance.VIEW_STATISTICS, DHTView.MSGID_PREFIX);
            pluginUI.removeViews(UISWTInstance.VIEW_STATISTICS, DHTOpsView.MSGID_PREFIX);
            pluginUI.removeViews(UISWTInstance.VIEW_STATISTICS, VivaldiView.MSGID_PREFIX);
            if (NetworkAdmin.getSingleton().hasDHTIPV6()) {
                pluginUI.removeViews(UISWTInstance.VIEW_STATISTICS, DHTView.MSGID_PREFIX + ".6");
                pluginUI.removeViews(UISWTInstance.VIEW_STATISTICS, VivaldiView.MSGID_PREFIX + ".6");
            }
            if (Constants.isCVSVersion()) {
                pluginUI.removeViews(UISWTInstance.VIEW_STATISTICS, DHTView.MSGID_PREFIX + ".cvs");
                pluginUI.removeViews(UISWTInstance.VIEW_STATISTICS, VivaldiView.MSGID_PREFIX + ".cvs");
            }
            pluginUI.removeViews(UISWTInstance.VIEW_STATISTICS, TagStatsView.MSGID_PREFIX);
            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 5 with UIManager

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

the class TableViewSWT_TabsCommon method buildFolder.

private void buildFolder(final Composite form, final String props_prefix) {
    PluginInterface pi = PluginInitializer.getDefaultInterface();
    UIManager uim = pi.getUIManager();
    MenuManager menuManager = uim.getMenuManager();
    menuItemShowTabs = menuManager.addMenuItem(props_prefix + "._end_", "ConfigView.section.style.ShowTabsInTorrentView");
    menuItemShowTabs.setDisposeWithUIDetach(UIInstance.UIT_SWT);
    menuItemShowTabs.setStyle(MenuItem.STYLE_CHECK);
    menuItemShowTabs.addFillListener(new MenuItemFillListener() {

        @Override
        public void menuWillBeShown(MenuItem menu, Object data) {
            menu.setData(COConfigurationManager.getBooleanParameter("Library.ShowTabsInTorrentView"));
        }
    });
    menuItemShowTabs.addListener(new MenuItemListener() {

        @Override
        public void selected(MenuItem menu, Object target) {
            COConfigurationManager.setParameter("Library.ShowTabsInTorrentView", (Boolean) menu.getData());
        }
    });
    cTabsHolder.addListener(SWT.Resize, new Listener() {

        @Override
        public void handleEvent(Event e) {
            if (tabbedMDI.getMinimized()) {
                fdHeightChanger.height = tabbedMDI.getFolderHeight();
                cTabsHolder.getParent().layout();
                return;
            }
            Double l = (Double) sash.getData("PCT");
            if (l != null) {
                int newHeight = (int) (form.getBounds().height * l.doubleValue());
                if (newHeight != fdHeightChanger.height) {
                    fdHeightChanger.height = newHeight;
                    cTabsHolder.getParent().layout();
                }
            }
        }
    });
    String[] restricted_to = tv.getTabViewsRestrictedTo();
    Set<String> rt_set = new HashSet<>();
    if (restricted_to != null) {
        rt_set.addAll(Arrays.asList(restricted_to));
    }
    // Call plugin listeners
    UIFunctionsSWT uiFunctions = UIFunctionsManagerSWT.getUIFunctionsSWT();
    if (uiFunctions != null) {
        UISWTInstance pluginUI = uiFunctions.getUISWTInstance();
        if (pluginUI != null) {
            UISWTViewEventListenerWrapper[] pluginViews = pluginUI.getViewListeners(tv.getTableID());
            if (pluginViews != null) {
                for (final UISWTViewEventListenerWrapper l : pluginViews) {
                    if (l == null) {
                        continue;
                    }
                    try {
                        String view_id = l.getViewID();
                        if (restricted_to != null && !rt_set.contains(view_id)) {
                            continue;
                        }
                        tabbedMDI.registerEntry(view_id, new MdiEntryCreationListener2() {

                            @Override
                            public MdiEntry createMDiEntry(MultipleDocumentInterface mdi, String id, Object datasource, Map<?, ?> params) {
                                return addTabView(l, null);
                            }
                        });
                        tabbedMDI.loadEntryByID(view_id, false);
                    } catch (Exception e) {
                    // skip, plugin probably specifically asked to not be added
                    }
                }
            }
        }
    }
    if (!tabbedMDI.getMinimized()) {
        MdiEntry[] entries = tabbedMDI.getEntries();
        if (entries.length > 0) {
            tabbedMDI.showEntry(entries[0]);
        }
    }
}
Also used : MenuItemListener(com.biglybt.pif.ui.menus.MenuItemListener) TabbedMdiMaximizeListener(com.biglybt.ui.swt.mdi.TabbedMdiMaximizeListener) MenuItemFillListener(com.biglybt.pif.ui.menus.MenuItemFillListener) Listener(org.eclipse.swt.widgets.Listener) SelectedContentListener(com.biglybt.ui.selectedcontent.SelectedContentListener) UIManager(com.biglybt.pif.ui.UIManager) MdiEntryCreationListener2(com.biglybt.ui.mdi.MdiEntryCreationListener2) MdiEntry(com.biglybt.ui.mdi.MdiEntry) MenuItemListener(com.biglybt.pif.ui.menus.MenuItemListener) HashSet(java.util.HashSet) PluginInterface(com.biglybt.pif.PluginInterface) MenuItem(com.biglybt.pif.ui.menus.MenuItem) UIFunctionsSWT(com.biglybt.ui.swt.UIFunctionsSWT) MultipleDocumentInterface(com.biglybt.ui.mdi.MultipleDocumentInterface) MenuItemFillListener(com.biglybt.pif.ui.menus.MenuItemFillListener) MenuManager(com.biglybt.pif.ui.menus.MenuManager) Event(org.eclipse.swt.widgets.Event) UISWTViewEvent(com.biglybt.ui.swt.pif.UISWTViewEvent) SelectionEvent(org.eclipse.swt.events.SelectionEvent) UISWTViewEventListenerWrapper(com.biglybt.ui.swt.pif.UISWTInstance.UISWTViewEventListenerWrapper) UISWTInstance(com.biglybt.ui.swt.pif.UISWTInstance)

Aggregations

UIManager (com.biglybt.pif.ui.UIManager)48 UIInstance (com.biglybt.pif.ui.UIInstance)14 PluginInterface (com.biglybt.pif.PluginInterface)13 UIManagerListener (com.biglybt.pif.ui.UIManagerListener)13 UISWTInstance (com.biglybt.ui.swt.pif.UISWTInstance)10 MenuItemListener (com.biglybt.pif.ui.menus.MenuItemListener)8 MenuItem (com.biglybt.pif.ui.menus.MenuItem)7 MenuManager (com.biglybt.pif.ui.menus.MenuManager)7 LoggerChannelListener (com.biglybt.pif.logging.LoggerChannelListener)6 DownloadManager (com.biglybt.core.download.DownloadManager)5 BasicPluginConfigModel (com.biglybt.pif.ui.model.BasicPluginConfigModel)5 URL (java.net.URL)5 TableManager (com.biglybt.pif.ui.tables.TableManager)4 TableColumnManager (com.biglybt.ui.common.table.impl.TableColumnManager)4 ArrayList (java.util.ArrayList)4 VuzeFile (com.biglybt.core.vuzefile.VuzeFile)3 PluginListener (com.biglybt.pif.PluginListener)3 MenuItemFillListener (com.biglybt.pif.ui.menus.MenuItemFillListener)3 BasicPluginViewModel (com.biglybt.pif.ui.model.BasicPluginViewModel)3 DelayedTask (com.biglybt.pif.utils.DelayedTask)3