Package org.apache.batik.apps.svgbrowser
Class HistoryBrowserInterface
- java.lang.Object
-
- org.apache.batik.apps.svgbrowser.HistoryBrowserInterface
-
public class HistoryBrowserInterface extends java.lang.ObjectThe wrapper for the history browser. The commands for the historyBrowser are implemented here- Version:
- $Id: HistoryBrowserInterface.java 1733416 2016-03-03 07:07:13Z gadams $
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classHistoryBrowserInterface.AppendChildCommandThe AppendChild command.static classHistoryBrowserInterface.AttributeAddedCommandAdds the attribute to an element (MutationEvent.ADDITION)static classHistoryBrowserInterface.AttributeModifiedCommandModifies the attribute of an element (MutationEvent.MODIFICATION)static classHistoryBrowserInterface.AttributeRemovedCommandRemoves the attribute of an element (MutationEvent.REMOVAL)static classHistoryBrowserInterface.ChangeNodeValueCommandThe Change Node Value command.static classHistoryBrowserInterface.CharDataModifiedCommandSets the node value.static classHistoryBrowserInterface.CompoundUpdateCommandThe compound command.static classHistoryBrowserInterface.InsertNodeBeforeCommandInserts the given node as a child to the given parent node before the specified sibling node, or as the last child of the given parent, if the sibling node is null.static classHistoryBrowserInterface.NodeInsertedCommandInserts the given node as a child of another.static classHistoryBrowserInterface.NodeRemovedCommandRemoves the node from its parent node.static classHistoryBrowserInterface.RemoveChildCommandThe RemoveChild command.static classHistoryBrowserInterface.ReplaceChildCommandinsertBefore
-
Field Summary
Fields Modifier and Type Field Description private static java.lang.StringATTRIBUTE_ADDED_COMMANDprivate static java.lang.StringATTRIBUTE_MODIFIED_COMMANDprivate static java.lang.StringATTRIBUTE_REMOVED_COMMANDprivate static java.lang.StringCHAR_DATA_MODIFIED_COMMANDprivate static java.lang.StringCOMPOUND_TREE_NODE_DROPCompound tree node dropped command name.protected AbstractCompoundCommandcurrentCompoundCommandUsed to group custom number of changes into a single command.protected HistoryBrowserhistoryBrowserThe history browser.private static java.lang.StringNODE_INSERTED_COMMANDprivate static java.lang.StringNODE_REMOVED_COMMANDprivate static java.lang.StringOUTER_EDIT_COMMANDThe changes being performed outside of the DOMViewer.private static java.lang.StringREMOVE_SELECTED_NODESRemove selected nodes command name.
-
Constructor Summary
Constructors Constructor Description HistoryBrowserInterface(HistoryBrowser.CommandController commandController)Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddToCurrentCompoundCommand(AbstractUndoableCommand cmd)Adds the given command to current compound command.voidappendChild(org.w3c.dom.Node parent, org.w3c.dom.Node child)Adds and executes the AppendChildCommand to historyBrowser.voidattributeAdded(org.w3c.dom.Element contextElement, java.lang.String attributeName, java.lang.String newAttributeValue, java.lang.String namespaceURI)Adds the AttributeAddedCommand to historyBrowser.voidattributeModified(org.w3c.dom.Element contextElement, java.lang.String attributeName, java.lang.String prevAttributeValue, java.lang.String newAttributeValue, java.lang.String namespaceURI)Adds the AttributeModifiedCommand to historyBrowser.voidattributeRemoved(org.w3c.dom.Element contextElement, java.lang.String attributeName, java.lang.String prevAttributeValue, java.lang.String namespaceURI)Adds the AttributeRemovedCommand to historyBrowser.voidcharDataModified(org.w3c.dom.Node contextNode, java.lang.String oldValue, java.lang.String newValue)Adds CharDataModifiedCommand to historyBrowser.HistoryBrowserInterface.AppendChildCommandcreateAppendChildCommand(org.w3c.dom.Node parent, org.w3c.dom.Node child)Creates and return the AppendChild command.HistoryBrowserInterface.AttributeAddedCommandcreateAttributeAddedCommand(org.w3c.dom.Element contextElement, java.lang.String attributeName, java.lang.String newAttributeValue, java.lang.String namespaceURI)Creates the AttributeAdded command.HistoryBrowserInterface.AttributeModifiedCommandcreateAttributeModifiedCommand(org.w3c.dom.Element contextElement, java.lang.String attributeName, java.lang.String prevAttributeValue, java.lang.String newAttributeValue, java.lang.String namespaceURI)Creates the AttributeModified command.HistoryBrowserInterface.AttributeRemovedCommandcreateAttributeRemovedCommand(org.w3c.dom.Element contextElement, java.lang.String attributeName, java.lang.String prevAttributeValue, java.lang.String namespaceURI)Creates the AttributeRemoved command.HistoryBrowserInterface.ChangeNodeValueCommandcreateChangeNodeValueCommand(org.w3c.dom.Node contextNode, java.lang.String newValue)Creates and returns the ChangeNodeValue command.HistoryBrowserInterface.CharDataModifiedCommandcreateCharDataModifiedCommand(org.w3c.dom.Node contextNode, java.lang.String oldValue, java.lang.String newValue)Creates the CharDataModified command.HistoryBrowserInterface.CompoundUpdateCommandcreateCompoundUpdateCommand(java.lang.String commandName)Creates the compound update command, that consists of custom number of commands.UndoableCommandcreateInsertChildCommand(org.w3c.dom.Node parent, org.w3c.dom.Node sibling, org.w3c.dom.Node child)Creates InsertChildBefore or AppendChild command, depending on the value of siblingNode.HistoryBrowserInterface.InsertNodeBeforeCommandcreateInsertNodeBeforeCommand(org.w3c.dom.Node parent, org.w3c.dom.Node sibling, org.w3c.dom.Node child)Creates and returns the InsertNodeBeforeCommand.HistoryBrowserInterface.CompoundUpdateCommandcreateNodeChangedCommand(org.w3c.dom.Node node)Creates the compound NodeChangedCommand.HistoryBrowserInterface.NodeInsertedCommandcreateNodeInsertedCommand(org.w3c.dom.Node newParent, org.w3c.dom.Node newSibling, org.w3c.dom.Node contextNode)Creates the NodeInserted command.HistoryBrowserInterface.NodeRemovedCommandcreateNodeRemovedCommand(org.w3c.dom.Node oldParent, org.w3c.dom.Node oldSibling, org.w3c.dom.Node contextNode)Creates the NodeRemoved command.HistoryBrowserInterface.CompoundUpdateCommandcreateNodesDroppedCommand(java.util.ArrayList nodes)Creates the compound NodesDroppedCommand.HistoryBrowserInterface.RemoveChildCommandcreateRemoveChildCommand(org.w3c.dom.Node parent, org.w3c.dom.Node child)Creates and returns the RemoveChild command.HistoryBrowserInterface.CompoundUpdateCommandcreateRemoveSelectedTreeNodesCommand(java.util.ArrayList nodes)Creates the compound RemoveSelectedTreeNodesCommand.private java.lang.StringgetAppendChildCommandName(org.w3c.dom.Node parentNode, org.w3c.dom.Node childNode)Generates the "Append Child" command name.private java.lang.StringgetBracketedNodeName(org.w3c.dom.Node node)Gets the node info in brackets.private java.lang.StringgetChangeNodeValueCommandName(org.w3c.dom.Node contextNode, java.lang.String newValue)Generates the "Change Node Value" command name.AbstractCompoundCommandgetCurrentCompoundCommand()Gets the current compound command.HistoryBrowsergetHistoryBrowser()Gets the history browser.private java.lang.StringgetInsertBeforeCommandName(org.w3c.dom.Node parentNode, org.w3c.dom.Node childNode, org.w3c.dom.Node siblingNode)Generates the "Insert Child Before" command name.private java.lang.StringgetNodeAsString(org.w3c.dom.Node node)Gets the node name and the nodes id (nodeName + "nodeId").private java.lang.StringgetNodeChangedCommandName(org.w3c.dom.Node node)Generates the "Node Changed" command name.private java.lang.StringgetRemoveChildCommandName(org.w3c.dom.Node parent, org.w3c.dom.Node child)Generates the "Remove Child" command name.voidinsertChildBefore(org.w3c.dom.Node parent, org.w3c.dom.Node sibling, org.w3c.dom.Node child)Adds and executes the InsertNodeBeforeCommand to historyBrowser.voidnodeInserted(org.w3c.dom.Node newParent, org.w3c.dom.Node newSibling, org.w3c.dom.Node contextNode)Adds the NodeInsertedCommand to historyBrowser.voidnodeRemoved(org.w3c.dom.Node oldParent, org.w3c.dom.Node oldSibling, org.w3c.dom.Node contextNode)Adds the NodeRemovedCommand to historyBrowser.voidperformCompoundUpdateCommand(UndoableCommand command)Executes the given compound update command.voidperformCurrentCompoundCommand()Adds and executes the current compound command to history browser.voidremoveChild(org.w3c.dom.Node parent, org.w3c.dom.Node child)Adds and executes the RemoveChild command to the History Browser.voidreplaceChild(org.w3c.dom.Node parent, org.w3c.dom.Node newChild, org.w3c.dom.Node oldChild)Adds and executes the ReplaceChild command to historyBrowser.voidsetCommmandController(HistoryBrowser.CommandController newCommandController)Sets the history browser's command controller.voidsetNodeValue(org.w3c.dom.Node contextNode, java.lang.String newValue)Adds and executes the ChangeNodeValueCommand to historyBrowser.
-
-
-
Field Detail
-
ATTRIBUTE_ADDED_COMMAND
private static final java.lang.String ATTRIBUTE_ADDED_COMMAND
- See Also:
- Constant Field Values
-
ATTRIBUTE_REMOVED_COMMAND
private static final java.lang.String ATTRIBUTE_REMOVED_COMMAND
- See Also:
- Constant Field Values
-
ATTRIBUTE_MODIFIED_COMMAND
private static final java.lang.String ATTRIBUTE_MODIFIED_COMMAND
- See Also:
- Constant Field Values
-
NODE_INSERTED_COMMAND
private static final java.lang.String NODE_INSERTED_COMMAND
- See Also:
- Constant Field Values
-
NODE_REMOVED_COMMAND
private static final java.lang.String NODE_REMOVED_COMMAND
- See Also:
- Constant Field Values
-
CHAR_DATA_MODIFIED_COMMAND
private static final java.lang.String CHAR_DATA_MODIFIED_COMMAND
- See Also:
- Constant Field Values
-
OUTER_EDIT_COMMAND
private static final java.lang.String OUTER_EDIT_COMMAND
The changes being performed outside of the DOMViewer.- See Also:
- Constant Field Values
-
COMPOUND_TREE_NODE_DROP
private static final java.lang.String COMPOUND_TREE_NODE_DROP
Compound tree node dropped command name.- See Also:
- Constant Field Values
-
REMOVE_SELECTED_NODES
private static final java.lang.String REMOVE_SELECTED_NODES
Remove selected nodes command name.- See Also:
- Constant Field Values
-
historyBrowser
protected HistoryBrowser historyBrowser
The history browser.
-
currentCompoundCommand
protected AbstractCompoundCommand currentCompoundCommand
Used to group custom number of changes into a single command.
-
-
Constructor Detail
-
HistoryBrowserInterface
public HistoryBrowserInterface(HistoryBrowser.CommandController commandController)
Constructor. Creates the history browser.
-
-
Method Detail
-
setCommmandController
public void setCommmandController(HistoryBrowser.CommandController newCommandController)
Sets the history browser's command controller.- Parameters:
newCommandController- The commandController to set
-
createCompoundUpdateCommand
public HistoryBrowserInterface.CompoundUpdateCommand createCompoundUpdateCommand(java.lang.String commandName)
Creates the compound update command, that consists of custom number of commands.- Parameters:
commandName- Compound command name- Returns:
- CompoundUpdateCommand
-
createNodeChangedCommand
public HistoryBrowserInterface.CompoundUpdateCommand createNodeChangedCommand(org.w3c.dom.Node node)
Creates the compound NodeChangedCommand. Used to create the 'dynamic' NodeChangedCommand name- Returns:
- the CompoundUpdateCommand
-
createNodesDroppedCommand
public HistoryBrowserInterface.CompoundUpdateCommand createNodesDroppedCommand(java.util.ArrayList nodes)
Creates the compound NodesDroppedCommand. Used to create the 'dynamic' NodesDroppedCommand name- Parameters:
nodes- The list of the nodes that are being dropped- Returns:
- the CompoundUpdateCommand
-
createRemoveSelectedTreeNodesCommand
public HistoryBrowserInterface.CompoundUpdateCommand createRemoveSelectedTreeNodesCommand(java.util.ArrayList nodes)
Creates the compound RemoveSelectedTreeNodesCommand. Used to create the 'dynamic' RemoveSelectedTreeNodesCommand name- Parameters:
nodes- The list of the nodes that are selected and should be removed- Returns:
- the RemoveSelectedTreeNodesCommand
-
performCompoundUpdateCommand
public void performCompoundUpdateCommand(UndoableCommand command)
Executes the given compound update command.- Parameters:
command- The given compound update command
-
getHistoryBrowser
public HistoryBrowser getHistoryBrowser()
Gets the history browser.- Returns:
- the historyBrowser
-
nodeInserted
public void nodeInserted(org.w3c.dom.Node newParent, org.w3c.dom.Node newSibling, org.w3c.dom.Node contextNode)Adds the NodeInsertedCommand to historyBrowser.- Parameters:
newParent- New parent nodenewSibling- New (next) sibling nodecontextNode- The node to be appended
-
createNodeInsertedCommand
public HistoryBrowserInterface.NodeInsertedCommand createNodeInsertedCommand(org.w3c.dom.Node newParent, org.w3c.dom.Node newSibling, org.w3c.dom.Node contextNode)
Creates the NodeInserted command.- Parameters:
newParent- New parent nodenewSibling- New (next) sibling nodecontextNode- The node to be appended
-
nodeRemoved
public void nodeRemoved(org.w3c.dom.Node oldParent, org.w3c.dom.Node oldSibling, org.w3c.dom.Node contextNode)Adds the NodeRemovedCommand to historyBrowser.- Parameters:
oldParent- The node's old parentoldSibling- The node's old next siblingcontextNode- The node to be removed
-
createNodeRemovedCommand
public HistoryBrowserInterface.NodeRemovedCommand createNodeRemovedCommand(org.w3c.dom.Node oldParent, org.w3c.dom.Node oldSibling, org.w3c.dom.Node contextNode)
Creates the NodeRemoved command.- Parameters:
oldParent- The node's old parentoldSibling- The node's old next siblingcontextNode- The node to be removed
-
attributeAdded
public void attributeAdded(org.w3c.dom.Element contextElement, java.lang.String attributeName, java.lang.String newAttributeValue, java.lang.String namespaceURI)Adds the AttributeAddedCommand to historyBrowser.- Parameters:
contextElement- The context elementattributeName- The attribute namenewAttributeValue- The attribute valuenamespaceURI- The namespaceURI
-
createAttributeAddedCommand
public HistoryBrowserInterface.AttributeAddedCommand createAttributeAddedCommand(org.w3c.dom.Element contextElement, java.lang.String attributeName, java.lang.String newAttributeValue, java.lang.String namespaceURI)
Creates the AttributeAdded command.- Parameters:
contextElement- The context elementattributeName- The attribute namenewAttributeValue- The attribute valuenamespaceURI- The namespaceURI
-
attributeRemoved
public void attributeRemoved(org.w3c.dom.Element contextElement, java.lang.String attributeName, java.lang.String prevAttributeValue, java.lang.String namespaceURI)Adds the AttributeRemovedCommand to historyBrowser.- Parameters:
contextElement- The context elementattributeName- The attribute nameprevAttributeValue- The previous attribute valuenamespaceURI- The namespaceURI
-
createAttributeRemovedCommand
public HistoryBrowserInterface.AttributeRemovedCommand createAttributeRemovedCommand(org.w3c.dom.Element contextElement, java.lang.String attributeName, java.lang.String prevAttributeValue, java.lang.String namespaceURI)
Creates the AttributeRemoved command.- Parameters:
contextElement- The context elementattributeName- The attribute nameprevAttributeValue- The previous attribute valuenamespaceURI- The namespaceURI
-
attributeModified
public void attributeModified(org.w3c.dom.Element contextElement, java.lang.String attributeName, java.lang.String prevAttributeValue, java.lang.String newAttributeValue, java.lang.String namespaceURI)Adds the AttributeModifiedCommand to historyBrowser.- Parameters:
contextElement- The context elementattributeName- The attribute nameprevAttributeValue- The previous attribute valuenewAttributeValue- The new attribute valuenamespaceURI- The namespaceURI
-
createAttributeModifiedCommand
public HistoryBrowserInterface.AttributeModifiedCommand createAttributeModifiedCommand(org.w3c.dom.Element contextElement, java.lang.String attributeName, java.lang.String prevAttributeValue, java.lang.String newAttributeValue, java.lang.String namespaceURI)
Creates the AttributeModified command.- Parameters:
contextElement- The context elementattributeName- The attribute nameprevAttributeValue- The previous attribute valuenewAttributeValue- The new attribute valuenamespaceURI- The namespaceURI
-
charDataModified
public void charDataModified(org.w3c.dom.Node contextNode, java.lang.String oldValue, java.lang.String newValue)Adds CharDataModifiedCommand to historyBrowser.- Parameters:
contextNode- The node whose nodeValue changedoldValue- The old node valuenewValue- The new node value
-
createCharDataModifiedCommand
public HistoryBrowserInterface.CharDataModifiedCommand createCharDataModifiedCommand(org.w3c.dom.Node contextNode, java.lang.String oldValue, java.lang.String newValue)
Creates the CharDataModified command.- Parameters:
contextNode- The node whose nodeValue changedoldValue- The old node valuenewValue- The new node value
-
appendChild
public void appendChild(org.w3c.dom.Node parent, org.w3c.dom.Node child)Adds and executes the AppendChildCommand to historyBrowser.- Parameters:
parent- The given parentchild- The node to be appended
-
createAppendChildCommand
public HistoryBrowserInterface.AppendChildCommand createAppendChildCommand(org.w3c.dom.Node parent, org.w3c.dom.Node child)
Creates and return the AppendChild command.- Parameters:
parent- The given parentchild- The node to be appended- Returns:
- the AppendChild command
-
insertChildBefore
public void insertChildBefore(org.w3c.dom.Node parent, org.w3c.dom.Node sibling, org.w3c.dom.Node child)Adds and executes the InsertNodeBeforeCommand to historyBrowser.- Parameters:
parent- The given parentsibling- Points where to be insertedchild- The node to insert
-
createInsertChildCommand
public UndoableCommand createInsertChildCommand(org.w3c.dom.Node parent, org.w3c.dom.Node sibling, org.w3c.dom.Node child)
Creates InsertChildBefore or AppendChild command, depending on the value of siblingNode.- Parameters:
parent- The parent nodesibling- The sibling nodechild- The child node- Returns:
- AppendChild command if sibling node is null, InsertChildBefore otherwise
-
createInsertNodeBeforeCommand
public HistoryBrowserInterface.InsertNodeBeforeCommand createInsertNodeBeforeCommand(org.w3c.dom.Node parent, org.w3c.dom.Node sibling, org.w3c.dom.Node child)
Creates and returns the InsertNodeBeforeCommand.- Parameters:
parent- The given parentsibling- Points where to be insertedchild- The node to insert- Returns:
- the InsertNodeBeforeCommand
-
replaceChild
public void replaceChild(org.w3c.dom.Node parent, org.w3c.dom.Node newChild, org.w3c.dom.Node oldChild)Adds and executes the ReplaceChild command to historyBrowser.- Parameters:
parent- The parent nodenewChild- Points where to be insertedoldChild- The node to be appended
-
removeChild
public void removeChild(org.w3c.dom.Node parent, org.w3c.dom.Node child)Adds and executes the RemoveChild command to the History Browser.- Parameters:
parent- The given parentchild- The given child
-
createRemoveChildCommand
public HistoryBrowserInterface.RemoveChildCommand createRemoveChildCommand(org.w3c.dom.Node parent, org.w3c.dom.Node child)
Creates and returns the RemoveChild command.- Parameters:
parent- The parent nodechild- The child node- Returns:
- The RemoveChild command
-
setNodeValue
public void setNodeValue(org.w3c.dom.Node contextNode, java.lang.String newValue)Adds and executes the ChangeNodeValueCommand to historyBrowser.- Parameters:
contextNode- The node whose nodeValue changednewValue- The new node value
-
createChangeNodeValueCommand
public HistoryBrowserInterface.ChangeNodeValueCommand createChangeNodeValueCommand(org.w3c.dom.Node contextNode, java.lang.String newValue)
Creates and returns the ChangeNodeValue command.- Parameters:
contextNode- The node whose nodeValue changednewValue- The new node value- Returns:
- the ChangeNodeValue command
-
getCurrentCompoundCommand
public AbstractCompoundCommand getCurrentCompoundCommand()
Gets the current compound command.- Returns:
- the currentCompoundCommand
-
addToCurrentCompoundCommand
public void addToCurrentCompoundCommand(AbstractUndoableCommand cmd)
Adds the given command to current compound command.- Parameters:
cmd- The command to add
-
performCurrentCompoundCommand
public void performCurrentCompoundCommand()
Adds and executes the current compound command to history browser.
-
getNodeAsString
private java.lang.String getNodeAsString(org.w3c.dom.Node node)
Gets the node name and the nodes id (nodeName + "nodeId").- Parameters:
node- The given node- Returns:
- e.g. node name with quoted node id or node name if id is empty String
-
getBracketedNodeName
private java.lang.String getBracketedNodeName(org.w3c.dom.Node node)
Gets the node info in brackets.- Parameters:
node- The given node- Returns:
- e.g (rect "23")
-
getAppendChildCommandName
private java.lang.String getAppendChildCommandName(org.w3c.dom.Node parentNode, org.w3c.dom.Node childNode)Generates the "Append Child" command name.- Parameters:
parentNode- The parent nodechildNode- The child node- Returns:
- The command name
-
getInsertBeforeCommandName
private java.lang.String getInsertBeforeCommandName(org.w3c.dom.Node parentNode, org.w3c.dom.Node childNode, org.w3c.dom.Node siblingNode)Generates the "Insert Child Before" command name.- Parameters:
parentNode- The parentNodechildNode- The node being insertedsiblingNode- The new sibling node- Returns:
- The command name
-
getRemoveChildCommandName
private java.lang.String getRemoveChildCommandName(org.w3c.dom.Node parent, org.w3c.dom.Node child)Generates the "Remove Child" command name.- Parameters:
parent- The parent nodechild- The child node- Returns:
- The command name
-
getChangeNodeValueCommandName
private java.lang.String getChangeNodeValueCommandName(org.w3c.dom.Node contextNode, java.lang.String newValue)Generates the "Change Node Value" command name.- Parameters:
contextNode- The node whose value is to be changednewValue- The new node value- Returns:
- The command name
-
getNodeChangedCommandName
private java.lang.String getNodeChangedCommandName(org.w3c.dom.Node node)
Generates the "Node Changed" command name.- Returns:
- The command name
-
-