org.merlotxml.merlot
Class XMLEditorDoc

java.lang.Object
  extended byorg.merlotxml.merlot.XMLEditorDoc
All Implemented Interfaces:
java.awt.datatransfer.ClipboardOwner, java.util.EventListener, MerlotConstants, MerlotTransferableListener, java.beans.PropertyChangeListener

public class XMLEditorDoc
extends java.lang.Object
implements MerlotTransferableListener, java.awt.datatransfer.ClipboardOwner, MerlotConstants, java.beans.PropertyChangeListener

XMLEditorDoc contains information and classes for a single XML file. It provides the actions for a specific document such as cut, copy, paste.

Author:
Kelly A. Campbell

Nested Class Summary
protected  class XMLEditorDoc.CollapseNodeAction
          Description of the Class
protected  class XMLEditorDoc.DocCloseAction
          Description of the Class
protected  class XMLEditorDoc.DocCopyAction
          Description of the Class
protected  class XMLEditorDoc.DocCutAction
          Description of the Class
protected  class XMLEditorDoc.DocDeleteNodeAction
          Description of the Class
protected  class XMLEditorDoc.DocEditNodeAction
          Description of the Class
protected  class XMLEditorDoc.DocEditTextAction
          Description of the Class
protected  class XMLEditorDoc.DocPasteAfterAction
          Description of the Class
protected  class XMLEditorDoc.DocPasteBeforeAction
          Description of the Class
protected  class XMLEditorDoc.DocPasteIntoAction
          Description of the Class
protected  class XMLEditorDoc.DocSaveAction
          Description of the Class
protected  class XMLEditorDoc.DocSaveAsAction
          Description of the Class
protected  class XMLEditorDoc.ExpandNodeAction
          Description of the Class
 
Field Summary
protected  javax.swing.Action _collapseNodeAction
          Description of the Field
protected  javax.swing.Action _copyNodeAction
          Action for copying node(s) from the document
protected  javax.swing.Action _cutNodeAction
          Action for cutting node(s) from the document
protected  javax.swing.Action _deleteNodeAction
          Action to perform when the user deletes a node
protected  boolean _docActive
          true when this document is the active window in the main frame (actions are enabled)
protected static int _docseq
          Sequence which is incremented each time a new document is created.
protected  DOMTreeTableAdapter _domTree
          This provides the data model mapping DOM to JTreeTableModel
protected  javax.swing.Action _editNodeAction
          Action to perform when the user chooses to edit a node
protected  javax.swing.Action _editTextAction
          Action to perform when the user chooses to edit some text
protected  javax.swing.Action _expandNodeAction
          Description of the Field
protected  javax.swing.JInternalFrame _frame
          The frame for this document
protected  boolean _ok_to_close
          variable used while checking if the document needs saved when the user clicks the close box
protected  javax.swing.Action _pasteAfterAction
          Paste after current node action
protected  javax.swing.Action _pasteBeforeAction
          Paste before current node action
protected  javax.swing.Action _pasteIntoAction
          Paste into the current node
protected  java.lang.String _title
          Title for the document frame
protected  XMLEditorDocUI _ui
          The user interface class for the document
protected  javax.swing.undo.UndoManager _undoManager
          The undo manager for document node actions
protected  XMLFile _xmlFile
          The XML file object for this document
 
Fields inherited from interface org.merlotxml.merlot.MerlotConstants
ACTION_MENU_ACCELERATOR, ACTION_MENU_ICON, ACTION_NAME, ACTION_SHORT_DESCRIPTION, ACTION_SMALL_ICON, AFTER, BEFORE, ERR, INTO, UI, XML
 
Constructor Summary
XMLEditorDoc()
          Default constructor.
XMLEditorDoc(java.io.File f)
          Constructor for a document from a File
XMLEditorDoc(XMLFile f)
          Constructor from a XMLFile object
 
Method Summary
 void addNewNode(MerlotDOMNode parent, java.lang.String elementname)
          Adds a feature to the NewNode attribute of the XMLEditorDoc object
 void addNewNode(MerlotDOMNode parent, java.lang.String elementname, MerlotDOMNode sibling, int action)
          Adds a feature to the NewNode attribute of the XMLEditorDoc object
 void addUndoableEdit(javax.swing.undo.UndoableEdit e)
          Adds a feature to the UndoableEdit attribute of the XMLEditorDoc object
 boolean checkClose()
          returns true if the document window can be closed, false otherwise
 boolean closeDocument()
          Closes the document unless the document is dirty and the user hits cancel when prompted.
 void copy(java.awt.event.ActionEvent evt)
          Description of the Method
 void cut(java.awt.event.ActionEvent evt)
          Description of the Method
 void deleteNodes()
          Description of the Method
 org.w3c.dom.Document getDocument()
          Gets the document attribute of the XMLEditorDoc object
 DTDCacheEntry getDTDCacheEntry()
          Gets the dTDCacheEntry attribute of the XMLEditorDoc object
 DTDPluginConfig getDTDPluginConfig()
          Gets the dTDPluginConfig attribute of the XMLEditorDoc object
 XMLFile getFile()
          Gets the file attribute of the XMLEditorDoc object
