Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
View | Details | Raw Unified | Return to bug 347557 | Differences between
and this patch

Collapse All | Expand All

(-)a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/LocalResourceSaveableComparison.java (-4 / +5 lines)
Lines 248-257 public abstract class LocalResourceSaveableComparison extends SaveableComparison Link Here
248
	 */
248
	 */
249
	public String getName() {
249
	public String getName() {
250
		// Return the name of the file element as held in the compare input
250
		// Return the name of the file element as held in the compare input
251
		if (input.getLeft().equals(fileElement)) {
251
		if (input.getLeft() != null && input.getLeft().equals(fileElement)) {
252
			return input.getLeft().getName();
252
			return input.getLeft().getName();
253
		}
253
		}
254
		if (input.getRight().equals(fileElement)) {
254
		if (input.getRight() != null && input.getRight().equals(fileElement)) {
255
			return input.getRight().getName();
255
			return input.getRight().getName();
256
		}
256
		}
257
		// Fallback call returning name of the main non-null element of the input
257
		// Fallback call returning name of the main non-null element of the input
Lines 289-302 public abstract class LocalResourceSaveableComparison extends SaveableComparison Link Here
289
289
290
			ContentMergeViewer cmv = (ContentMergeViewer) e.getSource();
290
			ContentMergeViewer cmv = (ContentMergeViewer) e.getSource();
291
291
292
			if (input.getLeft().equals(fileElement)) {
292
			if (input.getLeft() != null && input.getLeft().equals(fileElement)) {
293
				if (changed && cmv.internalIsLeftDirty())
293
				if (changed && cmv.internalIsLeftDirty())
294
					setDirty(changed);
294
					setDirty(changed);
295
				else if (!changed && !cmv.internalIsLeftDirty()) {
295
				else if (!changed && !cmv.internalIsLeftDirty()) {
296
					setDirty(changed);
296
					setDirty(changed);
297
				}
297
				}
298
			}
298
			}
299
			if (input.getRight().equals(fileElement)) {
299
			if (input.getRight() != null
300
					&& input.getRight().equals(fileElement)) {
300
				if (changed && cmv.internalIsRightDirty())
301
				if (changed && cmv.internalIsRightDirty())
301
					setDirty(changed);
302
					setDirty(changed);
302
				else if (!changed && !cmv.internalIsRightDirty()) {
303
				else if (!changed && !cmv.internalIsRightDirty()) {
(-)a/tests/org.eclipse.team.tests.core/src/org/eclipse/team/tests/ui/SaveableCompareEditorInputTest.java (+52 lines)
Lines 272-275 public class SaveableCompareEditorInputTest extends TeamTest { Link Here
272
		 * handled, see javadoc to SaveableCompareEditorInput.
272
		 * handled, see javadoc to SaveableCompareEditorInput.
273
		 */
273
		 */
274
	}
274
	}
275
276
	public void testDirtyFlagOnLocalResourceTypedElementAndEmptyRight()
277
			throws CoreException, InvocationTargetException,
278
			InterruptedException, IllegalArgumentException, SecurityException,
279
			IllegalAccessException, NoSuchFieldException,
280
			NoSuchMethodException, IOException {
281
282
		// Create left element by SaveableCompareEditorInput to be properly
283
		// saved, see javadoc to SaveableCompareEditorInput
284
		LocalResourceTypedElement el1 = (LocalResourceTypedElement) SaveableCompareEditorInput
285
				.createFileElement(file1);
286
		ITypedElement el2 = null;
287
288
		CompareConfiguration conf = new CompareConfiguration();
289
		conf.setLeftEditable(true);
290
		TestSaveableEditorInput compareEditorInput = new TestSaveableEditorInput(
291
				el1, el2, conf);
292
293
		compareEditorInput.prepareCompareInput(null);
294
295
		verifyDirtyStateChanges(compareEditorInput);
296
297
		// check whether file was saved
298
299
		assertTrue(compareContent(new ByteArrayInputStream(
300
				(fileContents1 + appendFileContents).getBytes()),
301
				file1.getContents()));
302
	}
303
304
	public void testDirtyFlagOnCustomTypedElementAndEmptyRight()
305
			throws CoreException, InvocationTargetException,
306
			InterruptedException, IllegalArgumentException, SecurityException,
307
			IllegalAccessException, NoSuchFieldException,
308
			NoSuchMethodException, IOException {
309
310
		ITypedElement el1 = new TestFileElement(file1);
311
		ITypedElement el2 = null;
312
313
		CompareConfiguration conf = new CompareConfiguration();
314
		conf.setLeftEditable(true);
315
		TestSaveableEditorInput compareEditorInput = new TestSaveableEditorInput(
316
				el1, el2, conf);
317
318
		compareEditorInput.prepareCompareInput(null);
319
320
		verifyDirtyStateChanges(compareEditorInput);
321
322
		/*
323
		 * not checking if changes were saved because in this case saving is not
324
		 * handled, see javadoc to SaveableCompareEditorInput.
325
		 */
326
	}
275
}
327
}

Return to bug 347557