Skip to main content
summaryrefslogtreecommitdiffstats
blob: 92a9df9f938fe124b54ced60046cc6b650bc1bf2 (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
/*******************************************************************************
 * Copyright (c) 2004 - 2006 University Of British Columbia 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:
 *     University Of British Columbia - initial API and implementation
 *******************************************************************************/

package org.eclipse.mylyn.internal.bugzilla.ui;

import org.eclipse.compare.structuremergeviewer.IStructureComparator;
import org.eclipse.compare.structuremergeviewer.IStructureCreator;
import org.eclipse.mylyn.tasks.core.RepositoryTaskData;

/**
 * This implementation of the <code>IStructureCreator</code> interface makes
 * the contents of a <code>BugReport</code> object available as a hierarchical
 * structure of <code>IStructureComparator</code>s.
 * <p>
 * It is used when comparing a modified bug report to the one on the
 * corresponding server.
 */
public class BugzillaCompareStructureCreator implements IStructureCreator {

	/**
	 * Create a new BugzillaStructureCreator.
	 */
	public BugzillaCompareStructureCreator() {
		super();
	}

	public String getName() {
		return "Bugzilla Structure Creator";
	}

	public IStructureComparator getStructure(Object input) {
		if (input instanceof RepositoryTaskData) {
			RepositoryTaskData bugReport = (RepositoryTaskData) input;
			return BugzillaCompareNode.parseBugReport(bugReport);
		} else {
			return null;
		}
	}

	public IStructureComparator locate(Object path, Object input) {
		return null;
	}

	public String getContents(Object node, boolean ignoreWhitespace) {
		if (node instanceof BugzillaCompareNode) {
			String s = ((BugzillaCompareNode) node).getValue();
			if (ignoreWhitespace)
				s = s.trim();
			return s;
		}
		return null;
	}

	/**
	 * Called whenever a copy operation has been performed on a tree node. This
	 * implementation throws an <code>AssertionFailedException</code> since we
	 * cannot update a bug report object.
	 * 
	 * @param structure
	 *            the node for which to save the new content
	 * @param input
	 *            the object from which the structure tree was created in
	 *            <code>getStructure</code>
	 */
	public void save(IStructureComparator node, Object input) {
		// ignore
	}

}

Back to the top