org.salespointframework.desktop.multiwindow
Class MultiWindow

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by java.awt.Window
              extended by java.awt.Frame
                  extended by javax.swing.JFrame
                      extended by org.salespointframework.desktop.multiwindow.MultiWindow
All Implemented Interfaces:
java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable, java.util.EventListener, javax.accessibility.Accessible, javax.swing.event.ChangeListener, javax.swing.RootPaneContainer, javax.swing.WindowConstants

public class MultiWindow
extends javax.swing.JFrame
implements javax.swing.event.ChangeListener

A MultiWindow is a JFrame capable managing all kinds of Displays.

There are three view modes:

FRAME: Displays are DisplayFrames, that is, every Display has its own window (JFrame)
TAB: Displays are TabbedFrames. The MultiWindow contains a row of tabs, each of which is a Display
DESKTOP: Displays are DesktopFrames. These are Windows that can be moved within the frame borders of the MultiWindow. (see JDesktopPane)

The view mode can be chosen by client programs by calling the setViewMode(int) method or by the user using the "MultiWindow" menu.

Displays can be added via the addSalesPointDisplay(SalesPoint) method and removed with removeSalesPointDisplay(SalesPoint). When a display is added it will be saved until it is explicitly closed.

The displays will be updated automatically when FormSheets or MenuSheets are set.

Since:
v2.0
Version:
4.0
Author:
Sven Matznick, Stephan Gambke, Andreas Bartho, Thomas Kissinger
See Also:
Serialized Form

Nested Class Summary
 class MultiWindow.DesktopFrame
          This class is actually used by MultiWindow to display SalesPoints in desktop view mode.
 class MultiWindow.DisplayFrame
          This class is actually used by MultiWindow to display SalesPoints in window view mode.
static class MultiWindow.MultiWindowAction
          Special Actions are necessary for MultiWindow-MenuSheets in order for the serialization to work properly.
 class MultiWindow.TabbedFrame
          This class is actually used by MultiWindow to display SalesPoints in tabbed view mode.
 
Nested classes/interfaces inherited from class javax.swing.JFrame
javax.swing.JFrame.AccessibleJFrame
 
Nested classes/interfaces inherited from class java.awt.Frame
java.awt.Frame.AccessibleAWTFrame
 
Nested classes/interfaces inherited from class java.awt.Window
java.awt.Window.AccessibleAWTWindow
 
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
private static javax.swing.ImageIcon CASCADE_ICON
          Icon MenuItem "Cascade".
static java.lang.String CASCADE_MENU_TAG
          Constant used as tag for the "Cascade" option.
private  java.awt.image.BufferedImage currentWindowBackground
          Currently used background image
private  java.awt.image.BufferedImage currentWindowImage
          Currently used foreground image
static java.lang.String DESKTOP_MENU_TAG
          Constant used as tag for the "Desktop" menu option.
static int DESKTOP_VIEW
          Constant for the desktop view mode.
private static javax.swing.ImageIcon HORIZONTAL_ICON
          Icon MenuItem "Tile horizontally".
private  javax.swing.JPanel m_dragLayer
          the popup layer
private  javax.swing.JComponent m_jcShopComponent
          The main Component for this MultiWindow.
private  javax.swing.JDesktopPane m_jdpDesktopPane
          The main Component for this MultiWindow in DESKTOP view mode, i.e.
private  javax.swing.JPanel m_jpFramePane
          The main Component for this MultiWindow in FRAME view mode, i.e.
private  IconTabbedPane m_jtpTabPane
          The main Component for this MultiWindow in TAB view mode, i.e.
private  java.util.LinkedList<MultiWindow.MultiWindowAction> m_lActions
          The MultiWindowActions registered with this MultiWindow.
private  javax.swing.JPanel m_modalLayer
          the modal layer
private  java.util.HashMap<java.lang.Integer,JDisplayFrame> m_mpjdfDisplayFrames
          The map of currently open DisplayFrames.
private  java.util.HashMap<java.lang.Integer,JInternalDisplay> m_mpjidInternalDisplays
          The map of currently open DesktopFrames.
private  java.util.HashMap<java.lang.Integer,JTabDisplay> m_mpjtdTabDisplays
          The map of currently open TabbedFrames.
private  MenuSheet m_msCurrentMenuSheet
          The currently set global MenuSheet.
private  int m_nArrangement
          Current frame arrangement.
private  java.lang.Integer m_nSelectedFrame
          The ID of the currently selected frame.
private  int m_nViewMode
          Current view mode.
private  javax.swing.JPanel m_popupLayer
          The popup layer
private  Shop m_shShop
          Reference to the Shop for which the MultiWindow was created.
protected  java.lang.String m_sMergeBefore
          Contains the tag of the MultiWindow's MenuSheet, in front of which the active SalesPoint's MenuSheet should be merged when in tabbed view mode.
private  javax.swing.JPanel m_statusBar
          The statusbar in the bottom
