org.jhotdraw.app
Class DefaultOSXApplication

java.lang.Object
  extended by org.jhotdraw.beans.AbstractBean
      extended by org.jhotdraw.app.AbstractApplication
          extended by org.jhotdraw.app.DefaultOSXApplication
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, Application

public class DefaultOSXApplication
extends AbstractApplication

DefaultOSXApplication handles the lifecycle of Views using a Mac OS X document interface.

An application consists of a screen menu bar and JFrames for the Views. The application also provides floating toolbars and palette windows for the views.

The life cycle of the application is tied to the screen menu bar. Choosing the quit action in the screen menu bar quits the application.

The screen menu bar has the following standard menus:

 "Application-Name" File Window
The first menu, is the application menu. It has the following standard menu items:
  About "Application-Name" (AboutAction.ID)
  -
  Preferences... (AbstractPreferencesAction.ID)
  -
  Services
  -
  Hide "Application-Name"
  Hide Others
  Show All
  -
  Quit "Application-Name" (ExitAction.ID)
 
The file menu has the following standard menu items:
  New (NewAction.ID})
  Open... (OpenAction.ID})
  Open Recent > "Filename" (OpenRecentAction.ID)
  -
  Close (CloseAction.ID)
  Save (SaveAction.ID)
  Save As... (SaveAsAction.ID)
  -
  Print... (PrintAction.ID)
 
The window menu has the following standard menu items:
  Minimize (MinimizeAction.ID)
  Zoom (MaximizeAction.ID)
  -
  "Filename" (FocusAction.ID)
 
The menus provided by the ApplicationModel are inserted between the file menu and the window menu. In case the application model supplies a menu with the title "Help", it is inserted after the window menu.

Version:
$Id: DefaultOSXApplication.java 575 2009-10-18 11:26:50Z rawcoder $
Author:
Werner Randelshofer
See Also:
Serialized Form

Nested Class Summary
private  class DefaultOSXApplication.FrameHandler
          Updates the modifedState of the frame.
private  class DefaultOSXApplication.OpenRecentMenuHandler
          Updates the menu items in the "Open Recent" file menu.
private  class DefaultOSXApplication.WindowMenuHandler
          Updates the menu items in the "Open Recent" file menu.
 
Field Summary
private  java.util.LinkedList<javax.swing.Action> paletteActions
           
private  OSXPaletteHandler paletteHandler
           
private  java.util.prefs.Preferences prefs
           
 
Fields inherited from class org.jhotdraw.app.AbstractApplication
labels, VIEW_COUNT_PROPERTY
 
Fields inherited from class org.jhotdraw.beans.AbstractBean
propertySupport
 
Fields inherited from interface org.jhotdraw.app.Application
ACTIVE_VIEW_PROPERTY
 
Constructor Summary
DefaultOSXApplication()
          Creates a new instance.
 
Method Summary
 void addPalette(java.awt.Window palette)
          Adds a palette window to the application.
 void addWindow(java.awt.Window window, View view)
          Adds a (non-palette) window to the application.
 void configure(java.lang.String[] args)
          Configures the application using the provided arguments array.
protected  javax.swing.JMenu createFileMenu(View view)
           
protected  javax.swing.JMenuBar createMenuBar(View p)
          Creates a menu bar.
protected  javax.swing.JMenu createWindowMenu(View view)
           
 void dispose(View p)
          This is a convenience method for removing a view and disposing it.
 java.awt.Component getComponent()
          Returns the application component.
 void hide(View p)
          Hides a view.
 void init()
          Initializes the application.
protected  void initApplicationActions()
           
protected  void initLookAndFeel()
           
protected  void initPalettes(java.util.LinkedList<javax.swing.Action> paletteActions)
           
protected  void initScreenMenuBar()
           
protected  void initViewActions(View p)
           
 boolean isSharingToolsAmongViews()
          Returns true, if this application shares tools among multiple views.
 void launch(java.lang.String[] args)
          Launches the application from the main method.
 void removePalette(java.awt.Window palette)
          Removes a palette window from the application.
 void removeWindow(java.awt.Window window)
          Removes a (non-palette) window from the application.
 void show(View view)
          Shows a view.
protected  void updateViewTitle(View p, javax.swing.JFrame f)
          Updates the title of a view and displays it in the given frame.
 
Methods inherited from class org.jhotdraw.app.AbstractApplication
add, addRecentFile, basicCreateView, clearRecentFiles, createContainer, createView, getActiveView, getCopyright, getModel, getName, getVersion, initLabels, isEnabled, recentFiles, remove, setActiveView, setEnabled, setModel, start, stop, views
 
Methods inherited from class org.jhotdraw.beans.AbstractBean
addPropertyChangeListener, addPropertyChangeListener, clone, firePropertyChange, firePropertyChange, firePropertyChange, getPropertyChangeListeners, removePropertyChangeListener, removePropertyChangeListener
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.jhotdraw.app.Application
addPropertyChangeListener, removePropertyChangeListener
 

Field Detail

paletteHandler

private OSXPaletteHandler paletteHandler

prefs

private java.util.prefs.Preferences prefs

paletteActions

private java.util.LinkedList<javax.swing.Action> paletteActions
Constructor Detail

DefaultOSXApplication

public DefaultOSXApplication()
Creates a new instance.

Method Detail

init

public void init()
Description copied from interface: Application
Initializes the application. configure() should have been invoked before the application is inited. Alternatively an application can be configured using setter methods.

Specified by:
init in interface Application
Overrides:
init in class AbstractApplication

launch

public void launch(java.lang.String[] args)
Description copied from interface: Application
Launches the application from the main method. This method is typically invoked on the main Thread. This will invoke configure() on the current thread and then init() and start() on the AWT Event Dispatcher Thread.

Specified by:
launch in interface Application
Overrides:
launch in class AbstractApplication

configure

public void configure(java.lang.String[] args)
Description copied from interface: Application
Configures the application using the provided arguments array.

Specified by:
configure in interface Application
Overrides:
configure in class AbstractApplication

initLookAndFeel

protected void initLookAndFeel()

initApplicationActions

protected void initApplicationActions()

initViewActions

protected void initViewActions(View p)
Specified by:
initViewActions in class AbstractApplication

dispose

public void dispose(View p)
Description copied from interface: Application
This is a convenience method for removing a view and disposing it.

Specified by:
dispose in interface Application
Overrides:
dispose in class AbstractApplication

addPalette

public void addPalette(java.awt.Window palette)
Description copied from interface: Application
Adds a palette window to the application.

Specified by:
addPalette in interface Application
Overrides:
addPalette in class AbstractApplication

removePalette

public void removePalette(java.awt.Window palette)
Description copied from interface: Application
Removes a palette window from the application.

Specified by:
removePalette in interface Application
Overrides:
removePalette in class AbstractApplication

addWindow

public void addWindow(java.awt.Window window,
                      View view)
Description copied from interface: Application
Adds a (non-palette) window to the application.

Specified by:
addWindow in interface Application
Overrides:
addWindow in class AbstractApplication
Parameters:
window - The window.
view - The View to which this window is associated, or null, if the window is associated to the application.

removeWindow

public void removeWindow(java.awt.Window window)
Description copied from interface: Application
Removes a (non-palette) window from the application.

Specified by:
removeWindow in interface Application
Overrides:
removeWindow in class AbstractApplication

show

public void show(View view)
Description copied from interface: Application
Shows a view.


updateViewTitle

protected void updateViewTitle(View p,
                               javax.swing.JFrame f)
Updates the title of a view and displays it in the given frame.

Parameters:
p - The view.
f - The frame.

hide

public void hide(View p)
Description copied from interface: Application
Hides a view.


createMenuBar

protected javax.swing.JMenuBar createMenuBar(View p)
Creates a menu bar.

Parameters:
p - The view for which the menu bar is created. This may be null if the menu bar is attached to an application component, such as the screen menu bar or a floating palette window.

createWindowMenu

protected javax.swing.JMenu createWindowMenu(View view)

createFileMenu

protected javax.swing.JMenu createFileMenu(View view)

initScreenMenuBar

protected void initScreenMenuBar()

initPalettes

protected void initPalettes(java.util.LinkedList<javax.swing.Action> paletteActions)

isSharingToolsAmongViews

public boolean isSharingToolsAmongViews()
Description copied from interface: Application
Returns true, if this application shares tools among multiple views.


getComponent

public java.awt.Component getComponent()
Description copied from interface: Application
Returns the application component. This may return null, if the application is not represented by a component of its own on the user interface.