JHotDraw 7.0.9

org.jhotdraw.app
Interface Project

All Known Subinterfaces:
ExportableProject
All Known Implementing Classes:
AbstractProject, DrawProject, NetProject, ODGProject, PertProject, SVGProject, TeddyProject

public interface Project

A project represents a work space for a document or a set of related documents within an Application.

After a project has been initialized using init(), either method clear() must be called or method read, in order to fully initialize a Project.

FIXME - Maybe Project should be renamed to Workspace.

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

Method Summary
 void addPropertyChangeListener(java.beans.PropertyChangeListener l)
          Adds a property change listener.
 void clear()
          Clears the project.
 void dispose()
          Gets rid of all the resources of the project.
 void execute(java.lang.Runnable worker)
          Executes the specified runnable on the worker thread of the project.
 javax.swing.Action getAction(java.lang.String id)
          Returns the action with the specified id.
 Application getApplication()
          Gets the application to which this project belongs.
 javax.swing.JComponent getComponent()
          Returns the visual component of the project.
 java.io.File getFile()
          Returns the project file.
 int getMultipleOpenId()
          Returns the multiple open id.
 javax.swing.JFileChooser getOpenChooser()
          Gets the open file chooser for the project.
 javax.swing.JFileChooser getSaveChooser()
          Gets the save file chooser for the project.
 boolean hasUnsavedChanges()
          Returns true, if the project has unsaved changes.
 void init()
          Initializes the project.
 boolean isEnabled()
          Returns the enabled state of the project.
 boolean isShowing()
          This is used by Application to keep track if a project is showing.
 void markChangesAsSaved()
          Marks all changes as saved.
 void putAction(java.lang.String id, javax.swing.Action action)
          Puts an action with the specified id.
 void read(java.io.File f)
          Reads the project from the specified file.
 void removePropertyChangeListener(java.beans.PropertyChangeListener l)
          Removes a property change listener.
 void setApplication(Application newValue)
          Sets the application of the project.
 void setEnabled(boolean newValue)
          Sets the enabled state of the project.
 void setFile(java.io.File newValue)
          Sets the project file.
 void setMultipleOpenId(int newValue)
          Sets the multiple open id.
 void setShowing(boolean newValue)
          This is used by Application to keep track if a project is showing.
 void write(java.io.File f)
          Writes the project to the specified file.
 

Method Detail

getApplication

Application getApplication()
Gets the application to which this project belongs.


setApplication

void setApplication(Application newValue)
Sets the application of the project. By convention, this is only invoked by Application.addProject() and Application.removeProject(). This is a bound property.


getComponent

javax.swing.JComponent getComponent()
Returns the visual component of the project.


getFile

java.io.File getFile()
Returns the project file.


setFile

void setFile(java.io.File newValue)
Sets the project file. This is a bound property.


isEnabled

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


setEnabled

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


write

void write(java.io.File f)
           throws java.io.IOException
Writes the project to the specified file. By convention this is never invoked on the AWT Event Dispatcher Thread.

Throws:
java.io.IOException

read

void read(java.io.File f)
          throws java.io.IOException
Reads the project from the specified file. By convention this is never invoked on the AWT Event Dispatcher Thread.

Throws:
java.io.IOException

clear

void clear()
Clears the project.


getOpenChooser

javax.swing.JFileChooser getOpenChooser()
Gets the open file chooser for the project.


getSaveChooser

javax.swing.JFileChooser getSaveChooser()
Gets the save file chooser for the project.


hasUnsavedChanges

boolean hasUnsavedChanges()
Returns true, if the project has unsaved changes. This is a bound property.


markChangesAsSaved

void markChangesAsSaved()
Marks all changes as saved. This changes the state of hasUnsavedChanges to false.


execute

void execute(java.lang.Runnable worker)
Executes the specified runnable on the worker thread of the project. Execution is perfomred sequentially in the same sequence as the runnables have been passed to this method.


init

void init()
Initializes the project. This is invoked right before the application shows the project. A project must not consume many resources before method init() is called. This is crucial for the responsivenes of an application.

After a project has been initialized using init(), either method clear() must be called or method read, in order to fully initialize a Project.


dispose

void dispose()
Gets rid of all the resources of the project. No other methods should be invoked on the project afterwards. A project must not consume many resources after method dispose() has been called. This is crucial for the responsivenes of an application.


getAction

javax.swing.Action getAction(java.lang.String id)
Returns the action with the specified id.


putAction

void putAction(java.lang.String id,
               javax.swing.Action action)
Puts an action with the specified id.


addPropertyChangeListener

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


removePropertyChangeListener

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


setMultipleOpenId

void setMultipleOpenId(int newValue)
Sets the multiple open id. The id is used to help distinguish multiply opened projects. The id should be displayed in the title of the project.


getMultipleOpenId

int getMultipleOpenId()
Returns the multiple open id. If a project is open only once this should be 1.


isShowing

boolean isShowing()
This is used by Application to keep track if a project is showing.


setShowing

void setShowing(boolean newValue)
This is used by Application to keep track if a project is showing.


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