private  java.lang.Object menusheetLock
          menusheet lock
static java.lang.String MULTIWINDOW_MENU_TAG
          Constant used as tag for the MultiWindowMenu.
private static int NONE
          No view mode yet.
private  java.awt.image.BufferedImage offscreenBufferBackup
          Backup of the in memory offscreen buffer. used for paintimmediately issues
static int OVERLAPPED
          Constant for cascaded arrangement of the frames in window or desktop view mode.
static java.lang.String SEPARATOR_TAG
          Constant used as tag for the separator in the multi window menu.
static java.lang.String TABBED_MENU_TAG
          Constant used as tag for the "Tabbed" menu option.
static int TABBED_VIEW
          Constant for the tabbed view mode.
static java.lang.String TILE_HORIZ_MENU_TAG
          Constant used as tag for the "Tile horizontally" option.
static java.lang.String TILE_VERT_MENU_TAG
          Constant used as tag for the "Tile vertically" option.
static int TILED_HORIZONTALLY
          Constant for horizontally tiled arrangement of the frames in window or desktop view mode.
static int TILED_VERTICALLY
          Constant for vertically tiled arrangement of the frames in window or desktop view mode.
private static javax.swing.ImageIcon VERTICAL_ICON
          Icon MenuItem "Tile vertically".
private  java.awt.image.BufferedImage volatileOffscreenBufferBackup
          backup of the in vram offscreen buffer. used fpr paintimmediately issues
static java.lang.String WINDOW_MENU_TAG
          Constant used as tag for the "Window" menu option.
static int WINDOW_VIEW
          Constant for the window view mode.
 
Fields inherited from class javax.swing.JFrame
accessibleContext, EXIT_ON_CLOSE, rootPane, rootPaneCheckingEnabled
 
Fields inherited from class java.awt.Frame
CROSSHAIR_CURSOR, DEFAULT_CURSOR, E_RESIZE_CURSOR, HAND_CURSOR, ICONIFIED, MAXIMIZED_BOTH, MAXIMIZED_HORIZ, MAXIMIZED_VERT, MOVE_CURSOR, N_RESIZE_CURSOR, NE_RESIZE_CURSOR, NORMAL, NW_RESIZE_CURSOR, S_RESIZE_CURSOR, SE_RESIZE_CURSOR, SW_RESIZE_CURSOR, TEXT_CURSOR, W_RESIZE_CURSOR, WAIT_CURSOR
 
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Fields inherited from interface javax.swing.WindowConstants
DISPOSE_ON_CLOSE, DO_NOTHING_ON_CLOSE, HIDE_ON_CLOSE
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
MultiWindow(Shop sShop, int nViewMode)
          Creates a new MultiWindow for the given Shop and initializes the viewmode.
 
Method Summary
protected  void addAllDisplays()
          Sets the displays of all open SalesPoints according to the current view mode.
private  void addSalesPoint_InternalFrame(SalesPoint sp)
          Opens a DesktopFrame for a SalesPoint.
private  void addSalesPoint_Tab(SalesPoint sp)
          Opens a TabbedFrame for a SalesPoint.
private  void addSalesPoint_Window(SalesPoint sp)
          Opens a DisplayFrame for a SalesPoint.
 void addSalesPointDisplay(SalesPoint sp)
          Opens a display for a SalesPoint according to the current view mode.
 void arrangeFrames(int nArrangement)
          Sets the arrangement of the frames in the MultiWindow.
 void backupOffscreenBuffer(javax.swing.JComponent cmp, int surroundingX, int surroundingY)
          Backup the offscreenbuffer for preventing paintimmediately calls form corrupting paint operations, which are in progress
 void clearOffscreenBuffer(javax.swing.JComponent cmp, int surroundingX, int surroundingY)
          Clears the offscreen buffer
 void closeSalesPointDisplay(SalesPoint sp)
          Closes a SalesPoint's display as removeSalesPointDisplay(SalesPoint) does.
protected  javax.swing.JDesktopPane createDesktopPane()
          Creates and returns the JPanel which is used as content pane in DESKTOP_VIEW view mode.
protected  javax.swing.JPanel createFramePane()
          Creates and returns the JPanel which is used as content pane in WINDOW_VIEW view mode.
protected  IconTabbedPane createTabbedPane()
          Creates and returns the IconTabbedPane which is used as content pane in TABBED_VIEW view mode.
 MenuSheet getCurrentMenuSheet()
          Gets the current global MenuSheet.
protected  javax.swing.JDesktopPane getDesktopPane()
          Returns the JDesktopPane to be added to the content pane in DESKTOP_VIEW view mode.
 javax.swing.JPanel getDragLayer()
          get the drag layer of this frame
protected  javax.swing.JPanel getFramePane()
          Returns the JPanel to be added to the content pane in WINDOW_VIEW view mode.
private  Display getInternalFrame(SalesPoint sp)
          Tries to retrieve a DesktopFrame for a given SalesPoint.
