ilog.views.appframe.docview
Class IlvDocumentTemplate

java.lang.Object
  extended by ilog.views.appframe.docview.IlvDocumentTemplate
All Implemented Interfaces:
ActionHandler, IlvPropertyManager, ActionListener, EventListener
Direct Known Subclasses:
IlvFileDocumentTemplate

public class IlvDocumentTemplate
extends Object
implements ActionHandler, IlvPropertyManager

Document templates manage all aspects of the creation and the display of the documents.
They are automatically created and initialized by the application. When initializing, the application selects all the root settings elements with the SETTINGS_TYPE and initializes a new document template for each selected settings element. It is possible to extend the IlvDocumentTemplate or IlvFileDocumentTemplate classes and to add corresponding instances to the application using its IlvApplication.addDocumentTemplate(ilog.views.appframe.docview.IlvDocumentTemplate) method.

The entry point for creating documents is the application with methods like IlvApplication.newDocument() or IlvApplication.openDocument(). But, the application involves its document templates in all the steps of the creation of documents.

Creation of documents
First, the document template is asked to provide a new IlvDocument instance. If the document template is MDI (see isMDI()) or if no documents have yet been created by the document template, the method createDocument() is called to create a new document instance. Otherwise, the open document created by the document template has its modifications saved and is eventually cleaned.
Once a new document is created, the document template is asked to create document views to associate with this document, with its method createDocumentViews(ilog.views.appframe.docview.IlvMainWindow, ilog.views.appframe.docview.IlvDocument). The creation of views is parameterized by IlvDocumentViewConfiguration instances that are initialized by the document template from its settings. (See getViewConfiguration(java.lang.String) for more details.) For each view configuration that has the auto create mode, the document template creates a view container.
Finally, the document template activates one of the newly created view containers. This container is determined as follows:

Creation/closing of document view
After a document has been created with its views, it is possible to create new document views or to close existing ones.
Document views are created dynamically with the methods newViewContainer(IlvDocument, String, boolean) or newViewContainer(IlvDocument, IlvContainerTemplate, String), whereas views are closed with the methods closeDocumentViews(ilog.views.appframe.docview.IlvDocument) or closeViewContainer(IlvMDIViewContainer). It is also possible to ensure that a view for a document has been created with the method ensureDocumentViewExists(ilog.views.appframe.docview.IlvDocument, java.lang.String, boolean).

You can find documentation and examples of using document templates in the ILOG JViews Application Framework User's Manual, in the chapter on Applying the Document/View Architecture.


Field Summary
static String DATA_CLASS_PROPERTY
          Bound property name for the class of data the documents created by the template embed.
static String DEFAULT_DOCUMENT_NAME_PROPERTY
          Bound property name for the default name of the document created by the document template.
static String DESCRIPTION_PROPERTY
          Bound property name for the description of the document template.
static String DOCUMENT_CLASS_PROPERTY
          Bound property name for the class of documents that this document template creates.
static String ICON_PROPERTY
          Bound property name for the icon of the document template.
static String NAME_PROPERTY
          Bound property name for the name of the document template.
static String SELECTED_CONFIGURATION_PROPERTY
          Bound property name for the name of the configuration whose new container must be activated when creating views on a document.
static String SETTINGS_TYPE
          The type of settings elements providing the settings for document templates.
static String SHORT_NAME_PROPERTY
          Bound property name for the short name of the document template.
static String UNDO_LIMIT_PROPERTY
          Bound property name for the undo limit of the documents of this document template.
 
Constructor Summary
IlvDocumentTemplate()
          Constructs a new IlvDocumentTemplate instance.
IlvDocumentTemplate(String name)
          Constructs a new IlvDocumentTemplate instance with the specified name.
 
