Search in sources :

Example 1 with MenuItem

use of com.biglybt.pif.ui.menus.MenuItem 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 2 with MenuItem

use of com.biglybt.pif.ui.menus.MenuItem 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 3 with MenuItem

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

the class SideBar method fillDropDownMenu.

/**
 * @param menuDropDown
 *
 * @since 3.1.1.1
 */
protected void fillDropDownMenu(Menu menuDropDown, TreeItem[] items, int indent) {
    String s = "";
    for (int i = 0; i < indent; i++) {
        s += "   ";
    }
    for (int i = 0; i < items.length; i++) {
        TreeItem treeItem = items[i];
        SideBarEntrySWT entry = (SideBarEntrySWT) treeItem.getData("MdiEntry");
        if (entry == null) {
            continue;
        }
        org.eclipse.swt.widgets.MenuItem menuItem = new org.eclipse.swt.widgets.MenuItem(menuDropDown, entry.isSelectable() ? SWT.RADIO : SWT.CASCADE);
        String id = entry.getId();
        menuItem.setData("Plugin.viewID", id);
        ViewTitleInfo titleInfo = entry.getViewTitleInfo();
        String ind = "";
        if (titleInfo != null) {
            String o = (String) titleInfo.getTitleInfoProperty(ViewTitleInfo.TITLE_INDICATOR_TEXT);
            if (o != null) {
                ind = "  (" + o + ")";
            // ind = "\t" + o;
            }
        }
        menuItem.setText(s + entry.getTitle() + ind);
        menuItem.addSelectionListener(dropDownSelectionListener);
        if (currentEntry != null && currentEntry.getId().equals(id)) {
            menuItem.setSelection(true);
        }
        TreeItem[] subItems = treeItem.getItems();
        if (subItems.length > 0) {
            Menu parent = menuDropDown;
            if (!entry.isSelectable()) {
                parent = new Menu(menuDropDown.getParent().getShell(), SWT.DROP_DOWN);
                menuItem.setMenu(parent);
            }
            fillDropDownMenu(parent, subItems, indent + 1);
        }
    }
}
Also used : MenuItem(com.biglybt.pif.ui.menus.MenuItem) org.eclipse.swt.widgets(org.eclipse.swt.widgets) com.biglybt.ui.swt(com.biglybt.ui.swt) ViewTitleInfo(com.biglybt.ui.common.viewtitleinfo.ViewTitleInfo)

Example 4 with MenuItem

use of com.biglybt.pif.ui.menus.MenuItem 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)

Example 5 with MenuItem

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

the class DeviceManagerUI method createOverallMenu.