private  java.lang.Object getMenusheetLock()
          get the menusheet lock
 javax.swing.JPanel getModalLayer()
          get the modal layer of this frame
 MenuSheet getMultiWindowMenuSheet()
          Returns the MultiWindow management MenuSheet for this MultiWindow.
 Display getNewInternalFrame(SalesPoint sp)
          Creates and returns a new DesktopFrame for a SalesPoint.
 Display getNewTab(SalesPoint sp)
          Creates and returns a new TabbedFame for a SalesPoint.
 Display getNewWindow(SalesPoint sp)
          Creates and returns a new DisplayFrame for a SalesPoint.
 javax.swing.JPanel getPopupLayer()
          get the popup layer of this frame
protected  javax.swing.JPanel getStatusBar()
          create the status bar and register PersistenceStateListener
private  Display getTab(SalesPoint sp)
          Tries to retrieve a TabbedFrame for a given SalesPoint.
protected  IconTabbedPane getTabbedPane()
          Returns the IconTabbedPane to be added to the content pane in TABBED_VIEW view mode.
 int getViewMode()
          Gets the current view mode.
private  Display getWindow(SalesPoint sp)
          Tries to retrieve a DisplayFrame for a given SalesPoint.
private  void paintWindowBackground(java.awt.Graphics graphics, javax.swing.JComponent c)
          Paint the main window background
protected  void prepareNewContentPane(int viewMode)
          Prepares the MultiWindow's content pane for a new view mode.
(package private)  void registerAction(MultiWindow.MultiWindowAction mwa)
          Internal communications method: Register a MultiWindowAction so that it can be properly serialized.
protected  void removeAllDisplays()
          Closes the displays of all open SalesPoints.
private  void removeSalesPoint_InternalFrame(SalesPoint sp)
          Closes the DeskopFrame of a SalesPoint.
private  void removeSalesPoint_Tab(SalesPoint sp)
          Closes the TabbedFrame of a SalesPoint.
private  void removeSalesPoint_Window(SalesPoint sp)
          Closes the MultiWindow.DisplayFrame of a SalesPoint.
private  void removeSalesPointDisplay(SalesPoint sp)
          Closes a display for a SalesPoint.
 void restoreOffscreenBuffer(javax.swing.JComponent cmp)
          restore the offscreenbuffer which was backed up by backupOffscreenBuffer(JComponent, int, int)
private  void runAndWait(java.lang.Thread t)
          As Swing is not threadsafe, removing a tab or an internal frame might cause an ArrayIndexOutOfBoundsException.
private  void setAppropriateDisplay(SalesPoint sp, int mode)
          Prepares the SalesPoint's display according to a view mode.
protected  void setDefaultLayeredPane()
          We need to setup a Layoutmanager to layout our additional panes in z-order to take up the entire frame because of a weak implementation in RootLayout of JRootPane: "Note: This is laying out the children in the layeredPane, technically, these are not our children."
protected  void setDefaultLayers()
          prepare and set the frames popup layer
 void setDefaultMenuSheet()
          Sets the default MenuSheet.
 void setMenuSheet(MenuSheet msNewMenuSheet)
          Sets the given MenuSheet as a global MenuSheet in the MultiWindow.
protected  void setMergeBefore(java.lang.String sMergeBefore)
          Sets the value of m_sMergeBefore.
 void setSecondMenuSheet(MenuSheet ms)
          Merges the MultiWindow's MenuSheet with a second one.
 void setViewMode(int viewMode)
          Sets a new view mode.
 void stateChanged(javax.swing.event.ChangeEvent evt)
          Implementation of the method in ChangeListener.
private  void updateMenuBar(java.awt.Component cmpTab)
           
 
Methods inherited from class javax.swing.JFrame
addImpl, createRootPane, frameInit, getAccessibleContext, getContentPane, getDefaultCloseOperation, getGlassPane, getGraphics, getJMenuBar, getLayeredPane, getRootPane, getTransferHandler, isDefaultLookAndFeelDecorated, isRootPaneCheckingEnabled, paramString, processWindowEvent, remove, repaint, setContentPane, setDefaultCloseOperation, setDefaultLookAndFeelDecorated, setGlassPane, setIconImage, setJMenuBar, setLayeredPane, setLayout, setRootPane, setRootPaneCheckingEnabled, setTransferHandler, update
 
Methods inherited from class java.awt.Frame
addNotify, getCursorType, getExtendedState, getFrames, getIconImage, getMaximizedBounds, getMenuBar, getState, getTitle, isResizable, isUndecorated, remove, removeNotify, setCursor, setExtendedState, setMaximizedBounds, setMenuBar, setResizable, setState, setTitle, setUndecorated
 