Method Summary
 void actionPerformed(ActionEvent e)
          Invoked when an action occurs.
 void activateDocumentView(IlvDocument document)
          Activates the specified document by activating the view containers of the document.
 void activateDocumentView(IlvDocumentView view)
          Activates the specified view.
 void addPropertyChangeListener(PropertyChangeListener listener)
          Adds a listener that listens for changes to the properties of this document template.
 boolean alwaysShowMenu()
          Determines whether the document template completes the main menu and toolbar of the application main window when the application is initializing or after a document associated with this document template is activated.
 boolean canCloseViewContainer(IlvViewContainer container)
          Determines whether the specified view container can be closed.
 boolean closeDocument(IlvDocument document, boolean force)
          Tries to close the specified document.
 boolean closeDocumentView(IlvDocument document, String viewConfiguration)
          Closes the document view associated with the specified document and created for the specified viewConfiguration.
 void closeDocumentViews(IlvDocument document)
          Closes all the views of the specified document that are not static.
 boolean closeViewContainer(IlvMDIViewContainer container)
          Closes the specified view container.
 boolean closeViewContainer(IlvMDIViewContainer container, boolean closeDocument)
          Closes the specified view container.
 void connectMainWindow(IlvMainWindow mainWindow)
          Associates this document template with a main window.
 IlvDocument createDocument()
          Factory method for creating documents associated with this document template.
 boolean createDocumentViews(IlvMainWindow mainWindow, IlvDocument document)
          Creates the view containers of a document.
 void documentActivated(IlvDocument document, boolean activated)
          Invoked after a view of the specified document has been activated or deactivated, depending on the value of the specified activated parameter.
 IlvDocumentView documentViewExists(IlvDocument document, String viewConfiguration)
          Determines whether a document view associated with the specified document has been created for the specified viewConfiguration.
 IlvDocumentView ensureDocumentViewExists(IlvDocument document, String viewConfiguration, boolean activate)
          Ensures that a document view is created for the specified document and viewConfiguration.
 IlvApplication getApplication()
          Returns the application of this document template.
 Class getDataClass()
          Returns the class of the data that the documents created by this template embed.
 String getDefaultDocumentName()
          Returns the default name to be given to the document created by this document template.
 String getDescription()
          Returns the description of the document template.
 Class getDocumentClass()
          Returns the class of the documents created by this document template.
 IlvViewContainer[] getDocumentContainers(IlvDocument document)
          Returns all the view containers that contain views of the specified document.
 Icon getIcon()
          Returns the icon associated with this document template.
 Icon getIcon(String configurationName)
          Returns the icon for the specified view configuration with the specified name.
 IlvMenuCompletion getMenuCompletion(IlvMainWindow mainWindow)
          Returns the menu completion instance that is responsible for completing/removing items from the main menu and toolbars of the specified main window.
 String getName()
          Returns the name of the document template.
 Object getProperty(String key)
          Returns the property of this object with the specified key.
 String getRecentFileListCommand()
          Returns the command key of the action that stores the list of Most Recently Used files for this document template.
 IlvSettings getSettings()
          Returns the settings of the document template.
 IlvSettingsElement getSettingsElement()
          Returns the settings element that provides the settings for this document template.
 String getShortName()
          Returns a short name for the document template.
 IlvDocumentViewConfiguration getViewConfiguration(int index)
          Returns the view configuration at the specified storage index.
 IlvDocumentViewConfiguration getViewConfiguration(String configName)
          Returns the view configuration with the specified name.
 int getViewConfigurationCount()
          Returns the number of view configurations of the document template.
 boolean hasOwnRecentFileList()
          Determines whether the documents opened by this document template are referenced in a list of Most Recently Used files specific to this document template.
 void initializeDocumentViews(IlvDocument document)
          Initializes all the views of the specified document.
 void insertBars(IlvMainWindow mainWindow)
          Completes the menu and toolbars of the specified mainWindow and inserts additional toolbars as specified in the settings of the document template.
 boolean isMDI()
          Determines whether more than one document can be created by the document template at the same time.
 boolean isProcessingAction(String command)
          Determines whether the document template is able to perform the action with the specified command key.
 int matchData(Object data)
          Provides the matching level of the document template with a data object.
 IlvMDIViewContainer newMDIViewContainer(IlvDocument document, IlvMDIContainerTemplate containerTemplate, String configurationName)
          Creates a new MDI view container for the specified document and MDI container template.
 IlvViewContainer newViewContainer(IlvDocument document, IlvContainerTemplate containerTemplate, String configurationName)
          Creates a new view container for the specified document and container template.
 IlvViewContainer newViewContainer(IlvDocument document, String configurationName, boolean activate)
          Creates a new view container for the specified document and the specified configuration.
 boolean readSettings(IlvSettingsElement element, IlvApplication application)
          Reads the settings of the document template from the specified settings element.
 boolean readSettings(IlvSettings settings, IlvApplication application)
          Reads the settings of the document template.
 void removeBars(IlvMainWindow mainWindow)
          Removes all the toolbars and the menu completion that were added by this document template to the specified mainWindow.
 void removePropertyChangeListener(PropertyChangeListener listener)
          Removes the specified listener from the list of PropertyChange listeners managed by this document template.
 boolean saveDocumentModifications(IlvDocument document)
          Saves the specified document if it was modified.
 void setApplication(IlvApplication application)
          Sets the application of this document template.
 void setDefaultDocumentName(String defaultName)
          Sets the default name to set to the document created by this document template.
 void setDescription(String description)
          Sets the description of the document template.
 void setDocumentClass(Class documentClass)
          Sets the class of document that this document template creates.
 void setMDI(boolean mdi)
          Sets the document template as MDI or not, depending on the value of the mdi parameter.
 void setName(String name)
          Sets the name of the document template.
 Object setProperty(String key, Object value)
          Changes the value of one of the properties of this document template.
 void setSettings(IlvSettings settings)
          Sets the settings that initialize the document template.
 void setShortName(String shortName)
          Sets a short name to the document template.
 boolean updateAction(Action action)
          Invoked by the application for updating the state of the specified action.
 void updateViewContainerTitles(IlvDocument document)
          Updates the title of all the view containers containing document views of the specified document.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SETTINGS_TYPE

