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 }));
}
}
Aggregations