Methods inherited from class java.awt.Window
addPropertyChangeListener, addPropertyChangeListener, addWindowFocusListener, addWindowListener, addWindowStateListener, applyResourceBundle, applyResourceBundle, createBufferStrategy, createBufferStrategy, dispose, getBufferStrategy, getFocusableWindowState, getFocusCycleRootAncestor, getFocusOwner, getFocusTraversalKeys, getGraphicsConfiguration, getIconImages, getInputContext, getListeners, getLocale, getModalExclusionType, getMostRecentFocusOwner, getOwnedWindows, getOwner, getOwnerlessWindows, getToolkit, getWarningString, getWindowFocusListeners, getWindowListeners, getWindows, getWindowStateListeners, hide, isActive, isAlwaysOnTop, isAlwaysOnTopSupported, isFocusableWindow, isFocusCycleRoot, isFocused, isLocationByPlatform, isShowing, pack, postEvent, processEvent, processWindowFocusEvent, processWindowStateEvent, removeWindowFocusListener, removeWindowListener, removeWindowStateListener, reshape, setAlwaysOnTop, setBounds, setBounds, setCursor, setFocusableWindowState, setFocusCycleRoot, setIconImages, setLocationByPlatform, setLocationRelativeTo, setMinimumSize, setModalExclusionType, setSize, setSize, setVisible, show, toBack, toFront
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getAlignmentX, getAlignmentY, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalPolicy, getInsets, getLayout, getMaximumSize, getMinimumSize, getMousePosition, getPreferredSize, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paint, paintComponents, preferredSize, print, printComponents, processContainerEvent, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusTraversalKeys, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setFont, 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, contains, createImage, createImage, createVolatileImage, createVolatileImage, disable, disableEvents, dispatchEvent, enable, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBaseline, getBaselineResizeBehavior, getBounds, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getHeight, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocation, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getSize, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isDoubleBuffered, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isPreferredSizeSet, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, prepareImage, prepareImage, printAll, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, processMouseWheelEvent, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resize, resize, setBackground, setComponentOrientation, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeysEnabled, setForeground, setIgnoreRepaint, setLocale, setLocation, setLocation, setMaximumSize, setName, setPreferredSize, show, size, toString, transferFocus, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.awt.MenuContainer
getFont, postEvent
 

Field Detail

currentWindowBackground

private java.awt.image.BufferedImage currentWindowBackground
Currently used background image


currentWindowImage

private java.awt.image.BufferedImage currentWindowImage
Currently used foreground image


m_jcShopComponent

private javax.swing.JComponent m_jcShopComponent
The main Component for this MultiWindow. Will be set according to view mode.


m_jpFramePane

private javax.swing.JPanel m_jpFramePane
The main Component for this MultiWindow in FRAME view mode, i.e. Displays are DisplayFrames.


m_jtpTabPane

private IconTabbedPane m_jtpTabPane
The main Component for this MultiWindow in TAB view mode, i.e. Displays are TabbedFrames.


m_jdpDesktopPane

private javax.swing.JDesktopPane m_jdpDesktopPane
The main Component for this MultiWindow in DESKTOP view mode, i.e. Displays are DesktopFrames.


m_popupLayer

private javax.swing.JPanel m_popupLayer
The popup layer


m_modalLayer

private javax.swing.JPanel m_modalLayer
the modal layer


m_dragLayer

private javax.swing.JPanel m_dragLayer
the popup layer


m_statusBar

private javax.swing.JPanel m_statusBar
The statusbar in the bottom


m_nViewMode

private int m_nViewMode
Current view mode.


m_nArrangement

private int m_nArrangement
Current frame arrangement. Frames can be arranged OVERLAPPED, HORIZONTALLY or VERTICALLY.


m_mpjdfDisplayFrames

private java.util.HashMap<java.lang.Integer,JDisplayFrame> m_mpjdfDisplayFrames
The map of currently open DisplayFrames. The keys are the frames' ID.


m_mpjtdTabDisplays

private java.util.HashMap<java.lang.Integer,JTabDisplay> m_mpjtdTabDisplays
The map of currently open TabbedFrames. The keys are the frames' ID.


m_mpjidInternalDisplays

private java.util.HashMap<java.lang.Integer,JInternalDisplay> m_mpjidInternalDisplays
The map of currently open DesktopFrames. The keys are the frames' ID.


m_msCurrentMenuSheet

private MenuSheet m_msCurrentMenuSheet
The currently set global MenuSheet.


m_nSelectedFrame

private java.lang.Integer m_nSelectedFrame
The ID of the currently selected frame. Used when arranging frames

See Also:
arrangeFrames(int)

m_lActions

private java.util.LinkedList<MultiWindow.MultiWindowAction> m_lActions
The MultiWindowActions registered with this MultiWindow. Necessary to keep reference to the actions after save/restore


offscreenBufferBackup

private java.awt.image.BufferedImage offscreenBufferBackup
Backup of the in memory offscreen buffer. used for paintimmediately issues


volatileOffscreenBufferBackup

private java.awt.image.BufferedImage volatileOffscreenBufferBackup
backup of the in vram offscreen buffer. used fpr paintimmediately issues