public static final String SETTINGS_TYPE
The type of settings elements providing the settings for document templates.

See Also:
Constant Field Values

NAME_PROPERTY

public static final String NAME_PROPERTY
Bound property name for the name of the document template.

See Also:
getName(), setName(java.lang.String), Constant Field Values

ICON_PROPERTY

public static final String ICON_PROPERTY
Bound property name for the icon of the document template.

See Also:
getIcon(), Constant Field Values

DESCRIPTION_PROPERTY

public static final String DESCRIPTION_PROPERTY
Bound property name for the description of the document template.

See Also:
Constant Field Values

SHORT_NAME_PROPERTY

public static final String SHORT_NAME_PROPERTY
Bound property name for the short name of the document template.

See Also:
getShortName(), setShortName(java.lang.String), Constant Field Values

DEFAULT_DOCUMENT_NAME_PROPERTY

public static final String DEFAULT_DOCUMENT_NAME_PROPERTY
Bound property name for the default name of the document created by the document template.

See Also:
getDefaultDocumentName(), Constant Field Values

SELECTED_CONFIGURATION_PROPERTY

public static final String SELECTED_CONFIGURATION_PROPERTY
Bound property name for the name of the configuration whose new container must be activated when creating views on a document.

See Also:
Constant Field Values

DATA_CLASS_PROPERTY

public static final String DATA_CLASS_PROPERTY
Bound property name for the class of data the documents created by the template embed. This property is initialized from the dataJavaClass attribute of the settings element defining the document template.

See Also:
matchData(java.lang.Object), Constant Field Values

UNDO_LIMIT_PROPERTY

