JHotDraw 7.5.1

org.jhotdraw.app
Class OSXApplication

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

public class OSXApplication
extends AbstractApplication

OSXApplication handles the lifecycle of multiple Views using a Mac OS X application interface.

This user interface created by this application follows the guidelines given in the Apple Human Interface Guidelines.

An application of this type can open multiple Views. Each view is shown in a separate JFrame.

Conceptually all views share a global 'screen menu bar'. In Swing this is implemented as multiple JMenuBar instances. There is one JMenuBar for each opened JFrame, and a special JMenuBar which is shown when all views of the application are closed.

The application also provides floating toolbars and palette windows for the views.

In order for the screen menu bar and the floating palettes to function properly, it is essential that all code which opens JFrame's, JDialog's or JWindow's calls addWindow/Palette and removeWindow/Palette on the application object.

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 (NewFileAction.ID})
  Open... (OpenFileAction.ID})
  Open Recent > "Filename" (OpenRecentFileAction.ID)
  -
  Close (CloseFileAction.ID)
  Save (SaveFileAction.ID)
  Save As... (SaveFileAsAction.ID)
  -
  Print... (PrintFileAction.ID)
 
The window menu has the following standard menu items:
  Minimize (MinimizeWindowAction.ID)
  Zoom (MaximizeWindowAction.ID)
  -
  "Filename" (FocusWindowAction.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: OSXApplication.java 668 2010-07-28 21:22:39Z rawcoder $
Author:
Werner Randelshofer
See Also:
Serialized Form

Field Summary
 
Fields inherited from class org.jhotdraw.app.AbstractApplication
labels, model, VIEW_COUNT_PROPERTY
 
Fields inherited from class org.jhotdraw.beans.AbstractBean
propertySupport
 
Fields inherited from interface org.jhotdraw.app.Application
ACTIVE_VIEW_PROPERTY, RECENT_URIS_PROPERTY
 
Constructor Summary
OSXApplication()
          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.
 javax.swing.JMenu createEditMenu(View view)
          Creates an edit menu for the specified view or for the entire application.
 javax.swing.JMenu createFileMenu(View view)
          Creates a file menu for the specified view or for the entire application.
 javax.swing.JMenu createHelpMenu(View p)
          Creates a help menu for the specified view of for the entire application.
protected  javax.swing.JMenuBar createMenuBar(View v)
          Creates a menu bar.
protected  javax.swing.ActionMap createModelActionMap(ApplicationModel mo)
           
protected  javax.swing.ActionMap createViewActionMap(View v)
           
 javax.swing.JMenu createViewMenu(View view)
          Creates a view menu for the specified view or for the entire application.
 javax.swing.JMenu createWindowMenu(View view)
          Creates a window menu for the specified view or for the entire application.
 void dispose(View p)
          This is a convenience method for removing a view and disposing it.
 java.awt.Component getComponent()
          Returns the Frame which holds the frameless JMenuBar.
 void hide(View p)
          Hides a view.
 void init()
          Initializes the application.
protected  void initLookAndFeel()
           
protected  void initPalettes(java.util.LinkedList<javax.swing.Action> paletteActions)
           
protected  void initScreenMenuBar()
           
 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.
protected  void setScreenMenuBar(javax.swing.JMenuBar mb)
           
 void show(View view)
          Shows a view.
protected  void updateViewTitle(View v, 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, addAction, addAction, addMenuItem, addRecentURI, basicCreateView, clearRecentURIs, createContainer, createOpenRecentFileMenu, createView, destroy, getAction, getActionMap, getActiveView, getCopyright, getExportChooser, getImportChooser, getModel, getName, getOpenChooser, getRecentURIs, getSaveChooser, getVersion, initLabels, isEnabled, maybeAddSeparator, remove, setActionMap, 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
 

Constructor Detail

OSXApplication

public OSXApplication()
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()

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 v,
                               javax.swing.JFrame f)
Updates the title of a view and displays it in the given frame.

Parameters:
v - 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 v)
Creates a menu bar.


createViewMenu

public javax.swing.JMenu createViewMenu(View view)
Description copied from interface: Application
Creates a view menu for the specified view or for the entire application.

Parameters:
view - A view or null.
Returns:
A JMenu or null, if the menu is empty.

createWindowMenu

public javax.swing.JMenu createWindowMenu(View view)
Description copied from interface: Application
Creates a window menu for the specified view or for the entire application.

Parameters:
view - A view or null.
Returns:
A JMenu or null, if the menu is empty.

createFileMenu

public javax.swing.JMenu createFileMenu(View view)
Description copied from interface: Application
Creates a file menu for the specified view or for the entire application.

Parameters:
view - A view or null.
Returns:
A JMenu or null, if the menu is empty.

createEditMenu

public javax.swing.JMenu createEditMenu(View view)
Description copied from interface: Application
Creates an edit menu for the specified view or for the entire application.

Parameters:
view - A view or null.
Returns:
A JMenu or null, if the menu is empty.

createHelpMenu

public javax.swing.JMenu createHelpMenu(View p)
Description copied from interface: Application
Creates a help menu for the specified view of for the entire application.

Parameters:
p - A view or null.
Returns:
A JMenu or null, if the menu is empty.

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()
Returns the Frame which holds the frameless JMenuBar.


setScreenMenuBar

protected void setScreenMenuBar(javax.swing.JMenuBar mb)

createModelActionMap

protected javax.swing.ActionMap createModelActionMap(ApplicationModel mo)

createViewActionMap

protected javax.swing.ActionMap createViewActionMap(View v)
Specified by:
createViewActionMap in class AbstractApplication

Copyright 1996-2010 (c) by the authors and contributors of the JHotDraw project.
Some rights reserved.