dip.gui
Class OrderDisplayPanel

java.lang.Object
  extended byjava.awt.Component
      extended byjava.awt.Container
          extended byjavax.swing.JComponent
              extended byjavax.swing.JPanel
                  extended bydip.gui.OrderDisplayPanel
All Implemented Interfaces:
javax.accessibility.Accessible, java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable
Direct Known Subclasses:
F2FOrderDisplayPanel

public class OrderDisplayPanel
extends javax.swing.JPanel

The OrderDisplayPanel: displayer of orders.

OrderDisplayPanel provides a wrapper for viewing orders within a TurnState object, as well as adding orders to a TurnState object.

Advantages of using OrderDisplayPanel to modify TurnState include:

It is recommended that all orders are entered via the OrderDisplayPanel. Note that if orders are entered into the TurnState directly, approrpriate ClientFrame fire() methods must be called to inform the OrderDisplayPanel of updates. Also, care must be taken to avoid entering duplicate orders, and that only one order per unit (per province).

Important Note: The add/remove/removeAll methods will only operate on orderable power. Thus if an order is added and the power is not in the orderable power list, it will fail. This applies to removes as well. For removeAll, only orderable powers orders are removed.

See Also:
Serialized Form

Nested Class Summary
protected  class OrderDisplayPanel.ODPPropertyListener
          Property change listener
 
Nested classes inherited from class javax.swing.JPanel
javax.swing.JPanel.AccessibleJPanel
 
Nested classes inherited from class javax.swing.JComponent
javax.swing.JComponent.AccessibleJComponent
 
Nested classes inherited from class java.awt.Container
java.awt.Container.AccessibleAWTContainer
 
Nested classes inherited from class java.awt.Component
java.awt.Component.AccessibleAWTComponent, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy
 
Field Summary
protected  ClientFrame clientFrame
           
protected  javax.swing.JScrollPane orderListScrollPane
           
protected  AbstractCFPListener propListener
           
protected  TurnState turnState
           
protected  World world
           
 
Fields inherited from class javax.swing.JComponent
accessibleContext, 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
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
 
Constructor Summary
OrderDisplayPanel(ClientFrame clientFrame)
          Creates an OrderDisplayPanel
 
Method Summary
 boolean addOrder(Orderable order, boolean undoable)
          Add an order to the order list, possibly with undo/redo support, and only succeeding if the order passes validation given the validation constraints.
 boolean addOrder(java.lang.String orderText, boolean undoable)
          Parses and then adds an order to the order list, possibly with undo/redo support, and only succeeding if the order passes validation given the validation constraints.
 void addOrderRaw(Orderable order, boolean undoable)
          Add an order to the TurnState, possibly with undo/redo support, and only succeeding if the order passes validation given the validation constraints.
 void addOrderRaw(java.lang.String orderText, boolean undoable)
          Parses and then adds an order to the TurnState, possibly with undo/redo support, and only succeeding if the order passes validation given the validation constraints.
 java.util.Map addOrdersRaw(Orderable[] orders, boolean undoable)
          Adds multiple orders to the TurnState.
 void close()
          OrderDisplayPanel cleanup.
protected  AbstractCFPListener createPropertyListener()
          Create the ODPPropertyListener used to receive events.
 java.awt.Dimension getMinimumSize()
          Overriden to return the preferred size.
protected  void makeLayout()
          Perform layout, and create GUI elements for sort buttons.
protected  javax.swing.JPanel makeSortPanel()
          Makes the panel containing the sort buttons.
 void refresh()
          Refresh / revalidate the display
 void removeAllOrders(boolean undoable)
          Removes all orders for all powers within the orderablePowers group (see ClientFrame for more information).
 boolean removeOrder(Orderable order, boolean undoable)
          Remove the given order from the TurnState.
 boolean removeOrders(Orderable[] orders, boolean undoable)
          Removes the given orders.
 void removeSelected()
          Deletes the orders from the order list that are selected, and that are members of the orderablePowers group.
 void revalidateAllOrders()
          Force revalidation of all orders.
 void selectAll()
          Select all orders in the list.
 void selectNone()
          Select none of the orders in the list
 
Methods inherited from class javax.swing.JPanel
getAccessibleContext, getUI, getUIClassID, paramString, setUI, updateUI
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addPropertyChangeListener, addPropertyChangeListener, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBorder, getBounds, getClientProperty, getComponentGraphics, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getGraphics, getHeight, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getNextFocusableComponent, getPreferredSize, getPropertyChangeListeners, getPropertyChangeListeners, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isOptimizedDrawingEnabled, isPaintingTile, isPreferredSizeSet, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removePropertyChangeListener, removePropertyChangeListener, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFont, setForeground, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setFocusCycleRoot, setFocusTraversalKeys, setFocusTraversalPolicy, setLayout, transferFocusBackward, 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, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMouseWheelListeners, getName, getParent, getPeer, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

