ilog.views.appframe.docview.project
Class IlvDataContainerDocument

java.lang.Object
  extended by ilog.views.appframe.docview.IlvAbstractDocument
      extended by ilog.views.appframe.docview.IlvAbstractFileDocument
          extended by ilog.views.appframe.docview.project.IlvDataContainerDocument
All Implemented Interfaces:
IlvDocument, IlvFileDocument, IlvStreamDocument, IlvDataContainerProvider, ActionHandler, MessageListener, IlvPropertyManager, ActionListener, EventListener
Direct Known Subclasses:
IlvProjectDocument

public class IlvDataContainerDocument
extends IlvAbstractFileDocument
implements IlvDataContainerProvider

Defines documents associated with a data container.


Field Summary
static String DATA_CONTAINER_PROPERTY
          Bound property name for the data container associated with the document.
static String NODE_DOCUMENTS_ATTACHED_PROPERTY
          Bound property name for the mode that determines whether node documents created by this document are attached to it.
 
Fields inherited from class ilog.views.appframe.docview.IlvAbstractFileDocument
PATHNAME_PROPERTY
 
Fields inherited from class ilog.views.appframe.docview.IlvAbstractDocument
REDO_CMD, UNDO_CMD
 
Fields inherited from interface ilog.views.appframe.docview.IlvFileDocument
FILE_FILTER_PROPERTY, MRU_PROPERTY
 
Fields inherited from interface ilog.views.appframe.docview.IlvDocument
APPLICATION_PROPERTY, ATTACHED_DOCUMENTS_PROPERTY, DOCUMENT_OWNER_PROPERTY, DOCUMENT_TEMPLATE_PROPERTY, EDITABLE_PROPERTY, MODIFIED_PROPERTY, SAVEABLE_PROPERTY, TITLE_PROPERTY
 
Fields inherited from interface ilog.views.appframe.docview.IlvDocument
APPLICATION_PROPERTY, ATTACHED_DOCUMENTS_PROPERTY, DOCUMENT_OWNER_PROPERTY, DOCUMENT_TEMPLATE_PROPERTY, EDITABLE_PROPERTY, MODIFIED_PROPERTY, SAVEABLE_PROPERTY, TITLE_PROPERTY
 
Constructor Summary
IlvDataContainerDocument()
          Constructs an empty IlvDataContainerDocument.
 
Method Summary
 boolean areNodeDocumentsAttached()
          Determines whether the node documents are attached to the data container document.
 void attachNodeDocuments(boolean attach)
          Attaches or detaches the document created by this document for associating with the data container nodes.
 boolean canOpenDocument(Object node)
          Determines whether a new document can be opened and associated with the specified data container node.
protected  IlvDataContainer createDataContainer(Object userData)
          Factory method for creating a new data container to associate with this document.
protected  IlvDocument createDocument(Object node)
          Factory method for creating a document to associate with the specified data container node.
protected  void endInitializeDataContainer(IlvDataContainer dataContainer)
          Finishes initializing the specified dataContainer.
 IlvDataContainer getDataContainer()
          Returns the data container associated with this document.
 String getNodeTitle(Object node)
          Returns the title associated with the specified data container node.
 IlvDocument getOpenDocument(Object node)
          Retrieves a document opened for the specified node.
protected  void initializeDataContainer(IlvDataContainer dataContainer, Object userData)
          Initializes the specified dataContainer.
 boolean initializeDocument(Object userData)
          Initializes a new data container document.
 IlvDocument openDocument(Object node)
          Opens a document associated with the specified data container node.
protected  boolean readDataContainer(IlvDataContainer dataContainer, Reader reader, IlvFileFilter filter)
          Reads the content of the specified dataContainer from the specified reader.
protected  boolean readDocument(Reader reader, IlvFileFilter filter)
          Reads a data container from the specified reader.
 boolean readDocument(URL url, IlvFileFilter filter)
          Initializes the document data from the specified file url.
 void setDataContainer(IlvDataContainer dataContainer)
          Sets the data container of this document.
 void setNodeTitle(Object node, String title)
          Sets the title associated with the specified data container node.