protected  javax.swing.Icon getFrameIcon()
          Gets the frameIcon attribute of the XMLEditorDoc object
 javax.swing.JInternalFrame getInternalFrame()
          Gets the internalFrame attribute of the XMLEditorDoc object
 DOMTreeTableAdapter getTreeTableModel()
          Gets the treeTableModel attribute of the XMLEditorDoc object
 javax.swing.undo.UndoManager getUndoManager()
          Gets the undoManager attribute of the XMLEditorDoc object
 ValidationThread getValidationThread()
           
 XMLEditorDocUI getXMLEditorDocUI()
          Gets the xMLEditorDocUI attribute of the XMLEditorDoc object
protected  void init()
          Setup the ui and the internal frame stuff
 boolean isDirty()
          returns true if this document is marked as dirty (needs saved)
 void lostOwnership(java.awt.datatransfer.Clipboard cb, java.awt.datatransfer.Transferable t)
          for implementing the ClipboardOwner interface
 void paste(java.awt.event.ActionEvent evt)
          Description of the Method
 void pasteAfter(int row)
          Pastes what's on the clipboard after the given node.
 void pasteBefore(int row)
          Description of the Method
 void pasteInto(int row)
          Description of the Method
 void propertyChange(java.beans.PropertyChangeEvent evt)
          Get property change event for dirty attribute and enable/disable actions depending on the dirty attribute
 boolean saveDocument()
          Saves the document in the current file.
 boolean saveDocumentAs()
          Save a new document, or save the document under a new name.
 void setActive(boolean tf)
          Sets the active attribute of the XMLEditorDoc object
 void setDirty(boolean d)
          Mark this document to be saved
protected  void setupActions()
          Description of the Method
protected  void setupTree()
          Creates the treetable model from the document.
 void undo(java.awt.event.ActionEvent evt)
          Description of the Method
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_xmlFile

protected XMLFile _xmlFile
The XML file object for this document


_ui

protected XMLEditorDocUI _ui
The user interface class for the document


_domTree

protected DOMTreeTableAdapter _domTree
This provides the data model mapping DOM to JTreeTableModel


_frame

protected javax.swing.JInternalFrame _frame
The frame for this document


_ok_to_close

protected boolean _ok_to_close
variable used while checking if the document needs saved when the user clicks the close box


_docseq

protected static int _docseq
Sequence which is incremented each time a new document is created. used to generate the Untitled-# filename.


_title

protected java.lang.String _title
Title for the document frame


_editNodeAction

protected javax.swing.Action _editNodeAction
Action to perform when the user chooses to edit a node


_expandNodeAction

protected javax.swing.Action _expandNodeAction
Description of the Field


_collapseNodeAction

protected javax.swing.Action _collapseNodeAction
Description of the Field


_editTextAction

protected javax.swing.Action _editTextAction
Action to perform when the user chooses to edit some text


_deleteNodeAction

protected javax.swing.Action _deleteNodeAction
Action to perform when the user deletes a node


_cutNodeAction

protected javax.swing.Action _cutNodeAction
Action for cutting node(s) from the document


_copyNodeAction

protected javax.swing.Action _copyNodeAction
Action for copying node(s) from the document


_pasteBeforeAction

protected javax.swing.Action _pasteBeforeAction
Paste before current node action


_pasteAfterAction

protected javax.swing.Action _pasteAfterAction
Paste after current node action


_pasteIntoAction

protected javax.swing.Action _pasteIntoAction
Paste into the current node


_undoManager

protected javax.swing.undo.UndoManager _undoManager
The undo manager for document node actions


_docActive

protected boolean _docActive
true when this document is the active window in the main frame (actions are enabled)

Constructor Detail

XMLEditorDoc

public XMLEditorDoc(java.io.File f)
             throws MerlotException
Constructor for a document from a File

Parameters:
f - Description of the Parameter
Throws:
MerlotException - Description of the Exception

XMLEditorDoc

public XMLEditorDoc(XMLFile f)
             throws MerlotException
Constructor from a XMLFile object

Parameters:
f - Description of the Parameter
Throws:
MerlotException - Description of the Exception

XMLEditorDoc

public XMLEditorDoc()
Default constructor. Doesn't really do anything

Method Detail

init

protected void init()
Setup the ui and the internal frame stuff


setupActions

protected void setupActions()
Description of the Method


setupTree

protected void setupTree()
Creates the treetable model from the document.


getXMLEditorDocUI

public XMLEditorDocUI getXMLEditorDocUI()
Gets the xMLEditorDocUI attribute of the XMLEditorDoc object

Returns:
The xMLEditorDocUI value

getFrameIcon

protected javax.swing.Icon getFrameIcon()
Gets the frameIcon attribute of the XMLEditorDoc object

Returns:
The frameIcon value

