JHotDraw 7.0.9

org.jhotdraw.application
Class AbstractDocumentOrientedApplication

java.lang.Object
  extended by application.Application
      extended by org.jhotdraw.application.AbstractDocumentOrientedApplication
All Implemented Interfaces:
DocumentOrientedApplication
Direct Known Subclasses:
AbstractMDIApplication, AbstractOSXApplication, AbstractSDIApplication

public abstract class AbstractDocumentOrientedApplication
extends application.Application
implements DocumentOrientedApplication

Base class for DocumentOrientedApplications.

Version:
2007-07-08 Reworked for JSR-296 version 0.42.
1.1 2006-05-01 System.exit(0) explicitly in method stop().
1.0 October 4, 2005 Created.
Author:
Werner Randelshofer

Field Summary
static java.lang.String PROP_CURRENT_VIEW
           
static java.lang.String PROP_VIEW_COUNT
           
 
Constructor Summary
AbstractDocumentOrientedApplication()
           
 
Method Summary
 void add(DocumentView v)
          Adds a view to this application.
 void addPalette(java.awt.Window w)
          Adds a palette window to the application.
 void addRecentFile(java.io.File file)
          Appends a file to the list of recent files.
 void clearRecentFiles()
          Clears the list of recent files.
protected  javax.swing.ActionMap createActionMap()
          Creates an action map for actions which haven not been defined using the
protected  javax.swing.JMenu createEditMenu(DocumentView v)
          Creates the edit menu.
protected  javax.swing.JMenu createFileMenu(DocumentView v)
          Creates the file menu.
protected  javax.swing.JMenu createHelpMenu(DocumentView v)
          Creates the help menu.
protected  javax.swing.JMenuBar createMenuBar(DocumentView v, java.util.List<javax.swing.Action> toolBarActions)
          Creates a menu bar.
protected  java.util.LinkedList<javax.swing.JMenu> createMenus(DocumentView v)
          Creates the menus for the application.
protected  java.util.LinkedList<javax.swing.JToolBar> createToolBars(DocumentView v)
          Creates the toolbars for the application.
 DocumentView createView()
          Creates a new view.
protected  javax.swing.JMenu createViewMenu(DocumentView v)
          Creates the view menu.
protected  javax.swing.JMenu createWindowMenu(DocumentView v)
          Creates the window menu.
protected  void destroyView(DocumentView v)
          Destroys the view.
 javax.swing.Action getAction(java.lang.Object key)
          Convenience method for getting an action with the specified key from the ActionMap of the application.
abstract  DocumentView getCurrentView()
          Returns the current view.
protected  ResourceMap getFrameworkResourceMap()
          Convenience method for getting the resource map of the JHotDraw application framework.
protected  ResourceMap getResourceMap()
          Convenience method for getting the resource map of the current application.
abstract  java.lang.Class getViewClass()
           
 java.util.List<DocumentView> getViews()
          Returns a read only collection of all the views of this application.
abstract  void hide(DocumentView v)
          Hides a view.
protected  void initActionMap()
          Initializes the action map of the application.
static void initAWT(java.lang.String[] args)
          Initializes AWT before it is started.
protected  void initDefaults()
          Initializes the defaults of the application..
 void initialize(java.lang.String[] args)
          Initializes the application.
protected  void initLookAndFeel()
          Initializes the look and feel of the application.
protected  void initMainFrame()
          Initializes the main frame of the application - if there is one.
protected  void initRecentFiles()
          Initializes the recent files of the application.
protected  void initView(DocumentView v)
          Initializes the view.
abstract  boolean isEditorShared()
          Returns true, if this application shares an editor among multiple views.
 boolean isEnabled()
          Returns true, if the application is globally enabled.
static
<T extends AbstractDocumentOrientedApplication>
void
launch(java.lang.Class<T> applicationClass, java.lang.String[] args)
          Launches the application.
 java.util.List<java.io.File> recentFiles()
          Returns the recently opened files.
 void remove(DocumentView v)
          Removes a view from this application.
 void removePalette(java.awt.Window w)
          Removes a palette window from the application.
 void setEnabled(boolean newValue)
          Globally enable/disable the application.
abstract  void show(DocumentView v)
          Shows a view.
 void shutdown()
          Stops the application without saving any unsaved getViews.
 void startup()
          Starts the application.
 void updateName(DocumentView v)
          Updates the name of the supplied view.
protected  void updateOpenRecentMenu(javax.swing.JMenu openRecentMenu)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.jhotdraw.application.DocumentOrientedApplication
addPropertyChangeListener, getComponent, removePropertyChangeListener
 

Field Detail

PROP_VIEW_COUNT

public static final java.lang.String PROP_VIEW_COUNT
See Also:
Constant Field Values

PROP_CURRENT_VIEW

public static final java.lang.String PROP_CURRENT_VIEW
See Also:
Constant Field Values
Constructor Detail

AbstractDocumentOrientedApplication

public AbstractDocumentOrientedApplication()
Method Detail

launch

public static <T extends AbstractDocumentOrientedApplication> void launch(java.lang.Class<T> applicationClass,
                                                                          java.lang.String[] args)
Launches the application. This method must be called from the Main thread, before AWT is started.


initAWT

public static void initAWT(java.lang.String[] args)
Initializes AWT before it is started. This method is called by by @code launch} on the Main thread.


initialize

public void initialize(java.lang.String[] args)
Initializes the application. If you override this method, make sure to call initDefaults.

Specified by:
initialize in interface DocumentOrientedApplication

initDefaults

protected void initDefaults()
Initializes the defaults of the application..


initMainFrame

protected void initMainFrame()
Initializes the main frame of the application - if there is one.