propListener

protected AbstractCFPListener propListener

clientFrame

protected ClientFrame clientFrame

world

protected World world

turnState

protected TurnState turnState

orderListScrollPane

protected javax.swing.JScrollPane orderListScrollPane
Constructor Detail

OrderDisplayPanel

public OrderDisplayPanel(ClientFrame clientFrame)
Creates an OrderDisplayPanel

Method Detail

close

public void close()
OrderDisplayPanel cleanup.


createPropertyListener

protected AbstractCFPListener createPropertyListener()
Create the ODPPropertyListener used to receive events.


addOrder

public boolean addOrder(Orderable order,
                        boolean undoable)
Add an order to the order list, possibly with undo/redo support, and only succeeding if the order passes validation given the validation constraints. Duplicate orders are prevented.

This differs from addOrderRaw in that popup dialogs are displayed with an error message, instead of throwing OrderExceptions.

Parameters:
order - - true Orderable object
undoable - - true if this is an undoable action
Returns:
true if the order was accepted

addOrder

public boolean addOrder(java.lang.String orderText,
                        boolean undoable)
Parses and then adds an order to the order list, possibly with undo/redo support, and only succeeding if the order passes validation given the validation constraints. Duplicate orders are prevented.

This differs from addOrderRaw in that popup dialogs are displayed with an error message, instead of throwing OrderExceptions.

Parameters:
orderText - - true order text to parse
undoable - - true if this is an undoable action
Returns:
true if the order was accepted

addOrderRaw

public void addOrderRaw(java.lang.String orderText,
                        boolean undoable)
                 throws OrderException
Parses and then adds an order to the TurnState, possibly with undo/redo support, and only succeeding if the order passes validation given the validation constraints. Duplicate orders are prevented.

Parameters:
orderText - - true Order text to parse
undoable - - true if this is an undoable action
Throws:
OrderException - - if the order fails validation

addOrderRaw

public void addOrderRaw(Orderable order,
                        boolean undoable)
                 throws OrderException
Add an order to the TurnState, possibly with undo/redo support, and only succeeding if the order passes validation given the validation constraints. Duplicate orders are prevented.

Parameters:
order - - true Orderable object
undoable - - true if this is an undoable action
Throws:
OrderException - - if the order fails validation

addOrdersRaw

public java.util.Map addOrdersRaw(Orderable[] orders,
                                  boolean undoable)
Adds multiple orders to the TurnState. If failures occur, we return a Map of exceptions (key is order, value is the order exception). If no exceptions were created, a null HashMap is returned. All orders that do not fail are added to the TurnState. Warnings are also returned. If we are not in an editable state, an IllegalStateException is thrown. Orders that exist as duplicates within the TurnState are ignored.

Parameters:
orders - - true Orderable object array
undoable - - true if this is an undoable action
Returns:
A list of OrderExceptions, or null

removeOrder

public boolean removeOrder(Orderable order,
                           boolean undoable)
Remove the given order from the TurnState. Fails is order is not given by an orderable power.

Parameters:
order - - true Orderable object
undoable - - true if this is an undoable action
Returns:
true if the order was found and removed

removeOrders

public boolean removeOrders(Orderable[] orders,
                            boolean undoable)
Removes the given orders. Note that if an order is not a member of the orderablePowers group, it will not be removed.

Parameters:
orders - - true Orderable object array
undoable - - true if this is an undoable action
Returns:
true if all orders were found and removed

removeAllOrders

public void removeAllOrders(boolean undoable)
Removes all orders for all powers within the orderablePowers group (see ClientFrame for more information).

Parameters:
undoable - - true if this is an undoable action

removeSelected

public void removeSelected()
Deletes the orders from the order list that are selected, and that are members of the orderablePowers group. This is always an undoable action.


selectAll

public void selectAll()
Select all orders in the list.


selectNone

public void selectNone()
Select none of the orders in the list


revalidateAllOrders

public void revalidateAllOrders()
Force revalidation of all orders.


refresh

public void refresh()
Refresh / revalidate the display


getMinimumSize

public java.awt.Dimension getMinimumSize()
Overriden to return the preferred size. This ensures that we resize properly in a JSplitPane.


makeLayout

protected void makeLayout()
Perform layout, and create GUI elements for sort buttons. No border is created around the OrderDisplayPanel. Note that this is called by the constructor.


makeSortPanel

protected javax.swing.JPanel makeSortPanel()
Makes the panel containing the sort buttons. Defines actions for these buttons as well.



Copyright 2002-2004 Zachary DelProposto / jDip Development Team. All Rights Reserved.