View | Details | Raw Unified | Return to bug 112169
Collapse All | Expand All

(-)compare/org/eclipse/compare/internal/patch/Hunk.java (+4 lines)
Lines 165-168 Link Here
165
			return this;
165
			return this;
166
		return null;
166
		return null;
167
	}
167
	}
168
169
	protected boolean getHunkProblem() {
170
		return fHunkProblem;
171
	}
168
}
172
}
(-)compare/org/eclipse/compare/internal/patch/PreviewPatchPage.java (-1 / +21 lines)
Lines 338-348 Link Here
338
				DiffProject proj = null;
338
				DiffProject proj = null;
339
				if (obj instanceof DiffProject){
339
				if (obj instanceof DiffProject){
340
					proj = (DiffProject) obj;
340
					proj = (DiffProject) obj;
341
					//Check to see if any of the Diffs contained by the DiffProject
342
					//have their diff problems set
343
					Object[] diffs = proj.getChildren(null);
344
					for (int i= 0; i<diffs.length; i++) {
345
						if (((Diff) diffs[i]).containsProblems()){
346
							checked.setChecked(obj, false);
347
							break;
348
						}
349
					}
341
				} else if (obj instanceof Diff){
350
				} else if (obj instanceof Diff){
342
					proj = ((Diff) obj).getProject();
351
					proj = ((Diff) obj).getProject();
352
					//If Diff has any diff problems set, at least one hunk underneath 
353
					//does not match - so don't allow entire tree to be checked
354
					if (((Diff) obj).containsProblems()){
355
						checked.setChecked(obj, false);
356
					}
343
				} else if (obj instanceof Hunk){
357
				} else if (obj instanceof Hunk){
344
					Diff diff = (Diff) ((Hunk) obj).getParent(null);
358
					Diff diff = (Diff) ((Hunk) obj).getParent(null);
345
					proj = diff.getProject();
359
					proj = diff.getProject();
360
					//Check to see if this hunk has any problems OR
361
					//if its parent has any problems
362
					if( diff.getDiffProblem() ||
363
					   ((Hunk) obj).getHunkProblem()){
364
						checked.setChecked(obj, false);
365
					}
346
				}
366
				}
347
				if (proj!= null &&
367
				if (proj!= null &&
348
				   !proj.getProject().exists()){
368
				   !proj.getProject().exists()){
Lines 359-365 Link Here
359
				Object obj= sel.getFirstElement();
379
				Object obj= sel.getFirstElement();
360
380
361
				if (obj instanceof Hunk) {
381
				if (obj instanceof Hunk) {
362
					PreviewPatchPage.this.fHunkViewer.setInput(createInput((Hunk) obj));
382
					PreviewPatchPage.this.fHunkViewer.setInput(createInput((Hunk) obj));						
363
				} else
383
				} else
364
					PreviewPatchPage.this.fHunkViewer.setInput(null);
384
					PreviewPatchPage.this.fHunkViewer.setInput(null);
365
385
(-)compare/org/eclipse/compare/internal/patch/Diff.java (-1 / +25 lines)
Lines 159-165 Link Here
159
			if (hunkFailed)
159
			if (hunkFailed)
160
				this.fMatches= false;
160
				this.fMatches= false;
161
			hunk.reset(hunkFailed);
161
			hunk.reset(hunkFailed);
162
			if (!hunkFailed && projectExistsInWorkspace)
162
			//If the hunk can be applied and the project exists in the workspace and
163
			//there are no problems with the hunk's containing diff, then check the hunk
164
			if (!hunkFailed && projectExistsInWorkspace && !fDiffProblem)
163
				hunksToCheck.add(hunk);
165
				hunksToCheck.add(hunk);
164
		}
166
		}
165
		return hunksToCheck;
167
		return hunksToCheck;
Lines 253-257 Link Here
253
		return null;
255
		return null;
254
	}
256
	}
255
257
258
	protected boolean getDiffProblem() {
259
		return fDiffProblem;
260
	}
261
	
262
	/**
263
	 * Returns whether this Diff has any problems
264
	 * @return true if this Diff or any of its children Hunks have a problem, false if it doesn't
265
	 */
266
	protected boolean containsProblems(){
267
		
268
		if (fDiffProblem)
269
			return true;
270
		
271
		for (Iterator iter= fHunks.iterator(); iter.hasNext();) {
272
			Hunk element= (Hunk) iter.next();
273
			if (element.getHunkProblem()){
274
				return true;
275
			}
276
		}
277
		return false;
278
	}
279
256
}
280
}
257
281

Return to bug 112169