menusheetLock

private java.lang.Object menusheetLock
menusheet lock


m_sMergeBefore

protected java.lang.String m_sMergeBefore
Contains the tag of the MultiWindow's MenuSheet, in front of which the active SalesPoint's MenuSheet should be merged when in tabbed view mode.
The default implementation is null, so SalesPoint's menus appear behind all Shop's menus. It is also possible to use setMergeBefore(String) to change this variable's value.

See Also:
setSecondMenuSheet(org.salespointframework.core.MenuSheet)

m_shShop

private Shop m_shShop
Reference to the Shop for which the MultiWindow was created.


WINDOW_VIEW

public static final int WINDOW_VIEW
Constant for the window view mode. Should be used as parameter for setViewMode(int) and for recognizing the return values of getViewMode().

See Also:
Constant Field Values

TABBED_VIEW

public static final int TABBED_VIEW
Constant for the tabbed view mode. Should be used as parameter for setViewMode(int) and for recognizing the return values of getViewMode().

See Also:
Constant Field Values

DESKTOP_VIEW

public static final int DESKTOP_VIEW
Constant for the desktop view mode. Should be used as parameter for setViewMode(int) and for recognizing the return values of getViewMode().

See Also:
Constant Field Values

NONE

private static final int NONE
No view mode yet.

See Also:
Constant Field Values

OVERLAPPED

public static final int OVERLAPPED
Constant for cascaded arrangement of the frames in window or desktop view mode. Should be used as parameter for arrangeFrames(int).

See Also:
Constant Field Values

TILED_VERTICALLY

public static final int TILED_VERTICALLY
Constant for vertically tiled arrangement of the frames in window or desktop view mode. Should be used as parameter for arrangeFrames(int).

See Also:
Constant Field Values

TILED_HORIZONTALLY

public static final int TILED_HORIZONTALLY
Constant for horizontally tiled arrangement of the frames in window or desktop view mode. Should be used as parameter for arrangeFrames(int).

See Also:
Constant Field Values

MULTIWINDOW_MENU_TAG

public static final java.lang.String MULTIWINDOW_MENU_TAG
Constant used as tag for the MultiWindowMenu. Use this constant to gain access to the menu and manipulate it.

See Also:
Constant Field Values

WINDOW_MENU_TAG

public static final java.lang.String WINDOW_MENU_TAG
Constant used as tag for the "Window" menu option. Use this constant to gain access to the menu and manipulate it.

See Also:
Constant Field Values

TABBED_MENU_TAG

public static final java.lang.String TABBED_MENU_TAG
Constant used as tag for the "Tabbed" menu option. Use this constant to gain access to the menu and manipulate it.

See Also:
Constant Field Values

DESKTOP_MENU_TAG

public static final java.lang.String DESKTOP_MENU_TAG
Constant used as tag for the "Desktop" menu option. Use this constant to gain access to the menu and manipulate it.

See Also:
Constant Field Values

SEPARATOR_TAG

public static final java.lang.String SEPARATOR_TAG
Constant used as tag for the separator in the multi window menu. Use this constant to gain access to the menu and manipulate it.

See Also:
Constant Field Values

CASCADE_MENU_TAG

public static final java.lang.String CASCADE_MENU_TAG
Constant used as tag for the "Cascade" option. Use this constant to gain access to the menu and manipulate it.

See Also:
Constant Field Values

TILE_HORIZ_MENU_TAG

public static final java.lang.String TILE_HORIZ_MENU_TAG
Constant used as tag for the "Tile horizontally" option. Use this constant to gain access to the menu and manipulate it.

See Also:
Constant Field Values

TILE_VERT_MENU_TAG

public static final java.lang.String TILE_VERT_MENU_TAG
Constant used as tag for the "Tile vertically" option. Use this constant to gain access to the menu and manipulate it.

See Also:
Constant Field Values

HORIZONTAL_ICON

private static final javax.swing.ImageIcon HORIZONTAL_ICON
Icon MenuItem "Tile horizontally".


VERTICAL_ICON

private static final javax.swing.ImageIcon VERTICAL_ICON
Icon MenuItem "Tile vertically".


CASCADE_ICON

private static final javax.swing.ImageIcon CASCADE_ICON
Icon MenuItem "Cascade".

Constructor Detail

MultiWindow

public MultiWindow(Shop sShop,
                   int nViewMode)
Creates a new MultiWindow for the given Shop and initializes the viewmode. The MultiWindow's caption will be the Shop's frame title.

Parameters:
sShop - the Shop for which the MultiWindow is created
nViewMode - the initial view mode
Method Detail

registerAction

void registerAction(MultiWindow.MultiWindowAction mwa)
Internal communications method: Register a MultiWindowAction so that it can be properly serialized. Externally implemented MultiWindowActions will otherwise be lost after save/restore.

Parameters:
mwa - the action to be registered

