Search in sources :

Example 1 with ConfigSectionHolder

use of com.biglybt.pifimpl.local.ui.config.ConfigSectionHolder in project BiglyBT by BiglySoftware.

the class BaseMDI method fillMenu.

public void fillMenu(Menu menu, final MdiEntry entry, String menuID) {
    com.biglybt.pif.ui.menus.MenuItem[] menu_items;
    menu_items = MenuItemManager.getInstance().getAllAsArray(menuID);
    MenuBuildUtils.addPluginMenuItems(menu_items, menu, false, true, new MenuBuildUtils.MenuItemPluginMenuControllerImpl(new Object[] { entry }));
    if (entry != null) {
        menu_items = MenuItemManager.getInstance().getAllAsArray(getMenuIdPrefix() + entry.getId());
        if (menu_items.length == 0) {
            if (entry instanceof UISWTView) {
                PluginInterface pi = ((UISWTView) entry).getPluginInterface();
                if (pi != null) {
                    final List<String> relevant_sections = new ArrayList<>();
                    List<ConfigSectionHolder> sections = ConfigSectionRepository.getInstance().getHolderList();
                    for (ConfigSectionHolder cs : sections) {
                        if (pi == cs.getPluginInterface()) {
                            relevant_sections.add(cs.configSectionGetName());
                        }
                    }
                    if (relevant_sections.size() > 0) {
                        MenuItem mi = pi.getUIManager().getMenuManager().addMenuItem(getMenuIdPrefix() + entry.getId(), "MainWindow.menu.view.configuration");
                        mi.setDisposeWithUIDetach(UIInstance.UIT_SWT);
                        mi.addListener(new MenuItemListener() {

                            @Override
                            public void selected(MenuItem menu, Object target) {
                                UIFunctions uif = UIFunctionsManager.getUIFunctions();
                                if (uif != null) {
                                    for (String s : relevant_sections) {
                                        uif.getMDI().showEntryByID(SIDEBAR_SECTION_CONFIG, s);
                                    }
                                }
                            }
                        });
                        menu_items = MenuItemManager.getInstance().getAllAsArray(getMenuIdPrefix() + entry.getId());
                    }
                }
            }
        }
        MenuBuildUtils.addPluginMenuItems(menu_items, menu, false, true, new MenuBuildUtils.MenuItemPluginMenuControllerImpl(new Object[] { entry }));
        MdiSWTMenuHackListener[] menuHackListeners = getMenuHackListeners();
        for (MdiSWTMenuHackListener l : menuHackListeners) {
            try {
                l.menuWillBeShown(entry, menu);
            } catch (Exception e) {
                Debug.out(e);
            }
        }
        if (currentEntry instanceof SideBarEntrySWT) {
            menuHackListeners = ((SideBarEntrySWT) entry).getMenuHackListeners();
            for (MdiSWTMenuHackListener l : menuHackListeners) {
                try {
                    l.menuWillBeShown(entry, menu);
                } catch (Exception e) {
                    Debug.out(e);
                }
            }
        }
    }
    menu_items = MenuItemManager.getInstance().getAllAsArray(menuID + "._end_");
    if (menu_items.length > 0) {
        MenuBuildUtils.addPluginMenuItems(menu_items, menu, false, true, new MenuBuildUtils.MenuItemPluginMenuControllerImpl(new Object[] { entry }));
    }
}
Also used : PluginInterface(com.biglybt.pif.PluginInterface) SideBarEntrySWT(com.biglybt.ui.swt.views.skin.sidebar.SideBarEntrySWT) ConfigSectionHolder(com.biglybt.pifimpl.local.ui.config.ConfigSectionHolder) MenuItem(com.biglybt.pif.ui.menus.MenuItem) UISWTView(com.biglybt.ui.swt.pif.UISWTView) UIFunctions(com.biglybt.ui.UIFunctions) SWTSkinObject(com.biglybt.ui.swt.skin.SWTSkinObject) MenuItemListener(com.biglybt.pif.ui.menus.MenuItemListener) MenuBuildUtils(com.biglybt.ui.swt.MenuBuildUtils)

Aggregations

PluginInterface (com.biglybt.pif.PluginInterface)1 MenuItem (com.biglybt.pif.ui.menus.MenuItem)1 MenuItemListener (com.biglybt.pif.ui.menus.MenuItemListener)1 ConfigSectionHolder (com.biglybt.pifimpl.local.ui.config.ConfigSectionHolder)1 UIFunctions (com.biglybt.ui.UIFunctions)1 MenuBuildUtils (com.biglybt.ui.swt.MenuBuildUtils)1 UISWTView (com.biglybt.ui.swt.pif.UISWTView)1 SWTSkinObject (com.biglybt.ui.swt.skin.SWTSkinObject)1 SideBarEntrySWT (com.biglybt.ui.swt.views.skin.sidebar.SideBarEntrySWT)1