protected  boolean writeDataContainer(IlvDataContainer dataContainer, Writer writer, IlvFileFilter filter)
          Writes the content of the specified dataContainer into the specified writer.
 boolean writeDocument(URL url, IlvFileFilter filter)
          Stores the document data in the file with the specified url.
 boolean writeDocument(Writer writer, IlvFileFilter filter)
          Writes the associated data container to the specified writer.
 
Methods inherited from class ilog.views.appframe.docview.IlvAbstractFileDocument
activated, getFileDocumentTemplate, getPathName, readStreamDocument, setPathName, writeStreamDocument
 
Methods inherited from class ilog.views.appframe.docview.IlvAbstractDocument
actionPerformed, addActionHandler, addEdit, addPropertyChangeListener, addView, attachDocument, canRedo, canUndo, clean, documentClosed, documentClosing, getActiveView, getApplication, getDocumentTemplate, getProperty, getTitle, getUndoManager, getView, getViewCount, getViews, isModified, isProcessingAction, notifyViews, receiveMessage, redo, registerMappings, removeActionHandler, removePropertyChangeListener, removeView, removeViews, setApplication, setModified, setProperty, setTitle, undo, updateAction, updateModificationState
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface ilog.views.appframe.docview.IlvDocument
addView, clean, documentClosed, documentClosing, getApplication, getDocumentTemplate, getTitle, getView, getViewCount, isModified, removeView, removeViews, setModified, setTitle
 
Methods inherited from interface ilog.views.appframe.event.ActionHandler
isProcessingAction, updateAction
 
Methods inherited from interface java.awt.event.ActionListener
actionPerformed
 
Methods inherited from interface ilog.views.appframe.event.MessageListener
receiveMessage
 
Methods inherited from interface ilog.views.appframe.util.IlvPropertyManager
addPropertyChangeListener, getProperty, removePropertyChangeListener, setProperty
 
Methods inherited from interface ilog.views.appframe.docview.IlvDocument
addView, clean, documentClosed, documentClosing, getApplication, getDocumentTemplate, getTitle, getView, getViewCount, isModified, removeView, removeViews, setModified, setTitle
 
Methods inherited from interface ilog.views.appframe.event.ActionHandler
isProcessingAction, updateAction
 
Methods inherited from interface java.awt.event.ActionListener
actionPerformed
 
Methods inherited from interface ilog.views.appframe.event.MessageListener
receiveMessage
 
Methods inherited from interface ilog.views.appframe.util.IlvPropertyManager
addPropertyChangeListener, getProperty, removePropertyChangeListener, setProperty
 

Field Detail

DATA_CONTAINER_PROPERTY

public static final String DATA_CONTAINER_PROPERTY
Bound property name for the data container associated with the document.

See Also:
getDataContainer(), Constant Field Values

NODE_DOCUMENTS_ATTACHED_PROPERTY

public static final String NODE_DOCUMENTS_ATTACHED_PROPERTY
Bound property name for the mode that determines whether node documents created by this document are attached to it. If the value of the property is equal to Boolean.TRUE, node documents are attached to the document. Otherwise, node documents are not attached.

See Also:
areNodeDocumentsAttached(), Constant Field Values
Constructor Detail

IlvDataContainerDocument

public IlvDataContainerDocument()
Constructs an empty IlvDataContainerDocument.

Method Detail

initializeDocument

public boolean initializeDocument(Object userData)
Initializes a new data container document. If the specified userData is an IlvDataContainer instance, it will be associated with the document with the method setDataContainer(ilog.views.appframe.docview.project.IlvDataContainer). Otherwise, a new data container is created with the method createDataContainer(java.lang.Object) and associated with the document.

Specified by:
initializeDocument in interface IlvDocument
Overrides:
initializeDocument in class IlvAbstractDocument
Parameters:
userData - The user data to initialize the document with - can be null or an IlvDataContainer instance.
Returns:
false if the document could not create a new data container; true otherwise.
See Also:
IlvApplication.newDocument(java.lang.Object, boolean), IlvApplication.newDocument(), IlvApplication.newDocument(IlvDocumentTemplate, boolean, Object)

getDataContainer

public IlvDataContainer getDataContainer()
Returns the data container associated with this document.

Specified by:
getDataContainer in interface IlvDataContainerProvider
See Also:
setDataContainer(ilog.views.appframe.docview.project.IlvDataContainer), DATA_CONTAINER_PROPERTY

setDataContainer

