de.sciss.common
Class BasicMenuFactory

java.lang.Object
  extended by de.sciss.gui.MenuItem
      extended by de.sciss.gui.MenuGroup
          extended by de.sciss.gui.MenuRoot
              extended by de.sciss.common.BasicMenuFactory
All Implemented Interfaces:
DocumentListener, MenuNode, java.util.EventListener

public abstract class BasicMenuFactory
extends MenuRoot
implements DocumentListener

JMenus cannot be added to more than one frame. Since on MacOS there's one global menu for all the application windows we need to 'duplicate' a menu prototype. Synchronizing all menus is accomplished by using the same action objects for all menu copies. However when items are added or removed, synchronization needs to be performed manually. That's the point about this class.

There can be only one instance of MenuFactory for the application, and that will be created by the Main class.

Version:
0.71, 26-Aug-08
Author:
Hanns Holger Rutz

Nested Class Summary
protected  class BasicMenuFactory.ActionOpenRecent
           
 class BasicMenuFactory.ActionPreferences
          Action to be attached to the Preference item of the Edit menu.
 class BasicMenuFactory.ActionShowWindow
           
 
Nested classes/interfaces inherited from class de.sciss.gui.MenuItem
MenuItem.Realized
 
Nested classes/interfaces inherited from interface de.sciss.gui.MenuNode
MenuNode.DummyAction
 
Field Summary
protected  BasicMenuFactory.ActionOpenRecent actionOpenRecent
           
static int MENU_SHORTCUT
          KeyStroke modifier mask representing the platform's default menu accelerator (e.g.
protected  MenuGroup mgRecent
           
protected  PathList openRecentPaths
           
 
Fields inherited from class de.sciss.gui.MenuGroup
collElements, mapElements
 
Fields inherited from class de.sciss.gui.MenuItem
mapRealized
 
Fields inherited from interface de.sciss.gui.MenuNode
IDENTIFIER
 
Constructor Summary
BasicMenuFactory(BasicApplication app)
          The constructor is called only once by the Main class and will create a prototype main menu from which all copies are derived.
 
Method Summary
protected static java.lang.String abbrName(java.lang.String name)
           
protected abstract  void addMenuItems()
           
 void addRecent(java.io.File path)
           
 void addToWindowMenu(javax.swing.Action a)
           
 ProcessingThread closeAll(boolean force, Flag confirmed)
           
protected  BasicMenuFactory.ActionOpenRecent createOpenRecentAction(java.lang.String name, java.io.File path)
           
 void documentAdded(DocumentEvent e)
          Notifies the listener that a document has been created and added to the list of open documents.
 void documentFocussed(DocumentEvent e)
          Notifies the listener that a the active document has been switched.
 void documentRemoved(DocumentEvent e)
          Notifies the listener that a document has been removed from the list of open documents and was destroyed.
 BasicApplication getApplication()
           
protected abstract  javax.swing.Action getOpenAction()
           
 java.lang.String getResourceString(java.lang.String key)
           
 void init()
           
abstract  void openDocument(java.io.File f)
           
 void removeFromWindowMenu(javax.swing.Action a)
           
 void setSelectedWindow(javax.swing.Action a)
           
abstract  void showPreferences()
           
 
Methods inherited from class de.sciss.gui.MenuRoot
createBar, createComponent
 
Methods inherited from class de.sciss.gui.MenuGroup
add, add, addSeparator, create, destroy, get, getByAction, indexOf, put, putMimic, remove, remove
 
Methods inherited from class de.sciss.gui.MenuItem
getAction, getAction, getID, getRealized, put, remove, setEnabled
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

MENU_SHORTCUT

public static final int MENU_SHORTCUT
KeyStroke modifier mask representing the platform's default menu accelerator (e.g. Apple-key on Mac, Ctrl on Windows).

See Also:
Toolkit.getMenuShortcutKeyMask()

mgRecent

protected MenuGroup mgRecent

openRecentPaths

protected final PathList openRecentPaths

actionOpenRecent

protected BasicMenuFactory.ActionOpenRecent actionOpenRecent
Constructor Detail

BasicMenuFactory

public BasicMenuFactory(BasicApplication app)
The constructor is called only once by the Main class and will create a prototype main menu from which all copies are derived.

Method Detail

init

public void init()

getApplication

public BasicApplication getApplication()

closeAll

public ProcessingThread closeAll(boolean force,
                                 Flag confirmed)

createOpenRecentAction

protected BasicMenuFactory.ActionOpenRecent createOpenRecentAction(java.lang.String name,
                                                                   java.io.File path)

addMenuItems

protected abstract void addMenuItems()

showPreferences

public abstract void showPreferences()

getOpenAction

protected abstract javax.swing.Action getOpenAction()

openDocument

public abstract void openDocument(java.io.File f)

addRecent

public void addRecent(java.io.File path)

getResourceString

public java.lang.String getResourceString(java.lang.String key)

addToWindowMenu

public void addToWindowMenu(javax.swing.Action a)

removeFromWindowMenu

public void removeFromWindowMenu(javax.swing.Action a)

setSelectedWindow

public void setSelectedWindow(javax.swing.Action a)

documentAdded

public void documentAdded(DocumentEvent e)
Description copied from interface: DocumentListener
Notifies the listener that a document has been created and added to the list of open documents.

Specified by:
documentAdded in interface DocumentListener
Parameters:
e - the event describing the change

documentRemoved

public void documentRemoved(DocumentEvent e)
Description copied from interface: DocumentListener
Notifies the listener that a document has been removed from the list of open documents and was destroyed.

Specified by:
documentRemoved in interface DocumentListener
Parameters:
e - the event describing the change

documentFocussed

public void documentFocussed(DocumentEvent e)
Description copied from interface: DocumentListener
Notifies the listener that a the active document has been switched. e.getDocument will return the newly active document (or null, if no document is active any more).

Specified by:
documentFocussed in interface DocumentListener
Parameters:
e - the event describing the change

abbrName

protected static java.lang.String abbrName(java.lang.String name)