ilog.views.appframe.swing
Class IlvPanelView

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by javax.swing.JComponent
              extended by javax.swing.JPanel
                  extended by ilog.views.appframe.swing.IlvPanelView
All Implemented Interfaces:
IlvDocumentView, ActionHandler, MessageListener, IlvPropertyManager, ActionListener, ImageObserver, MenuContainer, Serializable, EventListener, Accessible
Direct Known Subclasses:
IlvTextView, IlvTreeView

public class IlvPanelView
extends JPanel
implements IlvDocumentView

Implements the IlvDocumentView interface for a JPanel.
Whatever is required for editing a document, such as a table or a tree, it is not recommended to make a Swing component implement the IlvDocumentView interface.
Instead, a good approach is to use an IlvPanelView as the view of the document, which contains the Swing component. The initializeView(ilog.views.appframe.docview.IlvDocument) method of the panel view is in charge of initializing the enclosed component with the data of the associated document.

Take the example of an application that has defined a table model for its business model, called BusinessTableModel, and a JTable inheriting class for editing this model, called BusinessTable. A document and document view can be defined to encapsulate those classes in the ILOG JViews Application Framework architecture, without Application Framework being intrusive in business classes.
The document may be defined as follows:

 public class BusinessDocument extends IlvAbstractFileDocument {
   ...
   public getBusinessTableModel() {...}
   ...
 }
 
and the document view:
 public class BusinessPanelView extends IlvPanelView {
   BusinessTable businessTable;

   public BusinessPanelView() {
     setLayout(new BorderLayout());
     this.businessTable = new BusinessTable();
     add(businessTable, BorderLayout.CENTER);
   }
   ...
   public void initializeView(IlvDocument document) {
     if (document != null) {
       businessTable.setModel(
                ((BusinessDocument)document).getBusinessTableModel());
     }
   }
   ...
 }
 

This approach is used for the IlvTextView, IlvTreeView, and IlvExplorerView classes.

See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class javax.swing.JPanel
JPanel.AccessibleJPanel
 
Nested classes/interfaces inherited from class javax.swing.JComponent
JComponent.AccessibleJComponent
 
Nested classes/interfaces inherited from class java.awt.Container
Container.AccessibleAWTContainer
 
Nested classes/interfaces inherited from class java.awt.Component
Component.AccessibleAWTComponent, Component.BltBufferStrategy, Component.FlipBufferStrategy
 
Field Summary
static String DEFAULT_SETTINGS_NAME
          Default attribute name for selecting the settings element that provides the settings of the panel view.
static String DEFAULT_SETTINGS_TYPE
          Type of settings element providing the settings for the panel views.
 
Fields inherited from class javax.swing.JComponent
accessibleContext, listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
 
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
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
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
  IlvPanelView()
          Constructs a new IlvPanelView.
protected IlvPanelView(String settingsType, String defaultSettingsName)
          Constructs a panel view that reads its settings from a settings element with the specified settingsType.
 
Method Summary
 void actionPerformed(ActionEvent e)
          Invoked when receiving action events.
 void addActionHandler(ActionHandler actionHandler)
          Adds the specified actionHandler to the list of action handlers of the view.
 boolean close()
          Closes the view by closing its container.
 IlvApplication getApplication()
          Returns the application of the view.
 IlvDocument getDocument()
          Returns the document associated with the view.
 Object getProperty(String key)
          Returns the client property of the panel with the specified key.
 IlvSettings getSettings()
          Returns the settings the panel view reads its settings from.
 IlvSettingsElement getSettingsElement()
          Returns the settings element that provides the settings for this panel view.
 String getSettingsName()
          Returns the name that identifies the panel view within the settings.
 IlvSettingsQuery getSettingsQuery()
          Returns the query that selects the settings element that provides the settings for this panel view.
 String getSettingsType()
          Returns the type of the settings element that provides the settings for this panel view.
 IlvViewContainer getViewContainer()
          Returns the view container that owns the view.
 void initializeView(IlvDocument document)
          Initializes the panel view with the specified document.
 boolean isProcessingAction(String command)
          Determines whether the panel view is able to process the action with the specified command key in its actionPerformed(java.awt.event.ActionEvent) method.
 boolean isStaticView()
          Determines whether this view has been registered as a static view or has been dynamically created for a specific document.
protected  void readSettings(IlvSettingsElement settingsElement)
          Reads the settings of the panel view.
 void receiveMessage(MessageEvent event)
          Invoked when receiving a message event.
protected  void registerMappings(IlvMessageMapper mapper)
          This method is called to register the mappings between action events and the panel view methods.
 boolean removeActionHandler(ActionHandler actionHandler)
          Removes the specified actionHandler from the list of action handlers managed by this view.
 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)
          Sets one of the client properties of this panel using the associated key.
 void setSettings(IlvSettings settings)
          Sets the settings the panel view reads its settings from.
 void setSettingsElement(IlvSettingsElement element)
          Forces the settings of the panel view to be read and written from the specified settings element.
 void setSettingsName(String name)
          Sets the name that identifies the panel view within the settings.
 void setSettingsQuery(IlvSettingsQuery query)
          Sets the query that selects the settings element that provides the settings for this panel view.
 void setViewContainer(IlvViewContainer container)
          Sets the view container of the view.
 boolean updateAction(Action action)
          Invoked by the application to update the state of the specified action.
 void viewClosed()
          Invoked after the view is closed.
 void viewClosing()
          Invoked before the view closes.
protected  void writeSettings(IlvSettingsElement settingsElement)
          Writes the settings of the panel view.
 