public void setDataContainer(IlvDataContainer dataContainer)
Sets the data container of this document. Triggers a property change event for the DATA_CONTAINER_PROPERTY.

Parameters:
dataContainer - The new data container of the document.
See Also:
getDataContainer(), DATA_CONTAINER_PROPERTY

readDocument

public boolean readDocument(URL url,
                            IlvFileFilter filter)
Initializes the document data from the specified file url. By default, a reader is created from the specified URL and is given as the parameter to the readDocument(Reader, IlvFileFilter) method.

Specified by:
readDocument in interface IlvFileDocument
Overrides:
readDocument in class IlvAbstractFileDocument
Parameters:
url - The URL of the file from which the data must be read.
filter - The file filter that indicates the format to use for reading the data.
Returns:
true if the document could read its data; false otherwise.
See Also:
writeDocument(java.net.URL, ilog.views.appframe.docview.IlvFileFilter)

readDocument

protected boolean readDocument(Reader reader,
                               IlvFileFilter filter)
Reads a data container from the specified reader. If no data container has already been associated with the document, a new one will be created. The readDataContainer(ilog.views.appframe.docview.project.IlvDataContainer, java.io.Reader, ilog.views.appframe.docview.IlvFileFilter) method is then invoked with the data container of the document as the parameter.

Overrides:
readDocument in class IlvAbstractFileDocument
Parameters:
reader - The reader to read the data from.
filter - The file filter that indicates the format to use for reading the data.
Returns:
true if a data container can be read; false otherwise.
See Also:
readDataContainer(ilog.views.appframe.docview.project.IlvDataContainer, java.io.Reader, ilog.views.appframe.docview.IlvFileFilter)

readDataContainer

protected boolean readDataContainer(IlvDataContainer dataContainer,
                                    Reader reader,
                                    IlvFileFilter filter)
Reads the content of the specified dataContainer from the specified reader.

Parameters:
dataContainer - The data container to read the data of.
reader - The reader to read from.
filter - The file filter that indicates the format to use for reading the data.
Returns:
true if the data container can be read; false otherwise.
See Also:
endInitializeDataContainer(ilog.views.appframe.docview.project.IlvDataContainer)

writeDocument

public boolean writeDocument(URL url,
                             IlvFileFilter filter)
Stores the document data in the file with the specified url. By default, a writer is created from the specified URL and given as the parameter to the writeDocument(Writer, IlvFileFilter) method.

Specified by:
writeDocument in interface IlvFileDocument
Overrides:
writeDocument in class IlvAbstractFileDocument
Parameters:
url - The URL of the file to which the data is written.
filter - The file filter that indicates the format to use for writing the data.
Returns:
true if the document could write its data; false otherwise.
See Also:
writeDocument(Writer, IlvFileFilter)

writeDocument

public boolean writeDocument(Writer writer,
                             IlvFileFilter filter)
Writes the associated data container to the specified writer. The implementation of this method is empty.

Overrides:
writeDocument in class IlvAbstractFileDocument
Parameters:
writer - The writer to write the data of the document to.
filter - The file filter that indicates the format to use for writing the data.
Returns:
true if the document can write its data; false otherwise.
See Also:
readDocument(java.net.URL, ilog.views.appframe.docview.IlvFileFilter)

writeDataContainer

protected boolean writeDataContainer(IlvDataContainer dataContainer,
                                     Writer writer,
                                     IlvFileFilter filter)
Writes the content of the specified dataContainer into the specified writer.

Parameters:
dataContainer - The data container to read the data of.
writer - The writer to writer into.
filter - The file filter that indicates the format to use for writing the data.
Returns:
true if the data container can be written; false otherwise.
See Also:
readDataContainer(ilog.views.appframe.docview.project.IlvDataContainer, java.io.Reader, ilog.views.appframe.docview.IlvFileFilter)

createDataContainer

protected IlvDataContainer createDataContainer(Object userData)
Factory method for creating a new data container to associate with this document. By default, the method creates an instance of IlvDefaultDataContainer. It can be overridden to create other data container types.

Parameters:
userData - The user data parameter of the initializeDocument(java.lang.Object) method - can be null.
Returns:
The newly created IlvDataContainer instance.

initializeDataContainer

protected void initializeDataContainer(IlvDataContainer dataContainer,
                                       Object userData)
