Class 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.

    • 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()
      • openRecentPaths

        protected final PathList openRecentPaths
    • 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()
      • 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)