Methods inherited from class javax.swing.JPanel
getAccessibleContext, getUI, getUIClassID, paramString, setUI, updateUI
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, transferFocusBackward, transferFocusDownCycle, validate, validateTree
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface ilog.views.appframe.util.IlvPropertyManager
addPropertyChangeListener, removePropertyChangeListener
 

Field Detail

DEFAULT_SETTINGS_TYPE

public static final String DEFAULT_SETTINGS_TYPE
Type of settings element providing the settings for the panel views.

See Also:
Constant Field Values

DEFAULT_SETTINGS_NAME

public static final String DEFAULT_SETTINGS_NAME
Default attribute name for selecting the settings element that provides the settings of the panel view.

See Also:
Constant Field Values
Constructor Detail

IlvPanelView

protected IlvPanelView(String settingsType,
                       String defaultSettingsName)
Constructs a panel view that reads its settings from a settings element with the specified settingsType.

Parameters:
settingsType - The type of the settings element providing the settings for the panel view.
defaultSettingsName - The default name used to select the settings element that provide the settings for this panel view.
See Also:
getSettingsType(), getSettingsName()

IlvPanelView

public IlvPanelView()
Constructs a new IlvPanelView. This method delegates the initialization of the panel to the constructor IlvPanelView(String, String), with the settings constants DEFAULT_SETTINGS_TYPE and DEFAULT_SETTINGS_NAME given as the parameters.

Method Detail

initializeView

public void initializeView(IlvDocument document)
Initializes the panel view with the specified document. Before the method is called, the specified document is associated with the view by setting the DOCUMENT_PROPERTY of the view.

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. Does nothing by default.

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

viewClosed

public void viewClosed()
Invoked after the view is closed. Does nothing by default.

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.
See Also:
setDocument(ilog.views.appframe.docview.IlvDocument), IlvDocumentView.DOCUMENT_PROPERTY

setDocument

public void setDocument(IlvDocument document)
Sets the document associated with the view.

Parameters:
document - The document of the view.
See Also:
getDocument(), 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.
See Also:
setViewContainer(ilog.views.appframe.docview.IlvViewContainer), IlvDocumentView.VIEW_CONTAINER_PROPERTY

setViewContainer

public void setViewContainer(IlvViewContainer container)
Sets the view container of the view.

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

isStaticView

public boolean isStaticView()
Determines whether this view has been registered as a static view or has been dynamically created for a specific document. The returned value is given by the IlvDocumentView.STATIC_VIEW_PROPERTY property of the view.

Returns:
true if this view is a static view; false otherwise.
See Also:
IlvDocumentView.STATIC_VIEW_PROPERTY

close

public boolean close()
Closes the view by closing its container.

Returns:
true if the container could be closed; false otherwise.

getApplication

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

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

setApplication

public void setApplication(IlvApplication application)
Sets the application of the view.

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

addActionHandler

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

Parameters:
actionHandler - The new action handler to add.
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 view.

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

registerMappings

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

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

receiveMessage

public void receiveMessage(MessageEvent event)
Invoked when receiving a message event.

Specified by:
receiveMessage in interface MessageListener
Parameters:
event - The message event.
See Also:
MessageEvent

isProcessingAction

public boolean isProcessingAction(String command)
Determines whether the panel view is able to process the action with the specified command key in its actionPerformed(java.awt.event.ActionEvent) method.

Specified by:
isProcessingAction in interface ActionHandler
Parameters:
command - The command key of the action.
Returns:
true if the action listener performs the specified action; false otherwise.

updateAction

public boolean updateAction(Action action)
Invoked by the application to update the state of the specified action.

Specified by:
updateAction in interface ActionHandler
Parameters:
action - The action to update.
Returns:
true if the action handler has updated the state of the action; false otherwise.

actionPerformed

public void actionPerformed(ActionEvent e)
Invoked when receiving action events.

Specified by:
actionPerformed in interface ActionListener
Parameters:
e - The action event.

setProperty

public Object setProperty(String key,
                          Object value)
Sets one of the client properties of this panel using the associated key. If the value has changed, a PropertyChangeEvent will be 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), JComponent.putClientProperty(java.lang.Object, java.lang.Object)

getProperty

public Object getProperty(String key)
Returns the client property of the panel 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), JComponent.getClientProperty(java.lang.Object)

getSettings

public IlvSettings getSettings()
Returns the settings the panel view reads its settings from.

Returns:
The settings of the panel view.
See Also:
setSettings(ilog.views.appframe.settings.IlvSettings)

setSettings

public void setSettings(IlvSettings settings)
Sets the settings the panel view reads its settings from.

Parameters:
settings - The settings of the panel view.
See Also:
getSettings()

getSettingsName

public String getSettingsName()
Returns the name that identifies the panel view within the settings. It corresponds to the value of the name attribute of the settings element that provides the settings for the associated object. If no name has been specified using the method setSettingsName(java.lang.String), null will be returned.

Returns:
The settings name.
See Also:
setSettingsName(java.lang.String), getSettingsElement(), getSettingsQuery()

setSettingsName

public void setSettingsName(String name)
Sets the name that identifies the panel view within the settings.

Parameters:
name - The new settings name.
See Also:
getSettingsName()

getSettingsType

public String getSettingsType()
Returns the type of the settings element that provides the settings for this panel view.

Returns:
The settings type or null if no settings type has been specified.
See Also:
getSettingsElement()

setSettingsQuery

public void setSettingsQuery(IlvSettingsQuery query)
Sets the query that selects the settings element that provides the settings for this panel view.

Parameters:
query - The new settings query.
See Also:
getSettingsQuery()

getSettingsQuery

public IlvSettingsQuery getSettingsQuery()
Returns the query that selects the settin