http://www.jpicedt.org

jpicedt.ui
Class MDIManager

java.lang.Object
  extended by jpicedt.ui.MDIManager
Direct Known Subclasses:
InternalFrameMDIManager, JFrameMDIManager

public abstract class MDIManager
extends java.lang.Object

An abstract class that serves as the superclass for jPicEdt's Multiple Document Interface desktop managers.

Concrete implementation know how to add or remove a document (e.g. a PEDrawingBoard or a DockablePanel) to the MDI interface. Each document is actually contained in a MDIComponent (i.e. either a JFrame or a JInternalFrame), which is created by the factory method createMDIComponent(). The list of MDIComponent's which currently belong to the desktop is hold in separate hash maps, one for each family of documents. There are currently two kind of documents supported:

Since:
jPicEdt 1.3
Version:
$Id: MDIManager.java,v 1.15.2.1 2007/09/02 11:56:30 reynal Exp $
Author:
Sylvain Reynal

Nested Class Summary
protected  class MDIManager.BoardEventHandler
          A handler for events triggered from any PEDrawingBoard, its PECanvas or its EditorKit.
 class MDIManager.DockablePanel
          A wrapper for dockable panels, e.g.
static interface MDIManager.MDIComponent
          A common interface for UI components being hosted by this MDIManager.
 
Field Summary
static java.lang.String ACTIVE_BOARD_CHANGE
          PropertyChangeEvent's name corresponding to a new board being activated
protected  PEDrawingBoard activeBoard
          Reference on the currently active board, or null if no board is currently open.
protected  MDIManager.BoardEventHandler boardEventHandler
          delegate which notifies dockable panels when a an event is triggered by a PEDrawingBoard
protected  java.util.HashMap boardMap
          A hash table used to bind a PEDrawingBoard (the key) and its MDIComponent container (the value) This map plays pretty much the same role as JDesktopPane, but it's able to manage any desktop component implementing the MDIComponent interface, e.g.
protected  java.util.HashMap dockablePanelsMap
          a hash table used to remember dockable panels added to the desktop, with key=panel's title
static java.lang.String KEY_MDIMANAGER
          key for persistent storage
static java.lang.String MDI_CHILDFRAMES
          value for persistent storage
static java.lang.String MDI_STANDALONEFRAMES
          value for persistent storage
 
Constructor Summary
MDIManager()
           
 
Method Summary
 void addDockablePanel(java.lang.String key, javax.swing.JPanel pane)
          Adds the given pane to the hashtable of dockable panels, then shows it.
 void addDrawingBoard(PEDrawingBoard board)
          Adds a new DrawingBoard component to the list of drawing boards.
abstract  void addMDIComponent(MDIManager.MDIComponent c)
          Adds the given component to the desktop of this MDIManager.
abstract  void cascadeDrawingBoards()
          Rearranges all open drawing-boards by cascading them
abstract  void closeBoard(PEDrawingBoard board)
          Ask the given board to close itself
abstract  MDIManager.MDIComponent createMDIComponent(javax.swing.JPanel pane)
          Factory method that creates a MDIComponent that acts as a wrapper for the given pane.
static MDIManager createMDIManager(java.lang.String value, PEProgressBar progress)
          Create an MDIManager according to the given value.
 PopupMenuFactory createPopupMenuFactory()
          Factory method to create a PopupMenuFactory for newly created board
abstract  PEDrawingBoard getActiveDrawingBoard()
          Returns the currently active drawing board
 PEDrawingBoard[] getAllDrawingBoards()
          Returns all opened drawing boards
static java.lang.String getDefaultManagerName()
           
abstract  java.awt.Dimension getDesktopSize()
          Returns the dimension of the desktop that hosts the components of this MDIManager.
 javax.swing.JPanel getDockablePanelFromKey(java.lang.String key)
          Return the inner pane contained in the dockable panel associated with the given key, or null if none match.
 java.util.Set getDockablePanelKeys()
          Returns a set containing all keys (of class "String") that map to a DockablePanel
 int getDrawingBoardCount()
          Returns the number of open boards
 MDIManager.MDIComponent getHostingContainer(PEDrawingBoard board)
          Returns the MDIComponent that contains the given board
static java.lang.String[] getInstalledMDIManagers()
           
abstract  javax.swing.JMenuItem[] getMenuItems()
          Return an array containing all the menu-items components attached to menubars
abstract  java.lang.String getName()
           
protected  boolean removeDrawingBoard(PEDrawingBoard board)
          Remove the given drawing board from the list of open drawing boards, possibly attempting to save its content if necessary, then unregisters any previously registered listener.
 void saveGeometry()
          Saves UI geometry to JPicEdt's preferences.
