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

Collapse All | Expand All

(-)compare/org/eclipse/compare/CompareEditorInput.java (-2 / +67 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2010 IBM Corporation and others.
2
 * Copyright (c) 2000, 2011 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 1087-1093 Link Here
1087
			Utilities.firePropertyChange(fListenerList, this, DIRTY_STATE, Boolean.valueOf(oldDirty), Boolean.valueOf(isSaveNeeded()));
1087
			Utilities.firePropertyChange(fListenerList, this, DIRTY_STATE, Boolean.valueOf(oldDirty), Boolean.valueOf(isSaveNeeded()));
1088
		}
1088
		}
1089
	}
1089
	}
1090
	
1090
1091
	/**
1092
	 * Sets the dirty state of left site of this input to the given value and
1093
	 * sends out a <code>PropertyChangeEvent</code> if the new value for whole
1094
	 * input differs from the old value. Direct calling this method with
1095
	 * parameter dirty equal to <code>false</code> when there are unsaved
1096
	 * changes in left viewer, results in inconsistent state. The dirty state of
1097
	 * compare input should be based only on the information if there are
1098
	 * changes in viewers for left side.
1099
	 * 
1100
	 * @param dirty
1101
	 *            the dirty state for this compare input
1102
	 * @since 3.7
1103
	 * @noreference This method is not intended to be referenced by clients.
1104
	 * @nooverride This method is not intended to be re-implemented or extended
1105
	 *             by clients.
1106
	 */
1107
	protected void setLeftDirty(boolean dirty) {
1108
		boolean oldDirty = isSaveNeeded();
1109
		boolean newDirty = dirty;
1110
		if (!newDirty) {
1111
			fLeftDirtyViewer = null;
1112
		} else {
1113
			if (fLeftDirtyViewer == null)
1114
				fLeftDirtyViewer = (ContentMergeViewer) fContentInputPane
1115
						.getViewer();
1116
1117
		}
1118
		if (oldDirty != isSaveNeeded()) {
1119
			Utilities.firePropertyChange(fListenerList, this, DIRTY_STATE,
1120
					Boolean.valueOf(oldDirty), Boolean.valueOf(isSaveNeeded()));
1121
		}
1122
	}
1123
1124
	/**
1125
	 * Sets the dirty state of right site of this input to the given value and
1126
	 * sends out a <code>PropertyChangeEvent</code> if the new value for whole
1127
	 * input differs from the old value. Direct calling this method with
1128
	 * parameter dirty equal to <code>false</code> when there are unsaved
1129
	 * changes in right viewer, results in inconsistent state. The dirty state
1130
	 * of compare input should be based only on the information if there are
1131
	 * changes in viewers for right side.
1132
	 * 
1133
	 * @param dirty
1134
	 *            the dirty state for this compare input
1135
	 * @since 3.7
1136
	 * @noreference This method is not intended to be referenced by clients.
1137
	 * @nooverride This method is not intended to be re-implemented or extended
1138
	 *             by clients.
1139
	 */
1140
	protected void setRightDirty(boolean dirty) {
1141
		boolean oldDirty = isSaveNeeded();
1142
		boolean newDirty = dirty;
1143
		if (!newDirty) {
1144
			fRightDirtyViewer = null;
1145
		} else {
1146
			if (fRightDirtyViewer == null)
1147
				fRightDirtyViewer = (ContentMergeViewer) fContentInputPane
1148
						.getViewer();
1149
		}
1150
		if (oldDirty != isSaveNeeded()) {
1151
			Utilities.firePropertyChange(fListenerList, this, DIRTY_STATE,
1152
					Boolean.valueOf(oldDirty), Boolean.valueOf(isSaveNeeded()));
1153
		}
1154
	}
1155
1091
	/**
1156
	/**
1092
	 * Method adds or removes viewers that changed left or right side of this
1157
	 * Method adds or removes viewers that changed left or right side of this
1093
	 * compare input. Any modification of any of the list of viewers may result
1158
	 * compare input. Any modification of any of the list of viewers may result
(-)src/org/eclipse/team/internal/ui/synchronize/LocalResourceSaveableComparison.java (-2 / +24 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2006, 2010 IBM Corporation and others.
2
 * Copyright (c) 2006, 2011 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 11-16 Link Here
11
package org.eclipse.team.internal.ui.synchronize;
11
package org.eclipse.team.internal.ui.synchronize;
12
12
13
import org.eclipse.compare.*;
13
import org.eclipse.compare.*;
14
import org.eclipse.compare.contentmergeviewer.ContentMergeViewer;
14
import org.eclipse.compare.internal.ISavingSaveable;
15
import org.eclipse.compare.internal.ISavingSaveable;
15
import org.eclipse.compare.structuremergeviewer.ICompareInput;
16
import org.eclipse.compare.structuremergeviewer.ICompareInput;
16
import org.eclipse.core.resources.IFile;
17
import org.eclipse.core.resources.IFile;
Lines 221-226 Link Here
221
	 * @see org.eclipse.team.ui.mapping.SaveableCompareModel#setDirty(boolean)
222
	 * @see org.eclipse.team.ui.mapping.SaveableCompareModel#setDirty(boolean)
222
	 */
