org.apache.batik.apps.svgbrowser

Class DOMViewer.Panel

public class DOMViewer.Panel extends JPanel

The panel that contains the viewer.
Nested Class Summary
protected classDOMViewer.Panel.AttributeModificationHandler
Handles "DOMAttrModified" event.
protected classDOMViewer.Panel.CapturingClickHandler
Handles the capturing "mouseclick" event.
protected classDOMViewer.Panel.CharacterPanel
The CharacterData panel text area.
protected classDOMViewer.Panel.CharDataModificationHandler
Handles "DOMCharacterDataModified" event.
protected classDOMViewer.Panel.DOMTreeSelectionListener
To listen to the tree selection.
protected classDOMViewer.Panel.NodeCSSValuesModel
To display the CSS properties of a DOM node in a table.
protected classDOMViewer.Panel.NodeInsertionHandler
Handles "DOMNodeInserted" event.
protected classDOMViewer.Panel.NodeRemovalHandler
Handles "DOMNodeRemoved" event.
protected classDOMViewer.Panel.NodeRenderer
To render the tree nodes.
protected classDOMViewer.Panel.NodeTemplateParser
Parser for the Element template.
protected classDOMViewer.Panel.TreeNodeAdder
Handles tree pop-up menu action for adding new node.
protected classDOMViewer.Panel.TreeNodeRemover
Handles tree pop-up menu action for removing nodes.
protected classDOMViewer.Panel.TreePopUpListener
Tree popup listener.
Field Summary
static StringATTRIBUTE_MODIFIED
protected NodePickerPanelattributePanel
The panel to show the nodes attributes.
protected GridBagConstraintsattributePanelLayout
The layout for the attribute panel.
protected EventListenerattrModification
"Attribute modified" DOM Mutation Listener.
protected EventListenercapturingListener
Capturing "click" event type listener.
protected DOMViewer.Panel.CharacterPanelcharacterDataPanel
The CharacterData node panel.
protected EventListenercharDataModification
"Character data modified" DOM Mutation Listener.
static StringCHAR_DATA_MODIFIED
protected Documentdocument
The DOM document.
protected JTextAreadocumentInfo
The documentInfo panel text area.
protected JPaneldocumentInfoPanel
The documentInfo node panel.
protected JPanelelementPanel
The element panel.
protected EventListenernodeInsertion
"Node inserted" DOM Mutation Listener.
protected EventListenernodeRemoval
"Node removed" DOM Mutation Listener.
static StringNODE_INSERTED
static StringNODE_REMOVED
protected JTablepropertiesTable
The properties table.
protected GridBagConstraintspropertiesTableLayout
The layout for the properties table.
protected JPanelrightPanel
The right panel.
protected JSplitPanesplitPane
The split pane.
protected DOMDocumentTreetree
The tree.
protected ViewCSSviewCSS
The ViewCSS object associated with the document.
Constructor Summary
Panel()
Creates a new Panel object.
Method Summary
protected voidaddCapturingListener(Document doc)
Registers capturing "click" listener on the document element of the given document.
protected voidaddDomMutationListeners(Document doc)
Registers DOM Mutation Listener on the given document.
protected JMenucreateTemplatesMenu(String name)
Creates JMenu menu using NodeTemplates.
protected MutableTreeNodecreateTree(Node node, boolean showWhitespace)
Creates a swing tree from a DOM document.
protected DefaultMutableTreeNodefindNode(JTree theTree, Node node)
Finds and returns the node in the tree that represents the given node in the document.
protected voidrefreshGUI(Runnable runnable)
Checks whether the DOMViewer can be used to edit the document and if true refreshes the DOMViewer after the DOM Mutation event occured.
protected voidregisterAttributeAdded(MutationEvent mevt)
Adds the "DOMAttrModified" Mutation event, of the MutationEvent.ADDITION type to current history browser's interface compound command
protected voidregisterAttributeChanged(MutationEvent mevt)
Checks what type of the "DOMAttrModified" mutation event occured, and invokes the appropriate method to register the change.
protected voidregisterAttributeModified(MutationEvent mevt)
Adds the "DOMAttrModified" Mutation event, of the MutationEvent.MODIFICATION type to current history browser's interface compound command
protected voidregisterAttributeRemoved(MutationEvent mevt)
Adds the "DOMAttrModified" Mutation event, of the MutationEvent.REMOVAL type to current history browser's interface compound command
protected voidregisterCharDataModified(MutationEvent mevt)
Adds the "DOMCharDataModified" Mutation event to current history browser's interface compound command
protected voidregisterDocumentChange(MutationEvent mevt)
Puts the document change in the current history browser's interface compound command if the document change occured outside of the DOMViewer.
protected voidregisterNodeInserted(MutationEvent mevt)
Adds the "DOMNodeInserted" Mutation event to current history browser's interface compound command
protected voidregisterNodeRemoved(MutationEvent mevt)
Adds the "DOMNodeRemoved" Mutation event to current history browser's interface compound command
protected voidremoveCapturingListener(Document doc)
Removes previously registered capturing "click" event listener from the document element of the given document.
protected voidremoveDomMutationListeners(Document doc)
Removes previously registered mutation listeners from the document.
voidselectNode(Node targetNode)
Finds and selects the given node in the document tree.
voidsetDocument(Document doc)
Sets the document to display.
voidsetDocument(Document doc, ViewCSS view)
Sets the document to display and its ViewCSS.
protected booleanshouldRegisterDocumentChange()
Checks if the document change that occured should be registered.

