JHotDraw 7.1

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

A DefaultOSXApplication can handle the life cycle of multiple document windows each being presented in a JFrame of its own. The application provides all the functionality needed to work with the document, such as a menu bar, tool bars and palette windows.

OSX stands for Mac OS X Application Document Interface. An OSX application can handle multiple View's at the same time. Each view gets a JFrame of its own. An OSX application has one menu bar, attached to the top of the screen. This 'screen menu bar' is shared by all View's.

DefaultOSXApplication is designed for Mac OS X. It will not work on other platforms.

The screen menu bar has the following standard menus:

 "Application-Name" File Edit Window Help
 
The first menu, is the application menu. It has the following standard menu items. DefaultOSXApplication wires the menu items to the action objects specified in brackets. The preferences menu item is only displayed, if the application has an action with PreferencesAction.ID. The other menu items are always displayed. Menu items without action wiring are generated by Mac OS X and can not be changed.
  About "Application-Name" (AboutAction.ID)
  -
  Preferences... (PreferencesAction.ID)
  -
  Services
  -
  Hide "Application-Name"
  Hide Others
  Show All
  -
  Quit "Application-Name" (ExitAction.ID)
 
The file menu has the following standard menu items. DefaultOSXApplication wires the menu items to the action objects specified in brackets. If the application hasn't an action with the specified ID, the menu item is not displayed. Menu items without action wiring are generated by this class, and can be changed by subclasses.
  New (NewAction.ID)
  Open... (OpenAction.ID)
  Open Recent >
  -
  Close (CloseAction.ID)
  Save (SaveAction.ID)
  Save As... (SaveAsAction.ID)
  Save All
  Revert to Saved (RevertToSavedAction.ID)
  -
  Page Setup... (PrintPageSetupAction.ID)
  Print... (PrintAction.ID)
 
The edit menu has the following standard menu items. DefaultOSXApplication wires the menu items to the action objects specified in brackets. If the application hasn't an action with the specified ID, the menu item is not displayed. Menu items without action wiring are generated by this class, and can be changed by subclasses.
  Undo (UndoAction.ID)
  Redo (RedoAction.ID)
  -
  Cut (CutAction.ID)
  Copy (CopyAction.ID)
  Paste (PasteAction.ID)
  Delete (DeleteAction.ID)
  Select All (SelectAllAction.ID)
 

Version:
1.2 2007-12-25 Added method updateViewTitle.
1.1 2007-01-11 Removed method addStandardActionsTo.
1.0.1 2007-01-02 Floating palettes disappear now if the application looses the focus. 1.0 October 4, 2005 Created.
Author:
Werner Randelshofer
See Also:
Serialized Form

Field Summary
 
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.
protected  void addViewWindowMenuItems(javax.swing.JMenu m, View p)
           
 void addWindow(java.awt.Window window, View p)
          Adds a (regular) window to the application.
 void configure(java.lang.String[] args)
          Configures the application using the provided arguments array.
protected  javax.swing.JMenu createFileMenu(View p)
           
protected  javax.swing.JMenuBar createMenuBar(View p)
          Creates a menu bar.
protected  javax.swing.JMenu createWindowMenu(View p)
           
 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 (regular) window from the application.
 void show(View p)
          Shows a view.
protected  void updateOpenRecentMenu(javax.swing.JMenu openRecentMenu)
           
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, dispose, 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, 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

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

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 p)
Description copied from interface: Application
Adds a (regular) window to the application.

Specified by:
addWindow in interface Application
Overrides:
addWindow in class AbstractApplication
Parameters:
window - The window.
p - 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 (regular) window from the application.

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

show

public void show(View p)
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 p)

addViewWindowMenuItems

protected void addViewWindowMenuItems(javax.swing.JMenu m,
                                      View p)

updateOpenRecentMenu

protected void updateOpenRecentMenu(javax.swing.JMenu openRecentMenu)

createFileMenu

protected javax.swing.JMenu createFileMenu(View p)

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.


Copyright 1996-2007 (c) JHotDraw.org.
Some rights reserved.