Initializes the specified dataContainer. This method is called when the document is initializing with the initializeDocument method and after the method createDataContainer(java.lang.Object) has been called. By default, it does nothing. It can be overridden to create a default hierarchy of data that corresponds to a document just initialized. For example, it is overridden by the IlvProjectDocument to create a project root node that corresponds to the project document.

Parameters:
dataContainer - The data container to initialize.
userData - The user data parameter of the initializeDocument(java.lang.Object) method - can be null.
See Also:
endInitializeDataContainer(ilog.views.appframe.docview.project.IlvDataContainer)

endInitializeDataContainer

protected void endInitializeDataContainer(IlvDataContainer dataContainer)
Finishes initializing the specified dataContainer. This method is called after the document and its associated data container have been initialized, whether with the initializeDocument or readDocument method. By default it does nothing. It should be overridden to finish initializing the data container of the document, whether it was initialized from a file or by default.
For example, it is overridden by the IlvProjectDocument class for adding listeners to the root node of the data container.

Parameters:
dataContainer - The data container to finish initializing.
See Also:
initializeDataContainer(ilog.views.appframe.docview.project.IlvDataContainer, java.lang.Object)

openDocument

public IlvDocument openDocument(Object node)
Opens a document associated with the specified data container node.

If a document was previously created for this node, it would be reactivated with its views. If its views have been closed, new views will be created and activated.

If no document was previously created for this node, a new one would be created, together with the views for editing it.

Parameters:
node - The node to create a document for.
Returns:
The associated document or null if a document cannot be created for the specified node.

canOpenDocument

public boolean canOpenDocument(Object node)
Determines whether a new document can be opened and associated with the specified data container node. By default, it returns true.

Returns:
true if the node can be opened; false otherwise.

areNodeDocumentsAttached

public boolean areNodeDocumentsAttached()
Determines whether the node documents are attached to the data container document.

If node documents are attached to this document, they will be closed when this document closes. Otherwise, they must be closed by the application user after this document is closed and node file documents appear in the Most Recently Used file list managed by the application.

In both modes, the application user can close the node document.

Returns:
true if the documents associated with data container nodes are attached to this document; false otherwise.
See Also:
attachNodeDocuments(boolean), IlvApplication.attachDocument(ilog.views.appframe.docview.IlvDocument, ilog.views.appframe.docview.IlvDocument), NODE_DOCUMENTS_ATTACHED_PROPERTY, attachNodeDocuments(boolean)

attachNodeDocuments

public void attachNodeDocuments(boolean attach)
Attaches or detaches the document created by this document for associating with the data container nodes.

Triggers a property change event for the NODE_DOCUMENTS_ATTACHED_PROPERTY.

Parameters:
attach - If true, node documents will be attached to this document. Otherwise, node documents are not attached.
See Also:
areNodeDocumentsAttached(), NODE_DOCUMENTS_ATTACHED_PROPERTY

getOpenDocument

public IlvDocument getOpenDocument(Object node)
Retrieves a document opened for the specified node.

Parameters:
node - The node to retrieve an associated document from.
Returns:
The document associated with the specified node or null if no document has previously been opened for this node.
See Also:
openDocument(java.lang.Object)

createDocument

protected IlvDocument createDocument(Object node)
Factory method for creating a document to associate with the specified data container node. This method is invoked by the openDocument(java.lang.Object) method to create a new document.

Returns:
The newly created document.

getNodeTitle

public String getNodeTitle(Object node)
Returns the title associated with the specified data container node.
By default, invokes the method IlvDataContainer.getTitle(java.lang.Object) for the specified node.

Parameters:
node - The node to get a title for.
Returns:
The node title.
See Also:
IlvDataContainer.getTitle(java.lang.Object), setNodeTitle(java.lang.Object, java.lang.String)

setNodeTitle

public void setNodeTitle(Object node,
                         String title)
Sets the title associated with the specified data container node.
By default, invokes the method IlvDataContainer.setTitle(java.lang.Object, java.lang.String) for the specified node with the specified title.

Parameters:
node - The node to associate a new title with.
title - The new title of the node.
See Also:
IlvDataContainer.setTitle(java.lang.Object, java.lang.String), getNodeTitle(java.lang.Object)


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