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 167607 | Differences between
and this patch

Collapse All | Expand All

(-)src/org/eclipse/team/internal/ui/synchronize/LocalResourceSaveableComparison.java (-11 / +51 lines)
Lines 17-27 Link Here
17
import org.eclipse.jface.dialogs.IDialogConstants;
17
import org.eclipse.jface.dialogs.IDialogConstants;
18
import org.eclipse.jface.dialogs.MessageDialog;
18
import org.eclipse.jface.dialogs.MessageDialog;
19
import org.eclipse.jface.resource.ImageDescriptor;
19
import org.eclipse.jface.resource.ImageDescriptor;
20
import org.eclipse.jface.text.IDocument;
20
import org.eclipse.jface.util.IPropertyChangeListener;
21
import org.eclipse.jface.util.IPropertyChangeListener;
21
import org.eclipse.jface.util.PropertyChangeEvent;
22
import org.eclipse.jface.util.PropertyChangeEvent;
22
import org.eclipse.swt.graphics.Image;
23
import org.eclipse.swt.graphics.Image;
23
import org.eclipse.team.internal.ui.*;
24
import org.eclipse.team.internal.ui.*;
24
import org.eclipse.team.ui.mapping.SaveableComparison;
25
import org.eclipse.team.ui.mapping.SaveableComparison;
26
import org.eclipse.ui.IEditorInput;
27
import org.eclipse.ui.Saveable;
28
import org.eclipse.ui.texteditor.IDocumentProvider;
25
29
26
/**
30
/**
27
 * A saveable that wraps a compare input in which the left side is a {@link LocalResourceTypedElement}
31
 * A saveable that wraps a compare input in which the left side is a {@link LocalResourceTypedElement}
Lines 252-274 Link Here
252
			setDirty(changed);
256
			setDirty(changed);
253
		}			
257
		}			
254
	}
258
	}
259
	
260
	/*
261
	 * @see org.eclipse.ui.Saveable#hashCode()
262
	 */
263
	public int hashCode() {
264
		Object document= getAdapter(IDocument.class);
265
		if (document == null)
266
			return input.hashCode();
267
		return document.hashCode();
268
	}
255
269
256
	/* (non-Javadoc)
270
	/*
257
	 * @see org.eclipse.ui.Saveable#equals(java.lang.Object)
271
	 * @see org.eclipse.ui.Saveable#equals(java.lang.Object)
258
	 */
272
	 */
259
	public boolean equals(Object object) {
273
	public boolean equals(Object obj) {
260
		if (object instanceof LocalResourceSaveableComparison) {
274
		if (this == obj)
261
			LocalResourceSaveableComparison rscm = (LocalResourceSaveableComparison) object;
275
			return true;
276
		
277
		if (!(obj instanceof Saveable))
278
			return false;
279
		
280
		if (obj instanceof LocalResourceSaveableComparison) {
281
			LocalResourceSaveableComparison rscm = (LocalResourceSaveableComparison) obj;
262
			return rscm.input.equals(input);
282
			return rscm.input.equals(input);
263
		}
283
		}
264
		return false;
284
		
285
		Object thisDocument= getAdapter(IDocument.class);
286
		Object otherDocument= ((Saveable)obj).getAdapter(IDocument.class);
287
		
288
		if (thisDocument == null && otherDocument == null)
289
			return false;
290
		
291
		return thisDocument != null && thisDocument.equals(otherDocument);
265
	}
292
	}
266
293
	
267
	/* (non-Javadoc)
294
	public Object getAdapter(Class adapter) {
268
	 * @see org.eclipse.ui.Saveable#hashCode()
295
		if (adapter == IDocument.class) {
269
	 */
296
			if (fileElement instanceof LocalResourceTypedElement) {
270
	public int hashCode() {
297
				LocalResourceTypedElement lrte = (LocalResourceTypedElement) fileElement;
271
		return input.hashCode();
298
				if (lrte.isConnected()) {
299
					ISharedDocumentAdapter sda = (ISharedDocumentAdapter)Utils.getAdapter(lrte, ISharedDocumentAdapter.class);
300
					if (sda != null) {
301
						IEditorInput input = sda.getDocumentKey(lrte);
302
						if (input != null) {
303
							IDocumentProvider provider = SharedDocumentAdapter.getDocumentProvider(input);
304
							if (provider != null)
305
								return provider.getDocument(input);
306
						}
307
					}
308
				}
309
			}
310
		}
311
		return super.getAdapter(adapter);
272
	}
312
	}
273
313
274
	/**
314
	/**

Return to bug 167607