Package adams.gui.application
Class ApplicationMenu
- java.lang.Object
-
- adams.core.logging.LoggingObject
-
- adams.gui.application.ApplicationMenu
-
- All Implemented Interfaces:
LoggingSupporter,SizeOfHandler,Serializable
public class ApplicationMenu extends LoggingObject implements Serializable
Generates the menu for the application frame.- Author:
- fracpete (fracpete at waikato dot ac dot nz)
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description static StringLAYOUT_AUTOMATICDISCOVERYthe props file key for the automatic menu item discovery.static StringLAYOUT_BLACKLISTED_PREFIXthe props file key prefix for the blacklisted menu items.static StringLAYOUT_CATEGORY_PREFIXthe props file key prefix for the menu items with a new category.static StringLAYOUT_MENU_PREFIXthe props file key prefix for the menus.static StringLAYOUT_MENU_TOOLSthe props file key for the tools menu.static StringLAYOUT_MENU_WINDOWSthe props file key for the windows menu.static StringLAYOUT_MENUBARthe props file key for the menu bar.static StringLAYOUT_SHORTCUT_PREFIXthe props file key prefix for the shortcuts.protected JMenum_MenuWindowsthe "windows" menu.protected AbstractApplicationFramem_Ownerthe parent application frame.protected Propertiesm_Propertiesthe properties read from the setup file.protected Stringm_Setupthe file with the layout, shortcuts and blacklisted menu items.protected static HashSet<String>m_UnavailableMenuItemsstores classnames that aren't available.protected UserModem_UserModethe user mode.static StringSEPARATORthe separator between classname and alternative title.-
Fields inherited from class adams.core.logging.LoggingObject
m_Logger, m_LoggingIsEnabled, m_LoggingLevel
-
-
Constructor Summary
Constructors Constructor Description ApplicationMenu(AbstractApplicationFrame owner)Initializes menu generator.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected intdetermineItemIndex(String[] items, JMenu menu)Determines the lowest index of the menu items in the given menu.StringgetCategory(Class cls)Returns the different category assigned for the class (if any).StringgetCategory(String classname)Returns the different category assigned for the class (if any).JMenuBargetMenuBar()Generates the menu and returns it.AbstractApplicationFramegetOwner()Returns the owning frame.protected PropertiesgetProperties()Returns the properties.StringgetSetup()Returns the setup file with the layout, etc.UserModegetUserMode()Returns the current user mode, i.e., the visibility level of menu items.JMenugetWindowsMenu()Returns the "Windows" menu from the last "getMenuBar" call.booleanhasCategory(Class cls)Checks whether the class has a different category assigned.booleanhasCategory(String classname)Checks whether the class has a different category assigned.booleanisBlacklisted(Class cls)Checks whether the class is blacklisted.booleanisBlacklisted(String classname)Checks whether the class is blacklisted.booleanisUnavailable(Class cls)Checks whether the class is unavailable (ie not found in classpath), based on previous menu generation.booleanisUnavailable(String classname)Checks whether the class is unavailable (ie not found in classpath), based on previous menu generation.voidsetBlacklisted(Class cls, boolean value)Sets whether the class is blacklisted or not.voidsetBlacklisted(String classname, boolean value)Sets whether the class is blacklisted or not.voidsetSetup(String value)Sets the setup file with the layout, etc.voidsetUnavailable(Class cls)Marks this class as unavailable.voidsetUnavailable(String classname)Marks this class as unavailable.voidsetUserMode(UserMode value)Sets the user mode to use, i.e., the visibility level of menu items.-
Methods inherited from class adams.core.logging.LoggingObject
configureLogger, getLogger, getLoggingLevel, initializeLogging, isLoggingEnabled, sizeOf
-
-
-
-
Field Detail
-
LAYOUT_MENUBAR
public static final String LAYOUT_MENUBAR
the props file key for the menu bar.- See Also:
- Constant Field Values
-
LAYOUT_AUTOMATICDISCOVERY
public static final String LAYOUT_AUTOMATICDISCOVERY
the props file key for the automatic menu item discovery.- See Also:
- Constant Field Values
-
LAYOUT_MENU_PREFIX
public static final String LAYOUT_MENU_PREFIX
the props file key prefix for the menus.- See Also:
- Constant Field Values
-
LAYOUT_SHORTCUT_PREFIX
public static final String LAYOUT_SHORTCUT_PREFIX
the props file key prefix for the shortcuts.- See Also:
- Constant Field Values
-
LAYOUT_BLACKLISTED_PREFIX
public static final String LAYOUT_BLACKLISTED_PREFIX
the props file key prefix for the blacklisted menu items.- See Also:
- Constant Field Values
-
LAYOUT_CATEGORY_PREFIX
public static final String LAYOUT_CATEGORY_PREFIX
the props file key prefix for the menu items with a new category.- See Also:
- Constant Field Values
-
LAYOUT_MENU_WINDOWS
public static final String LAYOUT_MENU_WINDOWS
the props file key for the windows menu.- See Also:
- Constant Field Values
-
LAYOUT_MENU_TOOLS
public static final String LAYOUT_MENU_TOOLS
the props file key for the tools menu.- See Also:
- Constant Field Values
-
SEPARATOR
public static final String SEPARATOR
the separator between classname and alternative title.- See Also:
- Constant Field Values
-
m_UnavailableMenuItems
protected static HashSet<String> m_UnavailableMenuItems
stores classnames that aren't available.
-
m_Owner
protected AbstractApplicationFrame m_Owner
the parent application frame.
-
m_Setup
protected String m_Setup
the file with the layout, shortcuts and blacklisted menu items.
-
m_Properties
protected Properties m_Properties
the properties read from the setup file.
-
m_UserMode
protected UserMode m_UserMode
the user mode.
-
m_MenuWindows
protected JMenu m_MenuWindows
the "windows" menu.
-
-
Constructor Detail
-
ApplicationMenu
public ApplicationMenu(AbstractApplicationFrame owner)
Initializes menu generator.- Parameters:
owner- the owning application frame
-
-
Method Detail
-
getOwner
public AbstractApplicationFrame getOwner()
Returns the owning frame.- Returns:
- the owner
-
setSetup
public void setSetup(String value)
Sets the setup file with the layout, etc.- Parameters:
value- the setup file
-
getSetup
public String getSetup()
Returns the setup file with the layout, etc.- Returns:
- the setup file
-
setUserMode
public void setUserMode(UserMode value)
Sets the user mode to use, i.e., the visibility level of menu items.- Parameters:
value- the user mode
-
getUserMode
public UserMode getUserMode()
Returns the current user mode, i.e., the visibility level of menu items.- Returns:
- the user mode
-
getProperties
protected Properties getProperties()
Returns the properties.- Returns:
- the properties
-
determineItemIndex
protected int determineItemIndex(String[] items, JMenu menu)
Determines the lowest index of the menu items in the given menu.- Parameters:
items- the items to look for in the menu (case-insensitive)menu- the menu to look through- Returns:
- the lowest index, -1 if none was found
-
getMenuBar
public JMenuBar getMenuBar()
Generates the menu and returns it.- Returns:
- the menu bar
-
setBlacklisted
public void setBlacklisted(Class cls, boolean value)
Sets whether the class is blacklisted or not.- Parameters:
cls- the class to blacklist/whitelistvalue- true if to blacklist
-
setBlacklisted
public void setBlacklisted(String classname, boolean value)
Sets whether the class is blacklisted or not.- Parameters:
classname- the class to blacklist/whitelistvalue- true if to blacklist
-
isBlacklisted
public boolean isBlacklisted(Class cls)
Checks whether the class is blacklisted.- Parameters:
cls- the class to check- Returns:
- true if blacklisted
-
isBlacklisted
public boolean isBlacklisted(String classname)
Checks whether the class is blacklisted.- Parameters:
classname- the class to check- Returns:
- true if blacklisted
-
hasCategory
public boolean hasCategory(Class cls)
Checks whether the class has a different category assigned.- Parameters:
cls- the class to check- Returns:
- true if a different category assigned
-
hasCategory
public boolean hasCategory(String classname)
Checks whether the class has a different category assigned.- Parameters:
classname- the class to check- Returns:
- true if a different category assigned
-
getCategory
public String getCategory(Class cls)
Returns the different category assigned for the class (if any).- Parameters:
cls- the class to get the category for- Returns:
- the category, null if no alternative assigned
-
getCategory
public String getCategory(String classname)
Returns the different category assigned for the class (if any).- Parameters:
classname- the class to get the category for- Returns:
- the category, null if no alternative assigned
-
isUnavailable
public boolean isUnavailable(Class cls)
Checks whether the class is unavailable (ie not found in classpath), based on previous menu generation.- Parameters:
cls- the class to check- Returns:
- true if unavailable
-
isUnavailable
public boolean isUnavailable(String classname)
Checks whether the class is unavailable (ie not found in classpath), based on previous menu generation.- Parameters:
classname- the name to check- Returns:
- true if unavailable
-
setUnavailable
public void setUnavailable(Class cls)
Marks this class as unavailable.- Parameters:
cls- the class to mark as unavailable
-
setUnavailable
public void setUnavailable(String classname)
Marks this class as unavailable.- Parameters:
classname- the name to mark as unavailable
-
getWindowsMenu
public JMenu getWindowsMenu()
Returns the "Windows" menu from the last "getMenuBar" call.- Returns:
- the "Windows" menu
- See Also:
getMenuBar()
-
-