http://www.jpicedt.org

jpicedt.ui
Class MDIManager

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

public abstract class MDIManager
extends Object
implements DialogFactory

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 kinds of documents supported:

Since:
jPicEdt 1.3
Version:
$Id: MDIManager.java,v 1.30 2013/07/14 21:20:50 vincentb1 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. the attribute editor or the toolkit palette.
 
Field Summary
static 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 an event is triggered by a PEDrawingBoard
protected  HashMap<PEDrawingBoard,MDIComponent> 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.
static String DOCKABLE_PANEL_TOGGLE
          PropertyChangeEvent's name corresponding to a dockable panel change in visibility
protected  HashMap<String,MDIManager.DockablePanel> dockablePanelsMap
          a hash table used to remember dockable panels added to the desktop, with key=panel's title
static String KEY_MDIMANAGER
          key for persistent storage
static String MDI_CHILDFRAMES
          value for persistent storage
static String MDI_STANDALONEFRAMES
          value for persistent storage
 
Constructor Summary
MDIManager()
           
 
Method Summary
 MDIManager.DockablePanel addDockablePanel(String key, JPanel pane)
          Adds the given pane to the hashtable of dockable panels, then shows it.
 void addDockablePanelPropertyChangeListener(PropertyChangeListener l)
           
 void addDrawingBoard(PEDrawingBoard board)
          Adds a new DrawingBoard component to the list of drawing boards.
abstract  void addMDIComponent(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  MDIComponent createMDIComponent(JComponent pane)
          Factory method that creates a MDIComponent that acts as a wrapper for the given pane.
static MDIManager createMDIManager(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
 Set<PEDrawingBoard> getAllDrawingBoards()
          Returns all opened drawing boards
static String getDefaultManagerName()
           
abstract  Dimension getDesktopSize()
          Returns the dimension of the desktop that hosts the components of this MDIManager.
 Container getDockablePanelFromKey(String key)
          Return the inner pane contained in the dockable panel associated with the given key, or null if none match.
 Set getDockablePanelKeys()
          Returns a set containing all keys (of class "String") that map to a DockablePanel
 int getDrawingBoardCount()
          Returns the number of open boards
 MDIComponent getHostingContainer(PEDrawingBoard board)
          Returns the MDIComponent that contains the given board
static String[] getInstalledMDIManagers()
           
abstract  JMenuItem[] getMenuItems()
          Return an array containing all the menu-items components attached to menubars
abstract  String getName()
           
 void removeDockablePanelPropertyChangeListener(PropertyChangeListener l)
           
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.
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(String title, PEDrawingBoard board)
          Sets the title of the frame/internal frame hosting the given board to the given string.
 void showDockablePanel(String key, boolean visible)
          Set the visible state of the dockable pane with the given key.
 int showDontAskMeAgainConfirmDialog(String message, String title, String dontAskMeAgainKey, int messageType)
          Describe showDontAskMeAgainConfirmDialog method here.
 void showStatus(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(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(PropertyChangeEvent e)
          update currently "selected" menuitem in Toolkit menu
abstract  void updateUndoRedoMenus(String undoName, 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
 
Methods inherited from interface jpicedt.graphic.toolkit.DialogFactory
createCustomizerDialog, createCustomizerDialog, createDialog, showConfirmDialog, showConfirmDialog, showInputDialog, showInputDialog, showInputDialog, showMessageDialog
 

Field Detail

KEY_MDIMANAGER

public static final String KEY_MDIMANAGER
key for persistent storage

See Also:
Constant Field Values

MDI_CHILDFRAMES

public static final String MDI_CHILDFRAMES
value for persistent storage

See Also:
Constant Field Values

MDI_STANDALONEFRAMES

public static final String MDI_STANDALONEFRAMES
value for persistent storage

See Also:
Constant Field Values

ACTIVE_BOARD_CHANGE

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

See Also:
Constant Field Values

DOCKABLE_PANEL_TOGGLE

public static final String DOCKABLE_PANEL_TOGGLE
PropertyChangeEvent's name corresponding to a dockable panel change in visibility

See Also:
Constant Field Values

dockablePanelsMap

protected HashMap<String,MDIManager.DockablePanel> dockablePanelsMap
a hash table used to remember dockable panels added to the desktop, with key=panel's title


boardMap

protected HashMap<PEDrawingBoard,MDIComponent> 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 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(String value,
                                          PEProgressBar progress)
Create an MDIManager according to the given value.

Parameters:
value - one of MDI_CHILDFRAMES or MDI_STANDALONEFRAMES

getInstalledMDIManagers

public static String[] getInstalledMDIManagers()

getDefaultManagerName

public static String getDefaultManagerName()

getName

public abstract String getName()

createMDIComponent

public abstract MDIComponent createMDIComponent(JComponent pane)
Factory method that creates a MDIComponent that acts as a wrapper for the given pane.


addMDIComponent

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


getDesktopSize

public abstract 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(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(String undoName,
                                         String redoName)
update "undo" and "redo" text

Since:
jpicedt 1.3.2

updateWindowMenu

public abstract void updateWindowMenu()
                               throws 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:
MissingResourceException
Since:
PicEdt 1.1

updateToolkitMenu

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


getMenuItems

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


getHostingContainer

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


setHostingContainerTitle

public void setHostingContainerTitle(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 Set<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 MDIManager.DockablePanel addDockablePanel(String key,
                                                 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.
Returns:
the DockablePanel, or null if it was already registered.

toggleDockablePanel

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


showDockablePanel

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


getDockablePanelKeys

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


getDockablePanelFromKey

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


addDockablePanelPropertyChangeListener

public void addDockablePanelPropertyChangeListener(PropertyChangeListener l)

removeDockablePanelPropertyChangeListener

public void removeDockablePanelPropertyChangeListener(PropertyChangeListener l)

showDontAskMeAgainConfirmDialog

public int showDontAskMeAgainConfirmDialog(String message,
                                           String title,
                                           String dontAskMeAgainKey,
                                           int messageType)
Description copied from interface: DialogFactory
Describe showDontAskMeAgainConfirmDialog method here.

Specified by:
showDontAskMeAgainConfirmDialog in interface DialogFactory
Parameters:
message - Un message textuel.
title - voir javax.swing#JOptionPane
dontAskMeAgainKey - une clef de propriété de type jpicedt.ui.dialog.
messageType - voir javax.swing.JOptionPane.
Returns:
voir javax.swing#JOptionPane, renvoie JOptionPane.YES_OPTION ou JOptionPane.NO_OPTION.

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