public static final String UNDO_LIMIT_PROPERTY
Bound property name for the undo limit of the documents of this document template.

See Also:
Constant Field Values

DOCUMENT_CLASS_PROPERTY

public static final String DOCUMENT_CLASS_PROPERTY
Bound property name for the class of documents that this document template creates.

See Also:
Constant Field Values
Constructor Detail

IlvDocumentTemplate

public IlvDocumentTemplate()
Constructs a new IlvDocumentTemplate instance.


IlvDocumentTemplate

public IlvDocumentTemplate(String name)
Constructs a new IlvDocumentTemplate instance with the specified name. This constructor is invoked when the application is creating its document templates from the settings. The specified name is the value of the name attribute of the settings element that defines the document template.

Parameters:
name - The name of the document template.
See Also:
getName(), setName(java.lang.String)
Method Detail

createDocumentViews

public boolean createDocumentViews(IlvMainWindow mainWindow,
                                   IlvDocument document)
Creates the view containers of a document.

Containers are created for all the document view configurations of this template that are in autocreate mode.

Parameters:
mainWindow - The main window in which the view containers are created.
document - The document for which the view container is created.
Returns:
true if view containers have been successfully created; false otherwise.
See Also:
IlvDocumentViewConfiguration.isAutoCreate(), IlvDocumentViewConfiguration

matchData

public int matchData(Object data)
Provides the matching level of the document template with a data object.

This method is called by the application when it looks for a document template that could create a document that embeds the specified data. By default, the class accessible with the property DATA_CLASS_PROPERTY of the document template is compared with the class of the specified data.

Parameters:
data - The data to match the class with the data class property stored in this document template.
Returns:
The matching level.
See Also:
DATA_CLASS_PROPERTY, getDataClass()

closeDocumentViews

public void closeDocumentViews(IlvDocument document)
Closes all the views of the specified document that are not static.

All the view containers of the document that are not static - that implement the IlvMDIViewContainer interface - are closed with their views. All the views of the document that are static, registered with the main window of the application through the method IlvMainWindow.registerStaticView(java.lang.String, ilog.views.appframe.docview.IlvDocumentView) are detached from this document and initialized with a null document.

Parameters:
document - The document that has its views closed.

getDocumentContainers

public IlvViewContainer[] getDocumentContainers(IlvDocument document)
Returns all the view containers that contain views of the specified document.

Parameters:
document - The document from which view containers are retrieved.
Returns:
The array of view containers.

newViewContainer

public IlvViewContainer newViewContainer(IlvDocument document,
                                         String configurationName,
                                         boolean activate)
Creates a new view container for the specified document and the specified configuration.

Parameters:
document - The document from which a view container is created.
configurationName - The name of the IlvDocumentViewConfiguration that is used for creating the new view container.
activate - If true, the new container is activated and the active view of the container receives action events of the application. Otherwise, the new view container is not activated, even though its creation may lead to its activation.
Returns:
The new view container. If the specified configuration name does not correspond to a registered configuration in this document template or if the container template fails to create a new view container, null will be returned.

newViewContainer

public IlvViewContainer newViewContainer(IlvDocument document,
                                         IlvContainerTemplate containerTemplate,
                                         String configurationName)
Creates a new view container for the specified document and container template.

Parameters:
document - The document from which a view container is created.
containerTemplate - The container template used to create the new view container.
configurationName - This parameter is used only if the specified container template is an IlvMDIContainerTemplate instance. It is the name of the window configuration used to create the views in the container created by the container template.
Returns:
The newly created view container. If the container template is an IlvSingleContainerTemplate instance, the container provided with its IlvSingleContainerTemplate.getViewContainer() method is returned.
See Also:
newViewContainer(IlvDocument, IlvContainerTemplate, String)

newMDIViewContainer

public IlvMDIViewContainer newMDIViewContainer(IlvDocument document,
                                               IlvMDIContainerTemplate containerTemplate,
                                               String configurationName)
