diva.gui.tutorial
Class MDIApplication

java.lang.Object
  extended by diva.gui.tutorial.AbstractApplication
      extended by diva.gui.tutorial.MDIApplication
All Implemented Interfaces:
Application
Direct Known Subclasses:
MDIApplicationTutorial

public abstract class MDIApplication
extends AbstractApplication

An abstract superclass for applications that use an MDI (multiple document interface) style of presentation. This class manages the interaction between documents of the application, and the frame that they are displayed in. For example, keeping documents and views in sync, handling focus changes, and so on. The context must implement MDIContext for this to work properly. Note: this application only manages one view per document. If you have multiple views per document, you will need to implement the view-document mapping yourself.

Version:
$Id: MDIApplication.java 41477 2006-03-29 00:03:58Z cxh $
Author:
John Reekie

Nested Class Summary
private  class MDIApplication.MDIViewListener
           
 
Field Summary
private  java.util.HashMap _viewMap
          A mapping from content panes to views
 
Constructor Summary
MDIApplication(MDIContext context)
          Create an MDI application in the given MDI context
 
Method Summary
 void addView(View v)
          Add a view to the list of views currently known by this application.
abstract  View createView(Document d)
          Given a document, create a new view which displays that document.
 MDIContext getMDIContext()
          Get the MDI frame -- type-specific version of getApplicationFrame().
 View getView(javax.swing.JComponent c)
          Get the Document displayed by the given component.
 void removeView(View v)
          Remove a view from the list of view currently known by this application.
 void setCurrentView(View v)
          Set the given document to be the current document, and raise the internal window that corresponds to that component.
 
Methods inherited from class diva.gui.tutorial.AbstractApplication
actions, addAction, addDocument, addDocumentListener, addMenuItem, addMenuItem, addPropertyChangeListener, addToolBarButton, addToolBarButton, addViewListener, closeDocument, closeView, documentList, getAction, getAppContext, getClipboard, getCurrentView, getDocumentFactory, getResources, getStoragePolicy, getTitle, isVisible, removeDocument, removeDocumentListener, removePropertyChangeListener, removeViewListener, setAppContext, setClipboard, setDocumentFactory, setStoragePolicy, setVisible, showError, viewList, viewList
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_viewMap

private java.util.HashMap _viewMap
A mapping from content panes to views

Constructor Detail

MDIApplication

public MDIApplication(MDIContext context)
Create an MDI application in the given MDI context

Method Detail

addView

public void addView(View v)
Description copied from class: AbstractApplication
Add a view to the list of views currently known by this application. Fire a view list event to registered listeners. Throw an exception if the view is already in the list of views.

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

createView

public abstract View createView(Document d)
Given a document, create a new view which displays that document. Subclasses must implement this method to create, initialize, and then return a View object that wraps a JComponent.

Specified by:
createView in interface Application
Specified by:
createView in class AbstractApplication

getMDIContext

public MDIContext getMDIContext()
Get the MDI frame -- type-specific version of getApplicationFrame().


getView

public View getView(javax.swing.JComponent c)
Get the Document displayed by the given component.


removeView

public void removeView(View v)
Remove a view from the list of view currently known by this application. Fire a document list event to registered listeners. Throw an exception if the document is not known. This method assumes that setCurrentView will be called subsequently on another view.

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

setCurrentView

public void setCurrentView(View v)
Set the given document to be the current document, and raise the internal window that corresponds to that component.

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