Package adams.gui.flow.menu
Class AbstractFlowEditorMenuItem
- java.lang.Object
-
- adams.core.logging.LoggingObject
-
- adams.gui.flow.menu.AbstractFlowEditorMenuItem
-
- All Implemented Interfaces:
LoggingSupporter
,SizeOfHandler
,Serializable
,Comparable<AbstractFlowEditorMenuItem>
- Direct Known Subclasses:
ShowTriggers
public abstract class AbstractFlowEditorMenuItem extends LoggingObject implements Comparable<AbstractFlowEditorMenuItem>
Ancestor for additional menu items in the flow editor.- Author:
- fracpete (fracpete at waikato dot ac dot nz)
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected AbstractBaseAction
m_Action
the underlying action.protected JMenuItem
m_MenuItem
the underlying menuitem.protected FlowEditorPanel
m_Owner
the owner.protected JMenu
m_SubMenu
the underlying submenu.-
Fields inherited from class adams.core.logging.LoggingObject
m_Logger, m_LoggingIsEnabled, m_LoggingLevel
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
AbstractFlowEditorMenuItem()
Initializes the menu item.
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description int
compareTo(AbstractFlowEditorMenuItem o)
Compares this object with the specified object for order.protected String
determineCaption(AbstractFlowEditorMenuItem item)
Determines the caption of the menu item.boolean
equals(Object o)
Returns whether the two objects are the same.AbstractBaseAction
getAction()
Returns the action to add to the flow editor menu.abstract String
getMenu()
Returns the name of the menu to list this item under.JMenuItem
getMenuItem()
Returns the menuitem to add to the flow editor menu.static Class[]
getMenuItems()
Returns a list with classnames of menu items.FlowEditorPanel
getOwner()
Returns the owner.JMenu
getSubMenu()
Returns the submenu to add to the flow editor menu.boolean
hasAction()
Returns whether the menu item is based on an action.boolean
hasMenuItem()
Returns whether the menu item is based on a menuitem.boolean
hasSubMenu()
Returns whether the menu item is based on a submenu.protected void
initialize()
Initializes the menu item.protected abstract AbstractBaseAction
newAction()
Creates the action to use.protected JMenuItem
newMenuItem()
Creates the menuitem to use.protected JMenu
newSubMenu()
Creates the submenu to use.void
setOwner(FlowEditorPanel value)
Sets the owning flow editor.abstract void
update()
Updating the action/menuitem/submenu, based on the current status of the owner.-
Methods inherited from class adams.core.logging.LoggingObject
configureLogger, getLogger, getLoggingLevel, initializeLogging, isLoggingEnabled, sizeOf
-
-
-
-
Field Detail
-
m_Owner
protected FlowEditorPanel m_Owner
the owner.
-
m_Action
protected AbstractBaseAction m_Action
the underlying action.
-
m_MenuItem
protected JMenuItem m_MenuItem
the underlying menuitem.
-
m_SubMenu
protected JMenu m_SubMenu
the underlying submenu.
-
-
Method Detail
-
initialize
protected void initialize()
Initializes the menu item.
-
hasAction
public boolean hasAction()
Returns whether the menu item is based on an action.
Default implementation returns true.- Returns:
- true if action-based
-
newAction
protected abstract AbstractBaseAction newAction()
Creates the action to use.- Returns:
- the action
-
getAction
public AbstractBaseAction getAction()
Returns the action to add to the flow editor menu.- Returns:
- the action to add
- See Also:
hasAction()
-
hasMenuItem
public boolean hasMenuItem()
Returns whether the menu item is based on a menuitem.
Default implementation returns false.- Returns:
- true if menuitem-based
-
newMenuItem
protected JMenuItem newMenuItem()
Creates the menuitem to use.
Default implementation returns null.- Returns:
- the menuitem
-
getMenuItem
public JMenuItem getMenuItem()
Returns the menuitem to add to the flow editor menu.- Returns:
- the menuitem to add
- See Also:
hasMenuItem()
-
hasSubMenu
public boolean hasSubMenu()
Returns whether the menu item is based on a submenu.
Default implementation returns false.- Returns:
- true if submenu-based
-
newSubMenu
protected JMenu newSubMenu()
Creates the submenu to use.
Default implementation returns null.- Returns:
- the submenu
-
getSubMenu
public JMenu getSubMenu()
Returns the submenu to add to the flow editor menu.- Returns:
- the submenu to add
- See Also:
hasSubMenu()
-
setOwner
public void setOwner(FlowEditorPanel value)
Sets the owning flow editor.- Parameters:
value
- the owner
-
getOwner
public FlowEditorPanel getOwner()
Returns the owner.- Returns:
- the owner, null if none set
-
getMenu
public abstract String getMenu()
Returns the name of the menu to list this item under.- Returns:
- the name of the menu
- See Also:
FlowEditorPanel.MENU_FILE
,FlowEditorPanel.MENU_EDIT
,FlowEditorPanel.MENU_RUN
,FlowEditorPanel.MENU_ACTIVE
,FlowEditorPanel.MENU_VIEW
,FlowEditorPanel.MENU_WINDOW
,FlowEditorPanel.MENU_HELP
-
update
public abstract void update()
Updating the action/menuitem/submenu, based on the current status of the owner.
-
determineCaption
protected String determineCaption(AbstractFlowEditorMenuItem item)
Determines the caption of the menu item.- Parameters:
item
- the item- Returns:
- the caption, empty string if unable to find one
-
compareTo
public int compareTo(AbstractFlowEditorMenuItem o)
Compares this object with the specified object for order. Returns a negative integer, zero, or a positive integer as this object is less than, equal to, or greater than the specified object.
Uses the name of the menu item text for comparison.- Specified by:
compareTo
in interfaceComparable<AbstractFlowEditorMenuItem>
- Parameters:
o
- the object to be compared.- Returns:
- a negative integer, zero, or a positive integer as this object is less than, equal to, or greater than the specified object.
-
equals
public boolean equals(Object o)
Returns whether the two objects are the same.
Only compares the menu item text of the two objects.
-
getMenuItems
public static Class[] getMenuItems()
Returns a list with classnames of menu items.- Returns:
- the menu item classnames
-
-