ilog.views.appframe.docview
Class IlvDocumentViewSupport

java.lang.Object
  extended by ilog.views.appframe.docview.IlvDocumentViewSupport
All Implemented Interfaces:
IlvDocumentView, ActionHandler, MessageListener, IlvPropertyManager, ActionListener, EventListener

public class IlvDocumentViewSupport
extends Object
implements IlvDocumentView

This is a utility class for implementing the IlvDocumentView interface. An instance of this class can be used as a member field of the document view class and can delegate implementation of methods to it.


Field Summary
 
Fields inherited from interface ilog.views.appframe.docview.IlvDocumentView
ACTIVE_PROPERTY, ACTIVE_VIEW_NAME, APPLICATION_PROPERTY, CLOSABLE_PROPERTY, CLOSING_VIEW_MSG, DOCUMENT_PROPERTY, SETTINGS_ELEMENT_PROPERTY, STATIC_VIEW_PROPERTY, VIEW_CONTAINER_PROPERTY
 
Constructor Summary
IlvDocumentViewSupport(Object view)
          Constructs a new IlvDocumentViewSupport.
 
Method Summary
 void actionPerformed(ActionEvent event)
          Invoked when an action event occurs.
 void addActionHandler(ActionHandler actionHandler)
          Adds the specified actionHandler to the list of action handlers of the support object.
 void addPropertyChangeListener(PropertyChangeListener listener)
          Adds a listener that listens for changes in the properties of this object.
 IlvApplication getApplication()
          Returns the application of the view.
 IlvDocument getDocument()
          Returns the document associated with the view.
 Object getProperty(String key)
          Returns the property of this view with the specified key.
 IlvViewContainer getViewContainer()
          Returns the view container that owns the view.
 void initializeView(IlvDocument document)
          Initializes the document view with the specified document.
 boolean isProcessingAction(String command)
          Determines whether the action with the specified command key can be processed by the support object.
 void receiveMessage(MessageEvent event)
          Processes the specified message event.
 void registerActionMethod(String command, String methodName)
          Maps the method with the specified methodName to the specified action command.
 void registerActionStateMethod(String command, String methodName)
          Registers a method to be called when updating the specified action.
protected  void registerMappings(IlvMessageMapper mapper)
          This method is automatically called to register the mappings between action events and updates with the view methods.
 boolean removeActionHandler(ActionHandler actionHandler)
          Removes the specified actionHandler from the list of action handlers managed by this support object.
 void removePropertyChangeListener(PropertyChangeListener listener)
          Removes the specified listener from the list of PropertyChange listeners managed by this object.
 void setApplication(IlvApplication application)
          Sets the application of the view.
 void setDocument(IlvDocument document)
          Sets the document associated with the view.
 Object setProperty(String key, Object value)
          Changes the value of one of the properties of the view.
 void setViewContainer(IlvViewContainer container)
          Sets the view container that owns the view.
 boolean updateAction(Action action)
          Updates the state of the specified action.
 void viewClosed()
          Invoked after the view has been closed.
 void viewClosing()
          Invoked before the view closes.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

IlvDocumentViewSupport

public IlvDocumentViewSupport(Object view)
Constructs a new IlvDocumentViewSupport.

Parameters:
view - The view that uses this support object.
Method Detail

initializeView

public void initializeView(IlvDocument document)
Initializes the document view with the specified document. The implementation of this method is empty.

Specified by:
initializeView in interface IlvDocumentView
Parameters:
document - The document to initialize the content of the view with.

viewClosing

public void viewClosing()
Invoked before the view closes. The implementation of this method is empty.

Specified by:
viewClosing in interface IlvDocumentView
See Also:
viewClosed()

viewClosed

public void viewClosed()
Invoked after the view has been closed. The implementation of this method is empty.

Specified by:
viewClosed in interface IlvDocumentView
See Also:
viewClosing()

getDocument

public IlvDocument getDocument()
Returns the document associated with the view.

Specified by:
getDocument in interface IlvDocumentView
Returns:
The document stored in the IlvDocumentView.DOCUMENT_PROPERTY.

setDocument

public void setDocument(IlvDocument document)
Sets the document associated with the view. The IlvDocumentView.DOCUMENT_PROPERTY is set to the new specified document.

Parameters:
document - The document of the view.
See Also:
IlvDocumentView.DOCUMENT_PROPERTY

getViewContainer

public IlvViewContainer getViewContainer()
Returns the view container that owns the view.

Specified by:
getViewContainer in interface IlvDocumentView
Returns:
The view container stored in the IlvDocumentView.VIEW_CONTAINER_PROPERTY.
See Also:
setViewContainer(ilog.views.appframe.docview.IlvViewContainer)

setViewContainer

public void setViewContainer(IlvViewContainer container)
Sets the view container that owns the view. The IlvDocumentView.VIEW_CONTAINER_PROPERTY is set to the new specified container.

Parameters:
container - The new view container of the view.
See Also:
getViewContainer()

getApplication

public IlvApplication getApplication()
Returns the application of the view.

Specified by:
getApplication in interface IlvDocumentView
Returns:
The application stored in the IlvDocumentView.APPLICATION_PROPERTY.
See Also:
setApplication(ilog.views.appframe.IlvApplication)

setApplication

public void setApplication(IlvApplication application)
Sets the application of the view. The IlvDocumentView.APPLICATION_PROPERTY is set to the new specified application.

Parameters:
application - The application of the view.
See Also:
getApplication()

receiveMessage