setDefaultLayeredPane

protected void setDefaultLayeredPane()
We need to setup a Layoutmanager to layout our additional panes in z-order to take up the entire frame because of a weak implementation in RootLayout of JRootPane: "Note: This is laying out the children in the layeredPane, technically, these are not our children." so we just need to layout our additional layers and let menubar and contentpane untouched


setDefaultLayers

protected void setDefaultLayers()
prepare and set the frames popup layer


getPopupLayer

public javax.swing.JPanel getPopupLayer()
get the popup layer of this frame

Returns:
a JPanel

getModalLayer

public javax.swing.JPanel getModalLayer()
get the modal layer of this frame

Returns:
a JPanel

getDragLayer

public javax.swing.JPanel getDragLayer()
get the drag layer of this frame

Returns:
a JPanel

getMultiWindowMenuSheet

public MenuSheet getMultiWindowMenuSheet()
Returns the MultiWindow management MenuSheet for this MultiWindow.

The MultiWindow management MenuSheet contains the following items for managing the look of the MultiWindow:

Item text Item tag Item action Comments
Window WINDOW_MENU_TAG Change to Window view. Executes WindowAction. All SalesPoints will have their displays converted to DisplayFrames, i.e. all SalesPoints are shown in a separate window.
Tabbed TABBED_MENU_TAG Change to Tab view. Executes TabAction. All SalesPoints will have their displays converted to TabbedFrames, i.e. the MultiFrame will contain a row of tabs each of which displays a SalesPoint. The SalesPoint's menus will be merged with the Shop's menu.
See also setSecondMenuSheet(org.salespointframework.core.MenuSheet)
Desktop DESKTOP_MENU_TAG Change to Desktop view. Executes DesktopAction. All SalesPoints will have their displays converted to DesktopFrames, i.e. all SalesPoints are shown in a separate window. But in contrast to Window view mode the SalesPoints cannot moved around the whole screen but only within the borders of the MultiWindow.
Separator SEPARATOR_TAG None.
Cascade CASCADE_MENU_TAG Cascade the Displays. Is ignored in tabbed view mode. Executes CascadeAction.
Tile horizontally TILE_HORIZ_MENU_TAG Tile internal frames horizontally. Is ignored in tabbed view mode. Executes TileHorizontallyAction.
Tile vertically TILE_VERT_MENU_TAG Tile internal frames vertically. Is ignored in tabbed view mode. Executes TileVerticallyAction.

This method is used by setDefaultMenuSheet().

Note: When adding new MenuSheetItems make sure the Actions are not implemented as anonymous inner classes as this causes problems on serialization. See MultiWindowAction for details.

Returns:
a MenuSheet representing the default MultiWindow menu

getMenusheetLock

private java.lang.Object getMenusheetLock()
get the menusheet lock


setDefaultMenuSheet

public void setDefaultMenuSheet()
Sets the default MenuSheet.

This method uses getMultiWindowMenuSheet() to get the MenuSheet to be set. The actual setting of the MenuSheet is performed by setMenuSheet(org.salespointframework.core.MenuSheet)


setMenuSheet

public void setMenuSheet(MenuSheet msNewMenuSheet)
Sets the given MenuSheet as a global MenuSheet in the MultiWindow.

Parameters:
msNewMenuSheet - the MenuSheet to be set

setSecondMenuSheet

public void setSecondMenuSheet(MenuSheet ms)
Merges the MultiWindow's MenuSheet with a second one.

The position of the inserted MenuSheet is determined from the m_sMergeBefore variable. The MultiWindow's very MenuSheet object will not be changed, only the MenuSheet's view is altered.

This method is used to insert SalesPoint's MenuSheets into the MultiFrame's MenuSheet when in tabbed view mode, because tabs cannot contain menus. The actual merging is done by MenuSheet.mergePeers(org.salespointframework.core.MenuSheet, java.lang.String).

Parameters:
ms - The MenuSheet to be added.
See Also:
setMergeBefore(java.lang.String)

setMergeBefore

protected void setMergeBefore(java.lang.String sMergeBefore)
Sets the value of m_sMergeBefore.

This variable contains a menu tag, in front of which a second MenuSheet will be added when executing setSecondMenuSheet(org.salespointframework.core.MenuSheet)

Parameters:
sMergeBefore - the menu's tag in front of which a second MenuSheet should be added

getCurrentMenuSheet

public MenuSheet getCurrentMenuSheet()
Gets the current global MenuSheet.


getViewMode

public int getViewMode()
Gets the current view mode.

Returns:
an int value representing the view mode
See Also:
WINDOW_VIEW, TABBED_VIEW, DESKTOP_VIEW

setViewMode

public void setViewMode(int viewMode)
Sets a new view mode.

When setting a new view mode, all open displays are closed, the MultiWindow's content pane is prepared for the new view mode and all displays that have been closed are converted and added according to the new view mode.

