public abstract class IlvAbstractDocument extends Object implements IlvDocument
IlvDocument
interface
to serve as a basis for implementing various kinds of documents.Modifier and Type | Field and Description |
---|---|
static String |
REDO_CMD
Action command key for the
Redo action. |
static String |
UNDO_CMD
Action command key for the
Undo action. |
APPLICATION_PROPERTY, ATTACHED_DOCUMENTS_PROPERTY, DOCUMENT_OWNER_PROPERTY, DOCUMENT_TEMPLATE_PROPERTY, EDITABLE_PROPERTY, MODIFIED_PROPERTY, SAVEABLE_PROPERTY, TITLE_PROPERTY
Constructor and Description |
---|
IlvAbstractDocument()
Constructs a new
IlvAbstractDocument . |
Modifier and Type | Method and Description |
---|---|
void |
actionPerformed(ActionEvent event)
Processes the specified action
event . |
void |
activated(boolean active)
Invoked when the document has been activated or deactivated.
|
void |
addActionHandler(ActionHandler actionHandler)
Adds the specified
actionHandler to the list of action handlers of
the document. |
void |
addEdit(UndoableEdit edit)
Adds the specified undoable edit to the undo manager owned by the document.
|
void |
addPropertyChangeListener(PropertyChangeListener listener)
Adds a listener that listens for changes to the document properties.
|
void |
addView(IlvDocumentView view)
Adds the specified instance of
IlvDocumentView to the list of views of the document. |
void |
attachDocument(IlvDocument document,
boolean attach)
Attaches or detaches the specified
document from this
document, depending on the value of the attach parameter. |
boolean |
canRedo()
Returns
true if a redo operation can be performed by the
document; false otherwise. |
boolean |
canUndo()
Returns
true if an undo operation can be performed by the
document; false otherwise. |
void |
clean()
Cleans up the document.
|
void |
documentClosed()
Invoked after the document was closed.
|
void |
documentClosing()
Invoked before the document closes.
|
IlvDocumentView |
getActiveView()
Returns the view currently active for the document, namely the
last view of the document that became active to the application.
|
IlvApplication |
getApplication()
Returns the application of the document.
|
IlvDocumentTemplate |
getDocumentTemplate()
Returns the document template that has created the document.
|
Object |
getProperty(String name)
Returns the value of the document property with the specified key.
|
String |
getTitle()
Returns the title of the document.
|
UndoManager |
getUndoManager()
Returns the undo manager that stores undoable edits added to the document.
|
IlvDocumentView |
getView(int index)
Returns the view of the document at the specified position in the
list of document views.
|
int |
getViewCount()
Returns the number of views associated with this document.
|
IlvDocumentView[] |
getViews()
Returns all the document views associated with the document.
|
boolean |
initializeDocument(Object userData)
Initializes a new document.
|
boolean |
isModified()
Returns the modification state of the document.
|
boolean |
isProcessingAction(String command)
Determines whether the document is able to perform the action
with the specified
command key in its
actionPerformed(java.awt.event.ActionEvent) method. |
protected void |
notifyViews(String name,
IlvDocumentView except,
Object[] params)
Notifies the views associated with this document of an event.
|
void |
receiveMessage(MessageEvent event)
Invoked when the specified message
event is received. |
void |
redo()
Redoes the last undoable edit undone by the document.
|
protected void |
registerMappings(IlvMessageMapper msgMapper)
This method is called to register the mappings between action events and
document methods.
|
boolean |
removeActionHandler(ActionHandler actionHandler)
Removes the specified
actionHandler from the list of action
handlers managed by this document. |
void |
removePropertyChangeListener(PropertyChangeListener listener)
Removes the specified listener from the document listener list.
|
boolean |
removeView(IlvDocumentView view)
Removes the specified
view from the list of views of the document. |
void |
removeViews()
Removes all the views owned by the document.
|
void |
setApplication(IlvApplication application)
Sets the application of the document.
|
void |
setModified(boolean modified)
Marks this document as modified.
|
Object |
setProperty(String name,
Object value)
Sets one of the properties of this document using the associated key.
|
void |
setTitle(String title)
Sets a new title to the document.
|
void |
undo()
Undoes the last undoable edit added to the document.
|
boolean |
updateAction(Action action)
Invoked by the application for updating the state of the specified
action . |
protected void |
updateModificationState()
Updates the modification state of the document.
|
public static final String UNDO_CMD
Undo
action.public static final String REDO_CMD
Redo
action.public IlvAbstractDocument()
IlvAbstractDocument
. Initialization
of the empty document should be performed in the initializeDocument(java.lang.Object)
method.initializeDocument(java.lang.Object)
public boolean initializeDocument(Object userData)
true
.initializeDocument
in interface IlvDocument
userData
- The user data to initialize the document with - can be
null
. This parameter is not used by default.true
. Overridden methods return true
if the document was successfully initialized, or false
otherwise.IlvApplication.newDocument(java.lang.Object, boolean)
,
IlvApplication.newDocument()
,
IlvApplication.newDocument(IlvDocumentTemplate, boolean, Object)
public void documentClosing()
documentClosing
in interface IlvDocument
documentClosed()
public void documentClosed()
documentClosed
in interface IlvDocument
documentClosing()
public void clean()
clean
in interface IlvDocument
public void activated(boolean active)
activated
in interface IlvDocument
active
- If this parameter is true
, the document has been activated.
If it is false
, the document has been deactivated.public int getViewCount()
getViewCount
in interface IlvDocument
public boolean removeView(IlvDocumentView view)
view
from the list of views of the document.removeView
in interface IlvDocument
true
if the specified view has been removed
from the list of views of the document; false
if the
view has not been added to the document.addView(ilog.views.appframe.docview.IlvDocumentView)
public void removeViews()
removeViews
in interface IlvDocument
public void addView(IlvDocumentView view)
IlvDocumentView
to the list of views of the document.addView
in interface IlvDocument
view
- The view to add to the list of views of the document.getViewCount()
,
removeView(ilog.views.appframe.docview.IlvDocumentView)
,
removeViews()
public IlvDocumentView getView(int index)
getView
in interface IlvDocument
index
- The storage index of the view to return.getView(int)
public IlvDocumentView[] getViews()
public IlvDocumentView getActiveView()
public boolean isModified()
isModified
in interface IlvDocument
true
if the document is modified; false
otherwise.setModified(boolean)
public void setModified(boolean modified)
setModified
in interface IlvDocument
modified
- The new modification state of the document. If
true
, the document is marked as modified. If
false
, the document is marked as unmodified.isModified()
,
addEdit(javax.swing.undo.UndoableEdit)
public String getTitle()
TITLE_PROPERTY
is returned.getTitle
in interface IlvDocument
setTitle(java.lang.String)
public void setTitle(String title)
setTitle
in interface IlvDocument
title
- The new title of the document.getTitle()
public IlvDocumentTemplate getDocumentTemplate()
getDocumentTemplate
in interface IlvDocument
IlvDocument.DOCUMENT_TEMPLATE_PROPERTY
that is automatically set by the
document template of the document.public boolean updateAction(Action action)
action
. For example, the implementation of this method
can enable or disable the action. By default, the document processes the state of
actions with the following command names:updateAction
in interface ActionHandler
action
- The action to update.true
if the action handler has updated the state
of the action; false
otherwise.public void actionPerformed(ActionEvent event)
event
.
This method is called only when isProcessingAction(java.lang.String)
returns
true
for the action command corresponding to this event as
the parameter. By default, the document processes the
actions with the following command keys:actionPerformed
in interface ActionListener
public boolean isProcessingAction(String command)
command
key in its
actionPerformed(java.awt.event.ActionEvent)
method. By default, the document processes the
actions with the following command names:isProcessingAction
in interface ActionHandler
command
- The command key of the action.true
if the document can handle
the specified action; false
otherwise.actionPerformed(java.awt.event.ActionEvent)
protected void registerMappings(IlvMessageMapper msgMapper)
msgMapper
- The message mapper to register mappings to.IlvMessageMapper.registerActionMethod(java.lang.String, java.lang.String)
,
IlvMessageMapper.registerActionStateMethod(java.lang.String, java.lang.String)
public void addActionHandler(ActionHandler actionHandler)
actionHandler
to the list of action handlers of
the document.actionHandler
- The new action handler to add.removeActionHandler(ilog.views.appframe.event.ActionHandler)
public boolean removeActionHandler(ActionHandler actionHandler)
actionHandler
from the list of action
handlers managed by this document.true
if the action handler has been previously added;
false
otherwise.addActionHandler(ilog.views.appframe.event.ActionHandler)
public void receiveMessage(MessageEvent event)
event
is received.receiveMessage
in interface MessageListener
event
- The message event.MessageEvent
public UndoManager getUndoManager()
addEdit(javax.swing.undo.UndoableEdit)
,
undo()
,
canUndo()
,
redo()
,
canRedo()
public boolean canUndo()
true
if an undo operation can be performed by the
document; false
otherwise.undo()
public void undo()
canUndo()
,
addEdit(javax.swing.undo.UndoableEdit)
public boolean canRedo()
true
if a redo operation can be performed by the
document; false
otherwise.redo()
public void redo()
canRedo()
public void addEdit(UndoableEdit edit)
edit
- the undoable edit to add.protected void updateModificationState()
getUndoManager()
protected void notifyViews(String name, IlvDocumentView except, Object[] params)
name
and list of
parameters to the associated document views.name
- The name of the message to send.except
- Specifies a particular view that must not receive this
message. Can be null
for notifying all the views of the
document.params
- The parameters of the message.public Object setProperty(String name, Object value)
PropertyChangeEvent
is sent to
property change listeners.setProperty
in interface IlvPropertyManager
name
- The non-null property namevalue
- An Object
value. If it is equal to
null
, the property with the specified key is removed.getProperty(java.lang.String)
public Object getProperty(String name)
getProperty
in interface IlvPropertyManager
name
- The name of the document property whose value is retrieved.IlvPropertyManager.setProperty(java.lang.String, java.lang.Object)
public IlvApplication getApplication()
getApplication
in interface IlvDocument
APPLICATION_PROPERTY
that is automatically
set by the document template of the document.setApplication(ilog.views.appframe.IlvApplication)
public void setApplication(IlvApplication application)
application
- The application of the document.public void addPropertyChangeListener(PropertyChangeListener listener)
addPropertyChangeListener
in interface IlvPropertyManager
listener
- The listener to add.removePropertyChangeListener(java.beans.PropertyChangeListener)
public void removePropertyChangeListener(PropertyChangeListener listener)
removePropertyChangeListener
in interface IlvPropertyManager
listener
- The listener to remove.addPropertyChangeListener(java.beans.PropertyChangeListener)
public void attachDocument(IlvDocument document, boolean attach)
document
from this
document, depending on the value of the attach
parameter.
Attached documents are automatically closed when the
document they are attached to is closed.document
- The document to attach to this document.attach
- If true
, the specified document is attached
to this document; if false
, the document is detached from this
document.© Copyright 2024 Rogue Wave Software, Inc., a Perforce company.. All Rights Reserved.