Field Detail

ATTRIBUTE_MODIFIED

public static final String ATTRIBUTE_MODIFIED

attributePanel

protected NodePickerPanel attributePanel
The panel to show the nodes attributes.

attributePanelLayout

protected GridBagConstraints attributePanelLayout
The layout for the attribute panel.

attrModification

protected EventListener attrModification
"Attribute modified" DOM Mutation Listener.

capturingListener

protected EventListener capturingListener
Capturing "click" event type listener. Allows the "capturing click" option

characterDataPanel

protected DOMViewer.Panel.CharacterPanel characterDataPanel
The CharacterData node panel.

charDataModification

protected EventListener charDataModification
"Character data modified" DOM Mutation Listener.

CHAR_DATA_MODIFIED

public static final String CHAR_DATA_MODIFIED

document

protected Document document
The DOM document.

documentInfo

protected JTextArea documentInfo
The documentInfo panel text area.

documentInfoPanel

protected JPanel documentInfoPanel
The documentInfo node panel.

elementPanel

protected JPanel elementPanel
The element panel.

nodeInsertion

protected EventListener nodeInsertion
"Node inserted" DOM Mutation Listener.

nodeRemoval

protected EventListener nodeRemoval
"Node removed" DOM Mutation Listener.

NODE_INSERTED

public static final String NODE_INSERTED

NODE_REMOVED

public static final String NODE_REMOVED

propertiesTable

protected JTable propertiesTable
The properties table.

propertiesTableLayout

protected GridBagConstraints propertiesTableLayout
The layout for the properties table.

rightPanel

protected JPanel rightPanel
The right panel.

splitPane

protected JSplitPane splitPane
The split pane.

tree

protected DOMDocumentTree tree
The tree.

viewCSS

protected ViewCSS viewCSS
The ViewCSS object associated with the document.

Constructor Detail

Panel

public Panel()
Creates a new Panel object.

Method Detail

addCapturingListener

protected void addCapturingListener(Document doc)
Registers capturing "click" listener on the document element of the given document.

Parameters: doc The given document

addDomMutationListeners

protected void addDomMutationListeners(Document doc)
Registers DOM Mutation Listener on the given document.

Parameters: doc The given document

createTemplatesMenu

protected JMenu createTemplatesMenu(String name)
Creates JMenu menu using NodeTemplates.

