Package com.biglybt.ui.swt
Class MenuBuildUtils
- java.lang.Object
-
- com.biglybt.ui.swt.MenuBuildUtils
-
public class MenuBuildUtils extends java.lang.Object
A class which helps generate build SWT menus. It provides two main functions. The first provides the ability to create regenerateable menus (it will dispose old items when not displayed and invoke a callback method to regenerate it). The second provides the ability to create SWT menus based on the plugin API for menu creation - this allows internal code that generates menus to include plugins to append to their own internal menus.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interface
MenuBuildUtils.ChatKeyResolver
private static class
MenuBuildUtils.ChatSelectionDelegator
static interface
MenuBuildUtils.ChatSelectionListener
static interface
MenuBuildUtils.MenuBuilder
An interface to be used for addMaintenanceListenerForMenu.static class
MenuBuildUtils.MenuItemPluginMenuControllerImpl
This is an implementation of the PluginMenuController interface for use with MenuItemImpl classes - note that this is not intended for use by subclasses of MenuItemImpl (like TableContextMenuItemImpl).static interface
MenuBuildUtils.PluginMenuController
This is an interface used by addPluginMenuItems.
-
Field Summary
Fields Modifier and Type Field Description private static java.util.concurrent.atomic.AtomicBoolean
anon_chat_pending
static MenuBuildUtils.PluginMenuController
BASIC_MENU_ITEM_CONTROLLER
An instance of MenuItemPluginMenuControllerImpl with a default value of null - this will be the value passed when notifying selection and fill listeners.private static java.util.concurrent.atomic.AtomicBoolean
pub_chat_pending
-
Constructor Summary
Constructors Constructor Description MenuBuildUtils()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static MenuItem
addChatMenu(MenuManager menu_manager, MenuItem chat_item, MenuBuildUtils.ChatKeyResolver chat_key_resolver)
static void
addChatMenu(org.eclipse.swt.widgets.Menu menu, java.lang.String chat_resource, java.lang.String chat_key)
static void
addChatSelectionMenu(MenuManager menu_manager, MenuItem chat_item, java.lang.String existing_chat, MenuBuildUtils.ChatSelectionListener _listener)
static void
addChatSelectionMenu(org.eclipse.swt.widgets.Menu menu, java.lang.String resource_key, java.lang.String existing_chat, MenuBuildUtils.ChatSelectionListener _listener)
static void
addCommunityChatMenu(org.eclipse.swt.widgets.Menu menu)
static void
addMaintenanceListenerForMenu(org.eclipse.swt.widgets.Menu menu, MenuBuildUtils.MenuBuilder builder)
static void
addMaintenanceListenerForMenu(org.eclipse.swt.widgets.Menu menu, MenuBuildUtils.MenuBuilder builder, boolean alwaysBuilt)
Creates and adds a listener object to implement regeneratable menus.static void
addPluginMenuItems(MenuItem[] items, org.eclipse.swt.widgets.Menu parent, boolean prev_was_separator, boolean enable_items, MenuBuildUtils.PluginMenuController controller)
Creates menu items inside the given menu based on the plugin API MenuItem instances provided.static void
addSeparater(org.eclipse.swt.widgets.Menu menu)
Adds a separator if the current last item isn't one alreadystatic java.util.List<java.lang.Object>
splitLongMenuListIntoHierarchy(java.util.List<java.lang.String> flat_entries, int split_after)
-
-
-
Field Detail
-
BASIC_MENU_ITEM_CONTROLLER
public static final MenuBuildUtils.PluginMenuController BASIC_MENU_ITEM_CONTROLLER
An instance of MenuItemPluginMenuControllerImpl with a default value of null - this will be the value passed when notifying selection and fill listeners.
-
pub_chat_pending
private static java.util.concurrent.atomic.AtomicBoolean pub_chat_pending
-
anon_chat_pending
private static java.util.concurrent.atomic.AtomicBoolean anon_chat_pending
-
-
Method Detail
-
addMaintenanceListenerForMenu
public static void addMaintenanceListenerForMenu(org.eclipse.swt.widgets.Menu menu, MenuBuildUtils.MenuBuilder builder)
-
addMaintenanceListenerForMenu
public static void addMaintenanceListenerForMenu(org.eclipse.swt.widgets.Menu menu, MenuBuildUtils.MenuBuilder builder, boolean alwaysBuilt)
Creates and adds a listener object to implement regeneratable menus. The first piece of functionality it offers is the ability to call a callback method to generate the menu when it is about to be displayed (the callback method is done by passing an object implementing the MenuBuilder interface). This means that the caller of this method only needs to provide the logic to construct the menu's contents. This is helpful if you want to update an existing menu. The second piece of functionality is that it automatically does what is required to dispose of existing menu items when the menu is hidden.
-
addPluginMenuItems
public static void addPluginMenuItems(MenuItem[] items, org.eclipse.swt.widgets.Menu parent, boolean prev_was_separator, boolean enable_items, MenuBuildUtils.PluginMenuController controller)
Creates menu items inside the given menu based on the plugin API MenuItem instances provided. This method is provided mainly as a utility method to make it easier for menus to incorporate menu components specified by plugins. Usually, the list of array items will be extracted from a class like MenuItemManager or TableContextMenuManager, where plugins will usually register menu items they have created.- Parameters:
items
- The list of plugin MenuItem to addparent
- The SWT Menu to add to.prev_was_separator
- Indicates if the previous item in the menu is a separator or notenable_items
- Indicates whether you want generated items to be enabled or not. If false, all items will be disabled. If true, then the items *may* be enabled, depending on how each MenuItem is configured.controller
- The callback object used by this method when creating the SWT menus (used for invoking fill and selection listeners).
-
splitLongMenuListIntoHierarchy
public static java.util.List<java.lang.Object> splitLongMenuListIntoHierarchy(java.util.List<java.lang.String> flat_entries, int split_after)
- Parameters:
flat_entries
- Overall list of menu entry namessplit_after
- Split if more than this- Returns:
- Entries are either a String or Object[]{ submeuname, List
submenu entries }
-
addCommunityChatMenu
public static void addCommunityChatMenu(org.eclipse.swt.widgets.Menu menu)
-
addChatMenu
public static void addChatMenu(org.eclipse.swt.widgets.Menu menu, java.lang.String chat_resource, java.lang.String chat_key)
-
addChatMenu
public static MenuItem addChatMenu(MenuManager menu_manager, MenuItem chat_item, MenuBuildUtils.ChatKeyResolver chat_key_resolver)
-
addChatSelectionMenu
public static void addChatSelectionMenu(MenuManager menu_manager, MenuItem chat_item, java.lang.String existing_chat, MenuBuildUtils.ChatSelectionListener _listener)
-
addChatSelectionMenu
public static void addChatSelectionMenu(org.eclipse.swt.widgets.Menu menu, java.lang.String resource_key, java.lang.String existing_chat, MenuBuildUtils.ChatSelectionListener _listener)
-
addSeparater
public static void addSeparater(org.eclipse.swt.widgets.Menu menu)
Adds a separator if the current last item isn't one already- Parameters:
menu
-
-
-