soc.client
Class SOCHandPanel.ResourceTradeMenuItem

java.lang.Object
  extended by java.awt.MenuComponent
      extended by java.awt.MenuItem
          extended by soc.client.SOCHandPanel.ResourceTradeMenuItem
All Implemented Interfaces:
java.io.Serializable, javax.accessibility.Accessible
Enclosing class:
SOCHandPanel

protected static class SOCHandPanel.ResourceTradeMenuItem
extends java.awt.MenuItem

Menu item for right-click on resource square to trade with bank/port.

Author:
Jeremy D Monin
See Also:
SOCHandPanel.ResourceTradePopupMenu, Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class java.awt.MenuItem
java.awt.MenuItem.AccessibleAWTMenuItem
 
Nested classes/interfaces inherited from class java.awt.MenuComponent
java.awt.MenuComponent.AccessibleAWTMenuComponent
 
Field Summary
private  SOCGame game
           
private static java.lang.Integer INT_1
           
private  boolean shortTxt
           
private  int tradeFrom
           
private  int tradeNum
           
private  int tradeTo
           
 
Constructor Summary
SOCHandPanel.ResourceTradeMenuItem(SOCGame game, int numFrom, int typeFrom, int typeTo, boolean shortText)
          Create a bank/port trade MenuItem, with text such as "Trade 2 brick for 1 wheat".
 
Method Summary
 void createBankTradeRequest(SOCHandPanel hp)
          Create a bank-trade-request, send to the server.
 int getTradeFrom()
           
 int getTradeTo()
           
 void setCost(int numFrom)
          Update menu item text to new cost of trade.
 void setEnabled(boolean enable)
          Enable or disable this menu item.
 
Methods inherited from class java.awt.MenuItem
addActionListener, addNotify, deleteShortcut, disable, disableEvents, enable, enable, enableEvents, getAccessibleContext, getActionCommand, getActionListeners, getLabel, getListeners, getShortcut, isEnabled, paramString, processActionEvent, processEvent, removeActionListener, setActionCommand, setLabel, setShortcut
 
Methods inherited from class java.awt.MenuComponent
dispatchEvent, getFont, getName, getParent, getPeer, getTreeLock, postEvent, removeNotify, setFont, setName, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

INT_1

private static final java.lang.Integer INT_1

game

private final SOCGame game

tradeFrom

private int tradeFrom

tradeTo

private int tradeTo

tradeNum

private int tradeNum

shortTxt

private boolean shortTxt
Constructor Detail

SOCHandPanel.ResourceTradeMenuItem

public SOCHandPanel.ResourceTradeMenuItem(SOCGame game,
                                          int numFrom,
                                          int typeFrom,
                                          int typeTo,
                                          boolean shortText)
Create a bank/port trade MenuItem, with text such as "Trade 2 brick for 1 wheat".

Parameters:
game - Game reference, needed for SOCStringManager.getSpecial(SOCGame, String, Object...)
numFrom - Number of resources to trade for 1 resource
typeFrom - Source resource type, as in SOCResourceConstants.
typeTo - Target resource type, as in SOCResourceConstants. If typeFrom == typeTo, menuitem will be disabled.
shortText - If true, short ("For 1 wheat") vs full "Trade 2 brick for 1 wheat"
Method Detail

setCost

public void setCost(int numFrom)
Update menu item text to new cost of trade.

Parameters:
numFrom - Trade this many resources; if the number is unchanged, the text is not updated.

setEnabled

public void setEnabled(boolean enable)
Enable or disable this menu item. If from-to resources are same, always disabled.

Overrides:
setEnabled in class java.awt.MenuItem

getTradeFrom

public int getTradeFrom()
Returns:
the resource type to trade from, shown in this menu item text

getTradeTo

public int getTradeTo()
Returns:
the resource type to trade to, shown in this menu item text

createBankTradeRequest

public void createBankTradeRequest(SOCHandPanel hp)
Create a bank-trade-request, send to the server.