Package net.sf.freecol.client.gui.panel
Class QuickActionMenu
- java.lang.Object
-
- java.awt.Component
-
- java.awt.Container
-
- javax.swing.JComponent
-
- javax.swing.JPopupMenu
-
- net.sf.freecol.client.gui.panel.QuickActionMenu
-
- All Implemented Interfaces:
java.awt.image.ImageObserver
,java.awt.MenuContainer
,java.io.Serializable
,javax.accessibility.Accessible
,javax.swing.MenuElement
public final class QuickActionMenu extends javax.swing.JPopupMenu
Handles the generation of popup menu's generated by DragListener objects attached to units within the Colony and Europe panels.- Author:
- Brian
- See Also:
- Serialized Form
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class javax.swing.JPopupMenu
javax.swing.JPopupMenu.AccessibleJPopupMenu, javax.swing.JPopupMenu.Separator
-
Nested classes/interfaces inherited from class javax.swing.JComponent
javax.swing.JComponent.AccessibleJComponent
-
-
Field Summary
Fields Modifier and Type Field Description private FreeColClient
freeColClient
private GUI
gui
private static java.util.logging.Logger
logger
private FreeColPanel
parentPanel
-
Fields inherited from class javax.swing.JComponent
listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
-
-
Constructor Summary
Constructors Constructor Description QuickActionMenu(FreeColClient freeColClient, FreeColPanel freeColPanel)
Creates a standard empty menu
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private boolean
addBoardItems(UnitLabel unitLabel, Location loc)
private boolean
addCarrierItems(UnitLabel unitLabel)
private boolean
addCommandItems(UnitLabel unitLabel)
private boolean
addEducationItems(UnitLabel unitLabel)
private boolean
addLoadItems(Goods goods, Location loc)
private boolean
addMarketItems(AbstractGoods ag, Europe europe)
QuickActionMenu
addMenuItems(javax.swing.JComponent comp)
Add specific menu items for a given component.private void
addPayArrears(GoodsType goodsType)
Add an item to pay arrears on the given goods type.private boolean
addRoleItems(UnitLabel unitLabel)
Add menu items for role manipulation for a unit.private boolean
addTileItem(UnitLabel unitLabel)
Add a menu item for the tile a unit is working.private void
addTileItem(Tile tile)
Add a menu item to show the tile panel for a tile.private boolean
addWorkItems(UnitLabel unitLabel)
private void
createGoodsMenu(GoodsLabel goodsLabel)
Creates a menu for some goods.private void
createMarketMenu(MarketLabel marketLabel)
Creates menu items for some goods in a market.private javax.swing.JMenuItem
createRoleItem(UnitLabel unitLabel, Role from, int fromCount, Role to, int toCount, int price)
Nasty hack to get menu item to change roles.private void
createTileMenu(ColonyPanel.TilesPanel.ASingleTilePanel singleTilePanel)
Creates a menu for a tile.private void
createUnitMenu(UnitLabel unitLabel)
Creates a popup menu for a Unit.private java.util.List<javax.swing.JMenuItem>
descendingList(java.util.Map<javax.swing.JMenuItem,java.lang.Integer> map)
private static java.lang.String
getWorkLabel(WorkLocation wl)
Gets a string corresponding to the UnitAction to work at a work location.private javax.swing.JMenuItem
makeProductionItem(GoodsType type, WorkLocation wl, int amount, UnitLabel unitLabel, boolean claim)
private void
promptForGoods(AbstractGoods ag)
Prompt for an amount of goods to use.-
Methods inherited from class javax.swing.JPopupMenu
add, add, add, addMenuKeyListener, addPopupMenuListener, addSeparator, createActionChangeListener, createActionComponent, firePopupMenuCanceled, firePopupMenuWillBecomeInvisible, firePopupMenuWillBecomeVisible, getAccessibleContext, getComponent, getComponentAtIndex, getComponentIndex, getDefaultLightWeightPopupEnabled, getInvoker, getLabel, getMargin, getMenuKeyListeners, getPopupMenuListeners, getSelectionModel, getSubElements, getUI, getUIClassID, insert, insert, isBorderPainted, isLightWeightPopupEnabled, isPopupTrigger, isVisible, menuSelectionChanged, pack, paintBorder, paramString, processFocusEvent, processKeyEvent, processKeyEvent, processMouseEvent, remove, removeMenuKeyListener, removePopupMenuListener, setBorderPainted, setDefaultLightWeightPopupEnabled, setInvoker, setLabel, setLightWeightPopupEnabled, setLocation, setPopupSize, setPopupSize, setSelected, setSelectionModel, setUI, setVisible, show, updateUI
-
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, hide, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingOrigin, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintChildren, paintComponent, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, unregisterKeyboardAction, update
-
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, transferFocusDownCycle, validate, validateTree
-
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isShowing, isValid, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, requestFocus, requestFocus, requestFocusInWindow, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setMixingCutoutShape, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle
-
-
-
-
Field Detail
-
logger
private static final java.util.logging.Logger logger
-
freeColClient
private final FreeColClient freeColClient
-
gui
private final GUI gui
-
parentPanel
private final FreeColPanel parentPanel
-
-
Constructor Detail
-
QuickActionMenu
public QuickActionMenu(FreeColClient freeColClient, FreeColPanel freeColPanel)
Creates a standard empty menu- Parameters:
freeColClient
- The enclosingFreeColClient
.freeColPanel
- The parentFreeColPanel
.
-
-
Method Detail
-
addMenuItems
public QuickActionMenu addMenuItems(javax.swing.JComponent comp)
Add specific menu items for a given component.- Parameters:
comp
- The specificJComponent
.- Returns:
- This
QuickActionMenu
.
-
getWorkLabel
private static java.lang.String getWorkLabel(WorkLocation wl)
Gets a string corresponding to the UnitAction to work at a work location.- Parameters:
wl
- TheWorkLocation
to use.- Returns:
- The unit action as a string.
-
promptForGoods
private void promptForGoods(AbstractGoods ag)
Prompt for an amount of goods to use. The amount is returned through the parameter amount.- Parameters:
ag
- TheAbstractGoods
to query.
-
createUnitMenu
private void createUnitMenu(UnitLabel unitLabel)
Creates a popup menu for a Unit.- Parameters:
unitLabel
- TheUnitLabel
to create items for.
-
addCarrierItems
private boolean addCarrierItems(UnitLabel unitLabel)
-
descendingList
private java.util.List<javax.swing.JMenuItem> descendingList(java.util.Map<javax.swing.JMenuItem,java.lang.Integer> map)
-
makeProductionItem
private javax.swing.JMenuItem makeProductionItem(GoodsType type, WorkLocation wl, int amount, UnitLabel unitLabel, boolean claim)
-
addWorkItems
private boolean addWorkItems(UnitLabel unitLabel)
-
addEducationItems
private boolean addEducationItems(UnitLabel unitLabel)
-
addCommandItems
private boolean addCommandItems(UnitLabel unitLabel)
-
createRoleItem
private javax.swing.JMenuItem createRoleItem(UnitLabel unitLabel, Role from, int fromCount, Role to, int toCount, int price)
Nasty hack to get menu item to change roles. Hacky because we are continuing to express this in terms of equipment changes despite the point of the role cutover was to get rid of equipment types. However, its time to release, and we should avoid string changes. Get rid of this post 0.11.0-release.- Parameters:
unitLabel
- TheUnitLabel
to create items for.from
- The startingRole
.fromCount
- The starting role count.to
- The newRole
.toCount
- The new role count.price
- An optional price to charge for the change.- Returns:
- A suitable menu item.
-
addRoleItems
private boolean addRoleItems(UnitLabel unitLabel)
Add menu items for role manipulation for a unit. Note "clear speciality" is here too to keep it well separated from other items.- Parameters:
unitLabel
- TheUnitLabel
specifying the unit.- Returns:
- True if menu items were added and a separator is now needed.
-
createGoodsMenu
private void createGoodsMenu(GoodsLabel goodsLabel)
Creates a menu for some goods.- Parameters:
goodsLabel
- TheGoodsLabel
to create items for.
-
addPayArrears
private void addPayArrears(GoodsType goodsType)
Add an item to pay arrears on the given goods type.- Parameters:
goodsType
- TheGoodsType
to pay arrears on.
-
createMarketMenu
private void createMarketMenu(MarketLabel marketLabel)
Creates menu items for some goods in a market.- Parameters:
marketLabel
- TheMarketLabel
to create entries for.
-
addMarketItems
private boolean addMarketItems(AbstractGoods ag, Europe europe)
-
createTileMenu
private void createTileMenu(ColonyPanel.TilesPanel.ASingleTilePanel singleTilePanel)
Creates a menu for a tile.- Parameters:
singleTilePanel
- TheASingleTilePanel
to create with.
-
addTileItem
private boolean addTileItem(UnitLabel unitLabel)
Add a menu item for the tile a unit is working.- Parameters:
unitLabel
- TheUnitLabel
specifying the unit.- Returns:
- True if an item was added.
-
addTileItem
private void addTileItem(Tile tile)
Add a menu item to show the tile panel for a tile.- Parameters:
tile
- TheTile
to use.
-
-