2
* @(#)AppendMerge.java 1.4 06/10/30
4
* Copyright (c) 2006 Sun Microsystems, Inc. All Rights Reserved.
5
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
7
* This code is free software; you can redistribute it and/or modify it
8
* under the terms of the GNU General Public License version 2 only, as
9
* published by the Free Software Foundation. Sun designates this
10
* particular file as subject to the "Classpath" exception as provided
11
* by Sun in the LICENSE file that accompanied this code.
13
* This code is distributed in the hope that it will be useful, but WITHOUT
14
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
15
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
16
* version 2 for more details (a copy is included in the LICENSE file that
17
* accompanied this code).
19
* You should have received a copy of the GNU General Public License version
20
* 2 along with this work; if not, write to the Free Software Foundation,
21
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
23
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
24
* CA 95054 USA or visit www.sun.com if you need additional information or
30
import javax.swing.tree.*;
37
* @author Richard Gregor
38
* @version 1.4 10/30/06
40
public class AppendMerge extends Merge{
43
* Constructs AppendMerge
45
* @param master The master NavigatorView
46
* @param slave The slave NavigatorView
48
public AppendMerge(NavigatorView master, NavigatorView slave){
54
* Processes append merge
56
* @param node The master node
57
* @return Merged master node
59
public TreeNode processMerge(TreeNode node){
62
mergeNodes(node, slaveTopNode);
68
* Merge Nodes. Merge two nodes according to the Append merging rules
70
* @param masterNode The master node to merge with
71
* @param slaveNode The node to merge into the master
73
public static void mergeNodes(TreeNode master, TreeNode slave) {
74
DefaultMutableTreeNode masterNode = (DefaultMutableTreeNode)master;
75
DefaultMutableTreeNode slaveNode = (DefaultMutableTreeNode)slave;
76
debug("mergeNodes master=" + MergeHelpUtilities.getNodeName(masterNode) +
77
" slave=" + MergeHelpUtilities.getNodeName(slaveNode));
78
while (slaveNode.getChildCount() > 0) {
79
DefaultMutableTreeNode slaveNodeChild =
80
(DefaultMutableTreeNode)slaveNode.getFirstChild();
81
masterNode.add(slaveNodeChild);
82
MergeHelpUtilities.mergeNodeChildren("javax.help.AppendMerge",
88
* Merge Node Children. Merge the children of a node according to the
91
* @param node The parent node from which the children are merged
93
public static void mergeNodeChildren(TreeNode node) {
94
DefaultMutableTreeNode masterNode = (DefaultMutableTreeNode)node;
95
debug("mergeNodes master=" + MergeHelpUtilities.getNodeName(masterNode));
97
// The rules are there are no rules. Nothing else needs to be done
98
// except for merging through the children
99
for (int i=0; i < masterNode.getChildCount(); i++) {
100
DefaultMutableTreeNode child =
101
(DefaultMutableTreeNode)masterNode.getChildAt(i);
102
if (!child.isLeaf()) {
103
MergeHelpUtilities.mergeNodeChildren("javax.help.AppendMerge",
109
private static boolean debug = false;
110
private static void debug(String msg){
112
System.out.println("AppendMerge :"+msg);