setDirty

public void setDirty(boolean d)
Mark this document to be saved

Parameters:
d - The new dirty value

isDirty

public boolean isDirty()
returns true if this document is marked as dirty (needs saved)

Returns:
The dirty value

propertyChange

public void propertyChange(java.beans.PropertyChangeEvent evt)
Get property change event for dirty attribute and enable/disable actions depending on the dirty attribute

Specified by:
propertyChange in interface java.beans.PropertyChangeListener
Parameters:
evt - Description of the Parameter

setActive

public void setActive(boolean tf)
Sets the active attribute of the XMLEditorDoc object

Parameters:
tf - The new active value

getTreeTableModel

public DOMTreeTableAdapter getTreeTableModel()
Gets the treeTableModel attribute of the XMLEditorDoc object

Returns:
The treeTableModel value

getInternalFrame

public javax.swing.JInternalFrame getInternalFrame()
Gets the internalFrame attribute of the XMLEditorDoc object

Returns:
The internalFrame value

getFile

public XMLFile getFile()
Gets the file attribute of the XMLEditorDoc object

Returns:
The file value

getDocument

public org.w3c.dom.Document getDocument()
Gets the document attribute of the XMLEditorDoc object

Returns:
The document value

getDTDCacheEntry

public DTDCacheEntry getDTDCacheEntry()
Gets the dTDCacheEntry attribute of the XMLEditorDoc object

Returns:
The dTDCacheEntry value

getDTDPluginConfig

public DTDPluginConfig getDTDPluginConfig()
Gets the dTDPluginConfig attribute of the XMLEditorDoc object

Returns:
The dTDPluginConfig value

saveDocument

public boolean saveDocument()
Saves the document in the current file. Returns true if the document was saved, false if the user hit cancel.

Returns:
Description of the Return Value

saveDocumentAs

public boolean saveDocumentAs()
Save a new document, or save the document under a new name. Returns true if the document was saved, or false if the user hit cancel

Returns:
Description of the Return Value

checkClose

public boolean checkClose()
returns true if the document window can be closed, false otherwise

Returns:
Description of the Return Value

closeDocument

public boolean closeDocument()
Closes the document unless the document is dirty and the user hits cancel when prompted.

Returns:
true if the document was closed, false otherwise

deleteNodes

public void deleteNodes()
Description of the Method


cut

public void cut(java.awt.event.ActionEvent evt)
Description of the Method

Specified by:
cut in interface MerlotTransferableListener
Parameters:
evt - Description of the Parameter

copy

public void copy(java.awt.event.ActionEvent evt)
Description of the Method

Specified by:
copy in interface MerlotTransferableListener
Parameters:
evt - Description of the Parameter

pasteAfter

public void pasteAfter(int row)
Pastes what's on the clipboard after the given node. We assume this is a valid operation without checking it because it should have been checked via enablePasteItems when building the menu.

Parameters:
row - Description of the Parameter

pasteBefore

public void pasteBefore(int row)
Description of the Method

Parameters:
row - Description of the Parameter

pasteInto

public void pasteInto(int row)
Description of the Method

Parameters:
row - Description of the Parameter

paste

public void paste(java.awt.event.ActionEvent evt)
Description of the Method

Specified by:
paste in interface MerlotTransferableListener
Parameters:
evt - Description of the Parameter

undo

public void undo(java.awt.event.ActionEvent evt)
Description of the Method

Parameters:
evt - Description of the Parameter

addNewNode

public void addNewNode(MerlotDOMNode parent,
                       java.lang.String elementname)
Adds a feature to the NewNode attribute of the XMLEditorDoc object

Parameters:
parent - The feature to be added to the NewNode attribute
elementname - The feature to be added to the NewNode attribute

addNewNode

public void addNewNode(MerlotDOMNode parent,
                       java.lang.String elementname,
                       MerlotDOMNode sibling,
                       int action)
Adds a feature to the NewNode attribute of the XMLEditorDoc object

Parameters:
parent - The feature to be added to the NewNode attribute
elementname - The feature to be added to the NewNode attribute
sibling - The feature to be added to the NewNode attribute
action - The feature to be added to the NewNode attribute

addUndoableEdit

public void addUndoableEdit(javax.swing.undo.UndoableEdit e)
Adds a feature to the UndoableEdit attribute of the XMLEditorDoc object

Parameters:
e - The feature to be added to the UndoableEdit attribute

getUndoManager

public javax.swing.undo.UndoManager getUndoManager()
Gets the undoManager attribute of the XMLEditorDoc object

Returns:
The undoManager value

lostOwnership

public void lostOwnership(java.awt.datatransfer.Clipboard cb,
                          java.awt.datatransfer.Transferable t)
for implementing the ClipboardOwner interface

Specified by:
lostOwnership in interface java.awt.datatransfer.ClipboardOwner
Parameters:
cb - Description of the Parameter
t - Description of the Parameter

getValidationThread

public ValidationThread getValidationThread()