|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.ObjectjApp.Document
public class Document
The Document
class represents the document in memory. Each
document is associated with a disk file and a file type. Document objects are
NOT created directly, instead they must be registered to the
FileTypeRegistry
. The Document
s are then created,by
theApplication
, in responce to user actions (e.g. selecting 'New'
from 'File' menu).
Document
is a base class for the actual document classes. A
separate, derived, class is needed for each file type the application
handles. Most appilications handle only one file type, although they can
convert to and from many file types.
The contents of the document are maintained by the derived class and stored
to / read from a File
maintained by the Document
.
The derived class needs to override writeToStream(java.io.ObjectOutputStream)
and
readFromStream(java.io.ObjectInputStream)
to store and retrieve the contents of the
Document
.
Some (or all) content of the document can be stored in Variable
s,
the Document
maintains a list of named variables and handles
the storing / restoring of their values automatically in a file in a version
independent maner.
The Document
is not a visible user interface component,
instead a document is associated with on or more DocumentWindow
s.
The Document
maintains a list of windows associated with it.
Each Document
stores a reference to the active Command
.
At most one Command
can be active at a time.
Each Document
is also associated with a
AbstractSelection
to facilitate the implementation of object oriented
user interface.
Nested Class Summary | |
---|---|
protected static class |
Document.SaveOptions
The save options that can be passed to the save(SaveOptions) . |
Field Summary | |
---|---|
protected java.awt.print.PageFormat |
m_PageFormat
|
protected Variable |
m_PrintRequestAttributes
|
protected Variable |
m_SelectedPrintService
|
protected Selection |
m_Selection
|
protected Undoer |
m_Undoer
|
protected Variable |
m_WindowStates
|
static boolean |
TRACK_RESPONCE
|
Constructor Summary | |
---|---|
protected |
Document()
The sole constructor. |
Method Summary | |
---|---|
void |
addItemsToRightClick(javax.swing.JPopupMenu popupMenu)
Handles right clicks. |
Variable |
addVariable(java.util.LinkedList list,
java.lang.String name,
Variable variable)
Adds a variable to this document Document . |
BooleanVariable |
addVariable(java.lang.String name,
BooleanVariable variable)
Adds a < BooleanVariable to this document
Document . |
DoubleVariable |
addVariable(java.lang.String name,
DoubleVariable variable)
Adds a < DoubleVariable to this document
Document . |
LongVariable |
addVariable(java.lang.String name,
LongVariable variable)
Adds a < LongVariable to this document
Document . |
StringVariable |
addVariable(java.lang.String name,
StringVariable variable)
Adds a < StringVariable to this document
Document . |
Variable |
addVariable(java.lang.String name,
Variable variable)
Adds a variable to this document Document . |
protected boolean |
canPaste(java.awt.datatransfer.DataFlavor[] availableFlavors)
Checks if any of the availableFlavors can be pasted. |
void |
causeRegen()
Causes all the DocumentWindow s associated with this
Document to be regenerated. |
void |
cleanUp()
Called to do cleam up once the document has been closed. |
protected int |
confirmRevert()
Confirms Reverting a Document. |
protected int |
confirmSave()
Confirms saving a Document . |
protected boolean |
confirmWrite(java.io.File file)
Checks that the given file can be overwriten and if not show a dialog informing the user. |
protected java.awt.datatransfer.Clipboard |
createClipboard()
Creates the default Clipboard object. |
protected javax.swing.Action |
createCopyAction()
Creates the default 'Copy' action. |
protected javax.swing.Action |
createCutAction()
Creates the default 'Cut' action. |
DataTransferHandler |
createDataTransferHandler()
The Document initialization code calls this method once to create
the a DataTransferHandler for this Document , which can
then be accessed using getDataTransferHandler() . |
protected javax.swing.Action |
createDeleteAction()
Creates the default 'Delete' action. |
protected java.io.ObjectInputStream |
createObjectInputStream(java.io.FileInputStream stream)
Method readFromStream(FileInputStream) calls this to create the
input stream. |
protected java.io.ObjectOutputStream |
createObjectOutputStream(java.io.FileOutputStream stream)
Method writeToStream(ObjectOutputStream) calls this to create
the input stream. |
protected javax.swing.Action |
createPasteAction()
Creates the default 'Paste' action. |
PreviewDialog |
createPreviewDialog(Document d)
Creates and returns a new PreviewDialog for this document. |
protected Selection |
createSelection()
Creates the default Selection object. |
protected Undoer |
createUndoer()
Creates the Undoer object for this Document. |
protected void |
createWindows()
Application calls this to create windows for a document. |
void |
detachFile()
Detaches this Document from the disk file. |
void |
execute(jApp.UndoableTask task)
|
Variable |
getActiveCommandVariable()
Gets the variable that is used to store a referece to the currently active command. |
DocumentWindow |
getActiveWindow()
Gets the active DocumentWindow for this
Document which should be the top most visible window on
the screen that is associted with this Document . |
Application |
getApplication()
Gets the Application object that instantiated this Document. |
java.awt.datatransfer.Clipboard |
getClipboard()
Gets the default Clipboard |
javax.swing.Action |
getCloseAction()
Gets the built in 'Close' action. |
javax.swing.KeyStroke |
getCloseShortCut()
Gets the built in 'Close' keyboard shortcut. |
Command |
getCommand()
Gets the currently active command for this Document . |
javax.swing.Action |
getCopyAction()
Gets the built in 'Copy' action. |
javax.swing.KeyStroke |
getCopyShortcut()
Gets the built in 'Copy' keyboard shortcut. |
javax.swing.Action |
getCutAction()
Gets the built in 'Cut' action. |
javax.swing.KeyStroke |
getCutShortcut()
Gets the built in 'Cut' keyboard shortcut. |
DataTransferHandler |
getDataTransferHandler()
Returns the DataTransferHandler for this Document . |
javax.swing.Action |
getDeleteAction()
Gets the built in 'Delete' action. |
javax.swing.KeyStroke |
getDeleteShortcut()
Gets the built in 'Delete' keyboard shortcut. |
DocumentPrinter |
getDocumentPrinter()
Creates and returns a new DocumentPrinter for this document. |
javax.swing.Action |
getExitAction()
Gets the built in 'Exit' action. |
javax.swing.KeyStroke |
getExitShortcut()
Gets the built in 'Exit/Quit' keyboard shortcut. |
java.io.File |
getFile()
Gets the file associated with this document. |
FileType |
getFileType()
Gets the FileType for this document. |
javax.swing.KeyStroke |
getNextWindowShortcut()
Gets the built in 'Cycle Windows' keyboard shortcut. |
protected java.awt.Component |
getParentComponentForDialogs()
Returns a component that is used in calls to JOptionPane.showXXX calls as the parentComponent. |
javax.swing.Action |
getPasteAction()
Gets the built in 'Paste' action. |
javax.swing.KeyStroke |
getPasteShortcut()
Gets the built in 'Paste' keyboard shortcut. |
javax.swing.Action |
getPrintAction()
Gets the built in 'Print' action. |
javax.swing.KeyStroke |
getPrintShortcut()
Gets the built in 'Print' keyboard shortcut. |
javax.swing.Action |
getRedoAction()
Gets the built in 'Redo' action. |
javax.swing.KeyStroke |
getRedoShortCut()
Gets the built in 'Redor' keyboard shortcut. |
javax.swing.Action |
getRevertAction()
Gets the built in 'Revert' action. |
javax.swing.Action |
getSaveAction()
|
javax.swing.Action |
getSaveAsAction()
Gets the built in 'SaveAs' action. |
javax.swing.Action |
getSaveCopyAction()
Gets the built in 'SaveCopy' action. |
javax.swing.KeyStroke |
getSaveShortcut()
Gets the built in 'Save' keyboard shortcut. |
protected java.io.File |
getSaveToFile()
Gets a file to save the Document to using the
Application JFileChooser . |
Selection |
getSelection()
Gets the selection object associated with this Document . |
javax.swing.Action |
getUndoAction()
Gets the built in 'Undo' action. |
Undoer |
getUndoer()
Gets the Undoer object for this Document. |
javax.swing.KeyStroke |
getUndoShortCut()
Gets the built in 'Undo' keyboard shortcut. |
java.util.Map<java.lang.String,Variable> |
getVariables()
Gets the Variables for this document. |
java.util.LinkedList<DocumentWindow> |
getWindows()
Gets the list of open DocumentWindow s. |
protected void |
initialize()
The jApp / Application calls this both for new and old
documents. |
protected void |
initNewDocument()
The Application calls this for new documents only, it is not called for documents that are read from files. |
boolean |
isDirty()
Used to check if the file has been changed and the contents needs to be 'saved' to a file when this
Document is 'closed'. |
void |
markDirty()
The same as calling markDirty(String) }. |
void |
markDirty(java.lang.String name)
Marks the document dirty and associates a name with this (to be used by the undo/redo system). |
void |
markNotDirty()
Marks the document as not dirty. |
protected boolean |
okToSaveToFile(java.io.File f,
FileType ft)
Checks if it is ok to save to a file of the given type. |
protected void |
openWindows()
Opens all the DocumentWindow s for this Document. |
protected void |
performCopy(java.lang.String actionName)
Performs the default copy operation by calling DataTransferHandler.createTransferable(javax.swing.JComponent, MouseEvent)
on the transfer handler returned by getDataTransferHandler() if any. |
protected void |
performCut(java.lang.String actionName)
Performs the default cut operation by first calling DataTransferHandler.createTransferable(javax.swing.JComponent, MouseEvent)
on the transfer handler returned by getDataTransferHandler() if any and then performDelete(String) . |
protected void |
performDelete(java.lang.String actionName)
The dafaul delete implementation, which does nothing. |
protected void |
performPaste(java.lang.String actionName)
Performs the default paste operaton by first calling DataTransferHandler.importData(Transferable, javax.swing.JComponent, Point)
on the transfer handler returned by getDataTransferHandler() with the Transferable retrieved from the
clipboard retrived using getClipboard() . |
protected void |
postInitilize()
The Application calls this both for new and old documents. |
protected void |
readFromFile(java.io.File file)
The Application calls this to read documen contents from a file. |
protected void |
readFromStream(java.io.FileInputStream fstream)
The jApp / Document calls this to read the contents of a
document from a stream. |
protected void |
readFromStream(java.io.ObjectInputStream stream)
The jApp / Document calls this to read the contents of a
document from an object stream. |
protected void |
readPageFormat(java.io.ObjectInputStream fstream)
The jApp / Document calls this to read the PageFormat from
a stream. |
protected void |
removeWindow(DocumentWindow window)
Removes a DocumentWindow from this document. |
void |
reportException(java.lang.Exception e)
Short cut to reportException(Exception) . |
protected boolean |
save(Document.SaveOptions saveMode)
Performs the saving of the document through a temporari file according to save mode. |
void |
selectCommand(Command command)
Short cut to selectCommand(Command cmd,false) . |
void |
selectCommand(Command command,
boolean asTemp)
Makes a Command the active command for this document. |
int |
showConfirmDialog(java.lang.String message,
java.lang.String title,
int type)
Calls Application.showConfirmDialog(Component, Object, String, int)
with the active window of this document as the Component parameter. |
void |
showErrorMessage(java.lang.String message,
java.lang.String title)
Calls Application.showMessageDialog(Component, Object, String, int)
with the active window of this document as the Component parameter and
JOptionPane.ERROR_MESSAGE as the type parameter. |
void |
showInfoMessage(java.lang.String message,
java.lang.String title)
Calls Application.showMessageDialog(Component, Object, String, int)
with the active window of this document as the Component parameter and
JOptionPane.INFORMATION_MESSAGE as the type parameter. |
void |
showWarningMessage(java.lang.String message,
java.lang.String title)
Calls Application.showMessageDialog(Component, Object, String, int)
with the active window of this document as the Component parameter and
JOptionPane.WARNING_MESSAGE as the type parameter. |
boolean |
tryCloseDocument()
Tries to close the Document . |
boolean |
tryCloseWindow(DocumentWindow window)
Closes the given DocumentWindow . |
protected void |
tryPrint(DocumentPrinter printer,
boolean showDialog,
boolean withPreview)
Tries to print the Document. |
boolean |
tryRevertDocument()
Tries to revert the Document to the last saved version. |
void |
updateFeedback()
Calls updateFeedback() for all open windows. |
protected void |
writePageFormat(java.io.ObjectOutputStream fstream)
The jApp / Document calls this to write the
writePageFormat to a stream. |
protected void |
writeToStream(java.io.FileOutputStream fstream)
The jApp / Document calls this to read the contents of a
document to a stream. |
protected void |
writeToStream(java.io.ObjectOutputStream stream)
The jApp / Document calls this to write the contents of a
document to an object stream. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final boolean TRACK_RESPONCE
protected Undoer m_Undoer
protected Selection m_Selection
protected java.awt.print.PageFormat m_PageFormat
protected final Variable m_SelectedPrintService
protected final Variable m_PrintRequestAttributes
protected final Variable m_WindowStates
Constructor Detail |
---|
protected Document()
Method Detail |
---|
public Application getApplication()
protected boolean confirmWrite(java.io.File file)
file
- the file to be written
public void detachFile()
public void markNotDirty()
public java.io.File getFile()
Document
.
Can return null.
public boolean isDirty()
Document
is 'closed'.
Document
have been
changed.public Variable getActiveCommandVariable()
public Selection getSelection()
Document
.
Document
public void markDirty(java.lang.String name)
Undoer
.
name
- the name of the action that can be undone /redone. Passing
null is equivalent to passing "".public void execute(jApp.UndoableTask task)
public void markDirty()
markDirty(String)
}.
public void causeRegen()
DocumentWindow
s associated with this
Document
to be regenerated.
public DocumentWindow getActiveWindow()
DocumentWindow
for this
Document
which should be the top most visible window on
the screen that is associted with this Document
.
DocumentWindow
, could return
null
public Command getCommand()
Document
.
Command
, if any. Can return
null
public void selectCommand(Command command, boolean asTemp)
Command
the active command for this document.
Terminates or suspends the previously active command. The new active
command can be selected temporarily in which case case the currently
active command is suspened otherwise it is terminated.
command
- the command to be active commandasTemp
- true the previously active command is to be suspended (not
terminated).public void reportException(java.lang.Exception e)
reportException(Exception)
.
e
- the exceptionpublic void selectCommand(Command command)
selectCommand(Command cmd,false)
.
command
- the Command
public DocumentPrinter getDocumentPrinter()
DocumentPrinter
for this document.
Override this method if the default DocumentPrinter
is not
what you require.
DocumentPrinter
objectpublic PreviewDialog createPreviewDialog(Document d)
PreviewDialog
for this document.
Override this method if the default PreviewDialog
is not
what you require.
PreviewDialog
objectprotected void tryPrint(DocumentPrinter printer, boolean showDialog, boolean withPreview)
printer
- The printer object that actual does the paintingshowDialog
- true to show the Print DialogwithPreview
- true to show the Preview Dialogprotected void removeWindow(DocumentWindow window)
public final Undoer getUndoer()
createUndoer()
protected Undoer createUndoer()
Undoer
public FileType getFileType()
protected void initialize()
Application
calls this both for new and old
documents. This gets called before readFromFile(File)
or
initDocument(Application, FileType)
protected void postInitilize()
Application
calls this both for new and old documents.
This gets called after readFromFile or initNewDocument
protected void initNewDocument()
protected void createWindows()
protected void openWindows()
DocumentWindow
s for this Document. If no
info on old windows is available then calls createWindows()
.
protected void readFromFile(java.io.File file) throws java.lang.Exception
readFromStream(FileInputStream)
, override if that to
read the contents of your documents, ovveride this if you do need
to perform file reading as opposed to stream reading.
file
- the file to read from.
java.lang.Exception
public final Variable addVariable(java.util.LinkedList list, java.lang.String name, Variable variable)
Document
. Adds an
additional reference to the variable to a list if a list is provided.
list
- this to add the variable to, can be nullname
- the name for the variable.variable
- the variable.
public final Variable addVariable(java.lang.String name, Variable variable)
Document
. Save as
calling addVariable(LinkedList, String, Variable)
with the list
parameter set to null
name
- the name for the variable.variable
- the variable.
public final LongVariable addVariable(java.lang.String name, LongVariable variable)
LongVariable
to this document
Document
. Save as calling
addVariable(LinkedList, String, Variable)
with the list
parameter set to null
name
- the name for the variable.variable
- the variable.
public final StringVariable addVariable(java.lang.String name, StringVariable variable)
StringVariable
to this document
Document
. Save as calling
addVariable(LinkedList, String, Variable)
with the list
parameter set to null
name
- the name for the variable.variable
- the variable.
public final DoubleVariable addVariable(java.lang.String name, DoubleVariable variable)
DoubleVariable
to this document
Document
. Save as calling
addVariable(LinkedList, String, Variable)
with the list
parameter set to null
name
- the name for the variable.variable
- the variable.
public final BooleanVariable addVariable(java.lang.String name, BooleanVariable variable)
BooleanVariable
to this document
Document
. Save as calling
addVariable(LinkedList, String, Variable)
with the list
parameter set to null
name
- the name for the variable.variable
- the variable.
protected void writeToStream(java.io.ObjectOutputStream stream) throws java.lang.Exception
Document
calls this to write the contents of a
document to an object stream. Override to implement persistency of
documents using object serialization.
stream
- the stream to write the contents to.
java.lang.Exception
- if something goes wrongprotected void readFromStream(java.io.ObjectInputStream stream) throws java.lang.Exception
Document
calls this to read the contents of a
document from an object stream. Override to implement persistency of
documents using object serialization.
stream
- the stream to write the contents to.
java.lang.Exception
- if something goes wrongprotected void writePageFormat(java.io.ObjectOutputStream fstream) throws java.lang.Exception
Document
calls this to write the
writePageFormat to a stream.
java.lang.Exception
protected void readPageFormat(java.io.ObjectInputStream fstream) throws java.lang.Exception
Document
calls this to read the PageFormat from
a stream.
java.lang.Exception
public java.util.Map<java.lang.String,Variable> getVariables()
protected void writeToStream(java.io.FileOutputStream fstream) throws java.lang.Exception
Document
calls this to read the contents of a
document to a stream. By default calls
writeToStream(ObjectOutputStream)
, override to implement
peristency with plain file streams.
fstream
- the stream to write the contents to.
java.lang.Exception
- if something goes wrongprotected java.io.ObjectOutputStream createObjectOutputStream(java.io.FileOutputStream stream) throws java.io.IOException
writeToStream(ObjectOutputStream)
calls this to create
the input stream. Override and return a derived class for example to
override methods of the object stream when necessary.
stream
- the FileOutputStream
to read the objects from
the ObjectOutputStream
to read from
java.io.IOException
protected void readFromStream(java.io.FileInputStream fstream) throws java.lang.Exception
Document
calls this to read the contents of a
document from a stream. By default calls
readFromStream(ObjectInputStream)
, override to implement
peristency with plain file streams.
fstream
- the stream to write the contents to.
java.lang.Exception
- if something goes wrongprotected java.io.ObjectInputStream createObjectInputStream(java.io.FileInputStream stream) throws java.io.IOException
readFromStream(FileInputStream)
calls this to create the
input stream. Override and return a derived class for example to override
methods of the object stream when necessary.
stream
- the FileInputStream
to read the objects from
the ObjectInputStream
to read from
java.io.IOException
protected int confirmRevert() throws java.lang.Exception
java.lang.Exception
- if something unexpectedly goes wrongprotected int confirmSave() throws java.lang.Exception
Document
.
JOptionPane.YES_OPTION
, JOptionPane.NO_OPTION
or
JOptionPane.CANCEL_OPTION
java.lang.Exception
- if something unexpected happensprotected boolean okToSaveToFile(java.io.File f, FileType ft)
Document
can open multiple types but save to one type of file only.
f
- the file to check.ft
- the tile tape to save to
protected java.io.File getSaveToFile() throws java.lang.Exception
Document
to using the
Application
JFileChooser
.
java.lang.Exception
- if something unexpected happens.protected boolean save(Document.SaveOptions saveMode) throws java.lang.Exception
saveMode
- the save mode as per {Document#SaveOptions}
java.lang.Exception
- if something goes wrongpublic boolean tryCloseWindow(DocumentWindow window) throws java.lang.Exception
DocumentWindow
. If the window is the
last (open) window for this document tries to close the
Document
if this fails for any reason (for example the
user cancels) neither the window nor the document is closed.
window
- the window to close
java.lang.Exception
public boolean tryRevertDocument() throws java.lang.Exception
Document
to the last saved version.
java.lang.IllegalStateException
- if there is no previous version (document is un-saved)
java.lang.Exception
public boolean tryCloseDocument() throws java.lang.Exception
Document
.
java.lang.Exception
- if something unexpected happens.public void cleanUp()
public java.util.LinkedList<DocumentWindow> getWindows()
DocumentWindow
s.
DocumentWindow
s associated with this Document
.public void updateFeedback()
updateFeedback()
for all open windows.
public javax.swing.Action getSaveAction()
public javax.swing.Action getSaveAsAction()
public javax.swing.Action getSaveCopyAction()
public javax.swing.Action getRevertAction()
public javax.swing.Action getCloseAction()
public javax.swing.Action getPrintAction()
public javax.swing.Action getExitAction()
public javax.swing.Action getCopyAction()
public javax.swing.Action getCutAction()
public javax.swing.Action getPasteAction()
public javax.swing.Action getDeleteAction()
public javax.swing.Action getUndoAction()
public javax.swing.Action getRedoAction()
public javax.swing.KeyStroke getNextWindowShortcut()
public javax.swing.KeyStroke getSaveShortcut()
public javax.swing.KeyStroke getCloseShortCut()
public javax.swing.KeyStroke getPrintShortcut()
public javax.swing.KeyStroke getExitShortcut()
public javax.swing.KeyStroke getUndoShortCut()
public javax.swing.KeyStroke getRedoShortCut()
public javax.swing.KeyStroke getCopyShortcut()
public javax.swing.KeyStroke getCutShortcut()
public javax.swing.KeyStroke getPasteShortcut()
public javax.swing.KeyStroke getDeleteShortcut()
public int showConfirmDialog(java.lang.String message, java.lang.String title, int type)
Application.showConfirmDialog(Component, Object, String, int)
with the active window of this document as the Component parameter.
message
- the message to show in the confirm dialogtitle
- the title for the dialogtype
- the type parameter passed to the JOptionPane
public void showInfoMessage(java.lang.String message, java.lang.String title)
Application.showMessageDialog(Component, Object, String, int)
with the active window of this document as the Component parameter and
JOptionPane.INFORMATION_MESSAGE as the type parameter.
message
- the message to show in the confirm dialogtitle
- the title for the dialogpublic void showErrorMessage(java.lang.String message, java.lang.String title)
Application.showMessageDialog(Component, Object, String, int)
with the active window of this document as the Component parameter and
JOptionPane.ERROR_MESSAGE as the type parameter.
message
- the message to show in the confirm dialogtitle
- the title for the dialogpublic void showWarningMessage(java.lang.String message, java.lang.String title)
Application.showMessageDialog(Component, Object, String, int)
with the active window of this document as the Component parameter and
JOptionPane.WARNING_MESSAGE as the type parameter.
message
- the message to show in the confirm dialogtitle
- the title for the dialogprotected java.awt.Component getParentComponentForDialogs()
JOptionPane.showXXX
calls as the parentComponent. The
default implementation returns null which results in centering the
dialogs on screen, which is propably the best option.
public void addItemsToRightClick(javax.swing.JPopupMenu popupMenu)
popupMenu
- the popup menu to fill inprotected javax.swing.Action createCopyAction()
actionPerformed
calls performCopy(String)
.
The action is associated with the Document
s Selection
and enabled if the Selection
is not empty. The Document
initialization code calls this method once to create a default 'Copy' action
which can be access using getCopyAction()
.
protected javax.swing.Action createCutAction()
actionPerformed
calls performCut(String)
.
The action is associated with the Document
s Selection
and enabled if the Selection
is not empty. The Document
initialization code calls this method once to create a default 'Cut' action
which can be access using getCutAction()
.
protected javax.swing.Action createPasteAction()
actionPerformed
calls performPaste(String)
.
The action is associated with the Clipboard
s
and enabled if the canPaste(DataFlavor[])
return true for the
available DataFlavor
s. The Document
initialization code calls this method once to create a default 'Paste' action
which can be access using getPasteAction()
.
protected javax.swing.Action createDeleteAction()
actionPerformed
calls performDelete(String)
.
The action is associated with the Document
s Selection
and enabled if the Selection
is not empty. The Document
initialization code calls this method once to create a default 'Delete' action
which can be access using getDeleteAction()
.
protected void performCopy(java.lang.String actionName)
DataTransferHandler.createTransferable(javax.swing.JComponent, MouseEvent)
on the transfer handler returned by getDataTransferHandler()
if any.
actionName
- the name of the operation, i.e. "Copy"protected void performCut(java.lang.String actionName)
DataTransferHandler.createTransferable(javax.swing.JComponent, MouseEvent)
on the transfer handler returned by getDataTransferHandler()
if any and then performDelete(String)
.
actionName
- the name of the operation, i.e. "Cut"protected void performPaste(java.lang.String actionName)
DataTransferHandler.importData(Transferable, javax.swing.JComponent, Point)
on the transfer handler returned by getDataTransferHandler()
with the Transferable
retrieved from the
clipboard retrived using getClipboard()
.
actionName
- the name of the operation, i.e. "Paste"protected boolean canPaste(java.awt.datatransfer.DataFlavor[] availableFlavors)
availableFlavors
can be pasted.
The default implementation consults the document's DataTransferHandler
's
DataTransferHandler.canImport(javax.swing.JComponent, DataFlavor[])
method.
availableFlavors
- the flavors that are available for pasting
protected void performDelete(java.lang.String actionName)
actionName
- the name of the operation, "Delete","Cut" or "Remove"protected java.awt.datatransfer.Clipboard createClipboard()
Clipboard
object.
The implemention is Document
returns the system clipboard.
(On Mac OS this actually returns a proxy clipboard to implement a workaround
for some bugs in Apple JVM/JRE).
The Document
initialization code calls this method once to create
the default clipboad, which can then be accessed using getClipboard()
.
getClipboard()
public java.awt.datatransfer.Clipboard getClipboard()
Clipboard
createClipboard()
protected Selection createSelection()
Selection
object.
The Document
initialization code calls this method once to create
the default Selection object, which can then be accessed using getSelection()
.
Unless overriden this routine returns an instance of SimpleSelction
.
Document
createSelection()
,
Selection
public DataTransferHandler createDataTransferHandler()
Document
initialization code calls this method once to create
the a DataTransferHandler
for this Document
, which can
then be accessed using getDataTransferHandler()
. The default
implementation here returns null
. Override to return a concrete class
to enable the Copy/Paste and Drag/Drop functionality.
()
public DataTransferHandler getDataTransferHandler()
DataTransferHandler
for this Document
.
createDataTransferHandler()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |