Package gov.nih.mipav.view
Class ViewMenuBuilder
- java.lang.Object
-
- gov.nih.mipav.view.ViewMenuBuilder
-
public class ViewMenuBuilder extends java.lang.Object
This class provides a number of helper methods for building and manipulating menus.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private class
ViewMenuBuilder.MenuDragOp
Class for listening to dragging events within a menu.private class
ViewMenuBuilder.MipavMenuItem
DOCUMENT ME!class
ViewMenuBuilder.QuickList
QuickList class uses Preferences to build a list of the most recently opened images. the frame is passed in for purposes of ActionListener The QuickList is stored as JMenuItems in a Vector that can be retrieved.
-
Field Summary
Fields Modifier and Type Field Description private javax.swing.ButtonGroup
buttonGroup
private javax.swing.JMenu
fileMenu
Link to the file menu so that quicklist can be rebuilt and added.private java.awt.event.ActionListener
listener
The class which wants to listen to the menu items generated.private java.util.Vector<ViewMenuBuilder.MipavMenuItem>
menuItemVector
Holder of all the menu items.private ViewMenuBuilder.MenuDragOp
op
Menu dragging listenerprivate ViewMenuBuilder.QuickList
quickList
List that holds the last X number of recently opened images.private int
quicklistIndex
Index for rebuilding quicklist.
-
Constructor Summary
Constructors Constructor Description ViewMenuBuilder(java.awt.event.ActionListener al)
Sets frame to add menus to, and initializes menu item vector.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private void
addMenuDragListener(java.awt.Component comp, javax.swing.event.MenuDragMouseListener op)
Attaches a MenuDragMouseListener tocomp
and all of its sub-components (if comp is a JMenu/JMenuItem.javax.swing.JCheckBoxMenuItem
buildCheckBoxMenuItem(java.lang.String text, java.lang.String cmd, boolean selected)
Builds a JCheckBox with the given parameters and adds it to the Vector of menu items.static javax.swing.JCheckBoxMenuItem
buildCheckBoxMenuItem(java.lang.String text, java.lang.String cmd, java.awt.event.ActionListener listener, boolean selected)
Static method for building JCheckBoxes with the given parameters.static javax.swing.JMenuItem
buildHTMLMenuItem(java.lang.String text, java.lang.String cmd, int mnemonic, java.awt.event.ActionListener listener, java.lang.String iconName, boolean iconPadding)
DOCUMENT ME!static javax.swing.JMenu
buildMenu(java.lang.String text, int mnemonic, boolean iconPadding)
Static method for building a JMenu.javax.swing.JMenuItem
buildMenuItem(CustomUIBuilder.UIParams params, boolean useIconPadding)
Build a menu item using a pre-made UIParamsstatic javax.swing.JMenuItem
buildMenuItem(CustomUIBuilder.UIParams params, java.awt.event.ActionListener listener, boolean iconPadding)
Creates a Menu Item using pre-packaged UIParamsstatic javax.swing.JMenuItem
buildMenuItem(java.lang.String text, java.lang.String cmd, int mnemonic, java.awt.event.ActionListener listener, java.lang.String iconName, boolean iconPadding)
DOCUMENT ME!javax.swing.JMenuItem
buildMenuItem(java.lang.String text, java.lang.String cmd, int mnemonic, java.lang.String iconName, boolean useIconPadding)
DOCUMENT ME!ViewMenuBuilder.QuickList
buildQuickList()
Builds the quicklist for the first time.javax.swing.JRadioButtonMenuItem
buildRadioButtonMenuItem(java.lang.String text, java.lang.String cmd, boolean selected)
javax.swing.JRadioButtonMenuItem
buildRadioButtonMenuItem(java.lang.String text, java.lang.String cmd, boolean selected, javax.swing.ButtonGroup group)
void
finalize()
Clean up memory used by the menu builder.javax.swing.JMenuItem
getMenuItem(java.lang.String menuItemName)
DOCUMENT ME!boolean
isMenuItemEnabled(java.lang.String name)
Provides a method of checking the state of specified menu.boolean
isMenuItemSelected(java.lang.String name)
Provides a method of checking the state of specified menu.javax.swing.JMenu
makeMenu(java.lang.Object parentMenu, boolean iconPadding, javax.swing.JComponent[] menuComponent)
Makes a menu out of the menu components, usingparentMenu
as the base for this menu.javax.swing.JMenu
makeMenu(java.lang.Object parentMenu, char mnemonic, boolean iconPadding, java.util.Vector<javax.swing.JComponent> menuComponent)
javax.swing.JMenu
makeMenu(java.lang.Object parentMenu, char mnemonic, boolean iconPadding, javax.swing.JComponent[] menuComponent)
Makes a menu out of the menu components, usingparentMenu
as the base for this menu and adding a mnemonic.void
setMenuItemEnabled(java.lang.String name, boolean state)
Provides a method of setting the state of specified menu.void
setMenuItemSelected(java.lang.String name, boolean val)
Provides a method for changing the status of a checkbox menu item.void
updateQuickList()
Updates the most recently opened images list (called when images are opened etc).
-
-
-
Field Detail
-
fileMenu
private javax.swing.JMenu fileMenu
Link to the file menu so that quicklist can be rebuilt and added.
-
listener
private java.awt.event.ActionListener listener
The class which wants to listen to the menu items generated.
-
menuItemVector
private java.util.Vector<ViewMenuBuilder.MipavMenuItem> menuItemVector
Holder of all the menu items.
-
quickList
private ViewMenuBuilder.QuickList quickList
List that holds the last X number of recently opened images.
-
quicklistIndex
private int quicklistIndex
Index for rebuilding quicklist.
-
op
private final ViewMenuBuilder.MenuDragOp op
Menu dragging listener
-
buttonGroup
private javax.swing.ButtonGroup buttonGroup
-
-
Method Detail
-
buildCheckBoxMenuItem
public static javax.swing.JCheckBoxMenuItem buildCheckBoxMenuItem(java.lang.String text, java.lang.String cmd, java.awt.event.ActionListener listener, boolean selected)
Static method for building JCheckBoxes with the given parameters.- Parameters:
text
- String text to display on the boxcmd
- String the action commandlistener
- ActionListener the action listener for the boxselected
- boolean whether the box should be selected by default- Returns:
- JCheckBoxMenuItem the jcheckbox that is built
-
buildHTMLMenuItem
public static javax.swing.JMenuItem buildHTMLMenuItem(java.lang.String text, java.lang.String cmd, int mnemonic, java.awt.event.ActionListener listener, java.lang.String iconName, boolean iconPadding)
DOCUMENT ME!- Parameters:
text
- DOCUMENT ME!cmd
- DOCUMENT ME!mnemonic
- DOCUMENT ME!listener
- DOCUMENT ME!iconName
- DOCUMENT ME!iconPadding
- DOCUMENT ME!- Returns:
- DOCUMENT ME!
-
buildMenu
public static javax.swing.JMenu buildMenu(java.lang.String text, int mnemonic, boolean iconPadding)
Static method for building a JMenu.- Parameters:
text
- String the name of the menu to be displayedmnemonic
- int mnemonic for the menuiconPadding
- boolean an empty icon (transparent) is used to properly pad the text- Returns:
- JMenu the menu that is built
-
buildMenuItem
public static javax.swing.JMenuItem buildMenuItem(CustomUIBuilder.UIParams params, java.awt.event.ActionListener listener, boolean iconPadding)
Creates a Menu Item using pre-packaged UIParams- Parameters:
params
- UI Paramslistener
- Action listenericonPadding
- whether to use icon padding- Returns:
- the jmenuitem
-
buildMenuItem
public static javax.swing.JMenuItem buildMenuItem(java.lang.String text, java.lang.String cmd, int mnemonic, java.awt.event.ActionListener listener, java.lang.String iconName, boolean iconPadding)
DOCUMENT ME!- Parameters:
text
- DOCUMENT ME!cmd
- DOCUMENT ME!mnemonic
- DOCUMENT ME!listener
- DOCUMENT ME!iconName
- DOCUMENT ME!iconPadding
- DOCUMENT ME!- Returns:
- DOCUMENT ME!
-
buildRadioButtonMenuItem
public javax.swing.JRadioButtonMenuItem buildRadioButtonMenuItem(java.lang.String text, java.lang.String cmd, boolean selected)
-
buildRadioButtonMenuItem
public javax.swing.JRadioButtonMenuItem buildRadioButtonMenuItem(java.lang.String text, java.lang.String cmd, boolean selected, javax.swing.ButtonGroup group)
-
buildCheckBoxMenuItem
public javax.swing.JCheckBoxMenuItem buildCheckBoxMenuItem(java.lang.String text, java.lang.String cmd, boolean selected)
Builds a JCheckBox with the given parameters and adds it to the Vector of menu items.- Parameters:
text
- String Checkbox textcmd
- String actioncommandselected
- boolean whether the box is selected by default- Returns:
- JCheckBoxMenuItem
-
buildMenuItem
public javax.swing.JMenuItem buildMenuItem(CustomUIBuilder.UIParams params, boolean useIconPadding)
Build a menu item using a pre-made UIParams- Parameters:
params
- the UIParams (from CustomUIBuilder)useIconPadding
- use icon padding- Returns:
-
buildMenuItem
public javax.swing.JMenuItem buildMenuItem(java.lang.String text, java.lang.String cmd, int mnemonic, java.lang.String iconName, boolean useIconPadding)
DOCUMENT ME!- Parameters:
text
- Stringcmd
- Stringmnemonic
- inticonName
- StringuseIconPadding
- boolean- Returns:
- JMenuItem
-
buildQuickList
public ViewMenuBuilder.QuickList buildQuickList()
Builds the quicklist for the first time.- Returns:
- QuickList
-
finalize
public void finalize()
Clean up memory used by the menu builder.- Overrides:
finalize
in classjava.lang.Object
-
getMenuItem
public javax.swing.JMenuItem getMenuItem(java.lang.String menuItemName)
DOCUMENT ME!- Parameters:
menuItemName
- DOCUMENT ME!- Returns:
- DOCUMENT ME!
-
isMenuItemEnabled
public boolean isMenuItemEnabled(java.lang.String name)
Provides a method of checking the state of specified menu.- Parameters:
name
- The name of the item whose state needs to be checked.- Returns:
- Whether or not the item is enabled.
-
isMenuItemSelected
public boolean isMenuItemSelected(java.lang.String name)
Provides a method of checking the state of specified menu.- Parameters:
name
- The name of the item whose state needs to be checked.- Returns:
- Whether or not the item is selected.
-
makeMenu
public javax.swing.JMenu makeMenu(java.lang.Object parentMenu, boolean iconPadding, javax.swing.JComponent[] menuComponent)
Makes a menu out of the menu components, usingparentMenu
as the base for this menu.- Parameters:
parentMenu
- The parent menu, must be of typeString
or aJMenu
, cannot be null.iconPadding
- Array of menu items, must be of typeJMenu
,JMenuItem
,JCheckBoxMenuItem
, orJSeparator
.menuComponent
- Parent frame, used to add as an item listener to the checkbox menu items.- Returns:
- The newly created menu.
-
makeMenu
public javax.swing.JMenu makeMenu(java.lang.Object parentMenu, char mnemonic, boolean iconPadding, javax.swing.JComponent[] menuComponent)
Makes a menu out of the menu components, usingparentMenu
as the base for this menu and adding a mnemonic.- Parameters:
parentMenu
- The parent menu, must be of typeString
or aJMenu
, cannot be null.mnemonic
- Mnemonic key for the parent menu name.iconPadding
- Array of menu items, must be of typeJMenu
,JMenuItem
,JCheckBoxMenuItem
, orJSeparator
.menuComponent
- Parent frame, used to add as an item listener to the checkbox menu items.- Returns:
- The newly created menu.
-
makeMenu
public javax.swing.JMenu makeMenu(java.lang.Object parentMenu, char mnemonic, boolean iconPadding, java.util.Vector<javax.swing.JComponent> menuComponent)
-
setMenuItemEnabled
public void setMenuItemEnabled(java.lang.String name, boolean state)
Provides a method of setting the state of specified menu.- Parameters:
name
- The name of the item whose state needs to be set.state
-true
sets the menu item active;false
sets the menu item inactive.
-
setMenuItemSelected
public void setMenuItemSelected(java.lang.String name, boolean val)
Provides a method for changing the status of a checkbox menu item.- Parameters:
val
- whether the checkbox should be selected.
-
updateQuickList
public void updateQuickList()
Updates the most recently opened images list (called when images are opened etc).
-
addMenuDragListener
private void addMenuDragListener(java.awt.Component comp, javax.swing.event.MenuDragMouseListener op)
Attaches a MenuDragMouseListener tocomp
and all of its sub-components (if comp is a JMenu/JMenuItem.
-
-