Creates a new MDI view container for the specified document and MDI container template.

Parameters:
document - The document from which a view container is created.
containerTemplate - The MDI container template used to create the new view container.
configurationName - The name of the view configuration used to create the views in the container created by the container template.
Returns:
The newly created MDI view container.
See Also:
newViewContainer(IlvDocument, IlvContainerTemplate, String)

activateDocumentView

public void activateDocumentView(IlvDocumentView view)
Activates the specified view. The container of the view is activated previously and the view is set as the active view of the container.

Parameters:
view - The view to activate.
See Also:
IlvViewContainer.ACTIVE_VIEW_PROPERTY

activateDocumentView

public void activateDocumentView(IlvDocument document)
Activates the specified document by activating the view containers of the document. If no view containers have been created earlier for the document, they will be created.

Parameters:
document - The document of which a view is activated.

documentActivated

public void documentActivated(IlvDocument document,
                              boolean activated)
Invoked after a view of the specified document has been activated or deactivated, depending on the value of the specified activated parameter.

Parameters:
document - The document that has been activated or deactivated.
activated - If true, the document has been activated; otherwise, the document has been deactivated.

documentViewExists

public IlvDocumentView documentViewExists(IlvDocument document,
                                          String viewConfiguration)
Determines whether a document view associated with the specified document has been created for the specified viewConfiguration.

Parameters:
document - The document from which a view is retrieved.
viewConfiguration - The name of the view configuration from which a document view is retrieved.
Returns:
The first document view that was found that was created for the specified view configuration or null if no document view was found.
See Also:
ensureDocumentViewExists(ilog.views.appframe.docview.IlvDocument, java.lang.String, boolean), getViewConfiguration(java.lang.String)

ensureDocumentViewExists

public IlvDocumentView ensureDocumentViewExists(IlvDocument document,
                                                String viewConfiguration,
                                                boolean activate)
Ensures that a document view is created for the specified document and viewConfiguration. If a document view is not found for the specified view configuration, it will be created.

Parameters:
document - The document for which you want to ensure that a view exists.
viewConfiguration - The name of the view configuration from which a document view is retrieved or created.
activate - If true, the new document view that has been retrieved or created is activated; if false, the activation state of the view will remain unchanged.
Returns:
The document view that was found or created for the specified view configuration or null if no document view was found or could be created.
See Also:
documentViewExists(ilog.views.appframe.docview.IlvDocument, java.lang.String), getViewConfiguration(java.lang.String)

closeDocumentView

public boolean closeDocumentView(IlvDocument document,
                                 String viewConfiguration)
Closes the document view associated with the specified document and created for the specified viewConfiguration. The view container containing the document view is closed.

Parameters:
document - The document that has its views closed.
viewConfiguration - The name of the view configuration from which the document views to close were created originally.
Returns:
true if document views could be found and closed; false otherwise.
See Also:
closeViewContainer(ilog.views.appframe.docview.IlvMDIViewContainer)

initializeDocumentViews

public void initializeDocumentViews(IlvDocument document)
Initializes all the views of the specified document.
For each view of the document, this method invokes the method IlvDocumentView.initializeView(ilog.views.appframe.docview.IlvDocument) and fires a corresponding ApplicationEvent.DOCUMENT_VIEW_INITIALIZED event.

Parameters:
document - The document which views are being initialized.
Since:
JViews6.0

updateViewContainerTitles

public void updateViewContainerTitles(IlvDocument document)
Updates the title of all the view containers containing document views of the specified document.

Parameters:
document - The document with the view containers that have their title updated.

createDocument

public IlvDocument createDocument()
Factory method for creating documents associated with this document template. By default, a new document is instantiated from the class given by the getDocumentClass() method. This method can be overridden to create specific documents.

Returns:
The newly created document.

alwaysShowMenu

