public class IlvFileDocumentTemplate extends IlvDocumentTemplate
IlvFileDocument
instances.
<filters>
child element. This
element contains a variable list of <filter>
elements,
each element defining a file filter. The format
attribute
of the <filter>
element specifies a regular expression -
like "*.txt"
- that selects the file that the document template can
open. The description
attribute contains a string that describes
the files open with this filter, like "Text Document (*.txt)
.
This string should be a key to a string resource.
Filters of a file document template are accessible with the getFilter(int)
and getFilterCount()
methods. New file filters can be added with
the method addFilter(ilog.views.appframe.docview.IlvFileFilter)
.
Modifier and Type | Field and Description |
---|---|
static String |
DEFAULT_FILE_FILTER_PROPERTY
Bounds property for storing the default file filter to be used by
this document template.
|
DATA_CLASS_PROPERTY, DEFAULT_DOCUMENT_NAME_PROPERTY, DESCRIPTION_PROPERTY, DOCUMENT_CLASS_PROPERTY, ICON_PROPERTY, NAME_PROPERTY, SELECTED_CONFIGURATION_PROPERTY, SETTINGS_TYPE, SHORT_NAME_PROPERTY, UNDO_LIMIT_PROPERTY
Constructor and Description |
---|
IlvFileDocumentTemplate()
Creates an
IlvFileDocumentTemplate instance. |
IlvFileDocumentTemplate(String name)
Creates an
IlvFileDocumentTemplate instance with the specified
template name. |
Modifier and Type | Method and Description |
---|---|
void |
actionPerformed(ActionEvent e)
Invoked when an action occurs.
|
void |
addFilter(IlvFileFilter fileFilter)
Adds the specified
fileFilter to the list of filters
that this
document template accepts. |
boolean |
appearsInLoadFileFilters()
Determines whether files that can be opened by this file document template
can be selected from the main application file chooser or
the New document dialog box.
|
boolean |
appearsInNewDocuments()
Specifies whether this file document template is selectable
in the
New Document dialog box of the application. |
protected IlvFileFilter |
createFileFilter(String extension,
String description)
Factory method for creating a file filter for the specified
file
extension . |
IlvFileFilter |
getDefaultFilter()
Returns the file filter of this document template that is
selected by default in file choosers displayed for this file document
template.
|
IlvFileFilter |
getFilter(int index)
Returns the file filter at the specified storage
index in this document template. |
int |
getFilterCount()
Returns the number of file filters that this file document template supports.
|
int |
getFilterIndex(IlvFileFilter fileFilter)
Returns the storage index of the specified
fileFilter in the
array of file filters of the document template. |
IlvFileFilter |
getMatchingFilter(String filename)
Returns the file filter of this document template that matches the
specified
filename . |
IlvFileFilter |
getMatchingFilter(URL url)
Returns the file filter of this document template that matches the
specified
url . |
void |
initializeFileChooser(JFileChooser fileChooser,
boolean openMode)
Initializes the specified file chooser with all the file filters
of this document template that apply to the specified
open
mode. |
boolean |
isProcessingAction(String command)
Determines whether the document template is able to perform the action
with the specified
command key. |
boolean |
matchPathName(String filename)
Determines whether this document template can open a file with the
specified
filename . |
boolean |
matchPathName(URL url)
Determines whether this document template can open a file with the
specified
url . |
boolean |
readDocument(IlvFileDocument document,
URL url,
IlvFileFilter fileFilter)
Makes the specified file document read its data from the
file with the specified
url . |
boolean |
readDocument(IlvStreamDocument document,
Reader reader,
IlvFileFilter fileFilter)
Makes the specified stream document read its data with the
specified
reader . |
boolean |
readSettings(IlvSettingsElement element,
IlvApplication application)
Reads the settings of the file document template from the specified
settings element.
|
boolean |
removeFilter(IlvFileFilter fileFilter)
Removes the specified
fileFilter from the list of filters
that this document template accepts. |
boolean |
revertDocument(IlvFileDocument document)
Reloads the document data from the file of the document.
|
void |
setAppearsInLoadFileFilters(boolean appears)
Specifies whether this file document template appears in the main
file chooser or New document dialog box of the application.
|
void |
setAppearsInNewDocuments(boolean appearsInNewDocuments)
Specifies whether this file document template is selectable
in the
New Document dialog box of the application. |
IlvFileFilter |
setDefaultFilter(IlvFileFilter fileFilter)
Specifies that the specified
fileFilter of this document
template will be selected by default in file choosers displayed for
this file document template. |
void |
setDocumentPathName(IlvFileDocument document,
URL path)
Sets the document path of the specified
document to the
specified path . |
activateDocumentView, activateDocumentView, addPropertyChangeListener, alwaysShowMenu, canCloseViewContainer, closeDocument, closeDocumentView, closeDocumentViews, closeViewContainer, closeViewContainer, connectMainWindow, createDocument, createDocumentViews, documentActivated, documentViewExists, ensureDocumentViewExists, getApplication, getDataClass, getDefaultDocumentName, getDescription, getDocumentClass, getDocumentContainers, getIcon, getIcon, getMenuCompletion, getName, getProperty, getRecentFileListCommand, getSettings, getSettingsElement, getShortName, getViewConfiguration, getViewConfiguration, getViewConfigurationCount, hasOwnRecentFileList, initializeDocumentViews, insertBars, isMDI, matchData, newMDIViewContainer, newViewContainer, newViewContainer, readSettings, removeBars, removePropertyChangeListener, saveDocumentModifications, setApplication, setDefaultDocumentName, setDescription, setDocumentClass, setMDI, setName, setProperty, setSettings, setShortName, updateAction, updateViewContainerTitles
public static final String DEFAULT_FILE_FILTER_PROPERTY
public IlvFileDocumentTemplate()
IlvFileDocumentTemplate
instance.public IlvFileDocumentTemplate(String name)
IlvFileDocumentTemplate
instance with the specified
template name.name
- The name of the document template.public boolean matchPathName(URL url)
url
.true
if the specified path matches with at least one of
the document template filters.getMatchingFilter(java.net.URL)
public boolean matchPathName(String filename)
filename
.true
if the specified path matches with at least one of
the document template filters.getMatchingFilter(String)
public IlvFileFilter getMatchingFilter(URL url)
url
.url
or
null
if no file filter could be found.public IlvFileFilter getMatchingFilter(String filename)
filename
.filename
or
null
if no file filter could be found.getMatchingFilter(URL)
public boolean readDocument(IlvFileDocument document, URL url, IlvFileFilter fileFilter)
url
.
The document is first cleaned, its
IlvFileDocument.readDocument(java.net.URL, ilog.views.appframe.docview.IlvFileFilter)
is called,
and its modification state is then cleared.document
- The document to make read its data.url
- The URL of the file the document will read its data from.fileFilter
- The file filter selected when selecting the specified
url
.true
if the document could read its data;
false
otherwise.readDocument(IlvStreamDocument, Reader, IlvFileFilter)
public boolean readDocument(IlvStreamDocument document, Reader reader, IlvFileFilter fileFilter)
reader
.
The document is first cleaned, its
IlvStreamDocument.readStreamDocument(java.io.Reader, ilog.views.appframe.docview.IlvFileFilter)
is called,
and its modification state is then cleared.document
- The document to make read its data.reader
- The reader to read the document data from.fileFilter
- The file filter corresponding to the specified stream.true
if the document could read its data;
false
otherwise.readDocument(IlvFileDocument, URL, IlvFileFilter)
public void setDocumentPathName(IlvFileDocument document, URL path)
document
to the
specified path
.
This method must not be invoked explicitly: it is called by the document
template when the document loads its data from a file or when the document
saves its data with a new path through the File/Save As...
menu
item. By default, this method
updates the title of the document if the title was not previously
explicitly set using the method IlvDocument.setTitle(java.lang.String)
.public boolean revertDocument(IlvFileDocument document)
IlvDocument.clean()
method and
the method IlvFileDocument.readDocument(java.net.URL, IlvFileFilter)
is called with the
document path URL as the parameter.true
if the document data could be loaded from the
document file; false
otherwise.public void initializeFileChooser(JFileChooser fileChooser, boolean openMode)
open
mode.fileChooser
- The file chooser to initialize.openMode
- If true
the file chooser is used for
selecting a file to open; if false
the file chooser is used
for selecting a file for saving a document.public int getFilterCount()
addFilter(ilog.views.appframe.docview.IlvFileFilter)
public IlvFileFilter getFilter(int index)
index
in this document template.getFilterCount()
public void addFilter(IlvFileFilter fileFilter)
fileFilter
to the list of filters
that this
document template accepts.fileFilter
- The new file filter to add.removeFilter(ilog.views.appframe.docview.IlvFileFilter)
public IlvFileFilter setDefaultFilter(IlvFileFilter fileFilter)
fileFilter
of this document
template will be selected by default in file choosers displayed for
this file document template.fileFilter
- The new default file filter.null
if no file filter was previously the default one.getDefaultFilter()
public IlvFileFilter getDefaultFilter()
null
if no file
filter has been specified as the default.setDefaultFilter(ilog.views.appframe.docview.IlvFileFilter)
public boolean removeFilter(IlvFileFilter fileFilter)
fileFilter
from the list of filters
that this document template accepts.fileFilter
- The file filter to remove.true
if the filter is owned by the document
template; false
otherwise.addFilter(ilog.views.appframe.docview.IlvFileFilter)
public int getFilterIndex(IlvFileFilter fileFilter)
fileFilter
in the
array of file filters of the document template.-1
if the file filter is not
owned by the document template.public boolean appearsInLoadFileFilters()
true
if this document template is taken into account
by the application when processing the
IlvApplication.OPEN_DOCUMENT_CMD
or IlvApplication.NEW_DOCUMENT_CMD
;
false
otherwise.setAppearsInLoadFileFilters(boolean)
public void setAppearsInLoadFileFilters(boolean appears)
appears
- If true
, the document template appears in the
main file chooser or New document dialog box of the application. If
false
, it does not.appearsInLoadFileFilters()
public boolean appearsInNewDocuments()
New Document
dialog box of the application.
This dialog is launched when processing the action
NewDocument
.true
if the document template is liste in
the New Document
dialog box. Otherwise, this method
returns false
.setAppearsInNewDocuments(boolean)
,
appearsInLoadFileFilters()
public void setAppearsInNewDocuments(boolean appearsInNewDocuments)
New Document
dialog box of the application.
This dialog is launched when processing the action
NewDocument
.appearsInNewDocuments
- If true
,
the document template appears in the New Document
dialog box of the application. If
false
, it does not.appearsInNewDocuments()
public void actionPerformed(ActionEvent e)
isProcessingAction(java.lang.String)
method
returns true
with the e.getActionCommand()
value as the parameter.actionPerformed
in interface ActionListener
actionPerformed
in class IlvDocumentTemplate
e
- The action event.isProcessingAction(java.lang.String)
public boolean isProcessingAction(String command)
command
key.
A document template can handle actions only if a document of this
document template is active in the application.
isProcessingAction
in interface ActionHandler
isProcessingAction
in class IlvDocumentTemplate
command
- The command key of the action.true
if the document template can process the specified
action; false
otherwise.actionPerformed(java.awt.event.ActionEvent)
public boolean readSettings(IlvSettingsElement element, IlvApplication application)
readSettings
in class IlvDocumentTemplate
element
- The settings element to read the settings from.application
- The application of the document template. It can be used
for localizing strings or resolving URLs.true
if the settings of the document template could
be read; false
otherwise.protected IlvFileFilter createFileFilter(String extension, String description)
extension
. This method is invoked when the file
document template reads its filters from the settings.extension
- The file extension filtered by the filter to create.description
- The description associated with the file filter to
create. This description should be a string resource key.IlvFileFilter
instance.© Copyright Rogue Wave Software, Inc. 1997, 2018. All Rights Reserved.