Package diva.gui.tutorial
Class AbstractApplication
- java.lang.Object
-
- diva.gui.tutorial.AbstractApplication
-
- All Implemented Interfaces:
Application
- Direct Known Subclasses:
ApplicationTutorial,MDIApplication
public abstract class AbstractApplication extends java.lang.Object implements Application
An abstract implementation of the Application interface. This class implements the common elements of the Application abstraction, and takes care of listener notification for documents and properties. Concrete subclasses will generally override a number of these methods to add their own behavior. Most importantly, this abstract class does not provide any support for creating documents, or managing the views of those documents. For an example of one way of managing the view associated with a document, see MDIApplication.- Version:
- $Id$
- Author:
- John Reekie
- Pt.AcceptedRating:
- Red
-
-
Constructor Summary
Constructors Constructor Description AbstractApplication(AppContext context)Create an abstract application that resides in the given context (e.g.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Deprecated Methods Modifier and Type Method Description java.util.Iteratoractions()Get an iterator over the names of the actions that are contained by this application.voidaddAction(javax.swing.Action action)Add an action to the table of actions.voidaddDocument(Document d)Add a document to the list of documents currently known by this application.voidaddDocumentListener(javax.swing.event.ListDataListener listener)Add a document listener to this application.javax.swing.JMenuItemaddMenuItem(javax.swing.JMenu menu, java.lang.String label, javax.swing.Action action, int mnemonic, java.lang.String tooltip, boolean isEnabled)Deprecated.Use method in GUIUtilities instead.javax.swing.JMenuItemaddMenuItem(javax.swing.JMenu menu, javax.swing.Action action, int mnemonic, java.lang.String tooltip)Deprecated.Use method in GUIUtilities instead.voidaddPropertyChangeListener(java.beans.PropertyChangeListener listener)Add a property change listener to this application.javax.swing.JButtonaddToolBarButton(javax.swing.JToolBar toolbar, javax.swing.Action action, java.lang.String tooltip, javax.swing.Icon icon)Deprecated.Use method in GUIUtilities instead.javax.swing.JButtonaddToolBarButton(javax.swing.JToolBar toolbar, javax.swing.Action action, java.lang.String tooltip, javax.swing.Icon icon, boolean isEnabled)Deprecated.Use method in GUIUtilities instead.voidaddView(View v)Add a view to the list of views currently known by this application.voidaddViewListener(javax.swing.event.ListDataListener listener)Add a view listener to this application.booleancloseDocument(Document d)Try to close the given document using the storage policy.booleancloseView(View v)Try to close the given view using the storage policy.abstract ViewcreateView(Document d)Create a view to display the given document.java.util.ListdocumentList()Get list of all document objects known by this application.javax.swing.ActiongetAction(java.lang.String name)Get an action by name.AppContextgetAppContext()Get the frame that this application draws itself in.java.awt.datatransfer.ClipboardgetClipboard()Get the clipboard object for this application.ViewgetCurrentView()Get the current view.DocumentFactorygetDocumentFactory()Get the factory that creates new documentsRelativeBundlegetResources()Get the resources object.StoragePolicygetStoragePolicy()Get the storage policy of this application.abstract java.lang.StringgetTitle()Get the title of this applicationbooleanisVisible()Test whether the application frame is visible.voidremoveDocument(Document d)Remove a document from the list of documents currently known by this application, and remove all of the views associated with this document.voidremoveDocumentListener(javax.swing.event.ListDataListener listener)Remove a document list listener from this application.voidremovePropertyChangeListener(java.beans.PropertyChangeListener listener)Remove a property change listener from this application.voidremoveView(View v)Remove a view from the list of views currently known by this application.voidremoveViewListener(javax.swing.event.ListDataListener listener)Remove a view list listener from this application.protected voidsetAppContext(AppContext ac)Set the app context that this application draws itself in.voidsetClipboard(java.awt.datatransfer.Clipboard clipboard)Set the clipboard that is used by this application.voidsetCurrentView(View v)Set the given view to be the current view.protected voidsetDocumentFactory(DocumentFactory df)Set the factory that creates new documents for use by subclasses constructors only.voidsetStoragePolicy(StoragePolicy sp)Set the storage policy of this application, for use by subclass constructors onlyvoidsetVisible(boolean visible)Set the visibility of the application's framevoidshowError(java.lang.String op, java.lang.Exception e)Show an error in a dialog box with stack trace.java.util.ListviewList()Get a list of all view objects known by this application.java.util.ListviewList(Document d)Get a list of all view objects known by this application.
-
-
-
Constructor Detail
-
AbstractApplication
public AbstractApplication(AppContext context)
Create an abstract application that resides in the given context (e.g. a frame or an applet).
-
-
Method Detail
-
actions
public java.util.Iterator actions()
Get an iterator over the names of the actions that are contained by this application.- Specified by:
actionsin interfaceApplication
-
addAction
public void addAction(javax.swing.Action action)
Add an action to the table of actions. Every action known by the application should be added here so it can be retrieved and invoked later.- Specified by:
addActionin interfaceApplication
-
addMenuItem
@Deprecated public javax.swing.JMenuItem addMenuItem(javax.swing.JMenu menu, javax.swing.Action action, int mnemonic, java.lang.String tooltip)Deprecated.Use method in GUIUtilities instead.Add an action to a menu and return the menu item created. If the tool tip is null, use the "tooltip" property already in the action, otherwise add the property to the action. (The mnemonic isn't added.) The new menu item is added to the action as the "menuItem" property. The menu item's text is set using the action's name and is enabled by default.
-
addMenuItem
@Deprecated public javax.swing.JMenuItem addMenuItem(javax.swing.JMenu menu, java.lang.String label, javax.swing.Action action, int mnemonic, java.lang.String tooltip, boolean isEnabled)Deprecated.Use method in GUIUtilities instead.Add an action to a menu and return the menu item created. If the tool tip is null, use the "tooltip" property already in the action, otherwise add the property to the action. (The mnemonic isn't added.) The new menu item is added to the action as the "menuItem" property. The menu item's text is set to be "label", and is disabled or enabled according to "isEnabled."
-
addToolBarButton
@Deprecated public javax.swing.JButton addToolBarButton(javax.swing.JToolBar toolbar, javax.swing.Action action, java.lang.String tooltip, javax.swing.Icon icon)Deprecated.Use method in GUIUtilities instead.Add an action to the toolbar. If the tool tip is null, use the "tooltip" property already in the action, otherwise add the property to the action. The new button is added to the action as the "toolButton" property. The button is enabled by default.
-
addToolBarButton
@Deprecated public javax.swing.JButton addToolBarButton(javax.swing.JToolBar toolbar, javax.swing.Action action, java.lang.String tooltip, javax.swing.Icon icon, boolean isEnabled)Deprecated.Use method in GUIUtilities instead.Add an action to the toolbar. If the tool tip is null, use the "tooltip" property already in the action, otherwise add the property to the action. The new button is added to the action as the "toolButton" property.
-
addPropertyChangeListener
public void addPropertyChangeListener(java.beans.PropertyChangeListener listener)
Add a property change listener to this application. Changes to certain elements of the state will cause all registered property listeners to be notified.- Specified by:
addPropertyChangeListenerin interfaceApplication
-
addDocument
public void addDocument(Document d)
Add a document to the list of documents currently known by this application. Fire a document list event to registered listeners. Throw an exception if the document is already in the list of documents.- Specified by:
addDocumentin interfaceApplication
-
addView
public void addView(View v)
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:
addViewin interfaceApplication
-
addDocumentListener
public void addDocumentListener(javax.swing.event.ListDataListener listener)
Add a document listener to this application. The document listener is in fact a ListDataListener, which will be notified with intervalAdded() and intervalRemoved() events when documents are added or removed, and with a contentsChanged() event when the current document is changed.- Specified by:
addDocumentListenerin interfaceApplication
-
addViewListener
public void addViewListener(javax.swing.event.ListDataListener listener)
Add a view listener to this application. The view listener is in fact a ListDataListener, which will be notified with intervalAdded() and intervalRemoved() events when views are added or removed, and with a contentsChanged() event when the current view is changed.- Specified by:
addViewListenerin interfaceApplication
-
closeDocument
public boolean closeDocument(Document d)
Try to close the given document using the storage policy.- Specified by:
closeDocumentin interfaceApplication
-
closeView
public boolean closeView(View v)
Try to close the given view using the storage policy.- Specified by:
closeViewin interfaceApplication
-
createView
public abstract View createView(Document d)
Create a view to display the given document. The document should already be added to the application. After calling this method, most callers should set this view to be the current view.- Specified by:
createViewin interfaceApplication
-
documentList
public java.util.List documentList()
Get list of all document objects known by this application.- Specified by:
documentListin interfaceApplication
-
getAction
public javax.swing.Action getAction(java.lang.String name)
Get an action by name.- Specified by:
getActionin interfaceApplication
-
getAppContext
public AppContext getAppContext()
Get the frame that this application draws itself in.- Specified by:
getAppContextin interfaceApplication
-
getClipboard
public java.awt.datatransfer.Clipboard getClipboard()
Get the clipboard object for this application.- Specified by:
getClipboardin interfaceApplication
-
getCurrentView
public View getCurrentView()
Get the current view. Generally, this will be the one that is displayed in the window that is top-most in the display.- Specified by:
getCurrentViewin interfaceApplication
-
getDocumentFactory
public DocumentFactory getDocumentFactory()
Get the factory that creates new documents- Specified by:
getDocumentFactoryin interfaceApplication
-
getResources
public RelativeBundle getResources()
Get the resources object.
-
getStoragePolicy
public StoragePolicy getStoragePolicy()
Get the storage policy of this application.- Specified by:
getStoragePolicyin interfaceApplication
-
getTitle
public abstract java.lang.String getTitle()
Get the title of this application- Specified by:
getTitlein interfaceApplication
-
isVisible
public boolean isVisible()
Test whether the application frame is visible. Return false if the application has no frame or if the frame is not visible.- Specified by:
isVisiblein interfaceApplication
-
removeDocument
public void removeDocument(Document d)
Remove a document from the list of documents currently known by this application, and remove all of the views associated with this document. Fire a list data event to registered document listeners. Throw an exception if the document is not known.- Specified by:
removeDocumentin interfaceApplication
-
removeView
public void removeView(View v)
Remove a view from the list of views currently known by this application. Fire a list data event to registered view listeners. If the removed view is the current view it is up to the application to decide which view to display next. Throw an exception if the view is not known.- Specified by:
removeViewin interfaceApplication
-
removeDocumentListener
public void removeDocumentListener(javax.swing.event.ListDataListener listener)
Remove a document list listener from this application.- Specified by:
removeDocumentListenerin interfaceApplication
-
removeViewListener
public void removeViewListener(javax.swing.event.ListDataListener listener)
Remove a view list listener from this application.- Specified by:
removeViewListenerin interfaceApplication
-
removePropertyChangeListener
public void removePropertyChangeListener(java.beans.PropertyChangeListener listener)
Remove a property change listener from this application.- Specified by:
removePropertyChangeListenerin interfaceApplication
-
setClipboard
public void setClipboard(java.awt.datatransfer.Clipboard clipboard)
Set the clipboard that is used by this application. This is generally used by subclass constructors. To use the system clipboard use something likesetClipboard(Toolkit.getDefaultToolkit().getSystemClipboard())
-
setCurrentView
public void setCurrentView(View v)
Set the given view to be the current view. Fire a contentsChanged() event to registered view listeners. Throw an exception if the view is not known.- Specified by:
setCurrentViewin interfaceApplication
-
setDocumentFactory
protected void setDocumentFactory(DocumentFactory df)
Set the factory that creates new documents for use by subclasses constructors only.
-
setStoragePolicy
public void setStoragePolicy(StoragePolicy sp)
Set the storage policy of this application, for use by subclass constructors only
-
setVisible
public void setVisible(boolean visible)
Set the visibility of the application's frame- Specified by:
setVisiblein interfaceApplication
-
showError
public void showError(java.lang.String op, java.lang.Exception e)Show an error in a dialog box with stack trace.- Specified by:
showErrorin interfaceApplication
-
setAppContext
protected void setAppContext(AppContext ac)
Set the app context that this application draws itself in. For use by subclass constructors only.
-
viewList
public java.util.List viewList()
Get a list of all view objects known by this application.- Specified by:
viewListin interfaceApplication
-
viewList
public java.util.List viewList(Document d)
Get a list of all view objects known by this application.
-
-