public boolean alwaysShowMenu()
Determines whether the document template completes the main menu and toolbar of the application main window when the application is initializing or after a document associated with this document template is activated.

Returns:
true if the document template completes the main menu and toolbars when the application is initialized; false if the the main menu and toolbars are completed only if a document of this document template has been activated. In this case, the added items and toolbars are removed when the document becomes inactive.

insertBars

public void insertBars(IlvMainWindow mainWindow)
Completes the menu and toolbars of the specified mainWindow and inserts additional toolbars as specified in the settings of the document template.
This method is invoked after a document of this document template has been activated.

Parameters:
mainWindow - The main window that has its menu and toolbars completed.
See Also:
removeBars(ilog.views.appframe.docview.IlvMainWindow), ApplicationEvent.DOCUMENT_TEMPLATE_ACTIVATED

removeBars

public void removeBars(IlvMainWindow mainWindow)
Removes all the toolbars and the menu completion that were added by this document template to the specified mainWindow.
This method is invoked after a document of this document template has been deactivated.

Parameters:
mainWindow - The main window from which bar insertions are removed.
See Also:
insertBars(ilog.views.appframe.docview.IlvMainWindow), ApplicationEvent.DOCUMENT_TEMPLATE_DEACTIVATED

getName

public String getName()
Returns the name of the document template.

See Also:
setName(java.lang.String)

setName

public void setName(String name)
Sets the name of the document template.

Parameters:
name - The new name of the document template.
See Also:
getName()

getApplication

public IlvApplication getApplication()
Returns the application of this document template.

See Also:
setApplication(ilog.views.appframe.IlvApplication)

setApplication

public void setApplication(IlvApplication application)
Sets the application of this document template. This method is automatically invoked by the application when it registers this document template. It should not be invoked in other circumstances.

Parameters:
application - The new application of the document template.
See Also:
getApplication()

getSettings

public IlvSettings getSettings()
Returns the settings of the document template.

See Also:
setSettings(ilog.views.appframe.settings.IlvSettings), setApplication(ilog.views.appframe.IlvApplication)

setSettings

public void setSettings(IlvSettings settings)
Sets the settings that initialize the document template. By default, the document template is initialized with the settings of the application that is set with the method setApplication(ilog.views.appframe.IlvApplication).

Parameters:
settings - The new settings of the document template.
See Also:
getSettings(), setApplication(ilog.views.appframe.IlvApplication)

getDocumentClass

public Class getDocumentClass()
Returns the class of the documents created by this document template. This document class is initialized from the documentJavaClass attribute of the settings element that defines this document template.

See Also:
setDocumentClass(java.lang.Class), DOCUMENT_CLASS_PROPERTY, createDocument()

setDocumentClass

public void setDocumentClass(Class documentClass)
Sets the class of document that this document template creates.

Parameters:
documentClass - The new document class.
See Also:
getDocumentClass(), DOCUMENT_CLASS_PROPERTY, createDocument()

getDataClass

public Class getDataClass()
Returns the class of the data that the documents created by this template embed.

See Also:
matchData(java.lang.Object), DATA_CLASS_PROPERTY

getShortName

public String getShortName()
Returns a short name for the document template.

See Also:
setShortName(java.lang.String), SHORT_NAME_PROPERTY

setShortName

public void setShortName(String shortName)
Sets a short name to the document template.

Parameters:
shortName - The new short name of the document template.
See Also:
getShortName(), SHORT_NAME_PROPERTY

getDescription

public String getDescription()
Returns the description of the document template. The description of the document template is initialized from the description attribute of the settings element defining the document template.

See Also:
setDescription(java.lang.String), DESCRIPTION_PROPERTY

setDescription

public void setDescription(String description)
Sets the description of the document template.

Parameters:
description - The new description of the document template.
See Also:
getDescription(), DESCRIPTION_PROPERTY

getDefaultDocumentName

