Skip to main content
summaryrefslogtreecommitdiffstats
blob: a481f8e63ef9e0f613fd68c93d1374ead8d8a77b (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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
/*******************************************************************************
 * Copyright (c) 2004, 2008 Tasktop Technologies and others.
 * 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:
 *     Tasktop Technologies - initial API and implementation
 *******************************************************************************/

package org.eclipse.mylyn.bugzilla.deprecated;

import org.eclipse.compare.CompareConfiguration;
import org.eclipse.compare.CompareEditorInput;
import org.eclipse.compare.structuremergeviewer.Differencer;
import org.eclipse.compare.structuremergeviewer.IStructureComparator;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.mylyn.internal.tasks.core.deprecated.RepositoryTaskData;

/**
 * A two-way or three-way compare for <code>BugReport</code> objects.
 * 
 * @author Shawn Minto
 * @author Mik Kersten
 */
public class BugzillaCompareInput extends CompareEditorInput {

	private boolean threeWay = false;

	private Object root;

	private IStructureComparator ancestor = null;

	private IStructureComparator left = null;

	private IStructureComparator right = null;

	/**
	 * Constructor.
	 * 
	 * @param configuration
	 *            The compare configuration used in this compare input.
	 * @see CompareConfiguration
	 */
	public BugzillaCompareInput(CompareConfiguration configuration) {
		super(configuration);
	}

	@Override
	protected Object prepareInput(IProgressMonitor monitor) {
		if (left == null || right == null) {
			return null;
		}
		Differencer d = new Differencer();
		root = d.findDifferences(threeWay, monitor, null, ancestor, left, right);
		return root;
	}

	/**
	 * @return The original object that's to be compared (appears on the top of the compare view).
	 */
	public IStructureComparator getAncestor() {
		return ancestor;
	}

	/**
	 * Sets the original object that's to be compared (appears on the top of the compare view).
	 * 
	 * @param newAncestor
	 *            The new original object.
	 */
	public void setAncestor(RepositoryTaskData newAncestor) {
		threeWay = (newAncestor != null);
		BugzillaCompareStructureCreator structureCreator = new BugzillaCompareStructureCreator();
		ancestor = structureCreator.getStructure(newAncestor);
	}

	/**
	 * @return The local object that's to be compared (appears on the left side of the compare view).
	 */
	public IStructureComparator getLeft() {
		return left;
	}

	/**
	 * Sets the local object that's to be compared (appears on the left side of the compare view).
	 * 
	 * @param newLeft
	 *            The new local object.
	 */
	public void setLeft(RepositoryTaskData newLeft) {
		BugzillaCompareStructureCreator structureCreator = new BugzillaCompareStructureCreator();
		left = structureCreator.getStructure(newLeft);
	}

	/**
	 * @return The online object that's to be compared (appears on the right side of the compare view).
	 */
	public IStructureComparator getRight() {
		return right;
	}

	/**
	 * Sets the online object that's to be compared (appears on the right side of the compare view).
	 * 
	 * @param newRight
	 *            The new online object.
	 */
	public void setRight(RepositoryTaskData newRight) {
		BugzillaCompareStructureCreator structureCreator = new BugzillaCompareStructureCreator();
		right = structureCreator.getStructure(newRight);
	}

	/**
	 * @return <code>true</code> if a three-way comparison is to be done.
	 */
	public boolean isThreeWay() {
		return threeWay;
	}
}

Back to the top