private void createOverallMenu(final MenuManager menu_manager, String parentID) {
    MenuItem de_menu_item = menu_manager.addMenuItem(parentID, "device.search");
    de_menu_item.setDisposeWithUIDetach(UIInstance.UIT_SWT);
    de_menu_item.addListener(new MenuItemListener() {

        @Override
        public void selected(MenuItem menu, Object target) {
            search();
        }
    });
    // show generic
    de_menu_item = menu_manager.addMenuItem(parentID, "device.showGeneric");
    de_menu_item.setDisposeWithUIDetach(UIInstance.UIT_SWT);
    de_menu_item.setStyle(MenuItem.STYLE_CHECK);
    de_menu_item.addFillListener(new MenuItemFillListener() {

        @Override
        public void menuWillBeShown(MenuItem menu, Object data) {
            boolean is_hidden = COConfigurationManager.getBooleanParameter(CONFIG_VIEW_HIDE_REND_GENERIC, true);
            menu.setData(!is_hidden);
            boolean enabled = false;
            if (is_hidden) {
                Device[] devices = device_manager.getDevices();
                for (Device d : devices) {
                    if (d.isHidden()) {
                        continue;
                    }
                    if (d instanceof DeviceMediaRenderer) {
                        DeviceMediaRenderer rend = (DeviceMediaRenderer) d;
                        if (rend.isNonSimple()) {
                            enabled = true;
                        }
                    }
                }
            } else {
                enabled = true;
            }
            menu.setEnabled(enabled);
        }
    });
    de_menu_item.addListener(new MenuItemListener() {

        @Override
        public void selected(MenuItem menu, Object target) {
            COConfigurationManager.setParameter(CONFIG_VIEW_HIDE_REND_GENERIC, !COConfigurationManager.getBooleanParameter(CONFIG_VIEW_HIDE_REND_GENERIC, true));
        }
    });
    // show tagged
    de_menu_item = menu_manager.addMenuItem(parentID, "device.onlyShowTagged");
    de_menu_item.setDisposeWithUIDetach(UIInstance.UIT_SWT);
    de_menu_item.setStyle(MenuItem.STYLE_CHECK);
    de_menu_item.addFillListener(new MenuItemFillListener() {

        @Override
        public void menuWillBeShown(MenuItem menu, Object data) {
            menu.setData(COConfigurationManager.getBooleanParameter(CONFIG_VIEW_SHOW_ONLY_TAGGED, false));
            Device[] devices = device_manager.getDevices();
            boolean has_tagged = false;
            for (Device d : devices) {
                if (d.isTagged()) {
                    has_tagged = true;
                    break;
                }
            }
            menu.setEnabled(has_tagged);
        }
    });
    de_menu_item.addListener(new MenuItemListener() {

        @Override
        public void selected(MenuItem menu, Object target) {
            COConfigurationManager.setParameter(CONFIG_VIEW_SHOW_ONLY_TAGGED, !COConfigurationManager.getBooleanParameter(CONFIG_VIEW_SHOW_ONLY_TAGGED, false));
        }
    });
    // show hidden
    de_menu_item = menu_manager.addMenuItem(parentID, "device.show");
    de_menu_item.setDisposeWithUIDetach(UIInstance.UIT_SWT);
    de_menu_item.addListener(show_listener);
    de_menu_item.addFillListener(show_fill_listener);
    // simple
    de_menu_item = menu_manager.addMenuItem(parentID, "devices.sidebar.simple");
    de_menu_item.setDisposeWithUIDetach(UIInstance.UIT_SWT);
    de_menu_item.setStyle(MenuItem.STYLE_CHECK);
    de_menu_item.addFillListener(new MenuItemFillListener() {

        @Override
        public void menuWillBeShown(MenuItem menu, Object data) {
            menu.setData(COConfigurationManager.getIntParameter(CONFIG_VIEW_TYPE, SBV_SIMPLE) == SBV_SIMPLE);
        }
    });
    de_menu_item.addListener(new MenuItemListener() {

        @Override
        public void selected(MenuItem menu, Object target) {
            COConfigurationManager.setParameter(CONFIG_VIEW_TYPE, ((Boolean) menu.getData()) ? SBV_SIMPLE : SBV_FULL);
        }
    });
    de_menu_item = menu_manager.addMenuItem(parentID, "sep");
    de_menu_item.setDisposeWithUIDetach(UIInstance.UIT_SWT);
    de_menu_item.setStyle(MenuItem.STYLE_SEPARATOR);
    // on complete do
    final MenuItem de_oxc_menu = menu_manager.addMenuItem(parentID, "devices.sidebar.onxcodecomplete");
    de_oxc_menu.setDisposeWithUIDetach(UIInstance.UIT_SWT);
    de_oxc_menu.setStyle(MenuItem.STYLE_MENU);
    de_oxc_menu.addFillListener(new MenuItemFillListener() {

        @Override
        public void menuWillBeShown(MenuItem menu, Object data) {
            menu.removeAllChildItems();
            final List<MenuItem> oxc_items = new ArrayList<>();
            final MenuItem oxc_nothing = menu_manager.addMenuItem(de_oxc_menu, "devices.sidebar.oxc.nothing");
            oxc_items.add(oxc_nothing);
            oxc_nothing.setStyle(MenuItem.STYLE_CHECK);
            oxc_nothing.setData(oxc_action == OXC_NOTHING);
            final MenuItem oxc_close_vuze = menu_manager.addMenuItem(de_oxc_menu, "devices.sidebar.oxc.closevuze");
            oxc_items.add(oxc_close_vuze);
            oxc_close_vuze.setStyle(MenuItem.STYLE_CHECK);
            oxc_close_vuze.setData(oxc_action == OXC_QUIT_VUZE);
            PlatformManager pm = PlatformManagerFactory.getPlatformManager();
            int sdt = pm.getShutdownTypes();
            final Map<MenuItem, String> oxc_pm_map = new HashMap<>();
            for (int type : PlatformManager.SD_ALL) {
                if ((sdt | type) != 0) {
                    String action = OXC_NOTHING;
                    if (type == PlatformManager.SD_SLEEP) {
                        action = OXC_SLEEP;
                    } else if (type == PlatformManager.SD_HIBERNATE) {
                        action = OXC_HIBERNATE;
                    } else if (type == PlatformManager.SD_SHUTDOWN) {
                        action = OXC_SHUTDOWN;
                    } else {
                        Debug.out("Unknown type: " + type);
                    }
                    MenuItem oxc_pm = menu_manager.addMenuItem(de_oxc_menu, "devices.sidebar.oxc.pm." + type);
                    oxc_items.add(oxc_pm);
                    oxc_pm.setStyle(MenuItem.STYLE_CHECK);
                    oxc_pm.setData(oxc_action == action);
                    oxc_pm_map.put(oxc_pm, action);
                }
            }
            MenuItemListener oxc_mil = new MenuItemListener() {

                @Override
                public void selected(MenuItem menu, Object target) {
                    if ((Boolean) menu.getData()) {
                        if (menu == oxc_nothing) {
                            setOXCState(OXC_NOTHING);
                        } else if (menu == oxc_close_vuze) {
                            setOXCState(OXC_QUIT_VUZE);
                        } else {
                            setOXCState(oxc_pm_map.get(menu));
                        }
                    }
                }
            };
            for (MenuItem mi : oxc_items) {
                mi.addListener(oxc_mil);
            }
        }
    });
    de_menu_item = menu_manager.addMenuItem(parentID, "sep2");
    de_menu_item.setDisposeWithUIDetach(UIInstance.UIT_SWT);
    de_menu_item.setStyle(MenuItem.STYLE_SEPARATOR);
    // options
    de_menu_item = menu_manager.addMenuItem(parentID, "MainWindow.menu.view.configuration");
    de_menu_item.setDisposeWithUIDetach(UIInstance.UIT_SWT);
    de_menu_item.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, CONFIG_SECTION_ID);
            }
        }
    });
    if (Constants.isCVSVersion()) {
        de_menu_item = menu_manager.addMenuItem(parentID, "!(CVS Only)Show FTUX!");
        de_menu_item.setDisposeWithUIDetach(UIInstance.UIT_SWT);
        de_menu_item.addListener(new MenuItemListener() {

            @Override
            public void selected(MenuItem menu, Object target) {
                DevicesFTUX.showForDebug();
            }
        });
    }
}
Also used : PlatformManager(com.biglybt.platform.PlatformManager) UPnPDevice(com.biglybt.net.upnp.UPnPDevice) UnassociatedDevice(com.biglybt.core.devices.DeviceManager.UnassociatedDevice) UPnPRootDevice(com.biglybt.net.upnp.UPnPRootDevice) TableContextMenuItem(com.biglybt.pif.ui.tables.TableContextMenuItem) MenuItem(com.biglybt.pif.ui.menus.MenuItem) MenuItemFillListener(com.biglybt.pif.ui.menus.MenuItemFillListener) UIFunctions(com.biglybt.ui.UIFunctions) MenuItemListener(com.biglybt.pif.ui.menus.MenuItemListener) List(java.util.List)