223
	 */
223
	protected void setDirty(boolean dirty) {
224
	protected void setDirty(boolean dirty) {
225
		if (editorInput instanceof SaveablesCompareEditorInput) {
226
			((SaveablesCompareEditorInput) editorInput).setSaveNeeded(dirty,
227
					this);
228
			return;
229
		}
224
		// We need to set the dirty state on the compare editor input
230
		// We need to set the dirty state on the compare editor input
225
		// since it is our only connection to the merge viewer
231
		// since it is our only connection to the merge viewer
226
		editorInput.setDirty(dirty);
232
		editorInput.setDirty(dirty);
Lines 279-285 Link Here
279
			Object newValue= e.getNewValue();
285
			Object newValue= e.getNewValue();
280
			if (newValue instanceof Boolean)
286
			if (newValue instanceof Boolean)
281
				changed= ((Boolean)newValue).booleanValue();
287
				changed= ((Boolean)newValue).booleanValue();
282
			setDirty(changed);
288
289
			ContentMergeViewer cmv = (ContentMergeViewer) e.getSource();
290
291
			if (fileElement.equals(input.getLeft())) {
292
				if (changed && cmv.internalIsLeftDirty())
293
					setDirty(changed);
294
				else if (!changed && !cmv.internalIsLeftDirty()) {
295
					setDirty(changed);
296
				}
297
			}
298
			if (fileElement.equals(input.getRight())) {
299
				if (changed && cmv.internalIsRightDirty())
300
					setDirty(changed);
301
				else if (!changed && !cmv.internalIsRightDirty()) {
302
					setDirty(changed);
303
				}
304
			}
283
		}			
305
		}			
284
	}
306
	}
285
	
307
	
(-)src/org/eclipse/team/internal/ui/synchronize/SaveablesCompareEditorInput.java (-3 / +13 lines)
Lines 143-149 Link Here
143
			fLeftPropertyListener = new IPropertyListener() {
143
			fLeftPropertyListener = new IPropertyListener() {
144
				public void propertyChanged(Object source, int propId) {
144
				public void propertyChanged(Object source, int propId) {
145
					if (propId == SaveableComparison.PROP_DIRTY) {
145
					if (propId == SaveableComparison.PROP_DIRTY) {
146
						setDirty(fLeftSaveable.isDirty());
146
						setLeftDirty(fLeftSaveable.isDirty());
147
					}
147
					}
148
				}
148
				}
149
			};
149
			};
Lines 155-168 Link Here
155
			fRightPropertyListener = new IPropertyListener() {
155
			fRightPropertyListener = new IPropertyListener() {
156
				public void propertyChanged(Object source, int propId) {
156
				public void propertyChanged(Object source, int propId) {
157
					if (propId == SaveableComparison.PROP_DIRTY) {
157
					if (propId == SaveableComparison.PROP_DIRTY) {
158
						setDirty(fRightSaveable.isDirty());
158
						setRightDirty(fRightSaveable.isDirty());
159
					}
159
					}
160
				}
160
				}
161
			};
161
			};
162
			rscm.addPropertyListener(fRightPropertyListener);
162
			rscm.addPropertyListener(fRightPropertyListener);
163
		}
163
		}
164
164
165
		setDirty(fLeftSaveable.isDirty() || fRightSaveable.isDirty());
165
		setLeftDirty(fLeftSaveable.isDirty());
166
		setRightDirty(fRightSaveable.isDirty());
166
	}
167
	}
167
168
168
	/*
169
	/*
Lines 385-390 Link Here
385
		return isSaveNeeded();
386
		return isSaveNeeded();
386
	}
387
	}
387
388
389
	void setSaveNeeded(boolean dirty, Saveable saveable) {
390
		if (saveable.equals(fLeftSaveable)) {
391
			setLeftDirty(dirty);
392
		}
393
		if (saveable.equals(fRightSaveable)) {
394
			setRightDirty(dirty);
395
		}
396
	}
397
388
	void saveChanges(IProgressMonitor monitor, Saveable saveable)
398
	void saveChanges(IProgressMonitor monitor, Saveable saveable)
389
			throws CoreException {
399
			throws CoreException {
390
		if (saveable.equals(fLeftSaveable)) {
400
		if (saveable.equals(fLeftSaveable)) {

Return to bug 312893