public String getDefaultDocumentName()
Returns the default name to be given to the document created by this document template. This name is used to create the title of a document created by the document template using the methods IlvApplication.newDocument(IlvDocumentTemplate, boolean, Object) or IlvApplication.newDocument() or IlvApplication.newDocumentOnLastTemplate(). It is initialized with the defaultDocumentName attribute of the settings element defining the document template.

Returns:
The default name for documents created by the document template.
See Also:
setDefaultDocumentName(java.lang.String)

setDefaultDocumentName

public void setDefaultDocumentName(String defaultName)
Sets the default name to set to the document created by this document template.

Parameters:
defaultName - The new default name of the documents of this document template.
See Also:
getDefaultDocumentName()

isMDI

public boolean isMDI()
Determines whether more than one document can be created by the document template at the same time.
If the document template is not MDI and is asked to create a new document, it checks first whether a document previously created is still open. If so, this document is saved and cleaned and is used for opening the new data associated with the new document to open. Typically, applications that open workspace documents do not allow you to open more than one workspace at the same time. The document template defining workspace documents is not MDI. As another example, applications that open text or image documents usually allow you to have more than one text or image document open at the same time. Document templates associated with those documents are then MDI.

The MDI property of the document template is initialized from the isMDI attribute of the settings element defining the document template. If this attribute is not specified, the document template is considered to be MDI by default.

Returns:
true if more than one document can be open at the same time; false otherwise.
See Also:
setMDI(boolean)

setMDI

public void setMDI(boolean mdi)
Sets the document template as MDI or not, depending on the value of the mdi parameter.

Parameters:
mdi - If true, the document template is set to MDI; if false, the parameter is not MDI.
See Also:
isMDI()

hasOwnRecentFileList

public boolean hasOwnRecentFileList()
Determines whether the documents opened by this document template are referenced in a list of Most Recently Used files specific to this document template.
For example, storing Most Recently Used files in a separate file list can be useful for documents like projects or workspaces.

Returns:
true if the documents of this document template are referenced in a list of Most Recently Used files specific to this document template; false if the documents are referenced in the global list of Most Recently Used files of the application.
See Also:
getRecentFileListCommand()

getRecentFileListCommand

public String getRecentFileListCommand()
Returns the command key of the action that stores the list of Most Recently Used files for this document template. This method is invoked only if hasOwnRecentFileList() returns true.

Returns:
The command key of the recent file list action.
See Also:
hasOwnRecentFileList()

connectMainWindow

public void connectMainWindow(IlvMainWindow mainWindow)
Associates this document template with a main window. The container templates defined in the main window are connected to the document template.

Parameters:
mainWindow - The main window to which this document template is connected.
See Also:
IlvMainWindow.getContainerTemplate(java.lang.String)

getMenuCompletion

public IlvMenuCompletion getMenuCompletion(IlvMainWindow mainWindow)
Returns the menu completion instance that is responsible for completing/removing items from the main menu and toolbars of the specified main window. The menu completion of the document template is created from the <menuCompletion> child element of the settings element defining this document template. If no such element is specified, this method returns null.

Parameters:
mainWindow - The main window with the menus and toolbars that will be modified by the menu completion of this document template.
Returns:
The menu completion of the document template - can be null.

readSettings

public boolean readSettings(IlvSettings settings,
                            IlvApplication application)
Reads the settings of the document template. The document template is initialized from the root settings element with the documentTemplate type and whose name attribute is equal to the name of the document template, given by the method getName().

Parameters:
settings - The settings from which to initialize the document template.
application - The application to which this document template will be added. It can be used for localizing strings or resolving URLs.
Returns:
true if the document template could be initialized from the specified settings; false otherwise.
See Also:
readSettings(IlvSettingsElement, IlvApplication)

readSettings

public boolean readSettings(IlvSettingsElement element,
                            IlvApplication application)
Reads the settings of the document template from the specified settings element.

