Package com.nomagic.actions
Class ActionsMenuCreator
- java.lang.Object
-
- com.nomagic.actions.ActionsMenuCreator
-
@OpenApiAll public class ActionsMenuCreator extends java.lang.ObjectClass for creating GUI menu items from actions.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected classActionsMenuCreator.AMC_ActionsVisitorstatic classActionsMenuCreator.CustomJMenuItemclassActionsMenuCreator.MutableActionListenerClass for handling ActionsCategory changes.
-
Field Summary
Fields Modifier and Type Field Description static java.lang.StringACTIONstatic java.lang.StringCATEGORY_HEADERstatic java.lang.StringHIDDEN_ALWAYSstatic java.lang.StringPOPUP_HEADER_ITEM_NAME
-
Constructor Summary
Constructors Constructor Description ActionsMenuCreator()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidaddCleanupParticipant(java.lang.Runnable participant)protected voidaddJMenuItem(java.awt.Component item, NMAction action)Adds menu item, according to index item will be added to end when index less than 0, or to specified by index position.voidappendMenuItems(java.awt.Container container, ActionsManager manager)Appends menu items to given container.voidappendMenuItems(javax.swing.JPopupMenu popup, ActionsManager manager)Appends menu items to the given pop up menu.voidappendMenuItems(javax.swing.JPopupMenu popup, ActionsManager manager, boolean addSeparator)Appends menu items to given popup.protected ActionsVisitorcreateActionsVisitor()javax.swing.JPopupMenucreatePopupMenu(ActionsManager manager)Creates popup menu for given actions managerjavax.swing.JPopupMenucreatePopupMenu(ActionsManager manager, java.util.function.Supplier<javax.swing.JPopupMenu> factory)Creates popup menu for given actions managercom.nomagic.actions.MenuComponentFactorygetFactory()Return menu component factoryprotected voidinternalAppendMenuItems(java.awt.Container container, ActionsManager manager)protected voidinternalAppendMenuItems(javax.swing.JPopupMenu popup, ActionsManager manager, boolean addSeparator)static booleanisSeparatorComponent(java.awt.Component component)voidsetFactory(com.nomagic.actions.MenuComponentFactory factory)Set menu component factorystatic voidsetPropertiesToMenuItem(javax.swing.JMenuItem item, NMAction action)Sets properties to given JMenuItem from given action.voidsetUseMenuListener(boolean useMenuListener)Do we need to useMenuListeneron category? This flag should be set to true only if software is running on mac and using -Dapple.laf.useScreenMenuBar=true system property.
-
-
-
Field Detail
-
HIDDEN_ALWAYS
public static final java.lang.String HIDDEN_ALWAYS
- See Also:
- Constant Field Values
-
ACTION
public static final java.lang.String ACTION
- See Also:
- Constant Field Values
-
CATEGORY_HEADER
public static final java.lang.String CATEGORY_HEADER
- See Also:
- Constant Field Values
-
POPUP_HEADER_ITEM_NAME
public static final java.lang.String POPUP_HEADER_ITEM_NAME
- See Also:
- Constant Field Values
-
-
Method Detail
-
createPopupMenu
public final javax.swing.JPopupMenu createPopupMenu(ActionsManager manager)
Creates popup menu for given actions manager- Parameters:
manager- manager- Returns:
- popup menu
-
createPopupMenu
public final javax.swing.JPopupMenu createPopupMenu(ActionsManager manager, java.util.function.Supplier<javax.swing.JPopupMenu> factory)
Creates popup menu for given actions manager- Parameters:
manager- managerfactory- new popup menu factory- Returns:
- popup menu
-
appendMenuItems
public final void appendMenuItems(javax.swing.JPopupMenu popup, ActionsManager manager)Appends menu items to the given pop up menu. Adds separator before new items if given pop up is not empty.- Parameters:
popup- where items will be appendedmanager- manager from which actions menu items will be created
-
appendMenuItems
public final void appendMenuItems(javax.swing.JPopupMenu popup, ActionsManager manager, boolean addSeparator)Appends menu items to given popup.- Parameters:
popup- where items will be appendedmanager- manager from which actions menu items will be createdaddSeparator- add separator after last item in the given popup or not
-
internalAppendMenuItems
protected void internalAppendMenuItems(javax.swing.JPopupMenu popup, ActionsManager manager, boolean addSeparator)
-
appendMenuItems
public final void appendMenuItems(java.awt.Container container, ActionsManager manager)Appends menu items to given container.- Parameters:
container- container where items will be appendedmanager- manager from which actions items will be created
-
createActionsVisitor
protected ActionsVisitor createActionsVisitor()
-
internalAppendMenuItems
protected void internalAppendMenuItems(java.awt.Container container, ActionsManager manager)
-
addJMenuItem
protected void addJMenuItem(java.awt.Component item, NMAction action)Adds menu item, according to index item will be added to end when index less than 0, or to specified by index position.- Parameters:
item- item to add.action- action
-
setPropertiesToMenuItem
public static void setPropertiesToMenuItem(javax.swing.JMenuItem item, NMAction action)Sets properties to given JMenuItem from given action.- Parameters:
item- item to set properties.action- for getting properties.
-
setUseMenuListener
public void setUseMenuListener(boolean useMenuListener)
Do we need to useMenuListeneron category? This flag should be set to true only if software is running on mac and using -Dapple.laf.useScreenMenuBar=true system property.- Parameters:
useMenuListener- true if need to use.
-
getFactory
public com.nomagic.actions.MenuComponentFactory getFactory()
Return menu component factory- Returns:
- factory
-
setFactory
public void setFactory(com.nomagic.actions.MenuComponentFactory factory)
Set menu component factory- Parameters:
factory- factory
-
isSeparatorComponent
public static boolean isSeparatorComponent(@CheckForNull java.awt.Component component)
-
addCleanupParticipant
protected void addCleanupParticipant(java.lang.Runnable participant)
-
-