initRecentFiles

protected void initRecentFiles()
Initializes the recent files of the application. This method is called by initDefaults.


initActionMap

protected void initActionMap()
Initializes the action map of the application. This method is called by initDefaults.


initLookAndFeel

protected void initLookAndFeel()
Initializes the look and feel of the application. This method is called by initDefaults.


startup

public void startup()
Starts the application. This usually creates a new view, and adds it to the application. initialize() must have been invoked before the application is started.

Specified by:
startup in interface DocumentOrientedApplication

shutdown

public void shutdown()
Stops the application without saving any unsaved getViews. initialize() must have been invoked before the application is stopped.

Specified by:
shutdown in interface DocumentOrientedApplication

createActionMap

protected javax.swing.ActionMap createActionMap()
Creates an action map for actions which haven not been defined using the


getAction

public javax.swing.Action getAction(java.lang.Object key)
Convenience method for getting an action with the specified key from the ActionMap of the application.

Specified by:
getAction in interface DocumentOrientedApplication

createView

public final DocumentView createView()
Creates a new view.

Specified by:
createView in interface DocumentOrientedApplication

getViewClass

public abstract java.lang.Class getViewClass()

initView

protected void initView(DocumentView v)
Initializes the view.


destroyView

protected void destroyView(DocumentView v)
Destroys the view.


createToolBars

protected java.util.LinkedList<javax.swing.JToolBar> createToolBars(DocumentView v)
Creates the toolbars for the application.


createMenuBar

protected javax.swing.JMenuBar createMenuBar(DocumentView v,
                                             java.util.List<javax.swing.Action> toolBarActions)
Creates a menu bar.


createMenus

protected java.util.LinkedList<javax.swing.JMenu> createMenus(DocumentView v)
Creates the menus for the application. Most applications will put the menu bars into JMenuBar.


createFileMenu

protected javax.swing.JMenu createFileMenu(DocumentView v)
Creates the file menu. Return null, if you don't want this menu.


updateOpenRecentMenu

protected void updateOpenRecentMenu(javax.swing.JMenu openRecentMenu)

createEditMenu

protected javax.swing.JMenu createEditMenu(DocumentView v)
Creates the edit menu. Return null, if you don't want this menu.


createViewMenu

protected javax.swing.JMenu createViewMenu(DocumentView v)
Creates the view menu. Return null, if you don't want this menu.  @param v The document view.

Parameters:
toolbarActions - Toolbar actions. This value is null, if the toolbar actions do not get into this menu.

createWindowMenu

protected javax.swing.JMenu createWindowMenu(DocumentView v)
Creates the window menu. Return null, if you don't want this menu.  @param v The document view.

Parameters:
toolbarActions - Toolbar actions. This value is null, if the toolbar actions do not get into this menu.

createHelpMenu

protected javax.swing.JMenu createHelpMenu(DocumentView v)
Creates the help menu. Return null, if you don't want this menu.


add

public void add(DocumentView v)
Adds a view to this application. Calls init on the view. Fires a "viewCount" property change event. Invokes method setApplication(this) on the view object.

Specified by:
add in interface DocumentOrientedApplication

remove

public void remove(DocumentView v)
Removes a view from this application. Calls destroy on the view. Fires a "documentCount" property change event. Invokes method setApplication(null) on the view object.

Specified by:
remove in interface DocumentOrientedApplication

getViews

public java.util.List<DocumentView> getViews()
Returns a read only collection of all the views of this application.

Specified by:
getViews in interface DocumentOrientedApplication

show

public abstract void show(DocumentView v)
Shows a view. Calls start on the view.

Specified by:
show in interface DocumentOrientedApplication

hide

public abstract void hide(DocumentView v)
Hides a view. Calls stop on the view.

Specified by:
hide in interface DocumentOrientedApplication

getCurrentView

public abstract DocumentView getCurrentView()
Returns the current view. This is used by Actions which act on the current DocumentView. Current view is null, if the application has no visible view.

This is a bound property.

Specified by:
getCurrentView in interface DocumentOrientedApplication

isEnabled

public boolean isEnabled()
Returns true, if the application is globally enabled.

Specified by:
isEnabled in interface DocumentOrientedApplication

setEnabled

public void setEnabled(boolean newValue)
Globally enable/disable the application.

Specified by:
setEnabled in interface DocumentOrientedApplication

isEditorShared

public abstract boolean isEditorShared()
Returns true, if this application shares an editor among multiple views. This is true for MDI and OSX applications. This is false for SDI applications.

Specified by:
isEditorShared in interface DocumentOrientedApplication

recentFiles

public java.util.List<java.io.File> recentFiles()
Returns the recently opened files. By convention, this is an immutable list.

Specified by:
recentFiles in interface DocumentOrientedApplication

clearRecentFiles

public void clearRecentFiles()
Clears the list of recent files. This fires a property change event for the property "recentFiles".

Specified by:
clearRecentFiles in interface DocumentOrientedApplication

addRecentFile

public void addRecentFile(java.io.File file)
Appends a file to the list of recent files. This fires a property change event for the property "recentFiles".

Specified by:
addRecentFile in interface DocumentOrientedApplication

addPalette

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

Specified by:
addPalette in interface DocumentOrientedApplication

removePalette

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

Specified by:
removePalette in interface DocumentOrientedApplication

updateName

public void updateName(DocumentView v)
Updates the name of the supplied view.


getResourceMap

protected ResourceMap getResourceMap()
Convenience method for getting the resource map of the current application.


getFrameworkResourceMap

protected ResourceMap getFrameworkResourceMap()
Convenience method for getting the resource map of the JHotDraw application framework.


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