1 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 34 public String getName() { 35 return project.getName(); 36 } 37 38 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 66 public String 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 |