/** * Adds the given command to current compound command. * * @param cmd * The command to add */ public void addToCurrentCompoundCommand(AbstractUndoableCommand cmd) { getCurrentCompoundCommand().addCommand(cmd); // Fire the 'doCompoundEdit' event historyBrowser.fireDoCompoundEdit (new HistoryBrowserEvent(getCurrentCompoundCommand())); }
/** * Adds the given command to current compound command. * * @param cmd * The command to add */ public void addToCurrentCompoundCommand(AbstractUndoableCommand cmd) { getCurrentCompoundCommand().addCommand(cmd); // Fire the 'doCompoundEdit' event historyBrowser.fireDoCompoundEdit (new HistoryBrowserEvent(getCurrentCompoundCommand())); }
public void updateElement(NodePickerEvent event) { String result = event.getResult(); Element targetElement = (Element) event.getContextNode(); Element newElem = wrapAndParse(result, targetElement); addChangesToHistory(); AbstractCompoundCommand cmd = historyBrowserInterface .createNodeChangedCommand(newElem); Node parent = targetElement.getParentNode(); Node nextSibling = targetElement.getNextSibling(); cmd.addCommand(historyBrowserInterface .createRemoveChildCommand(parent, targetElement)); cmd.addCommand(historyBrowserInterface .createInsertChildCommand(parent, nextSibling, newElem)); historyBrowserInterface.performCompoundUpdateCommand(cmd); attributePanel.setPreviewElement(newElem); //selectNewNode(newElem); }
public void actionPerformed(ActionEvent e) { addChangesToHistory(); AbstractCompoundCommand cmd = historyBrowserInterface .createRemoveSelectedTreeNodesCommand(null); TreePath[] treePaths = tree.getSelectionPaths(); for (int i = 0; treePaths != null && i < treePaths.length; i++) { TreePath treePath = treePaths[i]; DefaultMutableTreeNode node = (DefaultMutableTreeNode) treePath .getLastPathComponent(); NodeInfo nodeInfo = (NodeInfo) node.getUserObject(); if (DOMUtilities.isParentOf(nodeInfo.getNode(), nodeInfo.getNode().getParentNode())) { cmd.addCommand(historyBrowserInterface .createRemoveChildCommand(nodeInfo.getNode() .getParentNode(), nodeInfo.getNode())); } } historyBrowserInterface.performCompoundUpdateCommand(cmd); } }
public void updateElement(NodePickerEvent event) { String result = event.getResult(); Element targetElement = (Element) event.getContextNode(); Element newElem = wrapAndParse(result, targetElement); addChangesToHistory(); AbstractCompoundCommand cmd = historyBrowserInterface .createNodeChangedCommand(newElem); Node parent = targetElement.getParentNode(); Node nextSibling = targetElement.getNextSibling(); cmd.addCommand(historyBrowserInterface .createRemoveChildCommand(parent, targetElement)); cmd.addCommand(historyBrowserInterface .createInsertChildCommand(parent, nextSibling, newElem)); historyBrowserInterface.performCompoundUpdateCommand(cmd); attributePanel.setPreviewElement(newElem); //selectNewNode(newElem); }
public void actionPerformed(ActionEvent e) { addChangesToHistory(); AbstractCompoundCommand cmd = historyBrowserInterface .createRemoveSelectedTreeNodesCommand(null); TreePath[] treePaths = tree.getSelectionPaths(); for (int i = 0; treePaths != null && i < treePaths.length; i++) { TreePath treePath = treePaths[i]; DefaultMutableTreeNode node = (DefaultMutableTreeNode) treePath .getLastPathComponent(); NodeInfo nodeInfo = (NodeInfo) node.getUserObject(); if (DOMUtilities.isParentOf(nodeInfo.getNode(), nodeInfo.getNode().getParentNode())) { cmd.addCommand(historyBrowserInterface .createRemoveChildCommand(nodeInfo.getNode() .getParentNode(), nodeInfo.getNode())); } } historyBrowserInterface.performCompoundUpdateCommand(cmd); } }
public void dropCompleted(DOMDocumentTreeEvent event) { DropCompletedInfo info = (DropCompletedInfo) event .getSource(); addChangesToHistory(); AbstractCompoundCommand cmd = historyBrowserInterface .createNodesDroppedCommand(info.getChildren()); int n = info.getChildren().size(); for (int i = 0; i < n; i++) { Node node = (Node) info.getChildren().get(i); // If the node has its ancestor in selected nodes, // it should stay as it's child if (!DOMUtilities.isAnyNodeAncestorOf(info .getChildren(), node)) { cmd.addCommand(historyBrowserInterface .createInsertChildCommand(info.getParent(), info.getSibling(), node)); } } historyBrowserInterface.performCompoundUpdateCommand(cmd); } });
public void dropCompleted(DOMDocumentTreeEvent event) { DropCompletedInfo info = (DropCompletedInfo) event .getSource(); addChangesToHistory(); AbstractCompoundCommand cmd = historyBrowserInterface .createNodesDroppedCommand(info.getChildren()); int n = info.getChildren().size(); for (int i = 0; i < n; i++) { Node node = (Node) info.getChildren().get(i); // If the node has its ancestor in selected nodes, // it should stay as it's child if (!DOMUtilities.isAnyNodeAncestorOf(info .getChildren(), node)) { cmd.addCommand(historyBrowserInterface .createInsertChildCommand(info.getParent(), info.getSibling(), node)); } } historyBrowserInterface.performCompoundUpdateCommand(cmd); } });