Skip to main content
summaryrefslogtreecommitdiffstats
blob: 78b1510530097a5a7b15970db22bfae6018eb10d (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
/*******************************************************************************
 * Copyright (c) 2016 Obeo.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 * 
 * Contributors:
 *     Obeo - initial API and implementation
 *******************************************************************************/
package org.eclipse.emf.compare.rcp.ui.internal.structuremergeviewer.nodes;

import com.google.common.collect.Iterables;

import org.eclipse.emf.compare.Diff;
import org.eclipse.emf.edit.tree.impl.TreeNodeImpl;

/**
 * This class is wrapper for TreeNode used to represent a diff TreeNode.
 * 
 * @author <a href="mailto:mathieu.cartaud@obeo.fr">Mathieu Cartaud</a>
 * @since 4.3
 */
public class DiffNode extends TreeNodeImpl {

	/**
	 * Constructor.
	 * 
	 * @param diff
	 *            The diff represented by this TreeNode
	 */
	public DiffNode(Diff diff) {
		setData(diff);
	}

	/**
	 * Add the given DiffNode to the children of this DiffNode. This is intended to be used only for refined
	 * diffs.
	 * 
	 * @param diffNode
	 *            The DiffNode to add
	 * @return <code>true</code> if the DiffNode has been added
	 */
	public boolean addRefinedDiffNode(DiffNode diffNode) {
		return getChildren().add(diffNode);
	}

	/**
	 * Remove the given DiffNode of the children of this DiffNode. This is intended to be used only for
	 * refined diffs.
	 * 
	 * @param diffNode
	 *            The DiffNode to remove
	 * @return <code>true</code> if the DiffNode has been removed
	 */
	public boolean removeRefinedDiffNode(DiffNode diffNode) {
		return getChildren().remove(diffNode);
	}

	/**
	 * Getter for the diff represented by this TreeNode.
	 * 
	 * @return the diff
	 */
	public Diff getDiff() {
		return (Diff)getData();
	}

	/**
	 * Get all the refined DiffNode that are part of this DiffNode.
	 * 
	 * @return an iterable of all refined DiffNode of this diff
	 */
	public Iterable<DiffNode> getRefinedDiffs() {
		return Iterables.filter(getChildren(), DiffNode.class);
	}

}

Back to the top