public void receiveMessage(MessageEvent event)
Processes the specified message event. This method retrieves the method associated with the name of the specified message and invokes it with the message event parameters as the parameter.

Specified by:
receiveMessage in interface MessageListener
Parameters:
event - The message event.
See Also:
registerMappings(ilog.views.appframe.event.IlvMessageMapper)

registerActionMethod

public void registerActionMethod(String command,
                                 String methodName)
Maps the method with the specified methodName to the specified action command. The method methodName of the view object specified to this support object is invoked when an action event with the specified command key occurs.

The specified method must have been defined with the following signatures:

 public void methodName(ActionEvent e) {
 ...
 }
 
or
 public void methodName() {
 ...
 }
 

Parameters:
command - The command key of the action.
methodName - The name of the method to map to the specified action.
See Also:
IlvMessageMapper.registerActionMethod(java.lang.String, java.lang.String), actionPerformed(java.awt.event.ActionEvent)

registerActionStateMethod

public void registerActionStateMethod(String command,
                                      String methodName)
Registers a method to be called when updating the specified action. The specified method must have been defined with the following signature:
 public boolean methodName(Action action) {
 ...
 }
 

Parameters:
command - The command key of the action to be updated.
methodName - The name of the method of the view to associate with the update events of the specified action.
See Also:
updateAction(javax.swing.Action)

registerMappings

protected void registerMappings(IlvMessageMapper mapper)
This method is automatically called to register the mappings between action events and updates with the view methods.

Parameters:
mapper - The message mapper to register mappings to.
See Also:
registerActionMethod(java.lang.String, java.lang.String), registerActionStateMethod(java.lang.String, java.lang.String)

isProcessingAction

public boolean isProcessingAction(String command)
Determines whether the action with the specified command key can be processed by the support object.

Specified by:
isProcessingAction in interface ActionHandler
Parameters:
command - The command key of the action.
Returns:
true if the action has been associated with a method or an action handler added with addActionHandler(ilog.views.appframe.event.ActionHandler); false otherwise.
See Also:
registerActionMethod(java.lang.String, java.lang.String)

updateAction

public boolean updateAction(Action action)
Updates the state of the specified action. If a method has been associated with this action using the method registerActionStateMethod(java.lang.String, java.lang.String), it will be called. If an action handler added with the addActionHandler(ilog.views.appframe.event.ActionHandler) method is associated with the action, it will be invoked. Otherwise, this method does nothing and returns false.

Specified by:
updateAction in interface ActionHandler
Parameters:
action - The action to update the state of.
Returns:
true if a method or an action handler could process the state of the specified action; false otherwise.
See Also:
ActionHandler.updateAction(javax.swing.Action), registerActionStateMethod(java.lang.String, java.lang.String)

actionPerformed

public void actionPerformed(ActionEvent event)
Invoked when an action event occurs. If a method has been registered with the method registerActionMethod(java.lang.String, java.lang.String) for the action corresponding to the action event, it will be called. If an action handler added with the addActionHandler(ilog.views.appframe.event.ActionHandler) has been added for processing this action, it will be invoked. Otherwise, nothing is done.

Specified by:
actionPerformed in interface ActionListener
Parameters:
event - The action event to handle.
See Also:
ActionListener.actionPerformed(java.awt.event.ActionEvent), registerActionMethod(java.lang.String, java.lang.String), addActionHandler(ilog.views.appframe.event.ActionHandler)

addActionHandler

public void addActionHandler(ActionHandler actionHandler)
Adds the specified actionHandler to the list of action handlers of the support object.

Parameters:
actionHandler - The new action handler.
See Also:
removeActionHandler(ilog.views.appframe.event.ActionHandler)

removeActionHandler

public boolean removeActionHandler(ActionHandler actionHandler)
Removes the specified actionHandler from the list of action handlers managed by this support object.

Returns:
true if the action handler was added previously; false otherwise.
See Also:
addActionHandler(ilog.views.appframe.event.ActionHandler)

setProperty

public Object setProperty(String key,
                          Object value)
Changes the value of one of the properties of the view. If the value has changed, a PropertyChangeEvent is sent to property change listeners.

Specified by:
setProperty in interface IlvPropertyManager
Parameters:
key - The non-null property key.
value - An Object value. If it is equal to null, the property with the specified key will be removed.
Returns:
The previous value of the property.
See Also:
getProperty(java.lang.String)

getProperty

public Object getProperty(String key)
Returns the property of this view with the specified key.

Specified by:
getProperty in interface IlvPropertyManager
Parameters:
key - The non-null property key.
Returns:
The value of the specified property or null if the specified property was not found.
See Also:
setProperty(java.lang.String, java.lang.Object)

addPropertyChangeListener

public void addPropertyChangeListener(PropertyChangeListener listener)
Adds a listener that listens for changes in the properties of this object.

Specified by:
addPropertyChangeListener in interface IlvPropertyManager
Parameters:
listener - The listener to add.
See Also:
removePropertyChangeListener(java.beans.PropertyChangeListener)

removePropertyChangeListener

public void removePropertyChangeListener(PropertyChangeListener listener)
Removes the specified listener from the list of PropertyChange listeners managed by this object.

Specified by:
removePropertyChangeListener in interface IlvPropertyManager
Parameters:
listener - The listener to remove
See Also:
addPropertyChangeListener(java.beans.PropertyChangeListener)


Copyright © 1996-2007 ILOG S.A. All rights reserved.   Documentation homepage.