|
Lines 41-46
Link Here
|
| 41 |
|
41 |
|
| 42 |
private final ICompareInput input; |
42 |
private final ICompareInput input; |
| 43 |
private final CompareEditorInput editorInput; |
43 |
private final CompareEditorInput editorInput; |
|
|
44 |
private boolean isEditorInputSaveNeeded; |
| 44 |
private boolean isSaving; |
45 |
private boolean isSaving; |
| 45 |
private IContentChangeListener contentChangeListener; |
46 |
private IContentChangeListener contentChangeListener; |
| 46 |
private ITypedElement fileElement; |
47 |
private ITypedElement fileElement; |
|
Lines 65-70
Link Here
|
| 65 |
this.input = input; |
66 |
this.input = input; |
| 66 |
this.editorInput = editorInput; |
67 |
this.editorInput = editorInput; |
| 67 |
this.fileElement = fileElement; |
68 |
this.fileElement = fileElement; |
|
|
69 |
if(this.fileElement==null){ |
| 70 |
//if there is no editor input we need to store dirty state |
| 71 |
//because we don't know which editorInput does this Comparison refer to |
| 72 |
//this variable stores conjunction of the dirty state of both sites of the editor |
| 73 |
isEditorInputSaveNeeded = false; |
| 74 |
} |
| 68 |
initializeContentChangeListeners(); |
75 |
initializeContentChangeListeners(); |
| 69 |
} |
76 |
} |
| 70 |
|
77 |
|
|
Lines 210-215
Link Here
|
| 210 |
* @see org.eclipse.team.ui.mapping.SaveableCompareModel#isDirty() |
217 |
* @see org.eclipse.team.ui.mapping.SaveableCompareModel#isDirty() |
| 211 |
*/ |
218 |
*/ |
| 212 |
public boolean isDirty() { |
219 |
public boolean isDirty() { |
|
|
220 |
if(editorInput==null) |
| 221 |
return isEditorInputSaveNeeded; |
| 222 |
|
| 213 |
// We need to get the dirty state from the compare editor input |
223 |
// We need to get the dirty state from the compare editor input |
| 214 |
// since it is our only connection to the merge viewer |
224 |
// since it is our only connection to the merge viewer |
| 215 |
if (editorInput instanceof SaveablesCompareEditorInput) { |
225 |
if (editorInput instanceof SaveablesCompareEditorInput) { |
|
Lines 227-232
Link Here
|
| 227 |
this); |
237 |
this); |
| 228 |
return; |
238 |
return; |
| 229 |
} |
239 |
} |
|
|
240 |
if(editorInput==null) |
| 241 |
isEditorInputSaveNeeded = dirty; |
| 242 |
else |
| 230 |
// We need to set the dirty state on the compare editor input |
243 |
// We need to set the dirty state on the compare editor input |
| 231 |
// since it is our only connection to the merge viewer |
244 |
// since it is our only connection to the merge viewer |
| 232 |
editorInput.setDirty(dirty); |
245 |
editorInput.setDirty(dirty); |
|
Lines 247-256
Link Here
|
| 247 |
*/ |
260 |
*/ |
| 248 |
public String getName() { |
261 |
public String getName() { |
| 249 |
// Return the name of the file element as held in the compare input |
262 |
// Return the name of the file element as held in the compare input |
| 250 |
if (fileElement.equals(input.getLeft())) { |
263 |
if (input.getLeft().equals(fileElement)) { |
| 251 |
return input.getLeft().getName(); |
264 |
return input.getLeft().getName(); |
| 252 |
} |
265 |
} |
| 253 |
if (fileElement.equals(input.getRight())) { |
266 |
if (input.getRight().equals(fileElement)) { |
| 254 |
return input.getRight().getName(); |
267 |
return input.getRight().getName(); |
| 255 |
} |
268 |
} |
| 256 |
// Fallback call returning name of the main non-null element of the input |
269 |
// Fallback call returning name of the main non-null element of the input |
|
Lines 288-307
Link Here
|
| 288 |
|
301 |
|
| 289 |
ContentMergeViewer cmv = (ContentMergeViewer) e.getSource(); |
302 |
ContentMergeViewer cmv = (ContentMergeViewer) e.getSource(); |
| 290 |
|
303 |
|
| 291 |
if (fileElement.equals(input.getLeft())) { |
304 |
if (input.getLeft().equals(fileElement)) { |
| 292 |
if (changed && cmv.internalIsLeftDirty()) |
305 |
if (changed && cmv.internalIsLeftDirty()) |
| 293 |
setDirty(changed); |
306 |
setDirty(changed); |
| 294 |
else if (!changed && !cmv.internalIsLeftDirty()) { |
307 |
else if (!changed && !cmv.internalIsLeftDirty()) { |
| 295 |
setDirty(changed); |
308 |
setDirty(changed); |
| 296 |
} |
309 |
} |
| 297 |
} |
310 |
} |
| 298 |
if (fileElement.equals(input.getRight())) { |
311 |
if (input.getRight().equals(fileElement)) { |
| 299 |
if (changed && cmv.internalIsRightDirty()) |
312 |
if (changed && cmv.internalIsRightDirty()) |
| 300 |
setDirty(changed); |
313 |
setDirty(changed); |
| 301 |
else if (!changed && !cmv.internalIsRightDirty()) { |
314 |
else if (!changed && !cmv.internalIsRightDirty()) { |
| 302 |
setDirty(changed); |
315 |
setDirty(changed); |
| 303 |
} |
316 |
} |
| 304 |
} |
317 |
} |
|
|
318 |
|
| 319 |
if(fileElement==null){ |
| 320 |
if(changed && (cmv.internalIsLeftDirty() || cmv.internalIsRightDirty())) |
| 321 |
setDirty(changed); |
| 322 |
if(!changed && !cmv.internalIsLeftDirty() && !cmv.internalIsRightDirty()) |
| 323 |
setDirty(changed); |
| 324 |
} |
| 325 |
|
| 305 |
} |
326 |
} |
| 306 |
} |
327 |
} |
| 307 |
|
328 |
|