Parameters:
viewMode - the view mode to be set
See Also:
WINDOW_VIEW, TABBED_VIEW, DESKTOP_VIEW

prepareNewContentPane

protected void prepareNewContentPane(int viewMode)
Prepares the MultiWindow's content pane for a new view mode.

In fact, not the content pane directly is set. Instead an appropriate JComponent is added to the content pane.

View mode Set Component
WINDOW_VIEW Adds the JComponent that is returned by getFramePane(), by default an empty JPanel.
TABBED_VIEW Adds the JComponent that is returned by getTabbedPane(), by default a IconTabbedPane.
DESKTOP_VIEW Adds the JComponent that is returned by getDesktopPane(), by default a JDesktopPane.

Parameters:
viewMode - the view mode to be prepared

getStatusBar

protected javax.swing.JPanel getStatusBar()
create the status bar and register PersistenceStateListener

Returns:
statusbar panel

clearOffscreenBuffer

public void clearOffscreenBuffer(javax.swing.JComponent cmp,
                                 int surroundingX,
                                 int surroundingY)
Clears the offscreen buffer

Parameters:
cmp - only size is needed
surroundingX - x space
surroundingY - y space

backupOffscreenBuffer

public void backupOffscreenBuffer(javax.swing.JComponent cmp,
                                  int surroundingX,
                                  int surroundingY)
Backup the offscreenbuffer for preventing paintimmediately calls form corrupting paint operations, which are in progress

Parameters:
cmp - the component you wish to paintimmediately
surroundingX - additional space to backup
surroundingY - additional space to backup

restoreOffscreenBuffer

public void restoreOffscreenBuffer(javax.swing.JComponent cmp)
restore the offscreenbuffer which was backed up by backupOffscreenBuffer(JComponent, int, int)

Parameters:
cmp, - component which just called paintimmediately

paintWindowBackground

private void paintWindowBackground(java.awt.Graphics graphics,
                                   javax.swing.JComponent c)
Paint the main window background

Parameters:
graphics -
c -

getTabbedPane

protected IconTabbedPane getTabbedPane()
Returns the IconTabbedPane to be added to the content pane in TABBED_VIEW view mode.


createTabbedPane

protected IconTabbedPane createTabbedPane()
Creates and returns the IconTabbedPane which is used as content pane in TABBED_VIEW view mode.


getDesktopPane

protected javax.swing.JDesktopPane getDesktopPane()
Returns the JDesktopPane to be added to the content pane in DESKTOP_VIEW view mode.


createDesktopPane

protected javax.swing.JDesktopPane createDesktopPane()
Creates and returns the JPanel which is used as content pane in DESKTOP_VIEW view mode.


getFramePane

protected javax.swing.JPanel getFramePane()
Returns the JPanel to be added to the content pane in WINDOW_VIEW view mode.


createFramePane

protected javax.swing.JPanel createFramePane()
Creates and returns the JPanel which is used as content pane in WINDOW_VIEW view mode.


addAllDisplays

protected void addAllDisplays()
Sets the displays of all open SalesPoints according to the current view mode.

This method iterates over the list of active SalesPoints (see Shop.getSalesPoints()) and calls addSalesPointDisplay(org.salespointframework.core.SalesPoint) for each one.


removeAllDisplays

protected void removeAllDisplays()
Closes the displays of all open SalesPoints.

This method iterates over the list of active SalesPoints (see Shop.getSalesPoints()) and calls removeSalesPointDisplay(org.salespointframework.core.SalesPoint) for each one.


addSalesPointDisplay

public void addSalesPointDisplay(SalesPoint sp)
Opens a display for a SalesPoint according to the current view mode.

Depending on the view mode set, this method calls addSalesPoint_Window(org.salespointframework.core.SalesPoint), addSalesPoint_Tab(org.salespointframework.core.SalesPoint) or addSalesPoint_InternalFrame(org.salespointframework.core.SalesPoint).

Parameters:
sp - the SalesPoint for which to add a Display.

removeSalesPointDisplay

private void removeSalesPointDisplay(SalesPoint sp)
Closes a display for a SalesPoint. The SalesPoint itself will not be closed.

Depending on the view mode set, this method calls addSalesPoint_Window(SalesPoint), addSalesPoint_Tab(SalesPoint) or addSalesPoint_InternalFrame(SalesPoint).

This method assumes, that only displays that match the current view mode are set, e.g. no JDisplayFrame must be set if the view mode is tabbed view and TabbedFrames are expected.

Parameters:
sp - the SalesPoint for which to add a Display.

closeSalesPointDisplay

public void closeSalesPointDisplay(SalesPoint sp)
Closes a SalesPoint's display as removeSalesPointDisplay(SalesPoint) does. Additionally all displays that have been saved for this SalesPoint will be deleted.

Parameters:
sp - the SalesPoint for which to close the display.

addSalesPoint_Window

private void addSalesPoint_Window(SalesPoint sp)
Opens a DisplayFrame for a SalesPoint.