Parameters: name The name of the submenu

Returns: The JMenu submenu

createTree

protected MutableTreeNode createTree(Node node, boolean showWhitespace)
Creates a swing tree from a DOM document.

findNode

protected DefaultMutableTreeNode findNode(JTree theTree, Node node)
Finds and returns the node in the tree that represents the given node in the document.

Parameters: theTree The given JTree node The given org.w3c.dom.Node

Returns: Node or null if not found

refreshGUI

protected void refreshGUI(Runnable runnable)
Checks whether the DOMViewer can be used to edit the document and if true refreshes the DOMViewer after the DOM Mutation event occured.

Parameters: runnable The runnable to invoke for refresh

registerAttributeAdded

protected void registerAttributeAdded(MutationEvent mevt)
Adds the "DOMAttrModified" Mutation event, of the MutationEvent.ADDITION type to current history browser's interface compound command

Parameters: mevt The Mutation Event

registerAttributeChanged

protected void registerAttributeChanged(MutationEvent mevt)
Checks what type of the "DOMAttrModified" mutation event occured, and invokes the appropriate method to register the change.

Parameters: mevt The Mutation Event

registerAttributeModified

protected void registerAttributeModified(MutationEvent mevt)
Adds the "DOMAttrModified" Mutation event, of the MutationEvent.MODIFICATION type to current history browser's interface compound command

Parameters: mevt The Mutation Event

registerAttributeRemoved

protected void registerAttributeRemoved(MutationEvent mevt)
Adds the "DOMAttrModified" Mutation event, of the MutationEvent.REMOVAL type to current history browser's interface compound command

Parameters: mevt The Mutation Event

registerCharDataModified

protected void registerCharDataModified(MutationEvent mevt)
Adds the "DOMCharDataModified" Mutation event to current history browser's interface compound command

Parameters: mevt The Mutation Event

registerDocumentChange

protected void registerDocumentChange(MutationEvent mevt)
Puts the document change in the current history browser's interface compound command if the document change occured outside of the DOMViewer.

Parameters: mevt The info on the event. Use to describe the document change to the history browser

registerNodeInserted

protected void registerNodeInserted(MutationEvent mevt)
Adds the "DOMNodeInserted" Mutation event to current history browser's interface compound command

Parameters: mevt The Mutation Event

registerNodeRemoved

protected void registerNodeRemoved(MutationEvent mevt)
Adds the "DOMNodeRemoved" Mutation event to current history browser's interface compound command

Parameters: mevt The Mutation Event

removeCapturingListener

protected void removeCapturingListener(Document doc)
Removes previously registered capturing "click" event listener from the document element of the given document.

Parameters: doc The given document

removeDomMutationListeners

protected void removeDomMutationListeners(Document doc)
Removes previously registered mutation listeners from the document.

Parameters: doc The document

selectNode

public void selectNode(Node targetNode)
Finds and selects the given node in the document tree.

Parameters: targetNode The node to be selected

setDocument

public void setDocument(Document doc)
Sets the document to display.

setDocument

public void setDocument(Document doc, ViewCSS view)
Sets the document to display and its ViewCSS.

shouldRegisterDocumentChange

protected boolean shouldRegisterDocumentChange()
Checks if the document change that occured should be registered. If the document change has occured out of the DOMViewer, the state of the history browser should be HistoryBrowserState.IDLE. Otherwise, if the DOMViewer caused the change, one of the following states is active: HistoryBrowserState.EXECUTING, HistoryBrowserState.UNDOING, HistoryBrowserState.REDOING. This method should be invoked while the document change is occuring (in mutation event handlers), otherwise, if put in another thread, the state flag becomes invalid. Also checks if the DOMViewer can be used to edit the document. If not, then the change shouldn't be registered by the HistoryBrowser

Returns: True if the DOMViewer can edit the document and the history browser state is IDLE at the moment

Copyright B) 2008 Apache Software Foundation. All Rights Reserved.