JHotDraw 7.0.9

org.jhotdraw.app
Interface Application

All Known Implementing Classes:
AbstractApplication, DefaultAppletApplication, DefaultMDIApplication, DefaultOSXApplication, DefaultSDIApplication

public interface Application

An Application handles the lifecycle of Projects and provides windows to present them on screen. Depending on the document interface style used by the Application, the Application can handle multiple Projects at the same time, or only one.

Typical document interface styles are the Single Document Interface (SDI), the Multiple Document Interface (MDI) and the Mac OS X Application Document Interface (OSX).

Typical usage of this class:

 public class MyMainClass {
     public static void main(String[] args) {
         Application app = new DefaultADIApplication();
         DefaultApplicationModel model = new DefaultApplicationModel();
         model.setName("MyAppliciation");
         model.setVersion("1.0");
         model.setCopyright("Copyright 2006 (c) Werner Randelshofer. All Rights Reserved.");
         model.setProjectClassName("org.jhotdraw.myapplication.MyProject");
         app.setModel(model);
         app.launch(args);
     } 
 

Version:
1.0 October 4, 2005 Created.
Author:
Werner Randelshofer

Method Summary
 void add(Project p)
          Adds a project to this application.
 void addPropertyChangeListener(java.beans.PropertyChangeListener l)
          Adds a property change listener.
 void addRecentFile(java.io.File file)
          Appends a file to the list of recent files.
 void clearRecentFiles()
          Clears the list of recent files.
 void configure(java.lang.String[] args)
          Configures the application using the provided arguments array.
 Project createProject()
          Creates a new project for this application.
 void dispose(Project p)
          This is a convenience method for removing a project and disposing it.
 java.awt.Component getComponent()
          Returns the application component.
 java.lang.String getCopyright()
          Returns the copyright of the application.
 Project getCurrentProject()
          Returns the current project.
 ApplicationModel getModel()
          Returns the application model.
 java.lang.String getName()
          Returns the name of the application.
 java.lang.String getVersion()
          Returns the version of the application.
 void hide(Project p)
          Hides a project.
 void init()
          Initializes the application.
 boolean isEnabled()
          Returns the enabled state of the application.
 boolean isSharingToolsAmongProjects()
          Returns true, if this application shares tools among multiple projects.
 void launch(java.lang.String[] args)
          Launches the application from the main method.
 java.util.Collection<Project> projects()
          Returns a read only collection view of the projects of this application.
 java.util.List<java.io.File> recentFiles()
          Returns the recently opened files.
 void remove(Project p)
          Removes a project from this application and removes it from the users view.
 void removePropertyChangeListener(java.beans.PropertyChangeListener l)
          Removes a property change listener.
 void setEnabled(boolean newValue)
          Sets the enabled state of the application.
 void setModel(ApplicationModel newValue)
          Sets the application model.
 void show(Project p)
          Shows a project.
 void start()
          Starts the application.
 void stop()
          Stops the application without saving any unsaved projects.
 

Method Detail

launch

void launch(java.lang.String[] args)
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.


configure

void configure(java.lang.String[] args)
Configures the application using the provided arguments array.


init

void init()
Initializes the application. configure() should have been invoked before the application is inited. Alternatively an application can be configured using setter methods.


start

void start()
Starts the application. This usually creates a new project, and adds it to the application. init() must have been invoked before the application is started.


stop

void stop()
Stops the application without saving any unsaved projects. init() must have been invoked before the application is stopped.


createProject

Project createProject()
Creates a new project for this application.


add

void add(Project p)
Adds a project to this application. Fires a "documentCount" property change event. Invokes method setApplication(this) on the project object.


remove

void remove(Project p)
Removes a project from this application and removes it from the users view. Fires a "documentCount" property change event. Invokes method setApplication(null) on the project object.


show

void show(Project p)
Shows a project.


hide

void hide(Project p)
Hides a project.


dispose

void dispose(Project p)
This is a convenience method for removing a project and disposing it.


projects

java.util.Collection<Project> projects()
Returns a read only collection view of the projects of this application.


getCurrentProject

Project getCurrentProject()
Returns the current project. This is used for OSXApplication and MDIApplication which share actions among multiple Project instances. Current project may be become null, if the application has no project.

This is a bound property.


isEnabled

boolean isEnabled()
Returns the enabled state of the application.


setEnabled

void setEnabled(boolean newValue)
Sets the enabled state of the application. The enabled state is used to prevent parallel invocation of actions on the application. If an action consists of a sequential part and a concurrent part, it must disable the application only for the sequential part. Actions that act on the application must check in their actionPerformed method whether the application is enabled. If the application is disabled, they must do nothing. If the application is enabled, they must disable the application, perform the action and then enable the application again. This is a bound property.


addPropertyChangeListener

void addPropertyChangeListener(java.beans.PropertyChangeListener l)
Adds a property change listener.


removePropertyChangeListener

void removePropertyChangeListener(java.beans.PropertyChangeListener l)
Removes a property change listener.


getName

java.lang.String getName()
Returns the name of the application.


getVersion

java.lang.String getVersion()
Returns the version of the application.


getCopyright

java.lang.String getCopyright()
Returns the copyright of the application.


setModel

void setModel(ApplicationModel newValue)
Sets the application model.


getModel

ApplicationModel getModel()
Returns the application model.


isSharingToolsAmongProjects

boolean isSharingToolsAmongProjects()
Returns true, if this application shares tools among multiple projects.


getComponent

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


recentFiles

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


addRecentFile

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


clearRecentFiles

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


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