Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

org.merlotxml.merlot
Class XMLEditorDoc  view XMLEditorDoc download XMLEditorDoc.java

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

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.

Version:
$Id: XMLEditorDoc.java,v 1.5 2002/03/22 13:38:41 flament Exp $

Nested Class Summary
protected  class XMLEditorDoc.DocCloseAction
           
protected  class XMLEditorDoc.DocCopyAction
           
protected  class XMLEditorDoc.DocCutAction
           
protected  class XMLEditorDoc.DocDeleteNodeAction
           
protected  class XMLEditorDoc.DocEditNodeAction
           
protected  class XMLEditorDoc.DocEditTextAction
           
protected  class XMLEditorDoc.DocPasteAfterAction
           
protected  class XMLEditorDoc.DocPasteBeforeAction
           
protected  class XMLEditorDoc.DocPasteIntoAction
           
protected  class XMLEditorDoc.DocSaveAction
           
protected  class XMLEditorDoc.DocSaveAsAction
           
private  class XMLEditorDoc.SelectNodeRunnable
           
 
Field Summary
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.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)
           
 void addNewNode(MerlotDOMNode parent, java.lang.String elementname, MerlotDOMNode sibling, int action)
           
 void addUndoableEdit(javax.swing.undo.UndoableEdit e)
           
 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)
           
 void cut(java.awt.event.ActionEvent evt)
           
 void deleteNodes()
           
 org.w3c.dom.Document getDocument()
           
 org.merlotxml.util.xml.DTDCacheEntry getDTDCacheEntry()
           
 org.merlotxml.merlot.plugin.dtd.DTDPluginConfig getDTDPluginConfig()
           
 XMLFile getFile()
           
protected  javax.swing.Icon getFrameIcon()
           
 javax.swing.JInternalFrame getInternalFrame()
           
 DOMTreeTableAdapter getTreeTableModel()
           
 javax.swing.undo.UndoManager getUndoManager()
           
 XMLEditorDocUI getXMLEditorDocUI()
           
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)
          requests a transferable object be pasted
 void pasteAfter(int row)
          Pastes what's on the clipboard after the given node.
 void pasteBefore(int row)
           
 void pasteInto(int row)
           
 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)
           
 void setDirty(boolean d)
          Mark this document to be saved
protected  void setupActions()
           
protected  void setupTree()
          Creates the treetable model from the document.
 void undo(java.awt.event.ActionEvent evt)
           
 
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


_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


XMLEditorDoc

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


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()

setupTree

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


getXMLEditorDocUI

public XMLEditorDocUI getXMLEditorDocUI()

getFrameIcon

protected javax.swing.Icon getFrameIcon()

setDirty

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


isDirty

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


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

setActive

public void setActive(boolean tf)

getTreeTableModel

public DOMTreeTableAdapter getTreeTableModel()

getInternalFrame

public javax.swing.JInternalFrame getInternalFrame()

getFile

public XMLFile getFile()

getDocument

public org.w3c.dom.Document getDocument()

getDTDCacheEntry

public org.merlotxml.util.xml.DTDCacheEntry getDTDCacheEntry()

getDTDPluginConfig

public org.merlotxml.merlot.plugin.dtd.DTDPluginConfig getDTDPluginConfig()

saveDocument

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


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


checkClose

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


closeDocument

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


deleteNodes

public void deleteNodes()

cut

public void cut(java.awt.event.ActionEvent evt)
Specified by:
cut in interface MerlotTransferableListener

copy

public void copy(java.awt.event.ActionEvent evt)
Specified by:
copy in interface MerlotTransferableListener

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.


pasteBefore

public void pasteBefore(int row)

pasteInto

public void pasteInto(int row)

paste

public void paste(java.awt.event.ActionEvent evt)
Description copied from interface: MerlotTransferableListener
requests a transferable object be pasted

Specified by:
paste in interface MerlotTransferableListener

undo

public void undo(java.awt.event.ActionEvent evt)

addNewNode

public void addNewNode(MerlotDOMNode parent,
                       java.lang.String elementname)

addNewNode

public void addNewNode(MerlotDOMNode parent,
                       java.lang.String elementname,
                       MerlotDOMNode sibling,
                       int action)

addUndoableEdit

public void addUndoableEdit(javax.swing.undo.UndoableEdit e)

getUndoManager

public javax.swing.undo.UndoManager getUndoManager()

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