Parameters:
element - The settings element from which the settings are read.
application - The application of the document template. It can be used for localizing strings or resolving URLs.
Returns:
true if the settings of the document template could be read; false otherwise.

getSettingsElement

public IlvSettingsElement getSettingsElement()
Returns the settings element that provides the settings for this document template.


actionPerformed

public void actionPerformed(ActionEvent e)
Invoked when an action occurs. A document template can handle action events only if a document of this document template is active in the application.
This method is invoked only if the isProcessingAction(java.lang.String) method returns true with the e.getActionCommand() value as the parameter.

Specified by:
actionPerformed in interface ActionListener
Parameters:
e - The action event.
See Also:
isProcessingAction(java.lang.String)

isProcessingAction

public boolean isProcessingAction(String command)
Determines whether the document template is able to perform the action with the specified command key. A document template can handle actions only if a document of this document template is active in the application.

Specified by:
isProcessingAction in interface ActionHandler
Parameters:
command - The command key of the action.
Returns:
true if the document template can process the specified action; false otherwise.
See Also:
actionPerformed(java.awt.event.ActionEvent)

updateAction

public boolean updateAction(Action action)
Invoked by the application for updating the state of the specified action.
A document template can handle actions only if a document of this document template is active in the application. By default, the method returns false.

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

getIcon

public Icon getIcon()
Returns the icon associated with this document template.
This icon is associated with the file names of the document that this template can open in the File Chooser of the application.
This icon is also set in the title bars of tab panes or internal frames created by this document template.

Returns:
The icon of the document template.
See Also:
ICON_PROPERTY, getIcon(java.lang.String)

getIcon

public Icon getIcon(String configurationName)
Returns the icon for the specified view configuration with the specified name. If no icon has been defined in the settings of this view configuration, this method returns the icon of the document template, given with the method getIcon().

Parameters:
configurationName - The name of the IlvDocumentViewConfiguration to return the icon for.
Returns:
The icon of the view configuration.
Since:
JViews6.0
See Also:
getIcon()

closeDocument

public boolean closeDocument(IlvDocument document,
                             boolean force)
Tries to close the specified document. If the force parameter is false, the application user is prompted for saving the document if it is modified. If the document can be closed, all the document views associated with this document that are not static are closed.

Parameters:
document - The document to close.
force - If true, the document will be closed whenever it has been modified, without the application user being asked for confirmation. If false, the user will be asked to saved the document if it has been modified and can cancel the operation.
Returns:
true if the document was closed; false otherwise.

saveDocumentModifications

public boolean saveDocumentModifications(IlvDocument document)
Saves the specified document if it was modified. If the document is a file document and does not yet have a specified file name, a file chooser is displayed to ask for it.

Returns:
true if the document was not modified or if the document was saved. Otherwise, the method returns false.

closeViewContainer

public boolean closeViewContainer(IlvMDIViewContainer container)
Closes the specified view container. The implementation of this method invokes the method closeViewContainer(IlvMDIViewContainer, boolean) with true as the closeDocument parameter.

Parameters:
container - The view container to close.
Returns:
true if the container could be closed; false otherwise.
See Also:
closeViewContainer(IlvMDIViewContainer, boolean)

closeViewContainer

public boolean closeViewContainer(IlvMDIViewContainer container,
                                  boolean closeDocument)
Closes the specified view container.

Parameters:
container - The view container to close.
closeDocument - If true, the document associated with the container and all the views of the document are closed; Otherwise, the document is not closed even though the document remains with no associated views.
Returns:
true if the container could be closed; false otherwise.
See Also:
closeViewContainer(IlvMDIViewContainer)

canCloseViewContainer

public boolean canCloseViewContainer(IlvViewContainer container)
Determines whether the specified view container can be closed. The view(s) of the container are first notified that their container is being closed.

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

setProperty

public Object setProperty(String key,
                          Object value)
Changes the value of one of the properties of this document template. 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 object 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 to the properties of this document template.