KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > compare > internal > patch > PatchProjectDiffNode


1 /*******************************************************************************
2  * Copyright (c) 2006, 2007 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

11 package org.eclipse.compare.internal.patch;
12
13 import org.eclipse.compare.CompareUI;
14 import org.eclipse.compare.ITypedElement;
15 import org.eclipse.compare.patch.PatchConfiguration;
16 import org.eclipse.compare.structuremergeviewer.*;
17 import org.eclipse.jface.resource.LocalResourceManager;
18 import org.eclipse.swt.graphics.Image;
19
20 public class PatchProjectDiffNode extends PatchDiffNode {
21
22     private final DiffProject project;
23     private final PatchConfiguration configuration;
24
25     public PatchProjectDiffNode(IDiffContainer parent, DiffProject project, PatchConfiguration configuration) {
26         super(project, parent, Differencer.NO_CHANGE);
27         this.project = project;
28         this.configuration = configuration;
29     }
30     
31     /* (non-Javadoc)
32      * @see org.eclipse.compare.structuremergeviewer.DiffNode#getName()
33      */

34     public String JavaDoc getName() {
35         return project.getName();
36     }
37     
38     /* (non-Javadoc)
39      * @see org.eclipse.compare.structuremergeviewer.DiffNode#getImage()
40      */

41     public Image getImage() {
42         Image image = CompareUI.getImage(project.getProject());
43         if (containsProblems()) {
44             LocalResourceManager imageCache = PatchCompareEditorInput.getImageCache(getConfiguration());
45             image = HunkTypedElement.getHunkErrorImage(image, imageCache, true);
46         }
47         return image;
48     }
49
50     private boolean containsProblems() {
51         IDiffElement[] elements = getChildren();
52         for (int i = 0; i < elements.length; i++) {
53             IDiffElement diffElement = elements[i];
54             if (diffElement instanceof PatchFileDiffNode) {
55                 PatchFileDiffNode node = (PatchFileDiffNode) diffElement;
56                 if (node.getDiffResult().containsProblems())
57                     return true;
58             }
59         }
60         return false;
61     }
62
63     /* (non-Javadoc)
64      * @see org.eclipse.compare.structuremergeviewer.DiffNode#getType()
65      */

66     public String JavaDoc getType() {
67         return ITypedElement.FOLDER_TYPE;
68     }
69     
70     protected PatchConfiguration getConfiguration() {
71         return configuration;
72     }
73
74     public DiffProject getDiffProject() {
75         return project;
76     }
77
78 }
79
Popular Tags