This includes converting the Display that is currently assigned to the SalesPoint and making it visible.

Parameters:
sp - the SalesPoint for which to open a Display.

removeSalesPoint_Window

private void removeSalesPoint_Window(SalesPoint sp)
Closes the MultiWindow.DisplayFrame of a SalesPoint.

Parameters:
sp - the SalesPoint for which to close the display.

addSalesPoint_Tab

private void addSalesPoint_Tab(SalesPoint sp)
Opens a TabbedFrame for a SalesPoint.

This includes converting the Display that is currently assigned to the SalesPoint, making it visible and attaching it to the MultiWindow which must be able to display tabs.

Parameters:
sp - the SalesPoint for which to open a Display.

removeSalesPoint_Tab

private void removeSalesPoint_Tab(SalesPoint sp)
Closes the TabbedFrame of a SalesPoint.

Parameters:
sp - the SalesPoint for which to close the display.

addSalesPoint_InternalFrame

private void addSalesPoint_InternalFrame(SalesPoint sp)
Opens a DesktopFrame for a SalesPoint.

This includes converting the Display that is currently assigned to the SalesPoint, making it visible and attaching it to the MultiWindow which must be able to display JInternalFrames.

Parameters:
sp - the SalesPoint for which to open a Display.

removeSalesPoint_InternalFrame

private void removeSalesPoint_InternalFrame(SalesPoint sp)
Closes the DeskopFrame of a SalesPoint.

Parameters:
sp - the SalesPoint for which to close the display.

setAppropriateDisplay

private void setAppropriateDisplay(SalesPoint sp,
                                   int mode)
                            throws java.lang.InterruptedException
Prepares the SalesPoint's display according to a view mode.

Depending on the desired view mode, a DisplayFrame, TabbedFrame or DesktopFrame for the SalesPoint is retrieved or created. Then the FormSheet, the MenuSheet and the bounds are copied from the old to the new display. Finally the new display is attached to the SalesPoint.

Parameters:
sp - the SalesPoint for which to change the display type
mode - the view mode to be prepared
Throws:
java.lang.InterruptedException

arrangeFrames

public void arrangeFrames(int nArrangement)
Sets the arrangement of the frames in the MultiWindow.

If in window or desktop viewing mode, the frames will be rearranged. In tabbed mode nothing happens.

Parameters:
nArrangement - the new Arrangement
See Also:
OVERLAPPED, TILED_HORIZONTALLY, TILED_VERTICALLY

getNewTab

public Display getNewTab(SalesPoint sp)
Creates and returns a new TabbedFame for a SalesPoint.

Parameters:
sp - the SalesPoint for which to create the display
Returns:
the created display

getTab

private Display getTab(SalesPoint sp)
Tries to retrieve a TabbedFrame for a given SalesPoint. If no such display exists a new one is created using getNewTab(SalesPoint).

Parameters:
sp - the SalesPoint for which to retrieve the display
Returns:
the retrieved display

getNewInternalFrame

public Display getNewInternalFrame(SalesPoint sp)
Creates and returns a new DesktopFrame for a SalesPoint.

Parameters:
sp - the SalesPoint for which to create the display
Returns:
the created display

getInternalFrame

private Display getInternalFrame(SalesPoint sp)
Tries to retrieve a DesktopFrame for a given SalesPoint. If no such display exists a new one is created using getNewInternalFrame(SalesPoint).

Parameters:
sp - the SalesPoint for which to retrieve the display
Returns:
the retrieved display

getNewWindow

public Display getNewWindow(SalesPoint sp)
Creates and returns a new DisplayFrame for a SalesPoint.

Parameters:
sp - the SalesPoint for which to create the display
Returns:
the created display

getWindow

private Display getWindow(SalesPoint sp)
Tries to retrieve a DisplayFrame for a given SalesPoint. If no such display exists a new one is created using getNewWindow(SalesPoint).

Parameters:
sp - the SalesPoint for which to retrieve the display
Returns:
the retrieved display

stateChanged

public void stateChanged(javax.swing.event.ChangeEvent evt)
Implementation of the method in ChangeListener.

This method is invoked when Tabs in tabbed mode are changed. This is to ensure that always the correct second MenuSheet is set.

ATTENTION: This method is public as an implementation detail and must not be called directly!

Specified by:
stateChanged in interface javax.swing.event.ChangeListener

updateMenuBar

private void updateMenuBar(java.awt.Component cmpTab)

runAndWait

private void runAndWait(java.lang.Thread t)
As Swing is not threadsafe, removing a tab or an internal frame might cause an ArrayIndexOutOfBoundsException. Swing periodically starts a an event-dispatching thread, which might also affect the UI. If a frame or tab is being removed when the event dispatch thread has already started, Swing might try to access components that are not part of the Shop Window any more and therefore causes the exception. To prevent this, invokeLater() is used. It causes the thread which it receives as argument to be executed by the the event-dispatching thread.