This implementation saves geometrical properties related to DockablePanel only.
abstract  void selectDrawingBoard(PEDrawingBoard board)
          Selects the given drawing board ; concrete implementation should call show() or any similar method on the MDIComponent (aka container) hosting the given board.
 void setHostingContainerTitle(java.lang.String title, PEDrawingBoard board)
          Sets the title of the frame/internal frame hosting the given board to the given string.
 void showDockablePanel(java.lang.String key, boolean visible)
          Set the visible state of the dockable pane with the given key.
 void showStatus(java.lang.String str)
          Requests that the argument string be displayed in the status bar
abstract  void tileDrawingBoardsHorizontally()
          Tiles all open drawing-boards horizontally
abstract  void tileDrawingBoardsVertically()
          Tiles all open drawing-boards vertically
 void toggleDockablePanel(java.lang.String key)
          Toggle the visible state of the dockable pane with the given key.
 void update()
          Updates local properties from the JPicEdt's preferences (e.g.
abstract  void updateAccelerators()
          Update JMenuItem's accelerators from the key/value pairs stored in JPicEdt's preferences
abstract  void updateFragmentsMenu()
          Updates the "fragments" menu items
abstract  void updateMenuBar()
          Update the content (i.e.
abstract  void updateRecentFilesSubmenu()
          Updates the "recent files" sub-menu items after a frame was saved or opened.
abstract  void updateScriptsMenu()
          Updates the "script" menu items
abstract  void updateToolkitMenu(java.beans.PropertyChangeEvent e)
          update currently "selected" menuitem in Toolkit menu
abstract  void updateUndoRedoMenus(java.lang.String undoName, java.lang.String redoName)
          update "undo" and "redo" text
abstract  void updateWindowMenu()
          Updates the Window menu as soon as an internal frame is opened or closed (this menu keeps tracks of every open internal frames so that the user can activate them quickly by use of a shortcut)
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

KEY_MDIMANAGER

public static final java.lang.String KEY_MDIMANAGER
key for persistent storage

See Also:
Constant Field Values

MDI_CHILDFRAMES

public static final java.lang.String MDI_CHILDFRAMES
value for persistent storage

See Also:
Constant Field Values

MDI_STANDALONEFRAMES

public static final java.lang.String MDI_STANDALONEFRAMES
value for persistent storage

See Also:
Constant Field Values

ACTIVE_BOARD_CHANGE

public static final java.lang.String ACTIVE_BOARD_CHANGE
PropertyChangeEvent's name corresponding to a new board being activated

See Also:
Constant Field Values

dockablePanelsMap

protected java.util.HashMap dockablePanelsMap
a hash table used to remember dockable panels added to the desktop, with key=panel's title


boardMap

protected java.util.HashMap boardMap
A hash table used to bind a PEDrawingBoard (the key) and its MDIComponent container (the value) This map plays pretty much the same role as JDesktopPane, but it's able to manage any desktop component implementing the MDIComponent interface, e.g. JFrame's as well as JInternalFrame's. In particular, since this map holds the list of PEDrawingBoard's together with their hosting MDIComponent, it's at the core of the desktop management, e.g. for adding or removing boards properly.


boardEventHandler

protected MDIManager.BoardEventHandler boardEventHandler
delegate which notifies dockable panels when a an event is triggered by a PEDrawingBoard


activeBoard

protected PEDrawingBoard activeBoard
Reference on the currently active board, or null if no board is currently open. This reference is constantly being updated by MDIDesktopManager when a MDIComponent gets (de)activated, and it contains a PEDrawingBoard.

Constructor Detail

MDIManager

public MDIManager()
Method Detail

createMDIManager

public static MDIManager createMDIManager(java.lang.String value,
                                          PEProgressBar progress)
Create an MDIManager according to the given value.

Parameters:
value - one of MDI_CHILDFRAMES or MDI_STANDALONEFRAMES

getInstalledMDIManagers

public static java.lang.String[] getInstalledMDIManagers()

getDefaultManagerName

public static java.lang.String getDefaultManagerName()

getName

public abstract java.lang.String getName()

createMDIComponent

public abstract MDIManager.MDIComponent createMDIComponent(javax.swing.JPanel pane)
Factory method that creates a MDIComponent that acts as a wrapper for the given pane.


addMDIComponent

public abstract void addMDIComponent(MDIManager.MDIComponent c)
Adds the given component to the desktop of this MDIManager.


getDesktopSize

public abstract java.awt.Dimension getDesktopSize()
Returns the dimension of the desktop that hosts the components of this MDIManager. Depending on the implementation, this may be either the whole screen, or the size of a JFrame containing all the documents.


update

public void update()
Updates local properties from the JPicEdt's preferences (e.g. GUI colours, rendering-hints,...) This implementation update the rendering hints of each currently opened PEDrawingBoard


saveGeometry

public void saveGeometry()
Saves UI geometry to JPicEdt's preferences.
This implementation saves geometrical properties related to DockablePanel only.

See Also:
addDockablePanel(java.lang.String, javax.swing.JPanel), MDIManager.DockablePanel.setVisible(boolean)

showStatus

public void showStatus(java.lang.String str)
Requests that the argument string be displayed in the status bar


createPopupMenuFactory

public PopupMenuFactory createPopupMenuFactory()
Factory method to create a PopupMenuFactory for newly created board


updateAccelerators

public abstract void updateAccelerators()
Update JMenuItem's accelerators from the key/value pairs stored in JPicEdt's preferences


updateMenuBar

public abstract void updateMenuBar()
Update the content (i.e. PEMenu's) of the menu-bar depending on the current state of the MDIManager.


updateRecentFilesSubmenu

public abstract void updateRecentFilesSubmenu()
Updates the "recent files" sub-menu items after a frame was saved or opened.

Since:
PicEdt 1.1

updateScriptsMenu

public abstract void updateScriptsMenu()
Updates the "script" menu items

Since:
jpicedt 1.3.2

updateFragmentsMenu

public abstract void updateFragmentsMenu()
Updates the "fragments" menu items

Since:
jpicedt 1.3.2

updateUndoRedoMenus

public abstract void updateUndoRedoMenus(java.lang.String undoName,
                                         java.lang.String redoName)
update "undo" and "redo" text

Since:
jpicedt 1.3.2

updateWindowMenu

public abstract void updateWindowMenu()
                               throws java.util.MissingResourceException
Updates the Window menu as soon as an internal frame is opened or closed (this menu keeps tracks of every open internal frames so that the user can activate them quickly by use of a shortcut)

Throws:
java.util.MissingResourceException
Since:
PicEdt 1.1

updateToolkitMenu

public abstract void updateToolkitMenu(java.beans.PropertyChangeEvent e)
update currently "selected" menuitem in Toolkit menu


getMenuItems

public abstract javax.swing.JMenuItem[] getMenuItems()
Return an array containing all the menu-items components attached to menubars


getHostingContainer

public MDIManager.MDIComponent getHostingContainer(PEDrawingBoard board)
Returns the MDIComponent that contains the given board


setHostingContainerTitle

public void setHostingContainerTitle(java.lang.String title,
                                     PEDrawingBoard board)
Sets the title of the frame/internal frame hosting the given board to the given string.


addDrawingBoard

public void addDrawingBoard(PEDrawingBoard board)
Adds a new DrawingBoard component to the list of drawing boards. The given board gets wrapped into a MDIComponent beforehands


closeBoard

public abstract void closeBoard(PEDrawingBoard board)
Ask the given board to close itself


removeDrawingBoard

protected boolean removeDrawingBoard(PEDrawingBoard board)
Remove the given drawing board from the list of open drawing boards, possibly attempting to save its content if necessary, then unregisters any previously registered listener. Closing the associated UI (i.e. the MDIComponent) is the responsibility of the caller.

Returns:
false if the operation failed because the action was cancelled by the user

getAllDrawingBoards

public PEDrawingBoard[] getAllDrawingBoards()
Returns all opened drawing boards


selectDrawingBoard

public abstract void selectDrawingBoard(PEDrawingBoard board)
Selects the given drawing board ; concrete implementation should call show() or any similar method on the MDIComponent (aka container) hosting the given board.


getDrawingBoardCount

public int getDrawingBoardCount()
Returns the number of open boards


getActiveDrawingBoard

public abstract PEDrawingBoard getActiveDrawingBoard()
Returns the currently active drawing board


addDockablePanel

public void addDockablePanel(java.lang.String key,
                             javax.swing.JPanel pane)
Adds the given pane to the hashtable of dockable panels, then shows it. If "pane" is an instance of SelectionListener (resp. PropertyChangeListener), it will be notified selection (resp. propery-change) events from any currently opened drawing board.

Parameters:
key - used to retrieve geometrical properties from the JPicEdt's preferences, i.e. "ui." + key + ".visible" for the visible state at init time.

toggleDockablePanel

public void toggleDockablePanel(java.lang.String key)
Toggle the visible state of the dockable pane with the given key.


showDockablePanel

public void showDockablePanel(java.lang.String key,
                              boolean visible)
Set the visible state of the dockable pane with the given key.


getDockablePanelKeys

public java.util.Set getDockablePanelKeys()
Returns a set containing all keys (of class "String") that map to a DockablePanel


getDockablePanelFromKey

public javax.swing.JPanel getDockablePanelFromKey(java.lang.String key)
Return the inner pane contained in the dockable panel associated with the given key, or null if none match.


cascadeDrawingBoards

public abstract void cascadeDrawingBoards()
Rearranges all open drawing-boards by cascading them


tileDrawingBoardsHorizontally

public abstract void tileDrawingBoardsHorizontally()
Tiles all open drawing-boards horizontally


tileDrawingBoardsVertically

public abstract void tileDrawingBoardsVertically()
Tiles all open drawing-boards vertically


http://www.jpicedt.org

Submit a bug : syd@jpicedt.org