Aggregations

MenuItem (com.biglybt.pif.ui.menus.MenuItem)33 MenuItemListener (com.biglybt.pif.ui.menus.MenuItemListener)26 MenuManager (com.biglybt.pif.ui.menus.MenuManager)13 MenuItemFillListener (com.biglybt.pif.ui.menus.MenuItemFillListener)12 TableContextMenuItem (com.biglybt.pif.ui.tables.TableContextMenuItem)10 PluginInterface (com.biglybt.pif.PluginInterface)8 UIFunctions (com.biglybt.ui.UIFunctions)8 UIManager (com.biglybt.pif.ui.UIManager)7 UnassociatedDevice (com.biglybt.core.devices.DeviceManager.UnassociatedDevice)5 DownloadManager (com.biglybt.core.download.DownloadManager)4 UPnPDevice (com.biglybt.net.upnp.UPnPDevice)4 UPnPRootDevice (com.biglybt.net.upnp.UPnPRootDevice)4 Download (com.biglybt.pif.download.Download)4 Point (org.eclipse.swt.graphics.Point)4 UIInstance (com.biglybt.pif.ui.UIInstance)3 ChatInstance (com.biglybt.plugin.net.buddy.BuddyPluginBeta.ChatInstance)3 ViewTitleInfo (com.biglybt.ui.common.viewtitleinfo.ViewTitleInfo)3 Core (com.biglybt.core.Core)2 ParameterListener (com.biglybt.core.config.ParameterListener)2 DownloadManagerState (com.biglybt.core.download.DownloadManagerState)2