Class 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
      • Nested classes/interfaces inherited from class java.awt.Container

        java.awt.Container.AccessibleAWTContainer
      • Nested classes/interfaces inherited from class java.awt.Component

        java.awt.Component.AccessibleAWTComponent, java.awt.Component.BaselineResizeBehavior, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy
    • 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
      • Fields inherited from class java.awt.Component

        accessibleContext, BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
      • Fields inherited from interface java.awt.image.ImageObserver

        ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
    • 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
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Field Detail

      • logger

        private static final java.util.logging.Logger logger
      • gui

        private final GUI gui
    • Constructor Detail

      • QuickActionMenu

        public QuickActionMenu​(FreeColClient freeColClient,
                               FreeColPanel freeColPanel)
        Creates a standard empty menu
        Parameters:
        freeColClient - The enclosing FreeColClient.
        freeColPanel - The parent FreeColPanel.
    • Method Detail

      • addMenuItems

        public QuickActionMenu addMenuItems​(javax.swing.JComponent comp)
        Add specific menu items for a given component.
        Parameters:
        comp - The specific JComponent.
        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 - The WorkLocation 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 - The AbstractGoods to query.
      • createUnitMenu

        private void createUnitMenu​(UnitLabel unitLabel)
        Creates a popup menu for a Unit.
        Parameters:
        unitLabel - The UnitLabel to create items for.
      • addBoardItems

        private boolean addBoardItems​(UnitLabel unitLabel,
                                      Location loc)
      • addLoadItems

        private boolean addLoadItems​(Goods goods,
                                     Location loc)
      • 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 - The UnitLabel to create items for.
        from - The starting Role.
        fromCount - The starting role count.
        to - The new Role.
        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 - The UnitLabel 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 - The GoodsLabel to create items for.
      • addPayArrears

        private void addPayArrears​(GoodsType goodsType)
        Add an item to pay arrears on the given goods type.
        Parameters:
        goodsType - The GoodsType to pay arrears on.
      • createMarketMenu

        private void createMarketMenu​(MarketLabel marketLabel)
        Creates menu items for some goods in a market.
        Parameters:
        marketLabel - The MarketLabel to create entries for.
      • createTileMenu

        private void createTileMenu​(ColonyPanel.TilesPanel.ASingleTilePanel singleTilePanel)
        Creates a menu for a tile.
        Parameters:
        singleTilePanel - The ASingleTilePanel to create with.
      • addTileItem

        private boolean addTileItem​(UnitLabel unitLabel)
        Add a menu item for the tile a unit is working.
        Parameters:
        unitLabel - The UnitLabel 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 - The Tile to use.